private void treeViewSource_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { try { TreeViewSortBy sortBy = (TreeViewSortBy)comboBoxViewBy.SelectedIndex; TreeViewModel selectedItem = e.NewValue as TreeViewModel; if (null != selectedItem) { if (null == selectedItem._parent && selectedItem.Children.Count > 0) //root { projectView.RefreshTreeView((ModelInfo)comboBoxSource.SelectedItem, (ModelInfo)comboBoxRecipient.SelectedItem, treeViewSource, treeViewRecipient, sortBy, (bool)checkBoxCreateLinks.IsChecked); } else if (null != selectedItem._parent && selectedItem.Children.Count > 0)//sheet name or view type { string selectedHeader = ((TreeViewModel)e.NewValue).Name; string filterString = ((TreeViewModel)e.NewValue).Tag.ToString(); projectView.RefreshTreeViewBySelection((ModelInfo)comboBoxSource.SelectedItem, (ModelInfo)comboBoxRecipient.SelectedItem, treeViewSource, treeViewRecipient, sortBy, filterString, (bool)checkBoxCreateLinks.IsChecked); } } } catch (Exception ex) { MessageBox.Show("Failed to refresh the treeview by the selection.\n" + ex.Message, "Selection of the Treeview Source", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void comboBoxViewBy_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (comboBoxSource.SelectedIndex > -1 && comboBoxRecipient.SelectedIndex > -1) { if (m_mode == ModelManagerMode.ProjectReplication) { if (comboBoxSource.SelectedIndex == comboBoxRecipient.SelectedIndex) { labelWarning.Visibility = System.Windows.Visibility.Visible; treeViewSource.ItemsSource = null; treeViewRecipient.ItemsSource = null; } else { checkBoxLinked.IsChecked = false; TreeViewSortBy sortBy = (TreeViewSortBy)comboBoxViewBy.SelectedIndex; projectView.RefreshTreeView((ModelInfo)comboBoxSource.SelectedItem, (ModelInfo)comboBoxRecipient.SelectedItem, treeViewSource, treeViewRecipient, sortBy, (bool)checkBoxCreateLinks.IsChecked); } } } } catch (Exception ex) { MessageBox.Show("Failed to refresh the treeview based upon the selection of View By.\n" + ex.Message, "View By", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void buttonUpdate_Click(object sender, RoutedEventArgs e) { try { bool duplicated = projectView.UpdateDraftingViews((ModelInfo)comboBoxSource.SelectedItem, (ModelInfo)comboBoxRecipient.SelectedItem, treeViewSource, treeViewRecipient, (bool)checkBoxSheet.IsChecked, (bool)checkBoxCreateLinks.IsChecked, statusLable, progressBar); if (duplicated) { if (comboBoxSource.SelectedIndex > -1 && comboBoxRecipient.SelectedIndex > -1) { if (m_mode == ModelManagerMode.ProjectReplication) { TreeViewSortBy sortBy = (TreeViewSortBy)comboBoxViewBy.SelectedIndex; RefreshModelInfo(comboBoxSource.SelectedIndex, comboBoxRecipient.SelectedIndex); //update viewmapclass } } } } catch (Exception ex) { MessageBox.Show("Failed to initialize settings before updating views.\n" + ex.Message, "Update Views", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void RefreshTreeViewBySelection(ModelInfo sourceModel, ModelInfo recipientModel, TreeView sourceView, TreeView recipientView, TreeViewSortBy sortBy, string filterString, bool createLinks) { try { ViewMapClass viewMap = new ViewMapClass(sourceModel, recipientModel, createLinks); if (null != viewMap) { List <string> strList = new List <string>(); strList.Add(filterString); recipientView.ItemsSource = null; if (sortBy == TreeViewSortBy.Sheet) { recipientView.ItemsSource = TreeViewModel.SetTreeBySheet(recipientModel.DocTitle, viewMap.RecipientViews, strList); } else if (sortBy == TreeViewSortBy.ViewType) { recipientView.ItemsSource = TreeViewModel.SetTreeByViewType(recipientModel.DocTitle, viewMap.RecipientViews, strList); } } } catch (Exception ex) { MessageBox.Show("Failed to refresh the tree view by " + filterString + "\n" + ex.Message, "Refresh Tree View By Selection", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void RefreshTreeView(ModelInfo sourceModel, ModelInfo recipientModel, TreeView sourceView, TreeView recipientView, TreeViewSortBy sortBy, bool createLinks) { try { ViewMapClass viewMap = new ViewMapClass(sourceModel, recipientModel, createLinks); if (null != viewMap) { sourceView.ItemsSource = null; recipientView.ItemsSource = null; if (sortBy == TreeViewSortBy.Sheet) { sourceView.ItemsSource = TreeViewModel.SetTreeBySheet(sourceModel.DocTitle, viewMap.SourceViews, sheetNumbers); recipientView.ItemsSource = TreeViewModel.SetTreeBySheet(recipientModel.DocTitle, viewMap.RecipientViews, sheetNumbers); } else if (sortBy == TreeViewSortBy.ViewType) { sourceView.ItemsSource = TreeViewModel.SetTreeByViewType(sourceModel.DocTitle, viewMap.SourceViews, viewTypeNames); recipientView.ItemsSource = TreeViewModel.SetTreeByViewType(recipientModel.DocTitle, viewMap.RecipientViews, viewTypeNames); } } } catch (Exception ex) { MessageBox.Show("Failed to refresh the tree view.\nSource Model:" + sourceModel.DocTitle + "\nRecipient Model:" + recipientModel.DocTitle + "\n" + ex.Message, "Refresh Tree View", MessageBoxButton.OK, MessageBoxImage.Warning); } }