private void typeColumn_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2) { if (string.IsNullOrWhiteSpace((runCommandViewSource.View.CurrentItem as RunCommand).Arguments)) { switch (((Control)sender).Tag.ToString()) { case "type": { if ((runCommandViewSource.View.CurrentItem as RunCommand).Type == CommandType.CMDExecutedCommand) (runCommandViewSource.View.CurrentItem as RunCommand).Type = CommandType.SimpleRunCommand; else if ((runCommandViewSource.View.CurrentItem as RunCommand).Type == CommandType.SimpleRunCommand) (runCommandViewSource.View.CurrentItem as RunCommand).Type = CommandType.AutoCadCommand; else if ((runCommandViewSource.View.CurrentItem as RunCommand).Type == CommandType.AutoCadCommand) (runCommandViewSource.View.CurrentItem as RunCommand).Type = CommandType.CMDExecutedCommand; break; } } } else { MyMessageBox b = new MyMessageBox(); b.ShowMe("If you have used arguments, you must use CMDExecutedCommand type!", "Toggle error"); e.Handled = true; b = null; } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { //commandRepositoryViewSource.View.CurrentChanging += new System.ComponentModel.CurrentChangingEventHandler(View_CurrentChanging); this.Topmost = false; commandRepositoryViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("commandRepositoryViewSource"))); // Load data by setting the CollectionViewSource.Source property: commandRepositoryViewSource.Source = RepositoryLibrary.Repositorys; commandRepositoryViewSource.View.CurrentChanged += new EventHandler(View_CurrentChanged); runCommandViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("runCommandViewSource"))); // Load data by setting the CollectionViewSource.Source property: if (((CommandRepository)(((ListCollectionView)(commandRepositoryViewSource.View)).CurrentItem)) != null) runCommandViewSource.Source = ((CommandRepository)(((ListCollectionView)(commandRepositoryViewSource.View)).CurrentItem)).Commands; } catch (Exception ex) { MyMessageBox b = new MyMessageBox(); b.ShowMe(ex.Message, "Unhandled error"); Application.Current.Shutdown(); } }
private void View_CurrentChanged(object sender, EventArgs e) { try { if ((CommandRepository)(((ListCollectionView)(commandRepositoryViewSource.View)).CurrentItem) != null) { runCommandViewSource.Source = ((CommandRepository)(((ListCollectionView)(commandRepositoryViewSource.View)).CurrentItem)).Commands; } else { runCommandViewSource.Source = null; } } catch (Exception ex) { MyMessageBox b = new MyMessageBox(); b.ShowMe(ex.Message, "Unhandled error"); Application.Current.Shutdown(); } }