using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace AIPractice.LabelEditor { /// /// Interaction logic for RootLabelView.xaml /// public partial class RootLabelView : UserControl { public RootLabelView() { InitializeComponent(); } private void OnDeleteClick(object sender, RoutedEventArgs e) { if (MessageBox.Show("确认删除此标签吗?", "删除标签", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var rootLabelViewModel = DataContext as RootLabelViewModel; if (rootLabelViewModel != null) { App.Container.Labels.Remove(rootLabelViewModel); } } } private void OnUpDownClick(object sender, UpDown e) { var rootLabelViewModel = DataContext as RootLabelViewModel; if (rootLabelViewModel != null) { var rootLabel = rootLabelViewModel.RootLabel; var index = App.Container.Labels.IndexOf(rootLabelViewModel); if (e == UpDown.Up) { if (index > 0) { App.Container.Container.Labels.Remove(rootLabel); App.Container.Labels.Remove(rootLabelViewModel); App.Container.Container.Labels.Insert(index -1,rootLabel); App.Container.Labels.Insert(index - 1, rootLabelViewModel); } } else { if (index < App.Container.Labels.Count - 1) { App.Container.Container.Labels.Remove(rootLabel); App.Container.Labels.Remove(rootLabelViewModel); App.Container.Container.Labels.Insert(index + 1, rootLabel); App.Container.Labels.Insert(index + 1, rootLabelViewModel); } } } } } }