public DesignableResizeAdorner(UIElement adornedElement, IDesignable designable, UIElement chrome) : base(adornedElement) { this.designable = designable; this.designable.LocationChanged += DesignableLayoutChanged; this.designable.SizeChanged += DesignableLayoutChanged; Chrome = chrome; }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { if (Designable==null) { Designable = VisualTreeUtils.TryFindParent<IDesignable>(this); if (Designable==null) throw new NullReferenceException(); } }
public virtual void OnLabelFontChanged(EventArgs e) { foreach (Control c in Controls) { IDesignable lp = c as IDesignable; if (lp != null) { lp.OnParentLabelFontChanged(e); } } PerformLayout(); Invalidate(); }
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); }
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 }
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(); }
private void RelocateChildWidth(IDesignable designable, double newWidth) { var proportion = childProportionsDictionary[designable].RelativeLocation.X; designable.Left = left + proportion * newWidth; }
private void RelocateChildHeight(IDesignable designable, double newHeight) { var proportion = childProportionsDictionary[designable].RelativeLocation.Y; designable.Top = top + proportion * newHeight; }
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; }
public Developer(IDesignable Designable) { this.Designable = Designable; }
public DesignableResizeChrome(IDesignable designable) { this.designable = designable; }
private void ResizeChildHeight(IDesignable designable, double value) { var proportion = childProportionsDictionary[designable].RelativeSize.Height; designable.Height = value * proportion; }
private void ResizeChildWidth(IDesignable designable, double newWidth) { var proportion = childProportionsDictionary[designable].RelativeSize.Width; designable.Width = newWidth * proportion; }
public void SetDraggable(IDesignable designable) { dragControl.Designable = designable; }