protected override void OnMove(EventArgs e) { base.OnMove(e); if (this.SuspendLayouting) { return; } if (this.ControlAnchors.Left != null) { this.ControlAnchors.Left.SetX(this.Left, this.Parent); } if (this.ControlAnchors.Top != null) { this.ControlAnchors.Top.SetY(this.Top, this.Parent); } if (this.ControlAnchors.Right != null) { this.ControlAnchors.Right.SetX(this.Right, this.Parent); } if (this.ControlAnchors.Bottom != null) { this.ControlAnchors.Bottom.SetY(this.Bottom, this.Parent); } if ((this.ControlAnchors.Left != null || this.ControlAnchors.Right != null) && this.ControlAnchors.Top == null && this.ControlAnchors.Bottom == null) { ControlAnchors.SideAnchor sideAnchor = this.ControlAnchors.Left != null ? this.ControlAnchors.Left : this.ControlAnchors.Right; sideAnchor.SetY(this.Top + this.Height / 2, this.Parent); } if ((this.ControlAnchors.Top != null || this.ControlAnchors.Bottom != null) && this.ControlAnchors.Left == null && this.ControlAnchors.Right == null) { ControlAnchors.SideAnchor sideAnchor = this.ControlAnchors.Top != null ? this.ControlAnchors.Top : this.ControlAnchors.Bottom; sideAnchor.SetX(this.Left + this.Width / 2, this.Parent); } if (this.ControlAnchors.Center != null) { this.ControlAnchors.Center.SetX((this.Right + this.Left) / 2, this.Parent); this.ControlAnchors.Center.SetY((this.Top + this.Bottom) / 2, this.Parent); } ChangeLayoutOfDependencies(); this.OnPropertyChanged(new PropertyChangedEventArgs("anchors")); }
/// <summary> /// Updates the control anchor. /// </summary> /// <param name="controlAnchor">The control anchor to be updated.</param> /// <param name="control">The control.</param> /// <param name="anchor">The anchor.</param> private void SetControlAnchor(LayoutFrameTypeAnchorsAnchor anchor, bool inherited) { Point anchorPoint = anchor.GetRelativePoint(this.Parent); if (anchor.Offset != null) { Size offset = anchor.Offset.GetSize(); // Height is substracted because MultiverseInterface y coordinate increases upwards anchorPoint.Offset(offset.Width, -offset.Height); } string pointText = anchor.point.ToStringValue(); ControlAnchors.SideAnchor sideAnchor = new ControlAnchors.SideAnchor() { Anchor = anchor, Offset = anchorPoint, Inherited = inherited }; if (pointText.StartsWith("TOP")) { this.ControlAnchors.Top = sideAnchor; } if (pointText.StartsWith("BOTTOM")) { this.ControlAnchors.Bottom = sideAnchor; } if (pointText.EndsWith("LEFT")) { this.ControlAnchors.Left = sideAnchor; } if (pointText.EndsWith("RIGHT")) { this.ControlAnchors.Right = sideAnchor; } if (anchor.point == FRAMEPOINT.CENTER) { this.ControlAnchors.Center = sideAnchor; } }
private bool IsInheritedAnchor(ControlAnchors.SideAnchor sideAnchor) { return(sideAnchor != null && sideAnchor.Inherited); }