private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { try { DependencyObject parent = VisualTreeHelper.GetParent(this); Window parentWindow = Window.GetWindow(parent); CarboLifeMainWindow mainViewer = parentWindow as CarboLifeMainWindow; if (mainViewer != null) { CarboLifeProject = mainViewer.getCarbonLifeProject(); } if (CarboLifeProject != null) { //A project Is loaded, Proceed to next SetupInterFace(); } //Rebuild the materialList } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; var path = openFileDialog.ShowDialog(); if (openFileDialog.FileName != "") { CarboProject newProject = new CarboProject(); CarboProject buffer = new CarboProject(); newProject = buffer.DeSerializeXML(openFileDialog.FileName); CarboLifeUI.UI.CarboLifeMainWindow CarboApp = new CarboLifeUI.UI.CarboLifeMainWindow(newProject); CarboApp.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { try { DependencyObject parent = VisualTreeHelper.GetParent(this); Window parentWindow = Window.GetWindow(parent); CarboLifeMainWindow mainViewer = parentWindow as CarboLifeMainWindow; if (mainViewer != null) { CarboLifeProject = mainViewer.getCarbonLifeProject(); } if (CarboLifeProject != null) { //A project Is loaded, Proceed to next RefreshInterFace(); if (cbb_GraphType.Items.Count <= 0) { cbb_GraphType.Items.Add("Materials"); cbb_GraphType.Items.Add("Totals"); cbb_GraphType.Text = "Totals"; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }