private void menuItem2_Click(object sender, System.EventArgs e) { Crainiate.ERM4.Printing.PrintDocument print = new Crainiate.ERM4.Printing.PrintDocument(model1); print.PrintPreview(new Point(100, 100), new Size(600, 480)); model1.Save("c:\\diagram.png", SaveFormat.Png); }
private void MenuItem_Activate(object sender, EventArgs e) { try { if (this.InvokeRequired) { this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { sender, e }); } else { // Get Schema and ActiveModel SchemaModel schemaModel = null; EsriModel activeModel = null; DockControl[] dockControls = this.sandDockManager1.GetDockControls(DockSituation.Document); TabbedDocument activeTab = null; if (dockControls.Length > 0) { foreach (TabbedDocument tab2 in dockControls) { if (tab2 is ITabModel) { ITabModel tabModel = (ITabModel)tab2; if (tabModel.Model.GetType() == typeof(SchemaModel)) { schemaModel = (SchemaModel)tabModel.Model; break; } } } activeTab = this.sandDockManager1.ActiveTabbedDocument as TabbedDocument; if (activeTab is ITabModel) { ITabModel tabModel = (ITabModel)activeTab; activeModel = tabModel.Model; } } // // File Menu // if (sender == this.menuButtonItemNew) { // Prompt to close the schema model (if available) if (schemaModel != null) { if (schemaModel.Dirty) { DialogResult dialogResult = MessageBox.Show( Resources.TEXT_SAVE_DOCUMENT_BEFORE_CLOSING, Resources.TEXT_ARCDIAGRAMMER, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); switch (dialogResult) { case DialogResult.Yes: this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuButtonItemSaveAs, EventArgs.Empty }); break; case DialogResult.No: break; case DialogResult.Cancel: default: return; } } } // Close all tabs foreach (TabbedDocument tab in dockControls) { if (tab is ITabModel) { ITabModel tabModel = (ITabModel)tab; EsriModel model = tabModel.Model; model.SuspendLayout(); } tab.Close(); } // Clear Catalog this.catalog1.Suspend(); this.catalog1.SchemaModel = null; this.catalog1.Resume(); this.catalog1.RefreshCatalog(); // Clear Property Grid this.propertyEditor1.PropertyGrid.SelectedObjects = null; // Clear Overview this.esriOverview1.Suspend(); this.esriOverview1.Diagram = null; this.esriOverview1.Resume(); this.esriOverview1.Refresh(); // Clear Error List this.errorList1.Clear(); // Clear Schema Model in Diagrammer Environment Singleton DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; diagrammerEnvironment.SchemaModel = null; // Create new schema tab string filename = null; this.CreateTabbedDocument(filename); } else if (sender == this.menuButtonItemOpen) { // Prompt to close the schema model (if available) if (schemaModel != null) { if (schemaModel.Dirty) { DialogResult dialogResult = MessageBox.Show( Resources.TEXT_SAVE_DOCUMENT_BEFORE_OPENING, Resources.TEXT_ARCDIAGRAMMER, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); switch (dialogResult) { case DialogResult.Yes: this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuButtonItemSaveAs, EventArgs.Empty }); break; case DialogResult.No: break; case DialogResult.Cancel: default: return; } } } // Close all tabs foreach (TabbedDocument tab in dockControls) { if (tab is ITabModel) { ITabModel tabModel = (ITabModel)tab; EsriModel model = tabModel.Model; model.SuspendLayout(); } tab.Close(); } // Clear Catalog this.catalog1.Suspend(); this.catalog1.SchemaModel = null; this.catalog1.Resume(); this.catalog1.RefreshCatalog(); // Clear Property Grid this.propertyEditor1.PropertyGrid.SelectedObjects = null; // Clear Overview this.esriOverview1.Suspend(); this.esriOverview1.Diagram = null; this.esriOverview1.Resume(); this.esriOverview1.Refresh(); // Clear Error List this.errorList1.Clear(); // Clear Schema Model in Diagrammer Environment Singleton DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; diagrammerEnvironment.SchemaModel = null; // Display OpenFileDialog OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.CheckFileExists = true; openFileDialog.Filter = Resources.TEXT_ALL_DIAGRAMMER_DOCUMENTS + " (*.xml; *.diagram)|*.xml;*.diagram|" + Resources.TEXT_XML_WORKSPACE_DOCUMENT + " (*.xml)|*.xml|" + Resources.TEXT_ARCGIS_DIAGRAMMER_DOCUMENT + " (*.diagram)|*.diagram"; openFileDialog.FilterIndex = 1; openFileDialog.Multiselect = false; openFileDialog.ShowHelp = true; openFileDialog.Title = Resources.TEXT_OPEN_XML_WORKSPACE_DOCUMENT; // Display Open File Dialog if (openFileDialog.ShowDialog(this) != DialogResult.OK) { return; } // Get Filename string filename = openFileDialog.FileName; if (string.IsNullOrEmpty(filename)) { return; } // Open File this.CreateTabbedDocument(filename); } else if (sender == this.menuButtonItemClose) { // Prompt to close the schema model (if available) if (schemaModel != null) { if (schemaModel.Dirty) { DialogResult dialogResult = MessageBox.Show( Resources.TEXT_SAVE_DOCUMENT_BEFORE_CLOSING, Resources.TEXT_ARCDIAGRAMMER, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); switch (dialogResult) { case DialogResult.Yes: //this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuButtonItemSaveAs, EventArgs.Empty }); this.MenuItem_Activate(this.menuButtonItemSaveAs, EventArgs.Empty); break; case DialogResult.No: break; case DialogResult.Cancel: default: return; } } } // Close all tabs foreach (TabbedDocument tab in dockControls) { if (tab is ITabModel) { ITabModel tabModel = (ITabModel)tab; EsriModel model = tabModel.Model; model.SuspendLayout(); } tab.Close(); } // Clear Catalog this.catalog1.Suspend(); this.catalog1.SchemaModel = null; this.catalog1.Resume(); this.catalog1.RefreshCatalog(); // Clear Property Grid this.propertyEditor1.PropertyGrid.SelectedObjects = null; // Clear Overview this.esriOverview1.Suspend(); this.esriOverview1.Diagram = null; this.esriOverview1.Resume(); this.esriOverview1.Refresh(); // Clear Error List this.errorList1.Clear(); // Clear Schema Model in Diagrammer Environment Singleton DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; diagrammerEnvironment.SchemaModel = null; } else if (sender == this.menuButtonItemSave) { // Exit if no model if (schemaModel == null) { return; } // If not path then SaveAs if (string.IsNullOrEmpty(schemaModel.Document)) { this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuButtonItemSaveAs, EventArgs.Empty }); } else { // Get Directory string directory = Path.GetDirectoryName(schemaModel.Document); // If Directory is in if (string.IsNullOrEmpty(directory) || !Directory.Exists(directory)) { this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuButtonItemSaveAs, EventArgs.Empty }); } else { // Save Model schemaModel.Save(schemaModel.Document, SaveFormat.Binary); schemaModel.Dirty = false; } } // Refresh PropertyGrid this.propertyEditor1.PropertyGrid.Refresh(); } else if (sender == this.menuButtonItemSaveAs) { // Exit if no model if (schemaModel == null) { return; } // Show SaveAs Dialog SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "diagram"; saveFileDialog.FileName = schemaModel.Title; saveFileDialog.Filter = Resources.TEXT_ARCGIS_DIAGRAMMER_DOCUMENT + " (*.diagram)|*.diagram"; // + saveFileDialog.FilterIndex = 1; saveFileDialog.OverwritePrompt = true; saveFileDialog.RestoreDirectory = false; saveFileDialog.ShowHelp = true; saveFileDialog.Title = Resources.TEXT_SAVE_DIAGRAM; // Check if user pressed "Save" and File is OK. if (saveFileDialog.ShowDialog(this) != DialogResult.OK) { return; } if (string.IsNullOrEmpty(saveFileDialog.FileName)) { return; } // Save to binary file schemaModel.Save(saveFileDialog.FileName, SaveFormat.Binary); schemaModel.Document = saveFileDialog.FileName; schemaModel.Dirty = false; // Refresh PropertyGrid this.propertyEditor1.PropertyGrid.Refresh(); } else if (sender == this.menuButtonItemPublish) { // Exit if no model if (schemaModel == null) { return; } // Show SaveAs Dialog SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "xml"; saveFileDialog.FileName = schemaModel.Title; saveFileDialog.Filter = Resources.TEXT_XML_WORKSPACE_DOCUMENT + " (*.xml)|*.xml"; saveFileDialog.FilterIndex = 1; saveFileDialog.OverwritePrompt = true; saveFileDialog.RestoreDirectory = false; saveFileDialog.ShowHelp = true; saveFileDialog.Title = Resources.TEXT_SAVE_DIAGRAM_AS_XML_WORKSPACE_DOCUMENT; // Check if user pressed "Save" and File is OK. if (saveFileDialog.ShowDialog(this) != DialogResult.OK) { return; } if (string.IsNullOrEmpty(saveFileDialog.FileName)) { return; } // Save Model to an Xml Workspace Document schemaModel.PublishModel(saveFileDialog.FileName); } else if (sender == this.menuButtonItemExport) { if (activeTab is ITabModel) { // Exit if not Active Model if (activeModel == null) { return; } // Show SaveAs Dialog SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "bmp"; saveFileDialog.FileName = activeTab.Text; saveFileDialog.Filter = "Windows Bitmap" + " (*.bmp)|*.bmp|" + "Windows Metafile" + " (*.wmf)|*.wmf|" + "GIF" + " (*.gif)|*.gif|" + "JPEG" + " (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Graphics" + " (*.png)|*.png|" + "Scalar Vector Graphic" + " (*.svg)|*.svg"; saveFileDialog.FilterIndex = 1; saveFileDialog.OverwritePrompt = true; saveFileDialog.RestoreDirectory = false; saveFileDialog.ShowHelp = true; saveFileDialog.Title = Resources.TEXT_EXPORT_DIAGRAM; // Check if user pressed "Save" and File is OK. if (saveFileDialog.ShowDialog(this) != DialogResult.OK) { return; } if (string.IsNullOrEmpty(saveFileDialog.FileName)) { return; } // switch (saveFileDialog.FilterIndex) { case 1: activeModel.ExportModel(saveFileDialog.FileName, SaveFormat.Bmp); break; case 2: activeModel.ExportModel(saveFileDialog.FileName, SaveFormat.Metafile); break; case 3: activeModel.ExportModel(saveFileDialog.FileName, SaveFormat.Gif); break; case 4: activeModel.ExportModel(saveFileDialog.FileName, SaveFormat.Jpeg); break; case 5: activeModel.ExportModel(saveFileDialog.FileName, SaveFormat.Png); break; case 6: activeModel.ExportModel(saveFileDialog.FileName, SaveFormat.Svg); break; default: break; } } else if (activeTab is ITabPrinter) { ITabPrinter tabPrinter = (ITabPrinter)activeTab; tabPrinter.SaveAs(); } } else if (sender == this.menuButtonItemPrintSetup) { if (activeTab is ITabModel) { // Display Diagrammer Printer Setup Window Office2007Renderer renderer = (Office2007Renderer)this.sandBarManager1.Renderer; FormPrinterSetup form = new FormPrinterSetup(); form.BackColor = renderer.BackgroundGradientColor1; form.Font = this.Font; form.ShowDialog(this); } else if (activeTab is ITabPrinter) { ITabPrinter tabPrinter = (ITabPrinter)activeTab; tabPrinter.PageSetup(); } } else if (sender == this.menuButtonItemPrint) { if (activeTab is ITabModel) { // Exit if not Active Model if (activeModel == null) { return; } // Get Print Document Crainiate.ERM4.Printing.PrintDocument printDocument = new Crainiate.ERM4.Printing.PrintDocument(activeModel); // DiagramPrinterSettings printer = DiagramPrinterSettings.Default; // Set Printer Properties if (printer.PrinterName != string.Empty) { printDocument.PrinterSettings.PrinterName = printer.PrinterName; } if (printer.PrinterPaperSize != string.Empty) { foreach (PaperSize paperSize in printDocument.PrinterSettings.PaperSizes) { if (paperSize.PaperName == printer.PrinterPaperSize) { printDocument.DefaultPageSettings.PaperSize = paperSize; break; } } } printDocument.DefaultPageSettings.Landscape = printer.Landscape; printDocument.DefaultPageSettings.Margins = printer.Margins; // Assign Print Document to Print Dialog this.printDialog1.Document = printDocument; DialogResult dialogResult = this.printDialog1.ShowDialog(this); // If the result is OK then print the document. switch (dialogResult) { case DialogResult.OK: printDocument.Print(); break; case DialogResult.Cancel: default: break; } } else if (activeTab is ITabPrinter) { ITabPrinter tabPrinter = (ITabPrinter)activeTab; tabPrinter.Print(); } } else if (sender == this.menuButtonItemPrintPreview) { if (activeTab is ITabModel) { // Exit if not Active Model if (activeModel == null) { return; } // Preview Printing Crainiate.ERM4.Printing.PrintDocument printDocument = new Crainiate.ERM4.Printing.PrintDocument(activeModel); // DiagramPrinterSettings printer = DiagramPrinterSettings.Default; if (printer.PrinterName != string.Empty) { printDocument.PrinterSettings.PrinterName = printer.PrinterName; } if (printer.PrinterPaperSize != string.Empty) { foreach (PaperSize paperSize in printDocument.PrinterSettings.PaperSizes) { if (paperSize.PaperName == printer.PrinterPaperSize) { printDocument.DefaultPageSettings.PaperSize = paperSize; break; } } } printDocument.DefaultPageSettings.Landscape = printer.Landscape; printDocument.DefaultPageSettings.Margins = printer.Margins; // Assign Print Document to Print Dialog this.printPreviewDialog1.Font = new Font("Tahoma", 8); this.printPreviewDialog1.Icon = Resources.DIAGRAMMER; this.printPreviewDialog1.Document = printDocument; DialogResult dialogResult = this.printPreviewDialog1.ShowDialog(this); } else if (activeTab is ITabPrinter) { ITabPrinter tabPrinter = (ITabPrinter)activeTab; tabPrinter.PrintPreview(); } } else if (sender == this.menuButtonItemExit) { this.Close(); } // // Edit Menu // else if (sender == this.menuButtonItemUndo) { if (this.propertyEditor1.PropertyGrid.RectangleToScreen(this.propertyEditor1.PropertyGrid.ClientRectangle).Contains(Cursor.Position)) { SendMessage(this.propertyEditor1.PropertyGrid.Handle, WM_UNDO, IntPtr.Zero, IntPtr.Zero); } else { // Exit if no model if (activeModel == null || !activeModel.CanUndo) { return; } // Select All Elements activeModel.DoCommand("undo"); // Fire Model SelectionChanged Event activeModel.Invoke(new EventHandler(this.Model_SelectedChanged), new object[] { activeModel, EventArgs.Empty }); } } else if (sender == this.menuButtonItemRedo) { if (this.propertyEditor1.PropertyGrid.RectangleToScreen(this.propertyEditor1.PropertyGrid.ClientRectangle).Contains(Cursor.Position)) { SendMessage(this.propertyEditor1.PropertyGrid.Handle, WM_UNDO, IntPtr.Zero, IntPtr.Zero); } else { // Exit if no model if (activeModel == null || !activeModel.CanRedo) { return; } // Select All Elements activeModel.DoCommand("redo"); // Fire Model SelectionChanged Event activeModel.Invoke(new EventHandler(this.Model_SelectedChanged), new object[] { activeModel, EventArgs.Empty }); } } else if (sender == this.menuButtonItemCut) { if (this.propertyEditor1.PropertyGrid.RectangleToScreen(this.propertyEditor1.PropertyGrid.ClientRectangle).Contains(Cursor.Position)) { SendMessage(this.propertyEditor1.PropertyGrid.Handle, WM_CUT, IntPtr.Zero, IntPtr.Zero); } else { // Exit if no model if (activeModel == null || !activeModel.CanCut) { return; } // Select All Elements activeModel.DoCommand("cut"); // Fire Model SelectionChanged Event activeModel.Invoke(new EventHandler(this.Model_SelectedChanged), new object[] { activeModel, EventArgs.Empty }); } } else if (sender == this.menuButtonItemCopy) { if (this.propertyEditor1.PropertyGrid.RectangleToScreen(this.propertyEditor1.PropertyGrid.ClientRectangle).Contains(Cursor.Position)) { FormDiagrammer.SendMessage(this.propertyEditor1.PropertyGrid.Handle, FormDiagrammer.WM_COPY, IntPtr.Zero, IntPtr.Zero); } else { // Exit if no model if (activeModel == null || !activeModel.CanCopy) { return; } // Select All Elements activeModel.DoCommand("copy"); } } else if (sender == this.menuButtonItemPaste) { if (this.propertyEditor1.PropertyGrid.RectangleToScreen(this.propertyEditor1.PropertyGrid.ClientRectangle).Contains(Cursor.Position)) { SendMessage(this.propertyEditor1.PropertyGrid.Handle, WM_PASTE, IntPtr.Zero, IntPtr.Zero); } else { // Select All Elements activeModel.DoCommand("paste"); // Fire Model SelectionChanged Event activeModel.Invoke(new EventHandler(this.Model_SelectedChanged), new object[] { activeModel, EventArgs.Empty }); } } else if (sender == this.menuButtonItemDelete) { if (this.propertyEditor1.PropertyGrid.RectangleToScreen(this.propertyEditor1.PropertyGrid.ClientRectangle).Contains(Cursor.Position)) { SendMessage(this.propertyEditor1.PropertyGrid.Handle, WM_CLEAR, IntPtr.Zero, IntPtr.Zero); } else { // Exit if no model if (activeModel == null || !activeModel.CanDelete) { return; } // Select All Elements activeModel.DoCommand("delete"); // Fire Model SelectionChanged Event activeModel.Invoke(new EventHandler(this.Model_SelectedChanged), new object[] { activeModel, EventArgs.Empty }); } } else if (sender == this.menuButtonItemSelectAll) { // Exit if no model if (activeModel == null || !activeModel.CanSelectAll) { return; } // Select All Elements activeModel.SelectElements(true); } // // View Menu // else if (sender == this.menuButtonItemOverviewWindow) { if (this.dockableWindowOverview.IsOpen) { this.dockableWindowOverview.Close(); } else { if (this.dockableWindowOverview.DockSituation != DockSituation.Docked) { this.dockableWindowOverview.Open(); } } } else if (sender == this.menuButtonItemCatalogWindow) { if (this.dockableWindowCatalog.IsOpen) { this.dockableWindowCatalog.Close(); } else { if (this.dockableWindowCatalog.DockSituation != DockSituation.Docked) { this.dockableWindowCatalog.Open(); } } } else if (sender == this.menuButtonItemPaletteWindow) { if (this.dockableWindowPalette.IsOpen) { this.dockableWindowPalette.Close(); } else { if (this.dockableWindowPalette.DockSituation != DockSituation.Docked) { this.dockableWindowPalette.Open(); } } } else if (sender == this.menuButtonItemPropertiesWindow) { if (this.dockableWindowProperties.IsOpen) { this.dockableWindowProperties.Close(); } else { if (this.dockableWindowProperties.DockSituation != DockSituation.Docked) { this.dockableWindowProperties.Open(); } } } else if (sender == this.menuButtonItemErrorList) { if (this.dockableWindowErrorList.IsOpen) { this.dockableWindowErrorList.Close(); } else { if (this.dockableWindowErrorList.DockSituation != DockSituation.Docked) { this.dockableWindowErrorList.Open(); } } } else if (sender == this.menuButtonItemExceptions) { ExceptionDialog.Default.Show(this); } else if (sender == this.menuButtonItemStatusBar) { this.statusBar1.Visible = !(this.statusBar1.Visible); } // // View > Color Scheme Menu // else if (sender == this.menuButtonItemColorSchemeBlack) { ColorSchemeSettings.Default.ColorScheme = Office2007ColorScheme.Black; ColorSchemeSettings.Default.Save(); } else if (sender == this.menuButtonItemColorSchemeBlue) { ColorSchemeSettings.Default.ColorScheme = Office2007ColorScheme.Blue; ColorSchemeSettings.Default.Save(); } else if (sender == this.menuButtonItemColorSchemeSilver) { ColorSchemeSettings.Default.ColorScheme = Office2007ColorScheme.Silver; ColorSchemeSettings.Default.Save(); } // // View > Layout Menu // else if (sender == this.menuButtonItemCircular) { // Exit if no model if (activeModel == null) { return; } // activeModel.ExecuteLayout(typeof(CircularLayout), false); // Recalculate scale of Overview Window this.esriOverview1.ZoomFullExtent(); } else if (sender == this.menuButtonItemForcedDirect) { // Exit if no model if (activeModel == null) { return; } // activeModel.ExecuteLayout(typeof(ForceDirectedLayout), false); // Recalculate scale of Overview Window this.esriOverview1.ZoomFullExtent(); } else if (sender == this.menuButtonItemHierachical) { // Exit if no model if (activeModel == null) { return; } // activeModel.ExecuteLayout(typeof(HierarchicalLayout), false); // Recalculate scale of Overview Window this.esriOverview1.ZoomFullExtent(); } else if (sender == this.menuButtonItemOrthogonal) { // Exit if no model if (activeModel == null) { return; } // activeModel.ExecuteLayout(typeof(OrthogonalLayout), false); // Recalculate scale of Overview Window this.esriOverview1.ZoomFullExtent(); } else if (sender == this.menuButtonItemTree) { // Exit if no model if (activeModel == null) { return; } // activeModel.ExecuteLayout(typeof(TreeLayout), false); // Recalculate scale of Overview Window this.esriOverview1.ZoomFullExtent(); } else if (sender == this.menuButtonItemAlignLeft) { // Exit if no model if (activeModel == null) { return; } // Get Elements Elements elements = activeModel.SelectedShapes(); if (elements.Count < 2) { return; } // Get Min Left float left = float.NaN; foreach (Shape shape in elements.Values) { if (float.IsNaN(left)) { left = shape.Location.X; continue; } left = Math.Min(left, shape.Location.X); } if (float.IsNaN(left)) { return; } // Move Elements foreach (Shape shape in elements.Values) { float leftTest = shape.Location.X; if (leftTest == left) { continue; } shape.Move(left - leftTest, 0f); } } else if (sender == this.menuButtonItemAlignCenter) { // Exit if no model if (activeModel == null) { return; } // Get Elements Elements elements = activeModel.SelectedShapes(); if (elements.Count < 2) { return; } // Get Max Right float center = float.NaN; foreach (Shape shape in elements.Values) { if (float.IsNaN(center)) { center = shape.Location.X + (shape.Width / 2); break; } } if (float.IsNaN(center)) { return; } // Move Elements foreach (Shape shape in elements.Values) { float centerTest = shape.Location.X + (shape.Width / 2); if (centerTest == center) { continue; } shape.Move(center - centerTest, 0f); } } else if (sender == this.menuButtonItemAlignRight) { // Exit if no model if (activeModel == null) { return; } // Get Elements Elements elements = activeModel.SelectedShapes(); if (elements.Count < 2) { return; } // Get Max Right float right = float.NaN; foreach (Shape shape in elements.Values) { if (float.IsNaN(right)) { right = shape.Location.X + shape.Width; continue; } right = Math.Max(right, shape.Location.X + shape.Width); } if (float.IsNaN(right)) { return; } // Move Elements foreach (Shape shape in elements.Values) { float rightTest = shape.Location.X + shape.Width; if (rightTest == right) { continue; } shape.Move(right - rightTest, 0f); } } else if (sender == this.menuButtonItemAlignTop) { // Exit if no model if (activeModel == null) { return; } // Get Elements Elements elements = activeModel.SelectedShapes(); if (elements.Count < 2) { return; } // Get Max Right float top = float.NaN; foreach (Shape shape in elements.Values) { if (float.IsNaN(top)) { top = shape.Location.Y; continue; } top = Math.Min(top, shape.Location.Y); } if (float.IsNaN(top)) { return; } // Move Elements foreach (Shape shape in elements.Values) { float topTest = shape.Location.Y; if (topTest == top) { continue; } shape.Move(0f, top - topTest); } } else if (sender == this.menuButtonItemAlignMiddle) { // Exit if no model if (activeModel == null) { return; } // Get Elements Elements elements = activeModel.SelectedShapes(); if (elements.Count < 2) { return; } // Get Max Right float middle = float.NaN; foreach (Shape shape in elements.Values) { if (float.IsNaN(middle)) { middle = shape.Location.Y + (shape.Height / 2); break; } } if (float.IsNaN(middle)) { return; } // Move Elements foreach (Shape shape in elements.Values) { float middleTest = shape.Location.Y + (shape.Height / 2); if (middleTest == middle) { continue; } shape.Move(0f, middle - middleTest); } } else if (sender == this.menuButtonItemAlignBottom) { // Exit if no model if (activeModel == null) { return; } // Get Elements Elements elements = activeModel.SelectedShapes(); if (elements.Count < 2) { return; } // Get Max Right float bottom = float.NaN; foreach (Shape shape in elements.Values) { if (float.IsNaN(bottom)) { bottom = shape.Location.Y + shape.Height; continue; } bottom = Math.Max(bottom, shape.Location.Y + shape.Height); } if (float.IsNaN(bottom)) { return; } // Move Elements foreach (Shape shape in elements.Values) { float bottomTest = shape.Location.Y + shape.Height; if (bottomTest == bottom) { continue; } shape.Move(0f, bottom - bottomTest); } } // // View > Toolbars Menu // else if (sender == this.menuButtonItemStandardToolbar) { this.toolBarStandard.Visible = !(this.toolBarStandard.Visible); } else if (sender == this.menuButtonItemLayoutToolbar) { this.toolBarLayout.Visible = !(this.toolBarLayout.Visible); } else if (sender == this.menuButtonItemInteractiveModeToolbar) { this.toolBarInteractiveMode.Visible = !(this.toolBarInteractiveMode.Visible); } // // View > Zoom Menu // else if (sender == this.menuButtonItemZoom300) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomModel(300f); } else if (sender == this.menuButtonItemZoom200) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomModel(200f); } else if (sender == this.menuButtonItemZoom100) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomModel(100f); } else if (sender == this.menuButtonItemZoom75) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomModel(75f); } else if (sender == this.menuButtonItemZoom50) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomModel(50f); } else if (sender == this.menuButtonItemZoom25) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomModel(25f); } else if (sender == this.menuButtonItemZoomFull) { // Exit if no model if (activeModel == null) { return; } activeModel.ZoomFullExtent(); } // // Tools Menu // else if (sender == this.menuButtonItemNormalMode) { // Set Interactive Mode to Normal if (activeModel == null) { return; } activeModel.Runtime.InteractiveMode = InteractiveMode.Normal; } else if (sender == this.menuButtonItemLinkMode) { // Set Interactive Mode to Link if (activeModel == null) { return; } activeModel.Runtime.InteractiveMode = InteractiveMode.AddLine; } else if (sender == this.menuButtonItemSchemaReport) { // Add Schema Report Tabbed Documenet this.CreateTabbedDocument(typeof(SchemaReport)); } else if (sender == this.menuButtonItemDataReport) { // Add Data Report Tabbed Document this.CreateTabbedDocument(typeof(DataReport)); } else if (sender == this.menuButtonItemXmlReport) { // Add Data Report Tabbed Document this.CreateTabbedDocument(typeof(XmlReport)); } else if (sender == this.menuButtonItemValidate) { // Exit if no model if (schemaModel == null) { return; } // Valid Schema Model this.errorList1.Validate2(); } else if (sender == this.menuButtonItemOptions) { // Dispaly Options Window Office2007Renderer r = (Office2007Renderer)this.sandBarManager1.Renderer; FormOptions options = new FormOptions(); options.BackColor = r.BackgroundGradientColor1; options.Font = this.Font; options.ShowDialog(this); } // // Window Menu // else if (sender == this.menuButtonItemNewHorizontalTabGroup || sender == this.menuButtonItemNewVerticalTabGroup) { SplitLayoutSystem splitLayoutSystem = new SplitLayoutSystem(); if (sender == this.menuButtonItemNewHorizontalTabGroup) { splitLayoutSystem.SplitMode = Orientation.Horizontal; } else if (sender == this.menuButtonItemNewVerticalTabGroup) { splitLayoutSystem.SplitMode = Orientation.Vertical; } LayoutSystemBase[] layoutSystemBase = new LayoutSystemBase[this.sandDockManager1.GetDockControls(DockSituation.Document).Length]; foreach (DockControl dockControl in this.sandDockManager1.GetDockControls(DockSituation.Document)) { DocumentLayoutSystem documentLayoutSystem = new DocumentLayoutSystem(); documentLayoutSystem.Controls.Add(dockControl); splitLayoutSystem.LayoutSystems.Add(documentLayoutSystem); } this.sandDockManager1.DocumentContainer.LayoutSystem = splitLayoutSystem; } else if (sender == this.menuButtonItemRestoreTabGroup) { SplitLayoutSystem splitLayoutSystem = new SplitLayoutSystem(); splitLayoutSystem.SplitMode = Orientation.Horizontal; LayoutSystemBase[] layoutSystemBase = new LayoutSystemBase[1]; DocumentLayoutSystem documentLayoutSystem = new DocumentLayoutSystem(); foreach (DockControl dockControl in this.sandDockManager1.GetDockControls(DockSituation.Document)) { documentLayoutSystem.Controls.Add(dockControl); } splitLayoutSystem.LayoutSystems.Add(documentLayoutSystem); this.sandDockManager1.DocumentContainer.LayoutSystem = splitLayoutSystem; } else if (sender == this.menuButtonItemCloseAllDocuments) { // if (schemaModel != null) { DialogResult dialogResult = MessageBox.Show( Resources.TEXT_SAVE_DOCUMENT_BEFORE_CLOSING, Resources.TEXT_ARCDIAGRAMMER, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); switch (dialogResult) { case DialogResult.Yes: this.Invoke(new EventHandler(this.MenuItem_Activate), new object[] { this.menuButtonItemSaveAs, EventArgs.Empty }); break; case DialogResult.No: break; case DialogResult.Cancel: default: return; } } // foreach (TabbedDocument tabbedDocument in this.sandDockManager1.GetDockControls(DockSituation.Document)) { tabbedDocument.Close(); } // Clear Catalog this.catalog1.Suspend(); this.catalog1.SchemaModel = null; this.catalog1.Resume(); this.catalog1.RefreshCatalog(); // Clear Property Grid this.propertyEditor1.PropertyGrid.SelectedObjects = null; // Clear Overview this.esriOverview1.Suspend(); this.esriOverview1.Diagram = null; this.esriOverview1.Resume(); this.esriOverview1.Refresh(); // Clear Error List this.errorList1.Clear(); // Clear Schema Model in Diagrammer Environment Singleton DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; diagrammerEnvironment.SchemaModel = null; } else if (sender == this.menuButtonItemWindows) { // Display Window Manager Office2007Renderer r = (Office2007Renderer)this.sandBarManager1.Renderer; FormWindows form = new FormWindows(this.sandDockManager1); form.BackColor = r.BackgroundGradientColor1; form.Font = this.Font; form.ShowDialog(this); } // // Help Menu // else if (sender == this.menuButtonItemUserGuide) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_USERGUIDE; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemCreateSchemaReport) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_CREATE_SCHEMA_REPORT; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemCreateDataReport) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_CREATE_DATA_REPORT; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemReorderFields) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_REORDER_FIELDS; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemAddSubtype) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_ADDSUBTYPE; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemCreateOneToManyRelationship) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_ADDRELATIONSHIP; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemSendFeedback) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_FEEDBACK; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemDiscussionForum) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_DISCUSSION; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemHistory) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_HISTORY; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemEsriHome) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_ESRI_HOME; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemEsriSupportCenter) { Process process = new Process(); process.StartInfo.FileName = Resources.TEXT_URL_ARCGIS_IDEAS; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = false; process.Start(); } else if (sender == this.menuButtonItemAbout) { // Display About Dialog Office2007Renderer r = (Office2007Renderer)this.sandBarManager1.Renderer; FormAbout about = new FormAbout(); about.BackColor = r.BackgroundGradientColor1; about.Font = this.Font; about.ShowDialog(this); } else if (sender is ZoomMenuItem) { if (activeModel == null) { return; } ZoomMenuItem item = (ZoomMenuItem)sender; if (item.Zoom == -1) { activeModel.ZoomFullExtent(); } else { activeModel.ZoomModel(item.Zoom); } } } } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }