private void btDeleteShape_Click(object sender, EventArgs e) { Core.ElementEnumerator<Core.ShapeInterface> Iterator = GetModel().GetSelectedShapes(); Core.CmdMacro Cmd = new Core.CmdMacro(); int i = 0; while (Iterator.MoveNext()) { Cmd.AddCmd(new Core.CmdDeleteShape(GetModel(), Iterator.Current)); i++; //Iterator = GetDiagram().GetSelectedShapes(); } if (i != 0) GetModel().GetUndoStack().Push(Cmd); }
private void ShowProperties_Click(object sender, EventArgs e) { Core.ElementEnumerator<Core.ShapeInterface> Iterator = GetModel().GetSelectedShapes(); List<ShapeInterface> Shapes = new List<ShapeInterface>(0); int i = 0; while (Iterator.MoveNext()) { Shapes.Add(Iterator.Current); i++; } if (i > 0) { Widgets.FormShapeSettings Editor = new Widgets.FormShapeSettings(); Editor.SetObject(Shapes); Editor.Show(); } }
/// <summary> /// Returns the available context-menu operations /// </summary> /// <param name="View"></param> /// <returns></returns> public virtual ToolStripItem[] GetViewContextMenu(IView View, Object ExtData) { ToolStripMenuItem Item; List<ToolStripItem> Items = new List<ToolStripItem>(); int Selected = 0; if (GetModel() != null) { Core.ElementEnumerator<Core.ShapeInterface> Iterator = GetModel().GetSelectedShapes(); while (Iterator.MoveNext()) { Selected++; ;//Iterator.Current.Draw(e.Graphics, m_DrawingContext); } } Item = new ToolStripMenuItem("&Kopieren", Properties.Resources.SymbolCopy, btCopyShape_Click); Item.ImageTransparentColor = System.Drawing.Color.Black; Item.MergeAction = MergeAction.Replace; Item.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); Item.Name = "copyToolStripMenuItem"; Item.Enabled = (Selected > 0); Items.Add(Item); Item = new ToolStripMenuItem("&Einfügen", Properties.Resources.SymbolPaste, btPasteShape_Click); Item.ImageTransparentColor = System.Drawing.Color.Black; Item.MergeAction = MergeAction.Replace; Item.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); Item.Name = "pasteToolStripMenuItem"; Item.Enabled = true; Item.Tag = ExtData; //stores MouseLocation Items.Add(Item); Item = new ToolStripMenuItem("&Löschen", Properties.Resources.SymbolDelete, btDeleteShape_Click); Item.ImageTransparentColor = System.Drawing.Color.Black; Item.MergeAction = MergeAction.Replace; Item.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); Item.Name = "deleteToolStripMenuItem"; Item.Enabled = (Selected > 0); Items.Add(Item); Items.Add(new ToolStripSeparator()); Item = new ToolStripMenuItem("Shape Properties...", Properties.Resources.SymbolOpen, ShowProperties_Click); Item.ImageTransparentColor = System.Drawing.Color.Black; Item.MergeAction = MergeAction.Replace; Item.Name = "ShowProperties"; Item.Enabled = (Selected > 0); Items.Add(Item); return Items.ToArray(); }
private void btCopyShape_Click(object sender, EventArgs e) { try { ToolStripItem contextMenuItem = (ToolStripItem)sender; Control contextMenu = (Control)contextMenuItem.GetCurrentParent(); System.Drawing.Point Location = (contextMenu.Location); System.Drawing.Point PointA, PointB; Core.ElementEnumerator<Core.ShapeInterface> Iterator = GetModel().GetSelectedShapes(); Core.CmdMacro Cmd = new Core.CmdMacro(); List<ShapeInterface> Shapes = new List<ShapeInterface>(); ShapeInterface Shape = null; DataObject _Data = new DataObject(); int i = 0; SerializerXML _Stream = new SerializerXML("JKFLOW", "1.0.0.0"); MemoryStream MemStream = new MemoryStream(); _Stream.OpenOutputStream(MemStream); string Node = "Shape"; while (Iterator.MoveNext()) { PointA = new System.Drawing.Point(Iterator.Current.GetBoundingBox().Left + 20, Iterator.Current.GetBoundingBox().Top + 20); PointB = new System.Drawing.Point(Iterator.Current.GetBoundingBox().Right + 20, Iterator.Current.GetBoundingBox().Bottom + 20); Shape = ShapeFactory.CreateShape(Iterator.Current.GetShapeTypeName()); Shapes.Add(Shape); _Stream.WriteElementStart(Node); Iterator.Current.WriteToSerializer(_Stream); _Stream.WriteElementEnd(Node); Cmd.AddCmd(new Core.CmdAddShape(GetModel(), Shape, PointA, PointB)); i++; } _Stream.CloseOutputStream(); //if (i != 0) GetModel().GetUndoStack().Push(Cmd); _Data.SetData(DataFormats.Text, Cmd.GetText()); _Data.SetData(Cmd.GetType(), Cmd); _Data.SetData("stream", MemStream.ToArray()); Clipboard.SetDataObject(_Data); } catch (System.Runtime.InteropServices.ExternalException) { MessageBox.Show("The Clipboard could not be accessed. Please try again."); } }