Example #1
0
        internal static void Remove(IDockPane dockPane, IDockElement dockElement)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(dockElement != null);
            Debug.Assert(dockPane != dockElement);

            var parent = GetParent(dockPane, dockElement);

            if (parent is IDockAnchorPane)
            {
                Debug.Assert(dockElement is IDockPane);

                var dockAnchorPane = (IDockAnchorPane)parent;
                dockAnchorPane.ChildPane = null;
            }
            else if (parent is IDockSplitPane)
            {
                Debug.Assert(dockElement is IDockPane);

                var dockSplitPane = (IDockSplitPane)parent;
                dockSplitPane.ChildPanes.Remove((IDockPane)dockElement);
            }
            else if (parent is IDockTabPane)
            {
                Debug.Assert(dockElement is IDockTabItem);

                var dockTabPane = (IDockTabPane)parent;
                dockTabPane.Items.Remove((IDockTabItem)dockElement);
            }
        }
        private static void RemoveItemProxies(IDockPane dockPane)
        {
            Debug.Assert(dockPane != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                    RemoveItemProxies(dockAnchorPane.ChildPane);
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                RemoveItemProxies(dockSplitPane.ChildPanes);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                for (int i = dockTabPane.Items.Count - 1; i >= 0; i--)
                {
                    if (dockTabPane.Items[i] is DockTabItemProxy)
                        dockTabPane.Items.RemoveAt(i);
                }
            }
        }
        private static void RemoveItemProxies(IDockPane dockPane)
        {
            Debug.Assert(dockPane != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                {
                    RemoveItemProxies(dockAnchorPane.ChildPane);
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                RemoveItemProxies(dockSplitPane.ChildPanes);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                for (int i = dockTabPane.Items.Count - 1; i >= 0; i--)
                {
                    if (dockTabPane.Items[i] is DockTabItemProxy)
                    {
                        dockTabPane.Items.RemoveAt(i);
                    }
                }
            }
        }
        private static void RestoreItemsFromProxies(IDockPane dockPane)
        {
            Debug.Assert(dockPane != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                {
                    RestoreItemsFromProxies(dockAnchorPane.ChildPane);
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                RestoreItemsFromProxies(dockSplitPane.ChildPanes);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                for (int i = dockTabPane.Items.Count - 1; i >= 0; i--)
                {
                    var proxy = dockTabPane.Items[i] as DockTabItemProxy;
                    if (proxy != null)
                    {
                        dockTabPane.Items[i] = proxy.Item;
                    }
                }
            }
        }
Example #5
0
        internal static void Replace(IDockPane parent, IDockPane oldChild, IDockPane newChild)
        {
            Debug.Assert(parent != null);
            Debug.Assert(oldChild != null);
            Debug.Assert(newChild != null);
            Debug.Assert(oldChild != newChild);

            if (parent is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)parent;
                Debug.Assert(dockAnchorPane.ChildPane == oldChild);
                dockAnchorPane.ChildPane = newChild;
            }
            else if (parent is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)parent;
                int index         = dockSplitPane.ChildPanes.IndexOf(oldChild);
                Debug.Assert(index >= -1, "Previous child not found in DockSplitPane.");

                // Important: Use Remove + Insert. Do not use Set (indexer)!
                // When the indexer is used, the ItemsControl reuses the previous item container
                // instead of creating the correct item container based on the data template.
                dockSplitPane.ChildPanes.RemoveAt(index);
                dockSplitPane.ChildPanes.Insert(index, newChild);
            }
        }
Example #6
0
 private static DockState Save(IDockPane p)
 {
     return(new DocumentsSave()
     {
         persiststring = p.Documents.Select(_i => Save(_i)).ToArray(),
         clientsize = p.WidgetSize
     });
 }
Example #7
0
        void IDockNotify.OnLoaded(IDockPane pane)
        {
            Debug.Assert(this.xwtdisplay == null);

            this.xwtdisplay = new OpenTK.XwtRender(this, this.xwtrender, this.xwt, TimeBase);
            this.xwtdisplay.FrameRenderer = new MovieRender(this);
            this.xwtdisplay.Initialize(this.factory, this.xwtrender, new FPS(1, 25, true), new size(1920, 1080));
            this.xwtdisplay.Play(0);
        }
Example #8
0
        public void ClosePane(IDockPane pane)
        {
            var avalonPane = FindAvalonPane(pane);

            if (avalonPane != null)
            {
                avalonPane.Close();
            }
        }
Example #9
0
        public void Hide(IDockPane pane)
        {
            Refresh();
            DockPaneShim form = _activePanes.Find(x => x.Pane == pane);

            if (form.Pane != null)
            {
                form.Content.Hide();
            }
        }
Example #10
0
        public string GetPaneName(IDockPane pane)
        {
            var avalonPane = pane.PaneContext as DockableContent;

            if (avalonPane == null)
            {
                throw new ArgumentException("pane is not a valid pane");
            }
            return(avalonPane.Name);
        }
Example #11
0
 private DockableContent FindAvalonPane(IDockPane pane)
 {
     foreach (var avalonDoc in dockingManager.DockableContents)
     {
         if (Object.ReferenceEquals(avalonDoc.Content, pane))
         {
             return(avalonDoc);
         }
     }
     return(null);
 }
Example #12
0
        public IDockPane ShowPane(string name, CreateDockPaneDelegate createDockPane)
        {
            IDockPane pane       = null;
            var       avalonPane = FindAvalonPane(name);

            if (avalonPane == null)
            {
                avalonPane = new DockableContent()
                {
                    Name = name
                };
                pane = createDockPane(avalonPane, name);

                BindingExtensions.CreateBinding(pane, "PaneTitle", avalonPane, DockableContent.TitleProperty, BindingMode.OneWay);

                avalonPane.Content = pane;

                avalonPane.Closing += AvalonPane_Closing;
                avalonPane.Closed  += AvalonPane_Closed;

                AnchorStyle anchor = AnchorStyle.None;
                switch (pane.DefaultPaneLocation)
                {
                case PaneLocation.Left:
                    anchor = AnchorStyle.Left;
                    break;

                case PaneLocation.Right:
                    anchor = AnchorStyle.Right;
                    break;

                case PaneLocation.Top:
                    anchor = AnchorStyle.Top;
                    break;

                case PaneLocation.Bottom:
                    anchor = AnchorStyle.Bottom;
                    break;
                }

                avalonPane.HideOnClose = pane.HidePaneOnClose;
                avalonPane.Show(dockingManager, anchor);
            }
            else
            {
                avalonPane.Show();
            }

            Dispatcher.BeginInvoke(new NoArgsDelegate(() => { avalonPane.Manager.ActiveDocument = avalonPane; }), null);

            return(pane);
        }
Example #13
0
        public void Refresh()
        {
            DockPaneShim[] removedForms = _activePanes
                                          .Where(x => PluginManager.Get <IDockPane>(x.Name) == null)
                                          .ToArray();
            foreach (DockPaneShim form in removedForms)
            {
                form.Content.Dispose();
                _activePanes.Remove(form);
            }
            var newPanels = from name in PluginManager.GetNames <IDockPane>()
                            where _activePanes.All(form => form.Name != name)
                            select name;

            foreach (string name in newPanels)
            {
                IDockPane    plugin = PluginManager.Get <IDockPane>(name);
                DockPaneShim shim   = new DockPaneShim()
                {
                    Name = name, Pane = plugin
                };
                shim.Content = new DockContent()
                {
                    Name = name, TabText = name
                };
                shim.Content.Controls.Add(plugin.Control);
                shim.Content.Icon = plugin.DockIcon != null
                    ? Icon.FromHandle(plugin.DockIcon.GetHicon())
                    : null;

                shim.Content.HideOnClose = true;
                shim.Content.DockAreas   = DockAreas.Float
                                           | DockAreas.DockLeft | DockAreas.DockRight
                                           | DockAreas.DockTop | DockAreas.DockBottom;
                bool      autoHide = Core.Settings.AutoHidePanes.Contains(name);
                DockState state    = plugin.DockHint == DockHint.Float ? DockState.Float
                    : plugin.DockHint == DockHint.Left ? (autoHide ? DockState.DockLeftAutoHide : DockState.DockLeft)
                    : plugin.DockHint == DockHint.Right ? (autoHide ? DockState.DockRightAutoHide : DockState.DockRight)
                    : plugin.DockHint == DockHint.Top ? (autoHide ? DockState.DockTopAutoHide : DockState.DockTop)
                    : plugin.DockHint == DockHint.Bottom ? (autoHide ? DockState.DockBottomAutoHide : DockState.DockBottom)
                    : DockState.Float;  // stacked and nested ternary = awesome
                plugin.Control.Dock = DockStyle.Fill;
                shim.Content.Show(_mainPanel, state);
                if (!plugin.ShowInViewMenu || Core.Settings.HiddenPanes.Contains(name))
                {
                    shim.Content.Hide();
                }
                _activePanes.Add(shim);
            }
        }
        private static bool ContainsItemsToSave(SerializationContext context, IDockPane dockPane)
        {
            if (dockPane == null)
            {
                return(false);
            }

            if (context.SaveNonPersistentItems)
            {
                return(true);
            }

            return(dockPane.GetDockElements().OfType <IDockTabItem>().Any(item => item.IsPersistent));
        }
Example #15
0
        public void Toggle(IDockPane pane)
        {
            DockPaneShim form = _activePanes.Find(x => x.Pane == pane);

            if (form.Pane != null)
            {
                if (!IsVisible(form.Pane))
                {
                    Show(pane);
                }
                else
                {
                    Hide(pane);
                }
            }
        }
        private static void ReplaceItemsWithProxies(IDockPane dockPane, List <IDockTabItem> items, IDockTabPane currentPane)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(items != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                {
                    ReplaceItemsWithProxies(dockAnchorPane.ChildPane, items, currentPane);
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                ReplaceItemsWithProxies(dockSplitPane.ChildPanes, items, currentPane);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                if (dockTabPane == currentPane)
                {
                    // Special: If the IDockTabPane is the current pane, add the item proxies but
                    // keep the original items.
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                        {
                            dockTabPane.Items.Insert(i + 1, new DockTabItemProxy(dockTabPane.Items[i]));
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                        {
                            dockTabPane.Items[i] = new DockTabItemProxy(dockTabPane.Items[i]);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Determines whether this dragged items may be docked at the specified position.
        /// </summary>
        /// <param name="target">The target pane.</param>
        /// <param name="position">The position relative to <paramref name="target"/>.</param>
        /// <returns>
        /// <see langword="true"/> the specified dock position in allowed; otherwise,
        /// <see langword="false"/>.
        /// </returns>
        private bool CanDock(IDockPane target, DockPosition position)
        {
            Debug.Assert(_dockStrategy != null);
            Debug.Assert(_draggedItems.Count > 0);

            target = target ?? _dockStrategy.DockControl.RootPane;

            foreach (var item in _draggedItems)
            {
                if (!_dockStrategy.CanDock(item, target, position))
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Gets the first visible instance of the specified type in the docking layout.
        /// </summary>
        /// <typeparam name="T">The type of the <see cref="IDockElement"/></typeparam>
        /// <param name="dockPane">The <see cref="IDockPane"/> to examine.</param>
        /// <returns>
        /// The first instance of <typeparamref name="T"/> found in <paramref name="dockPane"/>.
        /// </returns>
        private static T First <T>(IDockPane dockPane) where T : class, IDockElement
        {
            if (dockPane == null || !dockPane.IsVisible)
            {
                return(null);
            }

            T t = dockPane as T;

            if (t != null)
            {
                return(t);
            }

            var dockAnchorPane = dockPane as IDockAnchorPane;

            if (dockAnchorPane != null)
            {
                return(First <T>(dockAnchorPane.ChildPane));
            }

            var dockSplitPane = dockPane as IDockSplitPane;

            if (dockSplitPane != null)
            {
                foreach (var childPane in dockSplitPane.ChildPanes)
                {
                    var result = First <T>(childPane);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            var dockTabPane = dockPane as IDockTabPane;

            if (dockTabPane != null && dockTabPane.Items.Count > 0)
            {
                return(dockTabPane.Items[0] as T);
            }

            return(null);
        }
Example #19
0
        public void Show(IDockPane pane)
        {
            Refresh();
            DockPaneShim shim = _activePanes.Find(x => x.Pane == pane);

            if (shim.Pane != null && !IsVisible(shim.Pane))
            {
                Control oldFocus = _mainPanel.Parent;
                while (oldFocus is ContainerControl)
                {
                    oldFocus = ((ContainerControl)oldFocus).ActiveControl;
                }
                shim.Content.Show();
                if (oldFocus != null)
                {
                    oldFocus.Focus();
                }
            }
        }
Example #20
0
        private static void ReplaceItemsWithProxies(IDockPane dockPane, List<IDockTabItem> items, IDockTabPane currentPane)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(items != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                    ReplaceItemsWithProxies(dockAnchorPane.ChildPane, items, currentPane);
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                ReplaceItemsWithProxies(dockSplitPane.ChildPanes, items, currentPane);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                if (dockTabPane == currentPane)
                {
                    // Special: If the IDockTabPane is the current pane, add the item proxies but
                    // keep the original items.
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                        {
                            dockTabPane.Items.Insert(i + 1, new DockTabItemProxy(dockTabPane.Items[i]));
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                            dockTabPane.Items[i] = new DockTabItemProxy(dockTabPane.Items[i]);
                    }
                }
            }
        }
Example #21
0
        public static void StartDrag(IDockPane pane, IDockContent[] documents, Point position)
        {
            DragWindow dragwin = CreateDragWin(pane.DockPanel.xwt, position, pane.WidgetSize);

            //  pane.DockPanel.xwt.QueueOnUI(() => {

            dragwin.Show(pane.DockPanel.FloatForm?.MainDockPanel ?? pane.DockPanel, (result, droppane, drophit, pt) =>
            {
                if (result && droppane != null && drophit.HasValue)
                {
                    pane.DockPanel.MovePane(pane, documents, droppane, drophit.Value);
                }
                else if (result)
                {
                    pane.DockPanel.FloatPane(pane, documents, pt, pane.WidgetSize);
                }
                dragwin.Dispose();
            });
            //     });
        }
Example #22
0
        public static IDockPane GetParent(IDockPane dockPane, IDockElement child)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(child != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane == child)
                {
                    return(dockAnchorPane);
                }

                if (dockAnchorPane.ChildPane != null)
                {
                    return(GetParent(dockAnchorPane.ChildPane, child));
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                var childPane     = child as IDockPane;
                if (childPane != null && dockSplitPane.ChildPanes.Contains(childPane))
                {
                    return(dockSplitPane);
                }

                return(GetParent(dockSplitPane.ChildPanes, child));
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                var dockTabItem = child as IDockTabItem;
                if (dockTabItem != null && dockTabPane.Items.Contains(dockTabItem))
                {
                    return(dockTabPane);
                }
            }

            return(null);
        }
Example #23
0
        void IDockNotify.OnLoaded(IDockPane pane)
        {
            Debug.Assert(this.Renderer == null);

            this.Renderer = factory.Open(xwtrender, this, this, new FPS(1, 25, true), new size(1920, 1080));

            using (var lck = this.Renderer.GetDrawLock())
            {
                /*    List<Vector3> simpleVertices = new List<Vector3>();
                 *  simpleVertices.Add(new Vector3(0, 0, 0));
                 *  simpleVertices.Add(new Vector3(100, 0, 0));
                 *  simpleVertices.Add(new Vector3(100, 100, 0));*/

                this.vertices = new vertices <vertex>(
                    new vertex[] { new vertex(new Vector3(0, -1, 0)), new vertex(new Vector3(-1, 1, 0)), new vertex(new Vector3(1, 1, 0)) });

                this.shader = new shader(
                    @"#version 150 core

in vec4 position;
void main()
{
gl_Position = position;
}",
                    @"#version 150 core
precision mediump float;

out vec4 outColor;

void main()
{
    outColor = vec4(1,0,0,1);
}
",
                    this.vertices);

                vertices.define("position", "pos");
            }
            this.Renderer.Start();
        }
Example #24
0
        internal static bool Contains(this IDockPane dockPane, IDockElement dockElement)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(dockElement != null);

            if (dockPane == dockElement)
            {
                return(true);
            }

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                {
                    return(Contains(dockAnchorPane.ChildPane, dockElement));
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                if (Contains(dockSplitPane.ChildPanes, dockElement))
                {
                    return(true);
                }
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                var dockTabItem = dockElement as IDockTabItem;
                if (dockTabItem != null)
                {
                    return(dockTabPane.Items.Contains(dockTabItem));
                }
            }

            return(false);
        }
Example #25
0
 private IDockSplitter FindSplitter(IDockLayout content, IDockPane searchfor, out int ind)
 {
     if (content is IDockSplitter)
     {
         int cnt = 0;
         foreach (var l in (content as IDockSplitter).Layouts)
         {
             if (object.ReferenceEquals(searchfor, l))
             {
                 ind = cnt;
                 return(content as IDockSplitter);
             }
             var r = FindSplitter(l, searchfor, out ind);
             if (r != null)
             {
                 return(r);
             }
             cnt++;
         }
     }
     ind = -1;
     return(null);
 }
Example #26
0
        /// <summary>
        /// Gets all elements of the <see cref="IDockPane"/>. (May include duplicates!)
        /// </summary>
        /// <param name="dockPane">The <see cref="IDockPane"/>.</param>
        /// <returns>All <see cref="IDockElement"/>s. May include duplicates!</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="dockPane"/> is <see langword="null"/>.
        /// </exception>
        public static IEnumerable <IDockElement> GetDockElements(this IDockPane dockPane)
        {
            if (dockPane == null)
            {
                throw new ArgumentNullException(nameof(dockPane));
            }

            yield return(dockPane);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                {
                    foreach (var dockElement in GetDockElements(dockAnchorPane.ChildPane))
                    {
                        yield return(dockElement);
                    }
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                foreach (var dockElement in GetDockElements(dockSplitPane.ChildPanes))
                {
                    yield return(dockElement);
                }
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                foreach (var dockTabItem in dockTabPane.Items)
                {
                    yield return(dockTabItem);
                }
            }
        }
        /// <summary>
        /// Determines whether this dragged items may be docked at the specified position.
        /// </summary>
        /// <param name="target">The target pane.</param>
        /// <param name="position">The position relative to <paramref name="target"/>.</param>
        /// <returns>
        /// <see langword="true"/> the specified dock position in allowed; otherwise,
        /// <see langword="false"/>.
        /// </returns>
        private bool CanDock(IDockPane target, DockPosition position)
        {
            Debug.Assert(_dockStrategy != null);
            Debug.Assert(_draggedItems.Count > 0);

            target = target ?? _dockStrategy.DockControl.RootPane;

            foreach (var item in _draggedItems)
                if (!_dockStrategy.CanDock(item, target, position))
                    return false;

            return true;
        }
Example #28
0
 void IDockNotify.OnLoaded(IDockPane pane)
 {
     Console.WriteLine($"{base.GetHashCode()} doc onloaded");
 }
Example #29
0
 public DockPaneGroup(IDockPane first, IDockPane second, SplitOrientation split)
 {
     First = first;
     Second = second;
     Split = split;
 }
Example #30
0
        private static bool ContainsItemsToSave(SerializationContext context, IDockPane dockPane)
        {
            if (dockPane == null)
                return false;

            if (context.SaveNonPersistentItems)
                return true;

            return dockPane.GetDockElements().OfType<IDockTabItem>().Any(item => item.IsPersistent);
        }
Example #31
0
 public static IDockFloatWindow Create(DockPanel dock, IDockContent[] docs, Point formpos, out IDockPane panefloat)
 {
     return(Create(dock, docs, new Rectangle(formpos, new Size(200, 200)), out panefloat));
 }
Example #32
0
        public static IDockFloatWindow Create(DockPanel dock, IDockContent[] docs, Rectangle formpos, out IDockPane panefloat)
        {
            var r = new FloatWindow(dock, docs, formpos);

            r.Show();

            r.SetParent();
            panefloat = r.DockPanel.Current as IDockPane;

            r.maindock.AddFloat(r);

            return(r);
        }
Example #33
0
 IDockPane IDockFloatWindow.DockToolbar(IDockContent[] controls, DockPosition pos, IDockPane destination)
 {
     return(DockPanel.Dock(controls, pos, destination));
 }
Example #34
0
        internal static void CheckMove(DragWindow window, Point pt, bool setpos, Size floatsize, ref IDockPane droppane, ref DockPosition?drophit)
        {
            try
            {
                var hits = BaseLib.Xwt.Platform.Instance.Search(window, pt); // all hit window-handle son system

                foreach (var w in hits)
                {
                    if (object.ReferenceEquals((window.GetBackend() as IWindowBackend).Window, w.Item2))
                    {
                        continue;// hit through dragwindow
                    }
                    var hit = DockPanel.CheckHit(w.Item2, pt.X, pt.Y);

                    if (hit != null)
                    {
                        var b = hit.ConvertToScreenCoordinates(hit.Bounds.Location);

                        DockPanel.SetHighLight(hit, new Point(pt.X - b.X, pt.Y - b.Y), out droppane, out drophit);
                        return;
                    }
                    if (Toolkit.CurrentEngine.Type == ToolkitType.Wpf)
                    {
                        if (w.Item2.GetType().FullName != "Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.Adorners.AdornerLayerWindow")
                        {
                            break; // window in front
                        }
                    }
                    else
                    {
                        break;// window in front
                    }
                }
                droppane = null; drophit = null;
                DockPanel.ClrHightlight();
            }
            catch (Exception e)
            { throw; }
            finally
            {
                if (setpos)
                {
                    if (droppane == null || !drophit.HasValue)
                    {
                        window.SetPosition(new Rectangle(pt.Offset(-5, -5), floatsize));
                    }
                    else
                    {
                        window.SetPosition(new Rectangle(pt.Offset(-5, -5), new Size(32, 32)));
                    }
                }
            }
        }
Example #35
0
        private static void RestoreItemsFromProxies(IDockPane dockPane)
        {
            Debug.Assert(dockPane != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                    RestoreItemsFromProxies(dockAnchorPane.ChildPane);
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                RestoreItemsFromProxies(dockSplitPane.ChildPanes);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                for (int i = dockTabPane.Items.Count - 1; i >= 0; i--)
                {
                    var proxy = dockTabPane.Items[i] as DockTabItemProxy;
                    if (proxy != null)
                        dockTabPane.Items[i] = proxy.Item;
                }
            }
        }
Example #36
0
        private void Commit()
        {
            if (_layoutChanged)
            {
                if (IsDraggingDockTabItems)
                {
                    // Dragging ended in DockTabPanel.
                    RestoreFloatWindowPosition();
                }
                else if (_floatWindow != null)
                {
                    // Dragging ended outside of a DockTabPanel. Check the dock indicators to find the
                    // desired target position.
                    IDockPane    target   = null;
                    DockPosition position = DockPosition.None;
                    if (HasResult(_borderDockIndicators))
                    {
                        target   = _dockStrategy.DockControl.RootPane;
                        position = _borderDockIndicators.Result;
                    }
                    else if (HasResult(_paneDockIndicators))
                    {
                        target   = DockHelper.GetViewModel <IDockPane>(_paneDockIndicators.Target);
                        position = _paneDockIndicators.Result;
                    }

                    if (position != DockPosition.None && target != null)
                    {
                        // User has dropped FloatWindow on a DockIndicator.
                        // --> Dock content.
                        var floatWindowVM = _floatWindow.GetViewModel();
                        foreach (var item in _draggedItems)
                        {
                            DockHelper.Remove(floatWindowVM, item);
                            item.DockState = DockState.Hide;
                        }

                        var dockTabPane = _dockStrategy.CreateDockTabPane(_draggedItems[0], DockState.Hide);
                        for (int i = 1; i < _draggedItems.Count; i++)
                        {
                            dockTabPane.Items.Add(_draggedItems[i]);
                        }

                        _dockStrategy.Dock(dockTabPane, target, position);
                        RestoreFloatWindowPosition();
                    }
                    else
                    {
                        // The final state is DockState.Float.
                        if (!_canFloat && _originalDockState != DockState.Float)
                        {
                            // DockState.Float is not allowed.
                            Rollback();
                            return;
                        }
                    }
                }
            }

            // Keep the items at their new position.
            // --> Remove the item proxies.
            var dockState = _draggedItems[0].DockState;

            RemoveItemProxies(dockState);
            if (_layoutChanged && dockState == DockState.Dock)
            {
                // The position within the DockControl may have changed. The assignment to the
                // auto-hide bar is no longer valid.
                // --> Also remove item proxies from auto-hide bars.
                RemoveItemProxies(DockState.AutoHide);
            }

            // Restore the original dock state of the dragged items.
            RestoreItemsFromProxies();
        }