Ejemplo n.º 1
0
        public void AddTool(TabModel item, TabOwnerModelBase target, Dock dock)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var group = new ToolWellModel()
            {
                Width = item.Width, Height = item.Height, Dock = dock
            };

            group.Children.Add(item);

            var container = new SplitPanelModel(dock, group);

            if (target == null)
            {
                target  = Content;
                Content = container;
            }
            else if (target.ParentBranch != null)
            {
                target.ParentBranch.Replace(target, container);
            }
            else
            {
                System.Diagnostics.Debugger.Break();
                throw new InvalidOperationException();
            }

            container.Add(target);
        }
Ejemplo n.º 2
0
        public bool Remove(TabOwnerModelBase item)
        {
            if (Item1 == item)
            {
                Item1 = null;
                return(true);
            }
            else if (Item2 == item)
            {
                Item2 = null;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public bool Add(TabOwnerModelBase item)
        {
            if (Item1 == null)
            {
                Item1 = item;
                return(true);
            }
            else if (Item2 == null)
            {
                Item2 = item;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        public SplitPanelModel(Dock dock, TabWellModelBase content) : this()
        {
            Orientation = dock == Dock.Left || dock == Dock.Right ? Orientation.Horizontal : Orientation.Vertical;

            if (dock == Dock.Left || dock == Dock.Top)
            {
                Item1           = content;
                Item1.PanelSize = new GridLength(dock == Dock.Left ? content.Width : content.Height);
                Item2           = null;
            }
            else
            {
                Item1           = null;
                Item2           = content;
                Item2.PanelSize = new GridLength(dock == Dock.Right ? content.Width : content.Height);
            }
        }
Ejemplo n.º 5
0
        public bool Replace(TabOwnerModelBase prev, TabOwnerModelBase next)
        {
            if (Item1 == prev)
            {
                var sizeTemp = Item1.PanelSize;
                Item1           = next;
                Item1.PanelSize = sizeTemp;
                return(true);
            }
            else if (Item2 == prev)
            {
                var sizeTemp = Item2.PanelSize;
                Item2           = next;
                Item2.PanelSize = sizeTemp;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        private void OnItemChanged(TabOwnerModelBase prev, TabOwnerModelBase next)
        {
            prev?.SetParent(null);
            next?.SetParent(this);

            if (next == null)
            {
                var remaining = Item1 ?? Item2;
                if (remaining == null)
                {
                    return;
                }
                Item1 = Item2 = null;

                if (ParentBranch != null)
                {
                    ParentBranch.Replace(this, remaining);
                }
                else if (ParentContainer != null)
                {
                    ParentContainer.Content = remaining;
                }
            }
        }
Ejemplo n.º 7
0
 internal void SetParent(TabOwnerModelBase parent) => Parent = parent;
Ejemplo n.º 8
0
 protected virtual void OnParentChanged(TabOwnerModelBase prev, TabOwnerModelBase next)
 {
 }
Ejemplo n.º 9
0
 private void OnContentChanged(TabOwnerModelBase prev, TabOwnerModelBase next)
 {
     prev?.SetParent(null);
     next?.SetParent(this);
 }