Пример #1
0
 public void BindElements(IDrawableContainerList dcs)
 {
     foreach (var dc in dcs)
     {
         BindElement(dc);
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _listOfdrawableContainer?.Dispose();
     }
     _listOfdrawableContainer = null;
 }
 public DrawableContainerBoundsChangeMemento(IDrawableContainer drawableContainer)
 {
     _listOfdrawableContainer = new DrawableContainerList
     {
         drawableContainer
     };
     _listOfdrawableContainer.Parent = drawableContainer.Parent;
     StoreBounds();
 }
Пример #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _containerList?.Dispose();
     }
     _containerList = null;
     _surface       = null;
 }
Пример #5
0
 public FieldAggregator(ISurface parent)
 {
     foreach (var fieldType in FieldType.Values)
     {
         var field = new Field(fieldType, GetType());
         AddField(field);
     }
     _boundContainers = new DrawableContainerList
     {
         Parent = parent
     };
 }
Пример #6
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(IDrawableContainerList elements)
 {
     for (int i = 0; i < Count; i++)
     {
         var dc = this[i];
         if (!elements.Contains(dc))
         {
             continue;
         }
         if ((i > 0) && !elements.Contains(this[i - 1]))
         {
             SwapElements(i, i - 1);
         }
     }
 }
Пример #7
0
 /// <summary>
 /// Indicates whether the given list of elements can be pushed down,
 /// i.e. whether there is at least one unselected element lower in hierarchy
 /// </summary>
 /// <param name="elements">list of elements to push down</param>
 /// <returns>true if the elements could be pushed down</returns>
 public bool CanPushDown(IDrawableContainerList elements)
 {
     if (elements.Count == 0 || elements.Count == Count)
     {
         return(false);
     }
     foreach (var element in elements)
     {
         if (IndexOf(element) >= elements.Count)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #8
0
        /// <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(IDrawableContainerList elements)
        {
            var dcs = ToArray();

            foreach (var dc in dcs)
            {
                if (!elements.Contains(dc))
                {
                    continue;
                }
                Remove(dc);
                Add(dc);
                Parent.Modified = true;
            }
        }
Пример #9
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(IDrawableContainerList 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);
         }
     }
 }
Пример #10
0
        /// <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(IDrawableContainerList elements)
        {
            var dcs = ToArray();

            for (int i = dcs.Length - 1; i >= 0; i--)
            {
                var dc = dcs[i];
                if (!elements.Contains(dc))
                {
                    continue;
                }
                Remove(dc);
                Insert(0, dc);
                Parent.Modified = true;
            }
        }
 public DrawableContainerBoundsChangeMemento(IDrawableContainerList listOfdrawableContainer)
 {
     _listOfdrawableContainer = listOfdrawableContainer;
     StoreBounds();
 }
Пример #12
0
 public DeleteElementsMemento(Surface surface, IDrawableContainerList containerList)
 {
     _surface       = surface;
     _containerList = containerList;
 }
Пример #13
0
        /// <summary>
        /// Add items to a context menu for the selected item
        /// </summary>
        /// <param name="menu"></param>
        /// <param name="surface"></param>
        public virtual void AddContextMenuItems(ContextMenuStrip menu, ISurface surface)
        {
            bool push = surface.Elements.CanPushDown(this);
            bool pull = surface.Elements.CanPullUp(this);

            ToolStripMenuItem item;

            // Pull "up"
            if (pull)
            {
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_uptotop));
                item.Click += delegate {
                    surface.Elements.PullElementsToTop(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_uponelevel));
                item.Click += delegate {
                    surface.Elements.PullElementsUp(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
            }
            // Push "down"
            if (push)
            {
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_downtobottom));
                item.Click += delegate {
                    surface.Elements.PushElementsToBottom(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
                item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_downonelevel));
                item.Click += delegate {
                    surface.Elements.PushElementsDown(this);
                    surface.Elements.Invalidate();
                };
                menu.Items.Add(item);
            }

            // Duplicate
            item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_duplicate));
            item.Click += delegate {
                IDrawableContainerList dcs = this.Clone();
                dcs.Parent = surface;
                dcs.MoveBy(10, 10);
                surface.AddElements(dcs);
                surface.DeselectAllElements();
                surface.SelectElements(dcs);
            };
            menu.Items.Add(item);

            // Copy
            item = new ToolStripMenuItem(Language.GetString(LangKey.editor_copytoclipboard))
            {
                Image = (Image)EditorFormResources.GetObject("copyToolStripMenuItem.Image")
            };
            item.Click += delegate {
                ClipboardHelper.SetClipboardData(typeof(IDrawableContainerList), this);
            };
            menu.Items.Add(item);

            // Cut
            item = new ToolStripMenuItem(Language.GetString(LangKey.editor_cuttoclipboard))
            {
                Image = (Image)EditorFormResources.GetObject("btnCut.Image")
            };
            item.Click += delegate {
                ClipboardHelper.SetClipboardData(typeof(IDrawableContainerList), this);
                surface.RemoveElements(this);
            };
            menu.Items.Add(item);

            // Delete
            item        = new ToolStripMenuItem(Language.GetString(LangKey.editor_deleteelement));
            item.Image  = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image");
            item.Click += delegate {
                surface.RemoveElements(this);
            };
            menu.Items.Add(item);

            // Reset
            bool canReset = false;

            foreach (var drawableContainer in this)
            {
                var container = (DrawableContainer)drawableContainer;
                if (container.HasDefaultSize)
                {
                    canReset = true;
                }
            }
            if (canReset)
            {
                item = new ToolStripMenuItem(Language.GetString(LangKey.editor_resetsize));
                //item.Image = ((System.Drawing.Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
                item.Click += delegate {
                    MakeBoundsChangeUndoable(false);
                    foreach (var drawableContainer in this)
                    {
                        var container = (DrawableContainer)drawableContainer;
                        if (!container.HasDefaultSize)
                        {
                            continue;
                        }
                        Size defaultSize = container.DefaultSize;
                        container.MakeBoundsChangeUndoable(false);
                        container.Width  = defaultSize.Width;
                        container.Height = defaultSize.Height;
                    }
                    surface.Invalidate();
                };
                menu.Items.Add(item);
            }
        }