Ejemplo n.º 1
0
 private void ApplyLayoutFrameTypeAnchors(LayoutFrameTypeAnchors anchors)
 {
     foreach (var anchor in anchors.Anchor)
     {
         var offsetSpecified = anchor.xSpecified || anchor.ySpecified;
         var point           = this.util.ConvertEnum <FramePoint>(anchor.point);
         if (anchor.relativePointSpecified)
         {
             var relativePoint = this.util.ConvertEnum <FramePoint>(anchor.relativePoint);
             if (offsetSpecified)
             {
                 this.SetPoint(point, anchor.relativeTo, relativePoint, anchor.x, anchor.y);
             }
             else
             {
                 this.SetPoint(point, anchor.relativeTo, relativePoint);
             }
         }
         else if (offsetSpecified)
         {
             this.SetPoint(point, anchor.x, anchor.y);
         }
         else
         {
             this.SetPoint(point);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Called after the control has been added to another container.
        /// </summary>
        /// <remarks>Adds the TOPLEFT anchor</remarks>
        protected override void InitLayout()
        {
            base.InitLayout();

            // set ControlFactory
            ISerializableControl serializableParent = this.Parent as ISerializableControl;

            if (serializableParent == null)
            {
                return;
            }

            this.DesignerLoader = serializableParent.DesignerLoader;

            if (this.SuspendLayouting)
            {
                return;
            }

            if (this.LayoutFrameType.SizeDimension == null)
            {
                this.LayoutFrameType.SizeDimension = Dimension.FromSize <Dimension.Size>(this.Size);
            }

            LayoutFrameTypeAnchors anchors;

            if (this.LayoutFrameType.AnchorsCollection.Count == 0)
            {
                anchors = new LayoutFrameTypeAnchors();
                this.LayoutFrameType.AnchorsCollection.Add(anchors);
            }
            else
            {
                anchors = this.LayoutFrameType.AnchorsCollection[0];
            }
            if (anchors.Anchor.Count == 0)
            {
                LayoutFrameTypeAnchorsAnchor anchor = new LayoutFrameTypeAnchorsAnchor();
                anchor.point  = FRAMEPOINT.TOPLEFT;
                anchor.Offset = new Dimension();
                anchor.Offset.Update(this.Left, this.Top);
                anchors.Anchor.Add(anchor);
                this.DoChangeLayout();
            }
        }