public ComplexShape(ComplexShape prototype): base(prototype) { Children = new Elements(typeof(SolidElement),"Solid"); foreach (SolidElement solid in prototype.Children.Values) { mChildren.Add(solid.Key,(SolidElement) solid.Clone()); } }
//Constructors public ComplexShape() { SuspendEvents = true; Children = new Elements(typeof(SolidElement),"Solid"); KeepAspect = true; SuspendEvents = false; }
protected ComplexShape(SerializationInfo info, StreamingContext context): base(info,context) { Children = new Elements(typeof(SolidElement),"Solid"); SuspendEvents = true; Children = (Elements) info.GetValue("Children",typeof(Elements)); SuspendEvents = false; }
public Group(Group prototype): base(prototype) { Shapes = new Elements(typeof(Shape),"Shape"); Lines = new Elements(typeof(Line),"Line"); mRenderList = new RenderList(); mMargin = prototype.Margin; mCheckBounds = prototype.CheckBounds; mDrawExpand = prototype.DrawExpand; mExpanded = prototype.Expanded; mContractedSize = prototype.ContractedSize; mExpandedSize = prototype.ExpandedSize; }
public Line(Shape start,Shape end) { SuspendEvents = true; AllowMove = true; DrawSelected = true; Start = new Origin(start); End = new Origin(end); Interaction = UserInteraction.BringToFront; Ports = new Elements(typeof(Port),"Port"); SuspendEvents = false; }
//Constructors public Line() { SuspendEvents = true; AllowMove = true; DrawSelected = true; Start = new Origin(); End = new Origin(); Interaction = UserInteraction.BringToFront; SmoothingMode = SmoothingMode.HighQuality; Ports = new Elements(typeof(Port),"Port"); SuspendEvents = false; }
//Constructors public Shape() { SuspendEvents = true; AllowMove = true; AllowScale = true; AllowRotate = false; DrawSelected = true; Direction = Direction.Both; Interaction = UserInteraction.BringToFront; MinimumSize = new SizeF(32, 32); MaximumSize = new SizeF(320, 320); Ports = new Elements(typeof(Port),"Port"); SuspendEvents = false; }
//Constructors public Group() { SuspendEvents = true; DrawBackground = false; DrawShadow = false; BorderStyle = DashStyle.Dash; ExpandedSize = MaximumSize; ContractedSize = Size; DrawExpand = true; Expanded = true; CheckBounds = true; //Set up objects and event handlers Shapes = new Elements(typeof(Shape),"Shape"); Lines = new Elements(typeof(Line),"Line"); mMargin = new Margin(); mRenderList = new RenderList(); SuspendEvents = false; }
public Shape(StencilItem stencil) { SuspendEvents = true; AllowMove = true; AllowScale = true; AllowRotate = false; DrawSelected = true; Direction = Direction.Both; Interaction = UserInteraction.BringToFront; MinimumSize = new SizeF(32, 32); MaximumSize = new SizeF(320, 320); //Set up stencil StencilItem = stencil; stencil.CopyTo(this); Ports = new Elements(typeof(Port),"Port"); SuspendEvents = false; }
//Loop through and add if cut or copy selected shapes, lines with either shape selected, selected lines //Remove if cut or delete //Do not rewrite keys in copy buffer private void DoCutCopyDelete(bool add, bool remove) { ArrayList shapes = new ArrayList(); ArrayList lines = new ArrayList(); mClipboard.Elements = new Elements(); Suspend(); //Clear the selection cache lists mSelectedElements = null; mSelectedShapes = null; mSelectedLines = null; //Add any cut/copied shapes to a remove list DoCutCopyDeleteSelectedShapes(add, remove, Shapes, shapes); DoCutCopyDeleteSelectedLines(add,remove, Lines, lines); //Check for elements in a container if (shapes.Count == 0 && lines.Count ==0) { //Check groups foreach (Shape shape in Shapes.Values) { if (shape is Group) { Group group = (Group) shape; DoCutCopyDeleteSelectedShapes(add, remove, group.Shapes, shapes); if (shapes.Count > 0) break; DoCutCopyDeleteSelectedLines(add, remove, group.Lines, lines); if (lines.Count > 0) break; } } } //Write the items to the clipboard before they are removed and change the origins etc WriteToClipBoard(); //Remove any shapes from the collection if (remove) { foreach (Shape shape in shapes) { shape.Container.Shapes.Remove(shape.Key); } foreach (Line line in lines) { line.Container.Lines.Remove(line.Key); } } Resume(); Refresh(); }
private Elements GetSelectedElements(System.Type type) { Elements elements = new Elements(); foreach (Shape shape in Shapes.Values) { if (shape.Selected && (type.IsInstanceOfType(shape) || shape.GetType().IsSubclassOf(type))) elements.Add(shape.Key,shape); } foreach (Line line in Lines.Values) { if (line.Selected && (type.IsInstanceOfType(line) || line.GetType().IsSubclassOf(type))) elements.Add(line.Key,line); } elements.SetModifiable(false); return elements; }
//Sets the selected working elements private void GetSelectedElements() { mSelectedElements = new Elements(); mSelectedShapes = new Elements(typeof(Shape),"Shape"); mSelectedLines = new Elements(typeof(Line),"Line"); foreach (Shape shape in Shapes.Values) { if (shape.Selected) { mSelectedElements.Add(shape.Key,shape); mSelectedShapes.Add(shape.Key,shape); } } foreach (Line line in Lines.Values) { if (line.Selected) { mSelectedElements.Add(line.Key,line); mSelectedLines.Add(line.Key,line); } } mSelectedElements.SetModifiable(false); mSelectedShapes.SetModifiable(false); mSelectedLines.SetModifiable(false); }
//Add or remove items from the selected list private void selectable_SelectedChanged(object sender, EventArgs e) { mSelectedElements = null; mSelectedShapes = null; mSelectedLines = null; OnSelectedChanged(); }
//Resolve all string key references public virtual void Resolve(Elements Shapes) { //Add check for speed if (ShapeKey == null) return; SuspendEvents = true; //Resolve keys Shape shape = (Shape) Shapes[ShapeKey]; if (PortKey != null) { Port = (Port) shape.Ports[PortKey]; shape = null; } Shape = shape; //Reset to blank mShapeKey = null; mPortKey = null; SuspendEvents = false; }
protected virtual void SetLines(Elements lines) { mLines = lines; }
protected virtual void SetShapes(Elements shapes) { mShapes = shapes; }
private void ClearDiagram() { SuspendEvents = true; //Set default layers collection, need for shapes and lines Layers = new Layers(); mRenderList = new RenderList(); //Set up shapes and lines, needed for navigation Shapes = new Elements(typeof(Shape),"Shape"); Lines = new Elements(typeof(Line),"Line"); mNavigate = new Navigation.Navigate(this); Route = new Route(); Route.Container = this; SuspendEvents = false; }
public Line(Line prototype): base(prototype) { mAllowMove = prototype.AllowMove; mLineJoin = prototype.LineJoin; mDrawSelected = prototype.DrawSelected; mInteraction = prototype.Interaction; //Set up new origins Start = new Origin(prototype.FirstPoint); End = new Origin(prototype.LastPoint); Start.Marker = prototype.Start.Marker; End.Marker = prototype.End.Marker; mPoints = (ArrayList) prototype.Points.Clone(); //Copy ports Ports = new Elements(typeof(Port),"Port"); foreach (Port port in prototype.Ports.Values) { Port clone = (Port) port.Clone(); Ports.Add(port.Key,clone); clone.SuspendValidation(); clone.Location = port.Location; clone.ResumeValidation(); } if (prototype.Animation != null) mAnimation = (Animation) prototype.Animation.Clone(); DrawPath(); }
//Deserializes info into a new solid element protected Shape(SerializationInfo info, StreamingContext context): base(info,context) { Ports = new Elements(typeof(Port),"Port"); SuspendEvents = true; AllowMove = info.GetBoolean("AllowMove"); AllowScale = info.GetBoolean("AllowScale"); if (Serialize.Contains(info,"AllowRotate")) AllowRotate = info.GetBoolean("AllowRotate"); DrawSelected = info.GetBoolean("DrawSelected"); Selected = info.GetBoolean("Selected"); KeepAspect = info.GetBoolean("KeepAspect"); MinimumSize = Serialize.GetSizeF(info.GetString("MinimumSize")); MaximumSize = Serialize.GetSizeF(info.GetString("MaximumSize")); Direction = (Direction) Enum.Parse(typeof(Direction), info.GetString("Dock"),true); Interaction = (UserInteraction) Enum.Parse(typeof(UserInteraction), info.GetString("Interaction"),true); if (Serialize.Contains(info,"Ports",typeof(Elements))) Ports = (Elements) info.GetValue("Ports",typeof(Elements)); if (Serialize.Contains(info,"Animation",typeof(Animation))) Animation = (Animation) info.GetValue("Animation",typeof(Animation)); SuspendEvents = false; }
private void DoCutCopyDeleteSelectedShapes(bool add, bool remove, Elements collection, ArrayList shapes) { //Add any cut/copied shapes to a remove list foreach (Shape shape in collection.Values) { if (shape.Selected) { if (add) mClipboard.Elements.Add(shape.Key, shape); if (remove && Runtime.CanDelete(shape)) shapes.Add(shape); } } }
//Deserializes info into a new Line protected Line(SerializationInfo info, StreamingContext context): base(info,context) { Ports = new Elements(typeof(Port),"Port"); SuspendEvents = true; AllowMove = info.GetBoolean("AllowMove"); DrawSelected = info.GetBoolean("DrawSelected"); Selected = info.GetBoolean("Selected"); LineJoin = (LineJoin) Enum.Parse(typeof(LineJoin), info.GetString("LineJoin"),true); Interaction = (UserInteraction) Enum.Parse(typeof(UserInteraction), info.GetString("Interaction"),true); Start = (Origin) info.GetValue("Start",typeof(Origin)); End = (Origin) info.GetValue("End",typeof(Origin)); if (Serialize.Contains(info,"Ports",typeof(Elements))) Ports = (Elements) info.GetValue("Ports",typeof(Elements)); if (Serialize.Contains(info,"Animation",typeof(Animation))) Animation = (Animation) info.GetValue("Animation",typeof(Animation)); SuspendEvents = false; }
public Shape(Shape prototype): base(prototype) { mAllowMove = prototype.AllowMove; mAllowScale = prototype.AllowScale; mAllowRotate = prototype.AllowRotate; mDrawSelected = prototype.DrawSelected; mDirection = prototype.Direction; mInteraction = prototype.Interaction; mMaximumSize = prototype.MaximumSize; mMinimumSize = prototype.MinimumSize; mKeepAspect = prototype.KeepAspect; //Copy ports Ports = new Elements(typeof(Port),"Port"); foreach (Port port in prototype.Ports.Values) { Port clone = (Port) port.Clone(); Ports.Add(port.Key,clone); clone.SuspendValidation(); clone.Location = port.Location; clone.ResumeValidation(); } if (prototype.Animation != null) mAnimation = (Animation) prototype.Animation.Clone(); }
private void DoCutCopyDeleteSelectedLines(bool add, bool remove, Elements collection, ArrayList lines) { //Add any cut/copied lines foreach (Line line in collection.Values) { //Set line origin to location to avoid cut/copy reference problems //if (line.Start.DockedElement != null && ! shapes.Contains(line.Start.DockedElement)) line.Start.Location = line.FirstPoint; //if (line.End.DockedElement != null && ! shapes.Contains(line.End.DockedElement)) line.End.Location = line.LastPoint; if (line.Selected) { if (remove && Runtime.CanDelete(line)) lines.Add(line); if (add) mClipboard.Elements.Add(line.Key, line); } } }
public virtual void AddRange(Elements elements) { foreach (Element element in elements.Values) { Add(element.Key,element); } }