//private void RefPaletteSet() //{ // if (ViewHelper.DevAttributeCtl != null && ViewHelper.DevAttributeCtl.Visible) // { // ViewHelper.DevAttributeCtl.objId = CurrentObjId; // ViewHelper.DevAttributeCtl.AddDevAttribute(); // } //} /// <summary> /// 单击设备后对应的设备自身属性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void mouse_FixEntityHandler(object sender, EventArgs e) { try { var ee = (FixEntityArgs)e; CurrentFno = ee.g3eObject.G3E_FNO; CurrentFid = ee.g3eObject.G3E_FID; CurrentObjId = ee.ObjId; GenerateHelper.EmptyFidRecord();//清空FID的记录 CommonHelp.Instance.FromMouseFixEnitiyFid = CurrentFid; CommonHelp.Instance.FromMouseFixEntityFno = CurrentFno; //RefPaletteSet(); SelectDevAttribute(false); if (ViewHelper.labelManager != null && ViewHelper.labelManagerPs.Visible) { ViewHelper.LoadLabelManager(ee); } if (ViewHelper.TZCtl != null && ViewHelper.TZPalette.Visible) { var url = ObjectContextMenu.IsNewEquipmentAndURL(ee.ObjId); ViewHelper.LoadTZPalette(url); } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { LogManager.Instance.Error(ex); } }
public void UninstallCADPlugin() { if (IsInstall) { RemoveContextMenu(); ViewHelper.RemoveSymbolPanel(); ViewHelper.RemoveMenuPanel(); ObjectContextMenu.RemoveContextMenu(); IsInstall = false; } }
public void InstallCADPlugin() { if (!IsInstall) { ViewHelper.AddToolBar(); ViewHelper.AddMenuPanel(); ViewHelper.AddSymbolPanel(); ObjectContextMenu.AddContextMenu(); IsInstall = true; } }
private void Form1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (CurrectTool == Tool.Rect) { LeftMouseDown = true; rect.X = e.X; rect.Y = e.Y; rectStartPoint.X = e.X; rectStartPoint.Y = e.Y; RectIsEmrty = false; } if (CurrectTool == Tool.Ent) { if (CurrentEntTool != "Player Startpoint") { LeftMouseDown = true; rect.X = e.X; rect.Y = e.Y; rectStartPoint.X = e.X; rectStartPoint.Y = e.Y; RectIsEmrty = false; } else { } } } if (e.Button == MouseButtons.Right) { if (actors.Count > 0) { for (int i = actors.Count - 1; i >= 0; i--) { if (actors.ElementAt(i).Collision.Contains(e.X, e.Y)) { SelectedActor = actors.ElementAt(i); rect = SelectedActor.Collision; ObjectContextMenu.Show(new Point(this.Location.X + e.X, this.Location.Y + e.Y)); break; } } } } }
void _automation_OnShowContextMenu(object sender, AnnAutomationEventArgs e) { if (e != null && e.Object != null) { _rasterImageViewer.AutomationInvalidate(LeadRectD.Empty); AnnAutomationObject annAutomationObject = e.Object as AnnAutomationObject; if (annAutomationObject != null) { ObjectContextMenu menu = annAutomationObject.ContextMenu as ObjectContextMenu; if (menu != null) { menu.Automation = sender as AnnAutomation; menu.Show(this, RasterImageViewer.PointToClient(Cursor.Position)); } } } else { ManagerContextMenu defaultMenu = new ManagerContextMenu(); defaultMenu.Automation = sender as AnnAutomation; defaultMenu.Show(this, _rasterImageViewer.PointToClient(Cursor.Position)); } }
void automation_OnShowContextMenu(object sender, AnnAutomationEventArgs e) { AnnObject annEditObject = _automation.CurrentEditObject; if (e != null) { AnnAutomationObject annAutomationObject = e.Object; if (annAutomationObject != null) { _imageViewer.AutomationInvalidate(LeadRectD.Empty); ContextMenu contextMenu = annAutomationObject.ContextMenu as ContextMenu; if (annAutomationObject != null && contextMenu != null) { ObjectContextMenu menu = annAutomationObject.ContextMenu as ObjectContextMenu; AnnLayer layer = annEditObject.Layer; if (menu != null) { if (layer != null && !layer.IsVisible) { return; } menu.Automation = sender as AnnAutomation; contextMenu.Show(this, _imageViewer.PointToClient(Cursor.Position)); } } } } else { ManagerContextMenu defaultMenu = new ManagerContextMenu(); defaultMenu.Automation = sender as AnnAutomation; defaultMenu.Show(this, _imageViewer.PointToClient(Cursor.Position)); } }
private void CustomizeAutomationMenu() { AnnAutomationObject autoObj = _annAutomationManager.FindObjectById(AnnObject.LineObjectId); if (autoObj != null) { if (autoObj.ContextMenu != null) { ObjectContextMenu menu = autoObj.ContextMenu as ObjectContextMenu; if (menu != null) { menu.MenuItems.RemoveAt(13); //Unlock menu.MenuItems.RemoveAt(12); //Lock menu.MenuItems.RemoveAt(11); //Separator menu.MenuItems.RemoveAt(10); //Reverse menu.MenuItems.RemoveAt(9); //Flip menu.MenuItems.RemoveAt(8); //Separator } } autoObj = _annAutomationManager.FindObjectById(AnnObject.PolygonObjectId); if (autoObj != null && autoObj.ObjectTemplate != null) { AnnPolylineObject polygon = autoObj.ObjectTemplate as AnnPolylineObject; polygon.IsClosed = true; polygon.FillRule = AnnFillRule.Nonzero; } autoObj = _annAutomationManager.FindObjectById(AnnObject.ClosedCurveObjectId); if (autoObj != null && autoObj.ObjectTemplate != null) { AnnCurveObject closedCurve = autoObj.ObjectTemplate as AnnCurveObject; closedCurve.IsClosed = true; closedCurve.FillRule = AnnFillRule.Nonzero; } // Group autoObj = _annAutomationManager.FindObjectById(AnnObject.PolygonObjectId); if (autoObj != null && autoObj.ObjectTemplate != null) { AnnPolylineObject polygon = autoObj.ObjectTemplate as AnnPolylineObject; polygon.IsClosed = true; polygon.FillRule = AnnFillRule.Nonzero; } autoObj = _annAutomationManager.FindObjectById(AnnObject.ClosedCurveObjectId); if (autoObj != null && autoObj.ObjectTemplate != null) { AnnCurveObject closedCurve = autoObj.ObjectTemplate as AnnCurveObject; closedCurve.IsClosed = true; closedCurve.FillRule = AnnFillRule.Nonzero; } // Group autoObj = _annAutomationManager.FindObjectById(AnnObject.GroupObjectId); if (autoObj != null) { ObjectContextMenu menu = new ObjectContextMenu(); menu = autoObj.ContextMenu as ObjectContextMenu; if (menu != null) { menu.MenuItems.RemoveAt(16); //Ungroup menu.MenuItems.RemoveAt(15); //Group menu.MenuItems.RemoveAt(14); //Separator menu.MenuItems.RemoveAt(13); //Unlock menu.MenuItems.RemoveAt(12); //Lock menu.MenuItems.RemoveAt(11); //Separator menu.MenuItems.RemoveAt(10); //Reverse menu.MenuItems.RemoveAt(9); //Flip menu.MenuItems.RemoveAt(8); //Separator } if (menu != null) { // Remove the 'Control Points' item menu.MenuItems.RemoveAt(8); menu.MenuItems.RemoveAt(7); } } } }
public async Task OnMouseUp(MouseEventArgs e) { MouseDown = false; if (e.Button == 2) { RectSelection.Create = false; if (!e.CtrlKey && RectSelection.Width <= 0 && RectSelection.Height <= 0) { if (ObjectClicked.Right) { ObjectClicked.Right = false; ObjectContextMenu.Open(e.ClientX, e.ClientY); } else { if (GraphMode == GraphMode.Algorithm) { AlgorithmContextMenu.Open(e.ClientX, e.ClientY); } else { CanvasContextMenu.Open(e.ClientX, e.ClientY); origin[0] = e.ClientX; origin[1] = e.ClientY; if (ActiveGraph.Nodes.Any() || ActiveGraph.Edges.Any()) { await ActiveGraphChanged.InvokeAsync(new Graph()); } } } } else { bool aNodesChanged = false; bool aEdgesChanged = false; foreach (Node node in Graph.Nodes) { if (node.Xaxis <= RectSelection.X + RectSelection.Width && node.Xaxis >= RectSelection.X && node.Yaxis <= RectSelection.Y + RectSelection.Height && node.Yaxis >= RectSelection.Y) { if (!ActiveGraph.Nodes.Contains(node)) { ActiveGraph.Nodes.Add(node); aNodesChanged = true; } } else if (ActiveGraph.Nodes.Remove(node)) { aNodesChanged = true; } } foreach (Edge edge in Graph.Edges) { ShowEdge showEdge = new ShowEdge(edge); var x = 0.25 * edge.Head.Xaxis + 0.5 * showEdge.CurvePoint[0] + 0.25 * edge.Tail.Xaxis; var y = 0.25 * edge.Head.Yaxis + 0.5 * showEdge.CurvePoint[1] + 0.25 * edge.Tail.Yaxis; if (x <= RectSelection.X + RectSelection.Width && x >= RectSelection.X && y <= RectSelection.Y + RectSelection.Height && y >= RectSelection.Y) { if (!ActiveGraph.Edges.Contains(edge)) { ActiveGraph.Edges.Add(edge); aEdgesChanged = true; } } else if (ActiveGraph.Edges.Remove(edge)) { aEdgesChanged = true; } } if (aNodesChanged || aEdgesChanged) { await ActiveGraphChanged.InvokeAsync(ActiveGraph); } } RectSelection = new RectSelection(); return; } if (ObjectClicked.Left) { ObjectClicked.Left = false; if (GraphMode == GraphMode.InsertNode) { SvgClass = "pointer"; } else { SvgClass = "grab"; } } else if (!e.CtrlKey && !ActiveGraph.Nodes.Any() && !ActiveGraph.Nodes.Any() && GraphMode == GraphMode.InsertNode) { NodeService.AddNode(Graph.Nodes, Options.Default, e.ClientX * SVGControl.Scale + SVGControl.Xaxis, e.ClientY * SVGControl.Scale + SVGControl.Yaxis); } else if (ActiveGraph.Nodes.Any() || ActiveGraph.Edges.Any()) { await ActiveGraphChanged.InvokeAsync(new Graph()); } if (SVGControl.Pan) { SVGControl.Pan = false; SvgClass = "grab"; SVGControl.OldXaxis = SVGControl.Xaxis; SVGControl.OldYaxis = SVGControl.Yaxis; } }