public ShapeNode MakeNode(float x, float y) { ShapeNode note = diagramView1.Diagram.Factory.CreateShapeNode(x, y, NodeWidth, NodeHeight); note.Tag = ""; note.HyperLink = ""; note.Selected = true; //adjust the box properties ProxyNode node = new ProxyNode(note); node.FillColor = NodeFillColor; node.FrameColor = NodeFrameColor; node.FrameThickness = NodeFrameThickness; node.SnapToGrid(); return note; }
public XMLNode(ShapeNode _node) { node = _node; pnode = new ProxyNode(node); Text = node.Text; HyperLink = node.HyperLink; Tooltip = node.ToolTip; NodeFont = XMLFont.FromFont(node.Font); TextColor = System.Drawing.ColorTranslator.ToHtml(pnode.TextColor); FillColor = System.Drawing.ColorTranslator.ToHtml(pnode.FillColor); FrameColor = System.Drawing.ColorTranslator.ToHtml(pnode.FrameColor); FrameThickness = (int)pnode.FrameThickness; Width = (int)pnode.Width; Height = (int)pnode.Height; X = (int)pnode.X; Y = (int)pnode.Y; ZIndex = pnode.ZIndex; }
public void KeyDownHandler(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.X && e.Modifiers == Keys.Control) { Cut(); return; } if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control) { Copy(); return; } if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) { Paste(); return; } if (e.KeyCode == Keys.Z && e.Modifiers == Keys.Control) { diagramView1.Diagram.UndoManager.Undo(); return; } if (e.KeyCode == Keys.Y && e.Modifiers == Keys.Control) { diagramView1.Diagram.UndoManager.Redo(); return; } if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) { SelectAll(); return; } if (e.KeyCode == Keys.Back) { if (diagramView1.Diagram.Selection.Nodes.Count > 0) { DiagramNode node = diagramView1.Diagram.Selection.Nodes[0]; diagramView1.Diagram.Nodes.Remove(node); } return; } DiagramItemCollection selectedItems = diagramView1.Diagram.Selection.Items; if (e.KeyCode == Keys.S) { foreach (DiagramItem selectedItem in selectedItems) { if (selectedItem is ShapeNode) { ShapeNode selectedBox = (ShapeNode)selectedItem; float selectedBoxNewX, selectedBoxNewY; selectedBoxNewX = selectedBox.Bounds.X; selectedBoxNewY = selectedBox.Bounds.Y + 8; selectedBox.Move(selectedBoxNewX, selectedBoxNewY); } } return; } if (e.KeyCode == Keys.W) { foreach (DiagramItem selectedItem in selectedItems) { if (selectedItem is ShapeNode) { ShapeNode selectedBox = (ShapeNode)selectedItem; float selectedBoxNewX, selectedBoxNewY; selectedBoxNewX = selectedBox.Bounds.X; selectedBoxNewY = selectedBox.Bounds.Y - 8; selectedBox.Move(selectedBoxNewX, selectedBoxNewY); //if auto resize is enabled and the new position is outside document bounds //resize the document to fit the moved item //if(selectedBoxNewY>datagram. //datagram.ResizeToFitItem(selectedBox); } } return; } if (e.KeyCode == Keys.A) { foreach (DiagramItem selectedItem in selectedItems) { if (selectedItem is ShapeNode) { ShapeNode selectedBox = (ShapeNode)selectedItem; float selectedBoxNewX, selectedBoxNewY; selectedBoxNewX = selectedBox.Bounds.X - 8; selectedBoxNewY = selectedBox.Bounds.Y; selectedBox.Move(selectedBoxNewX, selectedBoxNewY); //if auto resize is enabled and the new position is outside document bounds //resize the document to fit the moved item //if(selectedBoxNewY>datagram. //datagram.ResizeToFitItem(selectedBox); } } return; } if (e.KeyCode == Keys.D) { foreach (DiagramItem selectedItem in selectedItems) { if (selectedItem is ShapeNode) { ShapeNode selectedBox = (ShapeNode)selectedItem; float selectedBoxNewX, selectedBoxNewY; selectedBoxNewX = selectedBox.Bounds.X + 8; selectedBoxNewY = selectedBox.Bounds.Y; selectedBox.Move(selectedBoxNewX, selectedBoxNewY); //if auto resize is enabled and the new position is outside document bounds //resize the document to fit the moved item //if(selectedBoxNewY>datagram. //datagram.ResizeToFitItem(selectedBox); } } return; } if (e.KeyCode == Keys.Oemplus) { foreach (DiagramItem selectedItem in selectedItems) { if (selectedItem is ShapeNode) { ShapeNode selectedBox = (ShapeNode)selectedItem; ProxyNode node = new ProxyNode(selectedBox); node.SnapToGrid(); node.IncreaseWidthByGrid(); } } return; } if (e.KeyCode == Keys.OemMinus) { foreach (DiagramItem selectedItem in selectedItems) { if (selectedItem is ShapeNode) { ShapeNode selectedBox = (ShapeNode)selectedItem; ProxyNode node = new ProxyNode(selectedBox); node.SnapToGrid(); node.DecreaseWidthByGrid(); } } return; } }
/// <summary> /// React to the note being selected. /// </summary> public void NoteSelectedHandler(object sender, NodeEventArgs e) { if (sender is Diagram) { Diagram datagram = (Diagram)sender; if (e.Node is ShapeNode) { //check if multiple notes are selected. if (datagram.Selection.Nodes.Count > 0) { ProxyNode[] selectedNotes = new ProxyNode[datagram.Selection.Nodes.Count + 1]; for (int i = 0; i < datagram.Selection.Nodes.Count; i++) { ShapeNode note = (ShapeNode)datagram.Selection.Nodes[i]; ProxyNode selectedNoteProxy = new ProxyNode(note); selectedNotes[i] = selectedNoteProxy; } selectedNotes[datagram.Selection.Nodes.Count] = new ProxyNode((ShapeNode)e.Node); propertyGrid1.SelectedObjects = selectedNotes; ClearNodeEditor(); return; } else { //Load the proxy into the property grid. if (e.Node is ShapeNode) { ShapeNode note = (ShapeNode)e.Node; ProxyNode selectedNoteProxy = new ProxyNode(note); propertyGrid1.SelectedObject = selectedNoteProxy; //mainUI.nodeEditor1.TagBoxLoadText(note); LoadFromNode(note); } } } } }
/// <summary> /// Paste object(s) from clipboard. /// </summary> public void Paste() { if (editing) { ((TextBox)editControl).Paste(); } else if (diagramView1.Diagram.Selection.Nodes.Count == 1 && Clipboard.ContainsText()) { if (diagramView1.Diagram.Selection.Nodes[0] is ShapeNode) { ShapeNode node = (ShapeNode)diagramView1.Diagram.Selection.Nodes[0]; if (node.Text == "" && Clipboard.ContainsText()) node.Text = Clipboard.GetText(); } } else { diagramView1.PasteFromClipboard(dX, dY); dX += 0; //Fix a strange font bug and increase the offsets by the size of the pasted object(s). foreach (ShapeNode note in diagramView1.Diagram.Selection.Nodes) { note.Font = note.Font; dY += (int)note.Bounds.Height; ProxyNode node = new ProxyNode(note); node.SnapToGrid(); } } }
public ShapeNode MakeNode(float x, float y, float width, float height) { ShapeNode note = chart.Factory.CreateShapeNode(x, y, width, height); note.Tag = ""; note.HyperLink = ""; note.Selected = true; //adjust the box properties ProxyNode node = new ProxyNode(note); node.FillColor = pchart.NodeFillColor; node.FrameColor = pchart.NodeFrameColor; node.FrameThickness = pchart.NodeFrameThickness; node.SnapToGrid(); return note; }
public void LoadChart(Diagram _chart) { chart = _chart; pchart = new ProxyDiagram(_chart); chart.AutoResize = AutoResize.None; pchart.BackColor = System.Drawing.ColorTranslator.FromHtml(BackgroundColor); chart.TextColor = System.Drawing.ColorTranslator.FromHtml(TextColor); chart.Font = Font.ToFont(); pchart.NodeFillColor = System.Drawing.ColorTranslator.FromHtml(NodeFillColor); pchart.NodeFrameColor = System.Drawing.ColorTranslator.FromHtml(NodeFrameColor); pchart.NodeFrameThickness = NodeFrameThickness; foreach (XMLNode node in Nodes) { ShapeNode box = MakeNode(node.X, node.Y, node.Width, node.Height); ProxyNode pnode = new ProxyNode(box); box.ZIndex = node.ZIndex; box.Text = node.Text; box.HyperLink = node.HyperLink; //box.Tag = node.Tag; box.ToolTip = node.Tooltip; box.Font = node.NodeFont.ToFont(); box.TextColor = System.Drawing.ColorTranslator.FromHtml(node.TextColor); pnode.FillColor = System.Drawing.ColorTranslator.FromHtml(node.FillColor); pnode.FrameColor = System.Drawing.ColorTranslator.FromHtml(node.FrameColor); pnode.FrameThickness = node.FrameThickness; pnode.ZIndex = node.ZIndex; } pchart.Width = (int)DocumentWidth; pchart.Height = (int)DocumentHeight; MainUI.NodeWidth = NodeWidth; MainUI.NodeHeight = NodeHeight; }