private void DeleteScene_Click(object sender, RoutedEventArgs e) { MenuItem mItem = sender as MenuItem; if (null == mItem) { return; } ViewModel.Scene scene = mItem.DataContext as ViewModel.Scene; if (null == scene) { return; } string msg = string.Format(Properties.Resources.WarnDeleteScene, scene.Description); string title = Properties.Resources.Warning; MessageBoxButton btn = MessageBoxButton.OKCancel; MessageBoxResult result = MessageBox.Show(msg, title, btn); switch (result) { case MessageBoxResult.OK: break; default: return; } scene.Delete(); }
private void Scene_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { TextBlock item = sender as TextBlock; if (null == item) { return; } ContextMenu cMenu = item.ContextMenu; if (null == cMenu) { return; } ViewModel.Scene scene = item.DataContext as ViewModel.Scene; if (null == scene) { return; } if (null == scene.Owner) { return; } /* WARN : MenuItem's index is hard coded... */ const int upItemIndex = 4; MenuItem upItem = cMenu.Items.GetItemAt(upItemIndex) as MenuItem; if (null != upItem) { upItem.IsEnabled = scene.Owner.CanUp(scene); } const int downItemIndex = 5; MenuItem downItem = cMenu.Items.GetItemAt(downItemIndex) as MenuItem; if (null != downItem) { downItem.IsEnabled = scene.Owner.CanDown(scene); } }