public DesignableResizeAdorner(UIElement adornedElement, IDesignable designable, UIElement chrome) : base(adornedElement) {
            this.designable = designable;

            this.designable.LocationChanged += DesignableLayoutChanged;
            this.designable.SizeChanged += DesignableLayoutChanged;            

            Chrome = chrome;
        }
Example #2
0
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     if (Designable==null) {
         Designable = VisualTreeUtils.TryFindParent<IDesignable>(this);
         if (Designable==null)
             throw new NullReferenceException();
     }
 }
        public DesignableResizeAdorner(UIElement adornedElement, IDesignable designable, UIElement chrome) : base(adornedElement)
        {
            this.designable = designable;

            this.designable.LocationChanged += DesignableLayoutChanged;
            this.designable.SizeChanged     += DesignableLayoutChanged;

            Chrome = chrome;
        }
Example #4
0
 public virtual void OnLabelFontChanged(EventArgs e)
 {
     foreach (Control c in Controls)
     {
         IDesignable lp = c as IDesignable;
         if (lp != null)
         {
             lp.OnParentLabelFontChanged(e);
         }
     }
     PerformLayout();
     Invalidate();
 }
Example #5
0
        private UserControl GetControlSet(string category)
        {
            Type             designerType    = designAbleResources[category];
            Type             genericType     = typeof(DesignerControl <>);
            Type             customListType  = genericType.MakeGenericType(designerType);
            IDesignerControl designerControl = (IDesignerControl)Activator.CreateInstance(customListType);

            IDesignable designable = designerControl.ControlSet;

            designable.JsonData = fastColoredTextBox1.Text;

            return((UserControl)designable);
        }
Example #6
0
        public virtual void Render(Graphics g)
        {
            CanvasPaintArgs e = new CanvasPaintArgs();

            e.g = g;


            #region RenderShapes
            foreach (Shape shape in shapes)
            {
                e.BorderPen = Pens.Black;
                e.FillBrush = Brushes.White;

                IDesignable designable = shape as IDesignable;

                if (designable != null)
                {
                    e.FillBrush = new SolidBrush(designable.FillColor);

                    e.BorderPen = new Pen(designable.BorderColor, designable.BorderSize);
                }



                shape.Render(e);
            }
            #endregion

            #region RenderSelection
            foreach (Shape shape in shapes)
            {
                ISelectable selectable = shape as ISelectable;
                if (selectable != null && selectable.IsSelected)
                {
                    selectable.RenderSelection(e);

                    IResizable resizable = shape as IResizable;
                    if (resizable != null)
                    {
                        resizable.RenderResize(e);
                    }
                }
            }
            #endregion
        }
Example #7
0
        private Rect GetCombinedBoundsForChildAddition(IDesignable child, Rect currentBounds)
        {
            var bounds    = new Rect();
            var leftDiff  = Math.Max(currentBounds.Left - child.Left, 0);
            var rightDiff = Math.Max(child.Left + child.Width - (currentBounds.Left + width), 0);
            var totalDiff = leftDiff + rightDiff;

            bounds.X     = currentBounds.Left - leftDiff;
            bounds.Width = width + totalDiff;

            var topDiff       = Math.Max(currentBounds.Top - child.Top, 0);
            var bottomDiff    = Math.Max(child.Top + child.Height - (currentBounds.Top + height), 0);
            var totalVertDiff = topDiff + bottomDiff;

            bounds.Y      = currentBounds.Top - topDiff;
            bounds.Height = height + totalVertDiff;
            return(bounds);
        }
        private void RegisterNewChild(IDesignable child)
        {
            Rect newBounds;

            if (items.Count == 1)
            {
                newBounds = new Rect
                                 {
                                     Location = new Point(child.Left, child.Top),
                                     Size = new Size(child.Width, child.Height),
                                 };
            }
            else
            {
                var currentBounds = new Rect(left, top, width, height);
                newBounds = GetCombinedBoundsForChildAddition(child, currentBounds);
            }
     
            childProportionsDictionary = CreateChildProportionsDictionary(items, newBounds);


            Console.WriteLine(string.Format("Left={0}, Width={1}", newBounds.Left, newBounds.Width));
            Console.WriteLine(string.Format("Top={0}, Height={1}", newBounds.Top, newBounds.Height));
            foreach (var childProportionse in childProportionsDictionary)
            {
                Console.WriteLine(string.Format("Lefts, Proporción={0}", childProportionse.Value.RelativeLocation.X));
            }
            foreach (var childProportionse in childProportionsDictionary)
            {
                Console.WriteLine(string.Format("Widths, Proporción={0}", childProportionse.Value.RelativeSize.Width));
            }

            left = newBounds.Left;
            top = newBounds.Top;
            width = newBounds.Width;
            height = newBounds.Height;

            RaiseLocationChanged();

            const double epsilon = 0.1;
            
            RaiseSizeChanged();            
        }
Example #9
0
        private void RegisterNewChild(IDesignable child)
        {
            Rect newBounds;

            if (items.Count == 1)
            {
                newBounds = new Rect
                {
                    Location = new Point(child.Left, child.Top),
                    Size     = new Size(child.Width, child.Height),
                };
            }
            else
            {
                var currentBounds = new Rect(left, top, width, height);
                newBounds = GetCombinedBoundsForChildAddition(child, currentBounds);
            }

            childProportionsDictionary = CreateChildProportionsDictionary(items, newBounds);


            Console.WriteLine(string.Format("Left={0}, Width={1}", newBounds.Left, newBounds.Width));
            Console.WriteLine(string.Format("Top={0}, Height={1}", newBounds.Top, newBounds.Height));
            foreach (var childProportionse in childProportionsDictionary)
            {
                Console.WriteLine(string.Format("Lefts, Proporción={0}", childProportionse.Value.RelativeLocation.X));
            }
            foreach (var childProportionse in childProportionsDictionary)
            {
                Console.WriteLine(string.Format("Widths, Proporción={0}", childProportionse.Value.RelativeSize.Width));
            }

            left   = newBounds.Left;
            top    = newBounds.Top;
            width  = newBounds.Width;
            height = newBounds.Height;

            RaiseLocationChanged();

            const double epsilon = 0.1;

            RaiseSizeChanged();
        }
Example #10
0
 private void RelocateChildWidth(IDesignable designable, double newWidth)
 {
     var proportion = childProportionsDictionary[designable].RelativeLocation.X;
     designable.Left = left + proportion * newWidth;
 }
Example #11
0
 private void RelocateChildHeight(IDesignable designable, double newHeight)
 {
     var proportion = childProportionsDictionary[designable].RelativeLocation.Y;
     designable.Top = top + proportion * newHeight;
 }
Example #12
0
        private Rect GetCombinedBoundsForChildAddition(IDesignable child, Rect currentBounds)
        {
            var bounds = new Rect();
            var leftDiff = Math.Max(currentBounds.Left - child.Left, 0);
            var rightDiff = Math.Max(child.Left + child.Width - (currentBounds.Left + width), 0);
            var totalDiff = leftDiff + rightDiff;

            bounds.X = currentBounds.Left - leftDiff;
            bounds.Width = width + totalDiff;

            var topDiff = Math.Max(currentBounds.Top - child.Top, 0);
            var bottomDiff = Math.Max(child.Top + child.Height - (currentBounds.Top + height), 0);
            var totalVertDiff = topDiff + bottomDiff;

            bounds.Y = currentBounds.Top - topDiff;
            bounds.Height = height + totalVertDiff;
            return bounds;
        }
Example #13
0
 public Developer(IDesignable Designable)
 {
     this.Designable = Designable;
 }
Example #14
0
 public DesignableResizeChrome(IDesignable designable)
 {
     this.designable = designable;
 }
Example #15
0
        private void ResizeChildHeight(IDesignable designable, double value)
        {
            var proportion = childProportionsDictionary[designable].RelativeSize.Height;

            designable.Height = value * proportion;
        }
Example #16
0
        private void ResizeChildWidth(IDesignable designable, double newWidth)
        {
            var proportion = childProportionsDictionary[designable].RelativeSize.Width;

            designable.Width = newWidth * proportion;
        }
Example #17
0
        private void RelocateChildHeight(IDesignable designable, double newHeight)
        {
            var proportion = childProportionsDictionary[designable].RelativeLocation.Y;

            designable.Top = top + proportion * newHeight;
        }
 public DesignableResizeChrome(IDesignable designable)
 {
     this.designable = designable;
 }
Example #19
0
 private void ResizeChildHeight(IDesignable designable, double value)
 {
     var proportion = childProportionsDictionary[designable].RelativeSize.Height;
     designable.Height = value * proportion;
 }
Example #20
0
 public void SetDraggable(IDesignable designable)
 {
     dragControl.Designable = designable;
 }
Example #21
0
 public void SetDraggable(IDesignable designable)
 {
     dragControl.Designable = designable;
 }
Example #22
0
 private void ResizeChildWidth(IDesignable designable, double newWidth)
 {
     var proportion = childProportionsDictionary[designable].RelativeSize.Width;
     designable.Width = newWidth * proportion;
 }
Example #23
0
        private void RelocateChildWidth(IDesignable designable, double newWidth)
        {
            var proportion = childProportionsDictionary[designable].RelativeLocation.X;

            designable.Left = left + proportion * newWidth;
        }