///-------------------------------------------------------------------------------- /// <summary>This method determines if the delete command can execute.</summary> /// /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> ///-------------------------------------------------------------------------------- private void PreviewDeleteCanExecute(object sender, CanExecuteRoutedEventArgs e) { IndexesViewModel items = DataContext as IndexesViewModel; if (items != null) { foreach (IndexViewModel item in items.Indexes) { if (item.IsSelected == true) { e.CanExecute = true; return; } } } e.CanExecute = false; e.Handled = true; }
///-------------------------------------------------------------------------------- /// <summary>This method handles the execution of the delete command.</summary> /// /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> ///-------------------------------------------------------------------------------- private void DeleteExecuted(object sender, ExecutedRoutedEventArgs e) { IndexesViewModel items = DataContext as IndexesViewModel; if (items != null) { foreach (IndexViewModel item in items.Indexes) { if (item.IsSelected == true) { if (MessageBox.Show(DisplayValues.Message_DeleteItemConfirmation, DisplayValues.Message_DeleteItemConfirmationCaption, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { items.DeleteIndex(item); } return; } } } }
///-------------------------------------------------------------------------------- /// <summary>This method handles the execution of the new command.</summary> /// /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> ///-------------------------------------------------------------------------------- private void NewExecuted(object sender, ExecutedRoutedEventArgs e) { Point currentPosition = MouseUtilities.GetMousePosition(this); IndexesViewModel items = DataContext as IndexesViewModel; EntityDiagramControl diagram = VisualItemHelper.VisualUpwardSearch <EntityDiagramControl>(this) as EntityDiagramControl; DiagramEntityViewModel diagramEntityView = diagram.DataContext as DiagramEntityViewModel; if (items != null && diagramEntityView != null) { dialog = new Window(); dialog.Height = 450 * UserSettingsHelper.Instance.ControlSize; dialog.Width = 400 * UserSettingsHelper.Instance.ControlSize; dialog.Left = Math.Max(currentPosition.X, 20); dialog.Top = Math.Max(currentPosition.Y, 20); dialog.Content = new IndexDialogControl(); Index newItem = new Index(); newItem.IndexID = Guid.NewGuid(); newItem.Solution = items.Solution; newItem.Entity = items.Entity; //newItem.ReferenceEntity = diagramEntityView.DiagramEntity.Entity; IndexViewModel newItemView = new IndexViewModel(newItem, items.Solution); newItemView.IsFreeDialog = true; dialog.DataContext = newItemView; dialog.Title = newItemView.Title; newItemView.RequestClose += new EventHandler(Item_RequestClose); #region protected #endregion protected dialog.ShowDialog(); if (newItemView.IsOK == true) { items.AddIndex(newItemView); } dialog.Close(); dialog = null; e.Handled = true; return; } }