private void SaveProjectAs_Executed(object sender, ExecutedRoutedEventArgs e) { var m = __any_binding_error(); if (m != null) { HandyControl.Controls.MessageBox.Show(this, $"At least one data binding error was found in <{m.FriendlyName}>.", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog(); save.Filter = "JavaScript Object Notation(*.json)|*.json"; save.AddExtension = true; save.DefaultExt = "json"; if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK) { __docking_documents_layout = __save_documents_docking_layout(_ToolboxContainer); var floatingLayout = __save_documents_floating_layout(); MainDataModel.SAVE_TO_JSON(__target_manager_data_model, __cabinets_navigation_data_model, __docking_documents_layout, floatingLayout, save.FileName); __main_wnd_data_model.ProjectPath = save.FileName; __main_wnd_data_model.IsDirty = false; } } catch (Exception ex) { HandyControl.Controls.MessageBox.Show(this, $"At least one unexpected error occured while saving the project.\n{ex.Message}", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void OpenProject_Executed(object sender, ExecutedRoutedEventArgs e) { if (__main_wnd_data_model.IsDirty == true || __docking_layout_comparison(_ToolboxContainer, __docking_documents_layout) == false) { if (HandyControl.Controls.MessageBox.Show(this, $"Discard the changes you have made ?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } } System.Windows.Forms.OpenFileDialog open = new System.Windows.Forms.OpenFileDialog(); open.Multiselect = false; open.Filter = "JavaScript Object Notation(*.json)|*.json"; open.AddExtension = true; open.DefaultExt = "json"; if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK) { List <LayoutDocument> floatingLayout = null; try { __cabinets_navigation_data_model.ClearToolbox((doc) => doc.Close()); MainDataModel.RESTORE_FROM_JSON(open.FileName, out __target_manager_data_model, __cabinets_navigation_data_model, out __docking_documents_layout, out floatingLayout); } catch (Exception ex) { HandyControl.Controls.MessageBox.Show(this, $"At least one unexpected error occured while opening the project.\n{ex.Message}", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error); } if (__target_manager_data_model == null) { __target_manager_data_model = new TargetManagerDataModel(); } _ConnectionTargetsContainer.Content = new TargetManagerControl(__target_manager_data_model); if (__docking_documents_layout == null) { __docking_documents_layout = __docking_documents_layout_null; } if (floatingLayout != null) { __restore_documents_floating_layout(floatingLayout); } _ToolboxContainer.Children.Clear(); if (__docking_documents_layout != null) { _ToolboxContainer.Orientation = (__docking_documents_layout as LayoutGroup).Orientation == TOOL_LAYOUT_ORIENTATION_T.HORIZONTAL ? Orientation.Horizontal : Orientation.Vertical; __restore_documents_docking_layout((__docking_documents_layout as LayoutGroup).SubLayout, _ToolboxContainer); } __main_wnd_data_model.ProjectPath = open.FileName; __main_wnd_data_model.IsDirty = false; } }
public MainWindow() { InitializeComponent(); __main_wnd_data_model = new MainDataModel(); DataContext = __main_wnd_data_model; try { __cabinets_navigation_data_model = new ToolsNavigationDataModel <LayoutDocument>(null, null, Plugin_PropertyChanged); _CabinetContainer.Content = new ToolsNavigationControl(__cabinets_navigation_data_model); __docking_documents_layout = __save_documents_docking_layout(_ToolboxContainer); __docking_documents_layout_null = __docking_documents_layout; __data_synchronizer = new DataSynchronizer(__cabinets_navigation_data_model.ToolDataCollection); __user_interface_synchronizer = new UserInterfaceSynchronizer(this, __ui_data_refresh_handler); } catch (Exception ex) { HandyControl.Controls.MessageBox.Show(this, $"At least one unexpected error occured during the boot process.\n{ex.Message}", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error); Close(); } }
private void SaveProject_Executed(object sender, ExecutedRoutedEventArgs e) { var m = __any_binding_error(); if (m != null) { HandyControl.Controls.MessageBox.Show(this, $"At least one data binding error was found in <{m.FriendlyName}>.", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { __docking_documents_layout = __save_documents_docking_layout(_ToolboxContainer); var floatingLayout = __save_documents_floating_layout(); MainDataModel.SAVE_TO_JSON(__target_manager_data_model, __cabinets_navigation_data_model, __docking_documents_layout, floatingLayout, __main_wnd_data_model.ProjectPath); __main_wnd_data_model.IsDirty = false; } catch (Exception ex) { HandyControl.Controls.MessageBox.Show(this, $"At least one unexpected error occured while saving the project.\n{ex.Message}", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error); } }