Ejemplo n.º 1
0
        private void OnElementMoving(_Control element, Rect rect)
        {
            if (!DesginCanvas.IsAutoAlign)
            {
                return;
            }
            List<AutoAlignLine> alignLines = new List<AutoAlignLine>();
            foreach (UIElement ui in DesginCanvas.Children)
            {
                if (DesginCanvas.SelectedControls.Contains(ui as _Control))
                {
                    continue;
                }
                if (ui is _Control && !(ui is _Line))
                {
                    AutoAlignLine alignLine = AlignCanvas.MeasureAlign(element, ui as _Control);
                    if (!alignLine.IsEmpty)
                    {
                        alignLines.Add(alignLine);
                    }
                }
            }

            AlignCanvas.DrawAlignLines(alignLines);
        }
Ejemplo n.º 2
0
 public ElementAdorner(_Control adornedElement)
     : base(adornedElement)
 {
     _element = adornedElement;
 }
Ejemplo n.º 3
0
 private void OnAddLineCompeledAction(_Control control)
 {
     DesginCanvas.AddNewControl(control);
 }
Ejemplo n.º 4
0
 private void OnAddElementCompletedAction(_Control control)
 {
     DesginCanvas.AddNewControl(control);
 }
Ejemplo n.º 5
0
        private void OnElementMoved(_Control element, Rect rect)
        {
            AlignCanvas.Clear();

            if (!DesginCanvas.IsAutoAlign)
            {
                return;
            }

            foreach (UIElement ui in DesginCanvas.Children)
            {
                if (DesginCanvas.SelectedControls.Contains(ui as _Control))
                {
                    continue;
                }
                if (ui is _Control)
                {
                    AutoAlignLine alignLine = AlignCanvas.MeasureAlign(element, ui as _Control);
                    if (!alignLine.IsEmpty)
                    {
                        switch (alignLine.AlignType)
                        {
                            case AlignType.Left:
                                element.Left = alignLine.X1;
                                break;
                            case AlignType.Top:
                                element.Top = alignLine.Y1;
                                break;
                            case AlignType.Right:
                                element.Left = alignLine.X1 - element.Width;
                                break;
                            case AlignType.Bottom:
                                element.Top = alignLine.Y1 - element.Height;
                                break;
                            case AlignType.HorizontalCenter:
                                element.Left = alignLine.X1 - element.Width / 2d;
                                break;
                            case AlignType.VerticalCenter:
                                element.Top = alignLine.Y1 - element.Height / 2d;
                                break;
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public AutoAlignLine MeasureAlign(_Control source, _Control target)
 {
     if (Math.Abs(source.Left + source.Width / 2d - target.Left - target.Width / 2d) <= AUTO_ALIGN_SIZE)
     {
         return new AutoAlignLine(
             target.Left + target.Width / 2d,
             target.Top - target.Height * 0.1d,
             target.Left + target.Width / 2d,
             target.Top + target.Height * 1.1d,
             AlignType.HorizontalCenter);
     }
     else if (Math.Abs(source.Top + source.Height / 2d - target.Top - target.Height / 2d) <= AUTO_ALIGN_SIZE)
     {
         return new AutoAlignLine(
             target.Left - target.Width * 0.1,
             target.Top + target.Height / 2d,
             target.Left + target.Width * 1.1,
             target.Top + target.Height / 2d,
             AlignType.VerticalCenter);
     }
     else if (Math.Abs(source.Top - target.Top) <= AUTO_ALIGN_SIZE)
     {
         return new AutoAlignLine(
             target.Left - target.Width * 0.1,
             target.Top,
             target.Left + target.Width * 1.1,
             target.Top,
             AlignType.Top);
     }
     else if (Math.Abs(source.Left - target.Left) <= AUTO_ALIGN_SIZE)
     {
         return new AutoAlignLine(
             target.Left,
             target.Top - target.Height * 0.1d,
             target.Left,
             target.Top + target.Height * 1.1,
             AlignType.Left);
     }
     else if (Math.Abs(source.Left + source.Width - target.Left - target.Width) <= AUTO_ALIGN_SIZE)
     {
         return new AutoAlignLine(
             target.Left + target.Width,
             target.Top - target.Height * 0.1d,
             target.Left + target.Width,
             target.Top + target.Height * 1.1,
             AlignType.Right);
     }
     else if (Math.Abs(source.Top + source.Height - target.Top - target.Height) <= AUTO_ALIGN_SIZE)
     {
         return new AutoAlignLine(
             target.Left - target.Width * 0.1,
             target.Top + target.Height,
             target.Left + target.Width * 1.1,
             target.Top + target.Height,
             AlignType.Bottom);
     }
     else
     {
         return AutoAlignLine.Empty;
     }
 }
Ejemplo n.º 7
0
 public void BeginAdd(_Control addBaseControl)
 {
     _addBaseControl = addBaseControl;
     this.Visibility = Visibility.Visible;
 }