public void InitBK() { if (form != null) { if (!form.IsDisposed) { if (!this.Created) { form.Close(); form = null; } else { return; } } else { form = null; } } if (this.Created) { form = new frmHotspots(); form.TopLevel = true; form.TopMost = true; form.SetCoverOwner(this); OnMove2(); form.BackColor = form.TransparencyKey; form.Opacity = CanvasOpacity; form.Show(); form.Cursor = CanvasCursor; form.TopMost = false; this.Visible = false; // form.MouseDown += new MouseEventHandler(form_mousedown); form.MouseMove += new MouseEventHandler(form_mousemove); form.MouseUp += new MouseEventHandler(form_mouseup); form.KeyDown += new KeyEventHandler(form_keydown); form.KeyUp += new KeyEventHandler(form_keyup); form.DoubleClick += new EventHandler(form_mousedoubleclick); // System.Windows.Forms.Control ctrl = this.Parent; while (ctrl != null) { ctrl.Move += new EventHandler(onPMove); ctrl = ctrl.Parent; } if (!bLinked) { bLinked = true; this.FindForm().VisibleChanged += new EventHandler(Hotspots_VisibleChanged); this.FindForm().GotFocus += new EventHandler(Hotspots_GotFocus); } if (!bHostVisible) { form.Hide(); } } }
protected override void OnMouseDown(MouseEventArgs e) { sHelp = ""; if (curDrawing != null) { float x1, y1; bool bAdded; systemToCustomerXY(e.X, e.Y, out x1, out y1); System.Windows.Forms.MouseEventArgs e1 = new System.Windows.Forms.MouseEventArgs(e.Button, e.Clicks, (int)x1, (int)y1, e.Delta); System.Windows.Forms.DialogResult ret = curDrawing.CallDlgDrawingsMouseDown(this, e1, ref nStep, this); switch (ret) { case System.Windows.Forms.DialogResult.OK: if (nType == 0) { bAdded = this.DrawingLayers[0].AddDrawing(curDrawing); } else { bAdded = lstShapes.AddDrawing(curDrawing); hs.SetDrawings(lstShapes); formHS.Show(); formHS.TopMost = true; formHS.Invalidate(); } if (bAdded) { AddDrawing(curDrawing); } else { } editor.SelectItem(curDrawing); curDrawing.FinishDesign(); curDrawing = null; nStep = 0; editor.Show(); break; case System.Windows.Forms.DialogResult.Cancel: curDrawing.FinishDesign(); curDrawing = null; nStep = 0; editor.Show(); break; case System.Windows.Forms.DialogResult.Retry: nStep = 0; break; case System.Windows.Forms.DialogResult.None: break; } this.Invalidate(); } else { Point p = new Point(e.X, e.Y); DrawingItem item = HitTest(p); if (item != null) { SetItemSelection(item); if (e.Button == MouseButtons.Right) { MenuItem[] menus = item.GetContextMenuItems(p); if (menus != null && menus.Length > 0) { ContextMenu cm = new ContextMenu(); cm.MenuItems.AddRange(menus); cm.Show(this, p); } } } else { ClearMarks(); if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { Type t = _toolBox.SelectedToolboxItem; if (t != null) { DrawingItem newObj = (DrawingItem)Activator.CreateInstance(t); if (_defaultDrawings == null) { _defaultDrawings = new DefaultDrawings(); } DrawingItem def = _defaultDrawings.GetDefaultDrawing(newObj.GetType()); if (def != null) { newObj.Copy(def); } _toolBox.ClearToolboxSelection(); newObj.ResetGuid(); makeNewName(newObj); newObj.Page = this; newObj.Location = p; AddDrawing(newObj); editor.SelectItem(newObj); editor.RefreshPropertyGrids(); _newObj = newObj; SetItemSelection(newObj); } } } } }