///-------------------------------------------------------------------------------- /// <summary>This method executes the new command.</summary> /// /// <param name="sender">Sender of the event.</param> /// <param name="e">Event arguments.</param> ///-------------------------------------------------------------------------------- private void NewExecuted(object sender, ExecutedRoutedEventArgs e) { DiagramViewModel view = DataContext as DiagramViewModel; if (view != null) { Point currentPosition = MouseUtilities.GetMousePosition(this); dialog = new Window(); dialog.Height = 350 * UserSettingsHelper.Instance.ControlSize; dialog.Width = 300 * UserSettingsHelper.Instance.ControlSize; dialog.Left = Math.Max(currentPosition.X, 20); dialog.Top = Math.Max(currentPosition.Y, 20); dialog.Content = new EntityDialogControl(); Entity newEntity = new Entity(); newEntity.EntityID = Guid.NewGuid(); newEntity.Solution = view.Solution; EntityViewModel newEntityView = new EntityViewModel(newEntity, view.Solution); dialog.DataContext = newEntityView; dialog.Title = newEntityView.Title; newEntityView.RequestClose += new EventHandler(newEntityView_RequestClose); dialog.ShowDialog(); if (newEntityView.IsOK == true) { // TODO: investigate why this workflow needs to be different than other elements in the model newEntityView.Entity.TransformDataFromObject(newEntityView.EditEntity, null, false); newEntityView.EditEntity = null; view.AddEntity(newEntityView, currentPosition, true); } } }