Пример #1
0
        private void mnuZoom_Click(object sender, System.EventArgs e)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            if (sender == mnuZoom50)
            {
                active.Model.Zoom = 50;
            }
            if (sender == mnuZoom75)
            {
                active.Model.Zoom = 75;
            }
            if (sender == mnuZoom100)
            {
                active.Model.Zoom = 100;
            }
            if (sender == mnuZoom200)
            {
                active.Model.Zoom = 200;
            }
            if (sender == mnuZoomBestFit)
            {
                active.ZoomBestFit();
            }

            active.Model.Refresh();
        }
Пример #2
0
        private void mnuTools_Click(object sender, System.EventArgs e)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            //Get a diagram point that is in the middle of the current display area
            PointF point = active.Model.PointToDiagram(active.Model.Size.Width / 2, active.Model.Size.Height / 2);

            //Add line
            if (sender == mnuAddLine)
            {
                active.AddLine(point);
            }

            //Add connector
            if (sender == mnuAddConnector)
            {
                active.AddConnector(point);
            }

            //Add group
            if (sender == mnuAddGroup)
            {
                active.AddGroup(point);
            }

            //Add layer
            if (sender == mnuAddLayer)
            {
                Layer layer = new Layer();
                layer.Name = "layer " + (active.Model.Layers.Count + 1).ToString();
                active.Model.Layers.Add(layer);
                active.Model.Layers.CurrentLayer = layer;
            }

            //Options
            if (sender == mnuToolsOptions)
            {
                frmOptions form = new frmOptions();
                form.DrawGrid     = active.Model.DrawGrid;
                form.AlignGrid    = active.Model.AlignGrid;
                form.HideActions  = Crainiate.Diagramming.Component.Instance.HideActions;
                form.Feedback     = active.Model.Runtime.Feedback;
                form.BasicActions = (active.Model.RenderDesign.ActionStyle == ActionStyle.Basic);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    active.Model.DrawGrid  = form.DrawGrid;
                    active.Model.AlignGrid = form.AlignGrid;
                    Crainiate.Diagramming.Component.Instance.HideActions = form.HideActions;
                    active.Model.Runtime.Feedback         = form.Feedback;
                    active.Model.RenderDesign.ActionStyle = (form.BasicActions) ? ActionStyle.Basic: ActionStyle.Default;
                }
            }
        }
Пример #3
0
        //Perform file and print actions
        private void DoFileAction(object sender)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            //Open
            if (sender == mnuFileOpen || sender == btnOpen)
            {
                active.Open("");
            }

            //Save
            if (sender == mnuFileSave || sender == btnSave)
            {
                active.Save(active.Path);
            }

            //Save as
            if (sender == mnuFileSaveAs)
            {
                active.Save("");
            }

            //Print preview
            if (sender == mnuFilePrintPreview)
            {
                Crainiate.Diagramming.Printing.PrintDocument print = new Crainiate.Diagramming.Printing.PrintDocument(active.Model);
                print.PrintPreview(new Point(100, 100), new Size(800, 600));
                return;
            }

            //Print with settings
            if (sender == mnuFilePrint || sender == btnPrint)
            {
                Crainiate.Diagramming.Printing.PrintDocument print         = new Crainiate.Diagramming.Printing.PrintDocument(active.Model);
                System.Windows.Forms.PrintDialog             printDialogue = new System.Windows.Forms.PrintDialog();
                printDialogue.Document = print;

                if (printDialogue.ShowDialog() == DialogResult.OK)
                {
                    print.Print();
                }
                return;
            }

            if (sender == mnuFileExit)
            {
                this.Close();
            }
        }
Пример #4
0
        //Occurs when a layer menu is clicked
        private void mnuLayer_Click(object sender, System.EventArgs e)
        {
            //Uncheck old menu item
            foreach (MenuItem menu in mnuLayers.MenuItems)
            {
                menu.Checked = false;
            }

            frmDiagram active = (frmDiagram)this.ActiveMdiChild;
            MenuItem   menu2  = (MenuItem)sender;
            Layer      layer  = active.Model.Layers[menu2.Text];

            menu2.Checked = true;
            active.Model.Layers.CurrentLayer = layer;
        }
Пример #5
0
        //Performs edit functions
        private void DoEditAction(object sender)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            //Undo
            if (sender == btnUndo || sender == mnuEditUndo)
            {
                active.Model.DoCommand("undo");
            }

            //Redo
            if (sender == btnRedo || sender == mnuEditRedo)
            {
                active.Model.DoCommand("redo");
            }

            //Cut
            if (sender == btnCut || sender == mnuEditCut)
            {
                active.Model.DoCommand("cut");
            }

            //Copy
            if (sender == btnCopy || sender == mnuEditCopy)
            {
                active.Model.DoCommand("copy");
            }

            //Paste
            if (sender == btnPaste || sender == mnuEditPaste)
            {
                active.Model.DoCommand("paste");
            }

            //Delete
            if (sender == mnuEditDelete)
            {
                active.Model.DoCommand("delete");
            }

            //Select all
            if (sender == mnuEditSelectAll)
            {
                active.Model.SelectElements(true);
            }
        }
Пример #6
0
        //Loads a new child Form and configues it to be displayed correctly
        private frmDiagram LoadChildForm()
        {
            frmDiagram form = new frmDiagram();

            //Set child form properties
            form.MdiParent       = this;
            form.Text            = "";
            form.WindowState     = FormWindowState.Normal;
            form.FormBorderStyle = FormBorderStyle.None;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.ControlBox      = false;
            form.ShowInTaskbar   = false;
            form.Dock            = DockStyle.Fill;

            form.Show();

            return(form);
        }
Пример #7
0
        //Load the current layers
        private void mnuView_Popup(object sender, System.EventArgs e)
        {
            MenuItem   menu;
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            //Clear old layers
            mnuLayers.MenuItems.Clear();

            //Add existing layers
            foreach (Layer layer in active.Model.Layers)
            {
                menu = new MenuItem(layer.Name);
                if (layer == active.Model.Layers.CurrentLayer)
                {
                    menu.Checked = true;
                }
                menu.Click += new EventHandler(mnuLayer_Click);

                mnuLayers.MenuItems.Add(0, menu);
            }
        }
Пример #8
0
        //Click on a toolbar button
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            if (e.Button == btnNew || e.Button == btnOpen || e.Button == btnSave || e.Button == btnPrint)
            {
                DoFileAction(e.Button);
            }
            if (e.Button == btnUndo || e.Button == btnRedo || e.Button == btnCut || e.Button == btnCopy || e.Button == btnPaste)
            {
                DoEditAction(e.Button);
            }


            if (e.Button == btnNormal)
            {
                btnAddLine.Pushed      = false;
                btnAddConnector.Pushed = false;
                btnAddComplex.Pushed   = false;
                btnNormal.Pushed       = true;
                active.Model.Runtime.InteractiveMode = InteractiveMode.Normal;
            }

            else if (e.Button == btnAddLine)
            {
                btnNormal.Pushed       = !btnAddLine.Pushed;
                btnAddConnector.Pushed = false;
                btnAddComplex.Pushed   = false;
                active.Model.Runtime.InteractiveMode = InteractiveMode.Normal;

                if (btnAddLine.Pushed)
                {
                    active.Model.Runtime.InteractiveMode = InteractiveMode.AddLine;
                }
            }

            else if (e.Button == btnAddConnector)
            {
                btnNormal.Pushed     = !btnAddConnector.Pushed;
                btnAddLine.Pushed    = false;
                btnAddComplex.Pushed = false;
                active.Model.Runtime.InteractiveMode = InteractiveMode.Normal;

                if (btnAddConnector.Pushed)
                {
                    active.Model.Runtime.InteractiveMode = InteractiveMode.AddConnector;
                }
            }

            else if (e.Button == btnAddComplex)
            {
                btnNormal.Pushed       = !btnAddComplex.Pushed;;
                btnAddLine.Pushed      = false;
                btnAddConnector.Pushed = false;
                active.Model.Runtime.InteractiveMode = InteractiveMode.Normal;

                if (btnAddComplex.Pushed)
                {
                    active.Model.Runtime.InteractiveMode = InteractiveMode.AddComplexLine;
                }
            }
        }