Exemple #1
0
        public void Undock(IDockContent content)
        {
            IDockLayout targetChild = null;

            foreach (IDockLayout child in m_children)
            {
                if (child.HasChild(content))
                {
                    targetChild = child;
                    break;
                }
            }
            if (targetChild != null)
            {
                targetChild.Undock(content);
            }
            else
            {
                foreach (IDockLayout child in m_children)
                {
                    if (child.HasDescendant(content))
                    {
                        targetChild = child;
                        break;
                    }
                }
                if (targetChild != null)
                {
                    targetChild.Undock(content);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Start dragging the given content. This includes undocking it from the UI,
 /// creating new window with the content, and then start dragging it.</summary>
 /// <param name="source"></param>
 /// <param name="content">Content to drag</param>
 internal void Drag(IDockLayout source, IDockContent content)
 {
     FrameworkElement sourceElement = (FrameworkElement)source;
     ContentSettings settings = (content is TabLayout) ? ((TabLayout)content).Children[0].Settings : ((DockContent)content).Settings;
     Size size = new Size(sourceElement.ActualWidth, sourceElement.ActualHeight);
     Point offset = new Point(settings.Size.Width / 2, 3);
     Point position = Mouse.GetPosition(this);
     position = PointToScreen(position);
     Matrix m = PresentationSource.FromVisual(Window.GetWindow(this)).CompositionTarget.TransformToDevice;
     if (m != Matrix.Identity)
     {
         m.Invert();
         position = m.Transform(position);
     }
     offset = Mouse.GetPosition(sourceElement);
     offset.Y = offset.Y > 20 ? 10 : offset.Y;
     position = (Point)(position - offset);
     if (Mouse.LeftButton == MouseButtonState.Pressed)
     {
         source.Undock(content);
         FloatingWindow wnd = new FloatingWindow(this, content, position, size);
         wnd.Closing += ChildWindowClosing;
         m_windows.Add(wnd);
         wnd.Owner = Window.GetWindow(this);
         wnd.Show();
         wnd.DragMove();
     }
 }