예제 #1
0
        public QGBindingLayer(IQGControl parentControl)
        {
            this.ChildControls = new QGControlCollection(this);

            this.ParentControl = parentControl;
            this.ParentControl.RegisterControlInitMethod(c => __initialize(this.ParentControl.WPFPrimaryElement));
        }
예제 #2
0
        private void __UpdateLayerBoundaries(IQGControl control)
        {
            this.RightmostControl ??= control;
            this.BottommostControl ??= control;

            double elXedge = control.GetRightEdge();
            double elYedge = control.GetBottomEdge();

            if (elXedge > _rightEdge)
            {
                this.RightmostControl = control;
                _rightEdge            = elXedge;
            }
            else if (elXedge < _rightEdge && this.RightmostControl == control)
            {
                this.RightmostControl = __selectControl(this.ChildControls, (c1, c2) => c1.GetRightEdge() > c2.GetRightEdge() ? c1 : c2);
                _rightEdge            = this.RightmostControl.GetRightEdge();
            }

            if (elYedge > _bottomEdge)
            {
                this.BottommostControl = control;
                _bottomEdge            = elYedge;
            }
            else if (elYedge < _bottomEdge && this.BottommostControl == control)
            {
                this.BottommostControl = __selectControl(this.ChildControls, (c1, c2) => c1.GetBottomEdge() > c2.GetBottomEdge() ? c1 : c2);
                _bottomEdge            = this.BottommostControl.GetBottomEdge();
            }

            if (this.Width != _rightEdge || this.Height != _bottomEdge)
            {
                this.SetSize(_rightEdge, _bottomEdge);
            }
        }
예제 #3
0
 private void __registerParent(IQGControl sender)
 {
     if (this.ParentLayer == null && this.Vertex1.IsInitialized && this.Vertex2.IsInitialized)
     {
         IQGLayer.FindNearestCommonLayer(this.Vertex1, this.Vertex2).ChildControls.Add(this);
     }
 }
예제 #4
0
        private void __initializeWPFElement(object caller, UIElement wpfElement)
        {
            IQGControl control = (IQGControl)caller;

            QGControlAdorner adorner = this.ControlAdorners[control];

            adorner.AdornerVisualCollection.Add(wpfElement);
        }
예제 #5
0
        private void __UpdateBoundariesAfterElementRemoval(IQGControl control)
        {
            if (this.RightmostControl == control)
            {
                this.RightmostControl = __selectControl(this.ChildControls, (c1, c2) => c1.GetRightEdge() > c2.GetRightEdge() ? c1 : c2);
                _rightEdge            = this.RightmostControl?.GetRightEdge() ?? 0;
            }

            if (this.BottommostControl == control)
            {
                this.BottommostControl = __selectControl(this.ChildControls, (c1, c2) => c1.GetBottomEdge() > c2.GetBottomEdge() ? c1 : c2);
                _bottomEdge            = this.BottommostControl?.GetBottomEdge() ?? 0;
            }
        }
예제 #6
0
        void IQGLayer.OnRemovingControl(IQGControl control)
        {
            if (!this.ControlAdorners.ContainsKey(control))
            {
                throw new Exception("Cannot remove control from binding layer: it is not present within the layer.");
            }

            control.SetParentLayer(null);
            QGControlAdorner adorner = this.ControlAdorners[control];

            this.ControlAdorners.Remove(control);
            this.WPFAdornerLayer?.Remove(adorner);

            this.OnRemovingControl(control);
        }
예제 #7
0
        private IQGControl __selectControl(IEnumerable <IQGControl> controls, Func <IQGControl, IQGControl, IQGControl> selector)
        {
            if (controls == null || !controls.Any())
            {
                return(null);
            }

            IQGControl currentSelection = controls.First();

            foreach (IQGControl item in controls)
            {
                currentSelection = selector(currentSelection, item);
            }

            return(currentSelection);
        }
예제 #8
0
        void IQGLayer.OnAddingControl(IQGControl control)
        {
            control.SetParentLayer(this);

            QGControlAdorner adorner = new QGControlAdorner(this.ParentControl);

            this.ControlAdorners.Add(control, adorner);
            this.WPFAdornerLayer?.Add(adorner);

            if (control is IWPFContainer wpfContainer)
            {
                wpfContainer.RegisterWPFElementInitMethod(__initializeWPFElement);
            }
            this.UpdateControlPosition(control);

            this.OnAddingControl(control);
        }
예제 #9
0
        public void UpdateControlPosition(IQGControl child)
        {
            if (!this.ChildControls.Contains(child))
            {
                throw new Exception("Cannot update control position: control is not a child of the calling layer.");
            }

            Point wpfControlPoint = ((IQGLayer)this).GetRenderingCoordinatesOf(child.Position);

            foreach (WPFElementInfo elementInfo in child.WPFElementInfoEnumeration)
            {
                Point wpfRenderPoint = wpfControlPoint + child.GetAlignmentOffset(elementInfo.Size) + elementInfo.PositionOffset;
                Rect  wpfDimensions  = new Rect(wpfRenderPoint, elementInfo.Size);

                if (!Double.IsFinite(elementInfo.Size.Width) || !Double.IsFinite(elementInfo.Size.Height))
                {
                    break;
                }

                elementInfo.UIElement.Arrange(wpfDimensions);
            }
        }
예제 #10
0
 public static double GetBottomEdge(this IQGControl control)
 {
     return(control.Y + (control.RenderSize.Height + control.GetAlignmentOffset().Y));
 }
예제 #11
0
 protected override void OnRemovingControl(IQGControl control)
 {
     control.PositionChange -= __updateControlOnMove;
     control.SizeChange     -= __updateControlOnResize;
     __UpdateBoundariesAfterElementRemoval(control);
 }
예제 #12
0
 protected override void OnAddingControl(IQGControl control)
 {
     __UpdateLayerBoundaries(control);
     control.PositionChange += __updateControlOnMove;
     control.SizeChange     += __updateControlOnResize;
 }
예제 #13
0
 public static double GetRightEdge(this IQGControl control)
 {
     return(control.X + (control.RenderSize.Width + control.GetAlignmentOffset().X));
 }
예제 #14
0
 protected virtual void OnRemovingControl(IQGControl control)
 {
 }
예제 #15
0
 public QGControlAdorner(IQGControl parentControl)
     : base(parentControl.WPFPrimaryElement)
 {
     this.ParentControl           = parentControl;
     this.AdornerVisualCollection = new VisualCollection(this);
 }
예제 #16
0
 protected virtual void OnAddingControl(IQGControl control)
 {
 }
예제 #17
0
 void IQGLayer.UpdateControlPosition(IQGControl child) => this.UpdateControlPosition(child);
예제 #18
0
 void IQGLayer.UpdateControlSize(IQGControl child)
 {
     this.UpdateControlPosition(child);
 }