Example #1
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            const int BT_PAGEATTR = 0;
            const int BT_NEW      = 1;
            const int BT_EDIT     = 2;
            const int BT_DEL      = 3;
            const int BT_UP       = 4;
            const int BT_DOWN     = 5;
            const int BT_OK       = 6;
            const int BT_CANCEL   = 7;
            const int BT_OPEN     = 9;
            const int BT_SAVE     = 10;
            const int BT_RESET    = 11;
            const int BT_MAX      = 12;
            const int BT_DEFAULT  = 14;
            int       nBT         = toolBar1.Buttons.IndexOf(e.Button);

            switch (nBT)
            {
            case BT_PAGEATTR:
                dlgPageAttrs dlg = new dlgPageAttrs();
                dlg.LoadData(drawPage.PageAttributes);
                dlg.TopMost = this.TopMost;
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    drawPage.PageAttributes = dlg.objRet;
                    this.Invalidate();
                }
                break;

            case BT_NEW:
                //drawPage.NewObject();
                drawPage.ToggleToolboxVisible();
                break;

            case BT_EDIT:
                drawPage.EditObject();
                break;

            case BT_DEL:
                drawPage.DeleteSelectedItem();
                break;

            case BT_UP:
                drawPage.MoveSelectedItemUp();
                break;

            case BT_DOWN:
                drawPage.MoveSelectedItemDown();
                break;

            case BT_OK:
                drawPage.OK();
                break;

            case BT_CANCEL:
                if (MessageBox.Show(this, "Do you want to cancel editing?", "Drawing Edit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    drawPage.CANCEL();
                }
                break;

            case BT_OPEN:
                break;

            case BT_SAVE:
                SaveFileDialog dlgSave = new SaveFileDialog();
                dlgSave.Title           = "Save drawings to file";
                dlgSave.DefaultExt      = "xml";
                dlgSave.OverwritePrompt = true;
                if (dlgSave.ShowDialog(this) == DialogResult.OK)
                {
                    drawPage.SaveDrawingsToFile(dlgSave.FileName);
                }
                break;

            case BT_RESET:
                drawPage.ResetPositions();
                break;

            case BT_MAX:
                this.WindowState = FormWindowState.Maximized;
                break;

            case BT_DEFAULT:
                drawPage.SetSelectedItemAsDefaultDrawing();
                break;
            }
        }
Example #2
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            int nBT = toolBar1.Buttons.IndexOf(e.Button);

            switch (nBT)
            {
            case BT_PAGEATTR:
                dlgPageAttrs dlg = new dlgPageAttrs();
                dlg.LoadData(drawPage.PageAttributes);
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    drawPage.PageAttributes = dlg.objRet;
                    this.Invalidate();
                }
                break;

            case BT_NEW:
                drawPage.ToggleToolboxVisible();
                break;

            case BT_EDIT:
                drawPage.EditObject();
                break;

            case BT_DEL:
                drawPage.DeleteSelectedItem();
                break;

            case BT_UP:
                drawPage.MoveSelectedItemUp();
                break;

            case BT_DOWN:
                drawPage.MoveSelectedItemDown();
                break;

            case BT_OK:
                drawPage.OK();
                break;

            case BT_CANCEL:
                drawPage.CANCEL();
                break;

            case BT_OPEN:
                break;

            case BT_SAVE:
                SaveFileDialog dlgSave = new SaveFileDialog();
                dlgSave.Title           = "Save drawings to file";
                dlgSave.DefaultExt      = "xml";
                dlgSave.OverwritePrompt = true;
                if (dlgSave.ShowDialog(this) == DialogResult.OK)
                {
                    drawPage.SaveDrawingsToFile(dlgSave.FileName);
                }
                break;

            case BT_RESET:
                drawPage.ResetPositions();
                break;

            case BT_DEFAULT:
                drawPage.SetSelectedItemAsDefaultDrawing();
                break;
            }
        }