Beispiel #1
0
        public void Grouping(T newItem, LayoutAlignType anch)
        {
            T map = new T();

            Replace(map);

            Row            = 0;
            Column         = 0;
            newItem.Row    = 0;
            newItem.Column = 0;

            if (anch == LayoutAlignType.Top)
            {
                Row = 1;
            }
            else if (anch == LayoutAlignType.Bottom)
            {
                newItem.Row = 1;
            }
            else if (anch == LayoutAlignType.Right)
            {
                newItem.Column = 1;
            }
            else if (anch == LayoutAlignType.Left)
            {
                Column = 1;
            }

            map.Add((T)this);
            map.Add(newItem);
        }
Beispiel #2
0
 public void InsertWith(T newItem, LayoutAlignType type, bool grouping)
 {
     if (grouping)
     {
         Grouping(newItem, type);
     }
     else
     {
         newItem.Row    = Row;
         newItem.Column = Column;
         //move only by change indexes
         bool inserRow = false;
         if (type == LayoutAlignType.Right)
         {
             newItem.Column++;
         }
         else if (type == LayoutAlignType.Top)
         {
             inserRow = true;
         }
         else if (type == LayoutAlignType.Bottom)
         {
             inserRow = true;
             newItem.Row++;
         }
         Map.Insert(newItem, inserRow);
     }
 }
Beispiel #3
0
 public DockItem GetDockItem(string name, DockItem exist, LayoutAlignType type, bool gp)
 {
     if (!(items.GetRecursive(name) is DockItem item))
     {
         item = CreateDockItem(name, exist, type, gp);
         Add(item, exist, type, gp);
     }
     return(item);
 }
Beispiel #4
0
        private void layoutCallback(object sender, EventArgs e)
        {
            if (!(sender is ToolStripMenuItem))
            {
                return;
            }
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            LayoutAlignType   type = (LayoutAlignType)item.Tag;

            execSetLayoutAlign(type);
        }
Beispiel #5
0
 public void Add(DockItem item, DockItem exist = null, LayoutAlignType type = LayoutAlignType.None, bool gp = false)
 {
     if (exist == null)
     {
         items.Add(item);
     }
     else
     {
         exist.InsertWith(item, type, gp);
     }
 }
Beispiel #6
0
        public DockItem CreateDockItem(string name, DockItem exist, LayoutAlignType type, bool gp)
        {
            var item = new DockItem()
            {
                Name       = name,
                Visible    = true,
                FillHeight = name == "Right" || name == "Left",
                Panel      = new DockPanel()
            };

            if (name == "Bottom")
            {
                item.Height = 200;
            }
            return(item);
        }
Beispiel #7
0
        public static LayoutAlignType GetAlignRect(Rectangle bound, double size, double x, double y, ref Rectangle rec)
        {
            var             sizes = (size + 3);
            LayoutAlignType type  = LayoutAlignType.None;

            if (x >= bound.Right - sizes && x <= bound.Right)
            {
                rec.X      = bound.Right - sizes;
                rec.Y      = bound.Top;
                rec.Width  = sizes;
                rec.Height = bound.Height;
                type       = LayoutAlignType.Right;
            }
            else if (x <= bound.Left + (size + 2) && x >= bound.Left)
            {
                rec.X      = bound.Left;
                rec.Y      = bound.Top;
                rec.Width  = sizes;
                rec.Height = bound.Height;
                type       = LayoutAlignType.Left;
            }
            else if (y <= bound.Top + size && y >= bound.Top)
            {
                rec.X      = bound.Left;
                rec.Y      = bound.Top;
                rec.Width  = bound.Width;
                rec.Height = size;
                type       = LayoutAlignType.Top;
            }
            else if (y >= bound.Bottom - size && y <= bound.Bottom)
            {
                rec.X      = bound.Left;
                rec.Y      = bound.Bottom - size;
                rec.Width  = bound.Width;
                rec.Height = size;
                type       = LayoutAlignType.Bottom;
            }
            else
            {
                type = LayoutAlignType.None;
            }
            return(type);
        }
Beispiel #8
0
        public void Move(T moved, LayoutAlignType type, bool builGroup)
        {
            //check collision
            //if (Contains(moved.Map, destination) && moved.Map != destination.Map && moved.Map.Map != null)
            //    return;

            if (moved.Map == Map && Map.Map != null)
            {
                builGroup = false;
            }

            //remove from old map
            Remove(moved);

            if (Map.Count == 1)
            {
                builGroup = false;
            }

            InsertWith(moved, type, builGroup);
        }
Beispiel #9
0
        public void execSetLayoutAlign(LayoutAlignType layout)
        {
            mouseOpItems = getSelectItems();
            if (mouseOpItems.Count <= 1)
            {
                return;
            }
            RenderBase        firstSelect = mouseOpItems[0];
            List <RenderBase> opItems     = new List <RenderBase>();

            foreach (RenderBase item in mouseOpItems)
            {
                if (item.getParent() == firstSelect.getParent())
                {
                    opItems.Add(item);
                }
            }
            if (opItems.Count <= 1)
            {
                return;
            }
            recordOriStatus(opItems);
            float      left = 0, centerHor = 0, right = 0, top = 0, centerVer = 0, bottom = 0;
            SizeF      selectSize  = firstSelect.size;
            PointF     selectPoint = firstSelect.pos;//scenePointToRender((int)firstSelect.pos.X, (int)firstSelect.pos.Y);
            RectangleF selectRect  = firstSelect.boxAtParent();

            left      = selectPoint.X;
            centerHor = selectPoint.X + selectSize.Width / 2;
            right     = selectPoint.X + selectSize.Width;
            top       = selectPoint.Y;
            centerVer = selectPoint.Y + selectSize.Height / 2;
            bottom    = selectPoint.Y + selectSize.Height;

            switch (layout)
            {
            case LayoutAlignType.LayoutAlign_Left:
            {
                foreach (RenderBase item in mouseOpItems)
                {
                    RectangleF rect = item.boxAtParent();
                    item.pos = new PointF(item.pos.X + left - rect.X, item.pos.Y);
                }
            }
            break;

            case LayoutAlignType.LayoutAlign_Right:
            {
                foreach (RenderBase item in mouseOpItems)
                {
                    RectangleF rect = item.boxAtParent();
                    item.pos = new PointF(item.pos.X + right - rect.X - rect.Width, item.pos.Y);
                }
            }
            break;

            case LayoutAlignType.LayoutAlign_CenterHor:
            {
                foreach (RenderBase item in mouseOpItems)
                {
                    RectangleF rect = item.boxAtParent();
                    item.pos = new PointF(item.pos.X + centerHor - rect.X - rect.Width / 2, item.pos.Y);
                }
            } break;

            case LayoutAlignType.LayoutAlign_Top:
            {
                foreach (RenderBase item in mouseOpItems)
                {
                    RectangleF rect = item.boxAtParent();
                    item.pos = new PointF(item.pos.X, item.pos.Y + top - rect.Y);
                }
            }
            break;

            case LayoutAlignType.LayoutAlign_Bottom:
            {
                foreach (RenderBase item in mouseOpItems)
                {
                    RectangleF rect = item.boxAtParent();
                    item.pos = new PointF(item.pos.X, item.pos.Y + bottom - rect.Y - rect.Height);
                }
            }
            break;

            case LayoutAlignType.LayoutAlign_CenterVer:
            {
                foreach (RenderBase item in mouseOpItems)
                {
                    RectangleF rect = item.boxAtParent();
                    item.pos = new PointF(item.pos.X, item.pos.Y + centerVer - rect.Y - rect.Height / 2);
                }
            } break;

            default:
                break;
            }
            commandManager.AddCommand(new CommandMoveList(this, mouseOpItems));
        }
Beispiel #10
0
 public DockItem GetDockItem(string name, LayoutAlignType type, bool gp)
 {
     return(GetDockItem(name, Main, type, gp));
 }