Ejemplo n.º 1
0
 /// <summary>
 /// Pulls one or several elements up one level in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">list of elements to pull up</param>
 public void PullElementsUp(DrawableContainerList elements)
 {
     for (int i = this.Count - 1; i >= 0; i--)
     {
         DrawableContainer dc = this[i];
         if (elements.Contains(dc))
         {
             if (Count > (i + 1) && !elements.Contains(this[i + 1]))
             {
                 SwapElements(i, i + 1);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Pushes one or several elements down one level in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">list of elements to push down</param>
 public void PushElementsDown(DrawableContainerList elements)
 {
     for (int i = 0; i < Count; i++)
     {
         DrawableContainer dc = this[i];
         if (elements.Contains(dc))
         {
             if ((i > 0) && !elements.Contains(this[i - 1]))
             {
                 SwapElements(i, i - 1);
             }
         }
     }
 }
 /// <summary>
 /// Pulls one or several elements up one level in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">list of elements to pull up</param>
 public void PullElementsUp(DrawableContainerList elements)
 {
     for (int i = Count - 1; i >= 0; i--)
     {
         var dc = this[i];
         if (!elements.Contains(dc))
         {
             continue;
         }
         if (Count > i + 1 && !elements.Contains(this[i + 1]))
         {
             SwapElements(i, i + 1);
         }
     }
 }
 /// <summary>
 /// Pushes one or several elements down to the bottommost level(s) in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">of elements to push to bottom</param>
 public void PushElementsToBottom(DrawableContainerList elements)
 {
     DrawableContainer[] dcs = this.ToArray();
     for (int i = dcs.Length - 1; i >= 0; i--)
     {
         DrawableContainer dc = dcs[i];
         if (elements.Contains(dc))
         {
             this.Remove(dc);
             this.Insert(0, dc);
         }
     }
 }
 /// <summary>
 /// Pulls one or several elements up to the topmost level(s) in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">of elements to pull to top</param>
 public void PullElementsToTop(DrawableContainerList elements)
 {
     DrawableContainer[] dcs = this.ToArray();
     for (int i = 0; i < dcs.Length; i++)
     {
         DrawableContainer dc = dcs[i];
         if (elements.Contains(dc))
         {
             this.Remove(dc);
             this.Add(dc);
         }
     }
 }
 /// <summary>
 /// Pushes one or several elements down to the bottommost level(s) in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">of elements to push to bottom</param>
 public void PushElementsToBottom(DrawableContainerList elements)
 {
     IDrawableContainer[] dcs = ToArray();
     for (int i = dcs.Length - 1; i >= 0; i--)
     {
         IDrawableContainer dc = dcs[i];
         if (elements.Contains(dc))
         {
             Remove(dc);
             Insert(0, dc);
             Parent.Modified = true;
         }
     }
 }
 /// <summary>
 /// Pulls one or several elements up to the topmost level(s) in hierarchy (z-index).
 /// </summary>
 /// <param name="elements">of elements to pull to top</param>
 public void PullElementsToTop(DrawableContainerList elements)
 {
     IDrawableContainer[] dcs = ToArray();
     for (int i = 0; i < dcs.Length; i++)
     {
         IDrawableContainer dc = dcs[i];
         if (elements.Contains(dc))
         {
             Remove(dc);
             Add(dc);
             Parent.Modified = true;
         }
     }
 }
        void SurfaceMouseUp(object sender, MouseEventArgs e)
        {
            mouseDown        = false;
            mouseDownElement = null;
            if (DrawingMode == DrawingModes.None) // check whether an existing element was clicked
            {
                DrawableContainer element = elements.ClickableElementAt(e.X, e.Y);
                bool shiftModifier        = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
                if (element != null)
                {
                    bool alreadySelected = selectedElements.Contains(element);
                    if (shiftModifier)
                    {
                        if (alreadySelected)
                        {
                            DeselectElement(element);
                        }
                        else
                        {
                            SelectElement(element);
                        }
                    }
                    else
                    {
                        if (!alreadySelected)
                        {
                            DeselectAllElements();
                            SelectElement(element);
                        }
                    }
                }
                else if (!shiftModifier)
                {
                    DeselectAllElements();
                }
            }

            if (selectedElements.Count > 0)
            {
                selectedElements.ShowGrippers();
                selectedElements.Selected = true;
            }
            if (drawingElement != null)
            {
                if (!drawingElement.InitContent())
                {
                    elements.Remove(drawingElement);
                    Invalidate();
                }
                else
                {
                    if (Math.Abs(drawingElement.Width) < 5 && Math.Abs(drawingElement.Height) < 5)
                    {
                        drawingElement.Width  = 25;
                        drawingElement.Height = 25;
                    }
                    SelectElement(drawingElement);
                    drawingElement.Selected = true;
                }
                drawingElement = null;
            }
            Invalidate();
        }