示例#1
0
        public void AddToolbar(ToolbarManager grip, double relativeGirth = 0.0)
        {
            int level = grip.Level;
            int i     = 0;

            if (layers.Count == 0)
            {
                layers.Add(new SidePanelLayer(level, this));
            }
            else
            {
                while (i < layers.Count && layers[i].LayerIndex < level)
                {
                    i++;
                }

                if (i >= layers.Count || layers[i].LayerIndex != level)
                {
                    layers.Insert(i, new SidePanelLayer(level, this));
                }
            }

            layers[i].AddControlAt(layers[i].Controls.Count, grip, relativeGirth);
            grip.Orientation = Orientation;
        }
示例#2
0
        public bool TryPlaceControl(ToolbarManager grip, Point p)
        {
            p = ToLocal(p);
            if (!IsInside(p, toolbarDragOverlap))
            {
                return(false);
            }

            foreach (DragRecepticle recepticle in toolbarDragHitBoxes)
            {
                if (recepticle.HitBox.Contains(p))
                {
                    if (recepticle.SidePanelLayerIndex < layers.Count && grip.SidePanelLayer == layers[recepticle.SidePanelLayerIndex] && grip.Index == recepticle.Index)
                    {
                        return(true);
                    }

                    grip.TryRemoveFromParent();
                    layers[recepticle.SidePanelLayerIndex].AddControlAt(recepticle.Index, grip);
                    grip.Orientation = Orientation;
                    return(true);
                }
            }

            return(false);
        }