private void EditSelect(FieldViewModel fieldViewModel)
        {
            FieldEdit fieldEdit = new FieldEdit();

            fieldEdit.DataContext = fieldViewModel;
            fieldEdit.Show();
        }
Exemple #2
0
 public static Field ToField(this FieldViewModel fieldViewModel)
 {
     return(new Field()
     {
         Type = fieldViewModel.Type,
         Name = fieldViewModel.Name
     });
 }
 public ClassViewModel()
 {
     MouseMove = new Command(() => {});
     MouseUp   = new Command(() =>
     {
         _mouseDownFlag = false;
         MouseMove      = new Command(() => { });
         OnPropertyChanged("MouseMove");
     });
     MouseDown = new Command(() =>
     {
         MainWindowViewModel.MainWindowSingleton.EndNewLine(this);
         MainWindowViewModel.MainWindowSingleton.EndDeleteLine(this);
         var mousePosition  = MainWindow.MousePosition - Position;
         _resizeDirection   = mousePosition.OnBorder(new Size(_width, _height), ThicknessResize);
         _lastPositionMouse = MainWindow.MousePosition;
         if (_resizeDirection == ResizeDirection.Nothing)
         {
             _mouseDownFlag = true;
             MouseMove      = new Command(() =>
             {
                 if (_mouseDownFlag == false)
                 {
                     return;
                 }
                 Position          += (MainWindow.MousePosition - _lastPositionMouse);
                 _lastPositionMouse = MainWindow.MousePosition;
             });
         }
         else
         {
             MouseMove = new Command(ResizeMove);
         }
         OnPropertyChanged("MouseMove");
     });
     EditAttributes            = new Command(() => { EditSelect(_selectAttribute); });
     EditMethods               = new Command(() => { EditSelect(_selectMethod); });
     SelectionAttributeChanged = new Command <RoutedEventArgs>((RoutedEventArgs e) =>
     {
         ListView listView = (ListView)e.Source;
         if (listView.SelectedItem == null)
         {
             return;
         }
         _selectAttribute = (FieldViewModel)listView.SelectedItem;
     });
     SelectionMethodChanged = new Command <RoutedEventArgs>((RoutedEventArgs e) =>
     {
         ListView listView = (ListView)e.Source;
         if (listView.SelectedItem == null)
         {
             return;
         }
         _selectMethod = (FieldViewModel)listView.SelectedItem;
     });
     AddAttribute = new Command(() =>
     {
         FieldViewModel fieldViewModel = new FieldViewModel();
         Attributes.Add(fieldViewModel);
         EditSelect(fieldViewModel);
     });
     AddMethod = new Command(() =>
     {
         FieldViewModel fieldViewModel = new FieldViewModel();
         Methods.Add(fieldViewModel);
         EditSelect(fieldViewModel);
     });
     DeleteAttribute = new Command(() =>
     {
         Attributes.Remove(_selectAttribute);
         _selectAttribute = null;
     });
     DeleteMethod = new Command(() =>
     {
         Methods.Remove(_selectMethod);
         _selectMethod = null;
     });
     AddLine = new Command(() =>
     {
         MainWindowViewModel.MainWindowSingleton.StartNewLine(this);
     });
     DeleteLine = new Command(() =>
     {
         MainWindowViewModel.MainWindowSingleton.StartDeleteLine(this);
     });
     DeleteClass = new Command(() =>
     {
         MainWindowViewModel.MainWindowSingleton.DeleteClass(this);
         ;
     });
 }