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; }
//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 bool Contains(PointF location, Margin margin) { return new RectangleF(margin.Left, margin.Top, DiagramSize.Width - margin.Right - margin.Left,DiagramSize.Height - margin.Bottom - margin.Top).Contains(location); }
public Diagram(Diagram prototype) { InitializeComponent(); SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true); SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true); SetStatus(Status.Default); //Create a new renderer SetRender(new Render()); //Sets up current layers reference etc ClearDiagram(); Margin = new Margin(); SuspendEvents = true; mDiagramSize = prototype.DiagramSize; mShowToolTips = prototype.ShowTooltips; mCheckBounds = prototype.CheckBounds; mMargin = prototype.Margin; Paged = prototype.Paged; WorkspaceColor = prototype.WorkspaceColor; SuspendEvents = false; }
//Constructor public Diagram() { //Create License Component.Instance.GetLicense(typeof(Diagram), this); // This call is required by the Windows.Forms Form Designer. InitializeComponent(); SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true); SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true); SetStatus(Status.Default); //Create a new renderer SetRender(new Render()); //Sets up current layers reference etc ClearDiagram(); Margin = new Margin(); Animator = new Animator(this); //Create an initial render and draw onto control surface mRender.RenderDiagram(new Rectangle(0,0,this.Width,this.Height)); DrawDiagram(new Rectangle(0,0,this.Width,this.Height)); }
private void LoadDiagram(Stream fs, IFormatter formatter) { Diagram diagram; SurrogateSelector selector = new SurrogateSelector(); DiagramSerialize surrogate = new DiagramSerialize(); try { selector.AddSurrogate(typeof(Diagram),new StreamingContext(StreamingContextStates.All), surrogate); //Raise the deserialize event and allow subclasses to add/change the surrogate to their own surrogate OnDeserialize(formatter,selector); formatter.SurrogateSelector = selector; formatter.Binder = Component.Instance.DefaultBinder; diagram = (Diagram) formatter.Deserialize(fs); } catch (Exception ex) { if (ex.InnerException == null) { throw ex; } else { throw ex.InnerException; } } finally { } surrogate = Serialization.Serialize.GetSurrogate(diagram,selector); if (surrogate == null) throw new Exception("A deserialization surrogate could not be found."); //Update this object using the surrogate and the diagram surrogate.UpdateObjectReferences(); SuspendEvents = true; Suspend(); //Copy settings from deserialized object DiagramSize = diagram.DiagramSize; Zoom = diagram.Zoom; ShowTooltips = diagram.ShowTooltips; CheckBounds = diagram.CheckBounds; Paged = diagram.Paged; WorkspaceColor = diagram.WorkspaceColor; //Copy all layers across Layers.Clear(); foreach (Layer layer in surrogate.Layers) { Layers.Add(layer); } Layers.CurrentLayer = surrogate.Layers.CurrentLayer; //Copy shapes and lines accross Shapes.Clear(); foreach (Shape shape in surrogate.Shapes.Values) { Shapes.Add(shape.Key,shape); } Lines.Clear(); foreach (Line line in surrogate.Lines.Values) { Lines.Add(line.Key,line); } mNavigate = new Navigation.Navigate(this); Route = new Route(); Route.Container = this; Margin = new Margin(); //##margin needs to be serialized/deserialized //Raise the deserialize complete event OnDeserializeComplete(diagram, formatter, selector); Resume(); SuspendEvents = false; Refresh(); }
//Methods public virtual bool Equals(Margin margin) { return (mTop == margin.Top && mLeft == margin.Left && mRight == margin.Right && mBottom == margin.Bottom); }
public virtual bool Contains(PointF location,Margin margin) { //Offset by group location location.X -= Rectangle.X; location.Y -= Rectangle.Y; return new RectangleF(margin.Left, margin.Top, Size.Width - margin.Right - margin.Left,Size.Height - margin.Bottom - margin.Top).Contains(location); }