public MullionModel(SerializationInfo info, StreamingContext context) : base(info, context) { mullion = (Mullion)info.GetValue("mullion", typeof(Mullion)); code = (string)info.GetValue("Code", typeof(string)); length = (float)info.GetValue("Length", typeof(float)); middlePoint = (float)info.GetValue("MiddlePoint", typeof(float)); mullionType = (MullionType)info.GetValue("MullionType", typeof(MullionType)); orientation = (Orientation)info.GetValue("Orientation", typeof(Orientation)); x = (float)info.GetValue("X", typeof(float)); y = (float)info.GetValue("Y", typeof(float)); _virtual = (bool)info.GetValue("IsVirtual", typeof(bool)); }
/// <summary> /// Removes a mullion reference from this aFrame object /// </summary> /// <param name="mullion"></param> internal void RemoveMullion(Mullion mullion) { if (mullion.Model.Orientation == Orientation.Horizontal) { horizontalMullions.Remove(mullion); ChildrenManager.UpdateMullionsCode(this, Orientation.Horizontal); } else if (mullion.Model.Orientation == Orientation.Vertical) { verticalMullions.Remove(mullion); ChildrenManager.UpdateMullionsCode(this, Orientation.Vertical); } OnDimensionChanged(); }
public static void RemoveShiftLeftMullion(Mullion mullion) { if (mullion == null || mullion.PreviousSurface() == null) { throw new ArgumentException("Invalid argument provided."); } if (mullion.Parent.ChildrenCount == 3) { mullion.Parent.RemoveAllChildren(); return; } Surface previousSurface = mullion.PreviousSurface(); Surface nextSurface = mullion.NextSurface(); float x = nextSurface.Model.X; float y = nextSurface.Model.Y; float width = nextSurface.Model.Width; float height = nextSurface.Model.Height; if (mullion.Model.Orientation == Domain.Entities.Orientation.Vertical) { x = previousSurface.Model.X; } else if (mullion.Model.Orientation == Domain.Entities.Orientation.Horizontal) { y = previousSurface.Model.Y; } PNodeList nodeList = new PNodeList(); nodeList.Add(mullion); nodeList.Add(previousSurface); mullion.Parent.RemoveChildren(nodeList); nextSurface.Model.Bounds = new System.Drawing.RectangleF(x, y, width, height); nextSurface.ParentBoundsChanged(); Mullion nextMullion = nextSurface.NextMullion(); Mullion prevMullion = nextSurface.PreviousMullion(); if (nextMullion != null) { nextMullion.ParentBoundsChanged(); } else if (prevMullion != null) { prevMullion.ParentBoundsChanged(); } }
/// <summary> /// Adds a mullion reference to this aFrame object /// </summary> /// <param name="mullion"></param> internal void AddMullion(Mullion mullion) { if (mullion.Model.Orientation == Orientation.Vertical) { if (!verticalMullions.Contains(mullion)) { verticalMullions.Add(mullion); ChildrenManager.UpdateMullionsCode(this, Orientation.Vertical); } } else if (mullion.Model.Orientation == Orientation.Horizontal) { if (!horizontalMullions.Contains(mullion)) { horizontalMullions.Add(mullion); ChildrenManager.UpdateMullionsCode(this, Orientation.Horizontal); } } }
public float MaxHeight() { float MAX = -1; if (Parent == null) { return(MAX); } if (Parent is PVCFrame) { return(((PVCFrame)Parent).InnerBounds.Height); } if (!(Parent is Surface)) { return(MAX); } Surface parent = (Surface)Parent; Mullion previousMullion = PreviousMullion(); Mullion nextMullion = NextMullion(); if (parent.Layout == SurfaceLayout.VERTICAL) { if (nextMullion != null) { return(nextMullion.MaxY() - Model.Y); } else if (previousMullion != null) { return(Parent.Height + Parent.Y - (previousMullion.MinY() + previousMullion.Thickness)); } else { return(Parent.Height); } } else { return(MAX); } }
public float MaxWidth() { float MAX = -1; if (Parent == null) { return(MAX); } if (Parent is PVCFrame) { return(((PVCFrame)Parent).InnerBounds.Width); } if (!(Parent is Surface)) { return(MAX); } Surface parent = (Surface)Parent; Mullion previousMullion = PreviousMullion(); Mullion nextMullion = NextMullion(); if (parent.Layout == SurfaceLayout.HORIZONTAL) { if (nextMullion != null) { return(nextMullion.MaxX() - X); } else if (previousMullion != null) { return(Parent.Width + Parent.X - (previousMullion.MinX() + previousMullion.Thickness)); } else { return(Parent.Width); } } else { return(MAX); } }
void Surface_BoundsChanged(object sender, PPropertyEventArgs e) { Mullion next = NextMullion(); Mullion previous = PreviousMullion(); if (next != null) { if (next.Model.Orientation == Domain.Entities.Orientation.Vertical) { if (Model.Width + Model.X != next.Model.X) { Model.Width += next.Model.X - (Model.X + Model.Width); } } else if (next.Model.Orientation == Domain.Entities.Orientation.Horizontal) { if (Model.Height + Model.Y != next.Model.Y) { Model.Height += next.Model.Y - (Model.Y + Model.Height); } } } else if (previous != null) { Surface parent = (Surface)Parent; if (previous.Model.Orientation == Domain.Entities.Orientation.Vertical) { if (Model.Width + Model.X != (parent.Model.Width + parent.Model.X)) { Model.Width += parent.Model.Width + parent.Model.X - (Model.Width + Model.X); } } else if (previous.Model.Orientation == Domain.Entities.Orientation.Horizontal) { if (Model.Height + Model.Y != (parent.Model.Y + parent.Model.Height)) { Model.Height += parent.Model.Height + parent.Model.Y - (Model.Height + Model.Y); } } } }
protected override void OnStartDrag(object sender, PInputEventArgs e) { base.OnStartDrag(sender, e); mullion = e.PickedNode as Mullion; }
public override void ParentBoundsChanged() { if (Parent is PVCFrame) { RectangleF parentInnerBounds = ((PVCFrame)Parent).InnerBounds; Model.X = parentInnerBounds.X; Model.Y = parentInnerBounds.Y; Model.Width = parentInnerBounds.Width; Model.Height = parentInnerBounds.Height; } else if (Parent is Sash) { Model.Bounds = ((Sash)Parent).InnerBounds; } else if (Parent is Surface) { Surface parent = (Surface)Parent; RectangleF parentBounds = parent.Model.Bounds; RectangleF myBounds = Model.Bounds; if (parent.Layout == SurfaceLayout.HORIZONTAL) { myBounds.Y = parent.Model.Y; myBounds.Height = parent.Model.Height; if (parent.FirstChild() == this) { myBounds.X = parent.Model.X; myBounds.Width = NextMullion().Model.X - parent.Model.X; } else if (parent.LastChild() == this) { Mullion prevMullion = PreviousMullion(); myBounds.X = prevMullion.Model.X + prevMullion.Thickness; myBounds.Width = parent.Model.Width + parent.Model.X - myBounds.X; } } else { myBounds.X = parent.Model.X; myBounds.Width = parent.Model.Width; if (parent.FirstChild() == this) { myBounds.Y = parent.Model.Y; if (parent.ChildrenCount > 1) { myBounds.Height = NextMullion().Model.Y - parent.Model.Y; } else { myBounds.Height = parent.Model.Height; } } else if (parent.LastChild() == this) { Mullion prevMullion = PreviousMullion(); myBounds.Y = prevMullion.Model.Y + prevMullion.Thickness; myBounds.Height = parent.Model.Height + parent.Model.Y - myBounds.Y; } } Model.Bounds = myBounds; } }
public MullionModel(Mullion mullion) : base() { this.mullion = mullion; }
private static Surface Divide(Surface surface, PointF position, MullionType mullionType) { if (surface.Frame == null) { throw new ArgumentException("Illegal surface provided."); } Surface parent = (Surface)surface.Parent; if (!surface.Bounds.Contains(position)) { return(null); } Surface next = new Surface(surface.Layout); Mullion mullion; RectangleF parentBounds = parent.Model.Bounds; RectangleF nextBounds = next.Bounds; RectangleF surfaceBounds = surface.Model.Bounds; if (parent.Layout == SurfaceLayout.VERTICAL) { mullion = new Mullion(Orientation.Horizontal, mullionType); mullion.Frame = surface.Frame; mullion.Model.MiddlePoint = position.Y - surface.Frame.Y; mullion.Model.X = surfaceBounds.X; mullion.Model.Length = surface.Width; nextBounds.X = surfaceBounds.X; nextBounds.Y = mullion.Model.Y + mullion.Thickness; nextBounds.Width = surfaceBounds.Width; nextBounds.Height = surfaceBounds.Height + surfaceBounds.Y - mullion.Model.Y - mullion.Thickness; surfaceBounds.Height = mullion.Model.Y - surfaceBounds.Y; } else if (parent.Layout == SurfaceLayout.HORIZONTAL) { mullion = new Mullion(Orientation.Vertical, mullionType); mullion.Frame = surface.Frame; mullion.Model.MiddlePoint = position.X - surface.Frame.X; mullion.Model.Y = surfaceBounds.Y; mullion.Model.Length = surfaceBounds.Height; nextBounds.X = mullion.Model.X + mullion.Thickness; nextBounds.Y = surfaceBounds.Y; nextBounds.Width = surfaceBounds.Width + surfaceBounds.X - mullion.Model.X - mullion.Thickness; nextBounds.Height = surfaceBounds.Height; surfaceBounds.Width = mullion.Model.X - surfaceBounds.X; } else { throw new ArgumentException("Illegal surface layout value."); } next.Model.SurfaceParent = parent; next.Frame = surface.Frame; next.Model.Bounds = nextBounds; int index = surface.Index(); parent.AddChild(index + 1, mullion); parent.AddChild(index + 2, next); mullion.Frame.AddMullion(mullion); // Because after setting bounds the surface will update herself with // her next mullion, So this setting MUST happen after adding mullion // and the next surface if (parent.Layout == SurfaceLayout.VERTICAL) { surface.Model.Height = mullion.Model.Y - surface.Model.Y; } else { surface.Model.Width = mullion.Model.X - surface.Model.X; } return(next); }