コード例 #1
0
        protected override object CreateInstance(Type itemType)
        {
            dlgNewDrawing dlg = new dlgNewDrawing();

            dlg.LoadData(false);
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DrawingLayerCollection ls = this.Context.Instance as DrawingLayerCollection;
                if (ls != null)
                {
                    ls.SetNewName(dlg.objRet);
                    dlg.objRet.Page = (DrawingPage)ls.Page;
                }
                return(dlg.objRet);
            }
            return(null);
        }
コード例 #2
0
        public void NewObject()
        {
            dlgNewDrawing dlg = new dlgNewDrawing();

            dlg.LoadData(false);
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                if (_defaultDrawings == null)
                {
                    _defaultDrawings = new DefaultDrawings();
                }
                DrawingItem def = _defaultDrawings.GetDefaultDrawing(dlg.objRet.GetType());
                if (def != null)
                {
                    dlg.objRet.Copy(def);
                }
                dlg.objRet.ResetGuid();
                makeNewName(dlg.objRet);
                dlg.objRet.Page = this;
                AddDrawing(dlg.objRet);
                editor.RefreshPropertyGrids();
            }
        }
コード例 #3
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (toolBar1.Buttons.IndexOf(e.Button))
            {
            case 0:                    //new
            {
                dlgNewDrawing dlg = new dlgNewDrawing();
                dlg.LoadData(HotspotOnly);
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    dlgDrawings frm = this.Parent as dlgDrawings;
                    dlg.objRet.Page = frm;
                    frm.StartDrawing(dlg.objRet);
                    this.Hide();
                }
            }
            break;

            case 1:                    //edit
                if (lstDrawings.SelectedIndex >= 0)
                {
                    dlgDrawings frm = this.Parent as dlgDrawings;
                    DrawingItem obj = lstDrawings.Items[lstDrawings.SelectedIndex] as DrawingItem;
                    if (obj != null)
                    {
                        obj.Edit(frm);
                    }
                }
                break;

            case 2:                    //delete
                DeleteObject();
                break;

            case 3:                     //up
                MoveUp();
                break;

            case 4:                     //down
                MoveDown();

                break;

            case 5:                     //finish
                this.DialogResult      = System.Windows.Forms.DialogResult.OK;
                frmParent.DialogResult = System.Windows.Forms.DialogResult.OK;
                frmParent.Close();
                break;

            case 6:                     //cancel
                this.DialogResult      = System.Windows.Forms.DialogResult.Cancel;
                frmParent.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                frmParent.Close();
                break;

            case 8:                     //show/hide background image
                if (e.Button.Pushed)
                {
                    if (frmParent != null)
                    {
                        if (frmParent.BKImage != null)
                        {
                            frmParent.BackgroundImage = frmParent.BKImage;
                        }
                    }
                }
                else
                {
                    frmParent.BackgroundImage = null;
                }
                frmParent.Invalidate();
                break;
            }
        }