Exemple #1
0
        /// <summary>
        /// Function called when dragged window enters already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragEnter(object sender, DockDragDropEventArgs e)
        {
            Point center          = new Point(ActualWidth / 2, ActualHeight / 2);
            int   space           = (int)Root.DockIconSize.Width / 4;
            ResourceDictionary rd = new ResourceDictionary();

            rd.Source = new Uri("/Atf.Gui.Wpf;component/Resources/DockIcons.xaml", UriKind.Relative);
            if (m_dockLeftIcon == null)
            {
                m_dockLeftIcon   = new DockIcon((Style)rd["DockLeftIcon"], Root.DockIconSize);
                m_dockRightIcon  = new DockIcon((Style)rd["DockRightIcon"], Root.DockIconSize);
                m_dockTopIcon    = new DockIcon((Style)rd["DockTopIcon"], Root.DockIconSize);
                m_dockBottomIcon = new DockIcon((Style)rd["DockBottomIcon"], Root.DockIconSize);
                m_dockTabIcon    = new DockIcon((Style)rd["DockTabIcon"], Root.DockIconSize);
            }
            Window owner  = Window.GetWindow(this);
            Point  offset = ((UIElement)Root).PointFromScreen(PointToScreen(new Point(0, 0)));

            m_dockLeftIcon.Offset   = new Point(offset.X + center.X - Root.DockIconSize.Width / 2 - Root.DockIconSize.Width - space, offset.Y + center.Y - Root.DockIconSize.Height / 2);
            m_dockRightIcon.Offset  = new Point(offset.X + center.X + Root.DockIconSize.Width / 2 + space, offset.Y + center.Y - Root.DockIconSize.Height / 2);
            m_dockTopIcon.Offset    = new Point(offset.X + center.X - Root.DockIconSize.Width / 2, offset.Y + center.Y - Root.DockIconSize.Height / 2 - Root.DockIconSize.Height - space);
            m_dockBottomIcon.Offset = new Point(offset.X + center.X - Root.DockIconSize.Width / 2, offset.Y + center.Y + Root.DockIconSize.Height / 2 + space);
            m_dockTabIcon.Offset    = new Point(offset.X + center.X - Root.DockIconSize.Width / 2, offset.Y + center.Y - Root.DockIconSize.Height / 2);

            DockIconsLayer dockIconLayer = Root.DockIconsLayer;

            dockIconLayer.AddChild(m_dockLeftIcon);
            dockIconLayer.AddChild(m_dockRightIcon);
            dockIconLayer.AddChild(m_dockTopIcon);
            dockIconLayer.AddChild(m_dockBottomIcon);
            dockIconLayer.AddChild(m_dockTabIcon);
        }
Exemple #2
0
 void FloatingWindow_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (IsMouseCaptured)
     {
         ReleaseMouseCapture();
         Topmost         = false;
         m_validPosition = false;
         m_dragging      = false;
         bool dropped = false;
         DockDragDropEventArgs args = new DockDragDropEventArgs(DockedContent, e);
         foreach (IDockable dockable in m_dockOver)
         {
             dockable.DockDragLeave(this, args);
             if (!dropped && dockable.DockPreview != null)
             {
                 Content       = null;
                 DockedContent = null;
                 dropped       = true;
                 dockable.DockDrop(this, args);
             }
         }
         m_dockOver = new List <IDockable>();
         if (dropped)
         {
             Owner.Focus();
             Owner.Activate();
             Close();
         }
         else
         {
             Focus();
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Function called when dragged window is dropped over already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDrop(object sender, DockDragDropEventArgs e)
        {
            DockPanel parent = Root;
            DockTo    dockTo = (DockTo)m_dockPreview;

            if (e.Content is TabLayout)
            {
                foreach (DockContent subContent in ((TabLayout)e.Content).Children)
                {
                    ContentSettings contentSettings = subContent.Settings;
                    contentSettings.DockState = DockState.Docked;
                }
            }
            else
            {
                ContentSettings contentSettings = ((DockContent)e.Content).Settings;
                contentSettings.DockState = DockState.Docked;
            }
            switch (dockTo)
            {
            case DockTo.Left:
            case DockTo.Right:
            case DockTo.Top:
            case DockTo.Bottom:
                ((IDockLayout)Parent).Dock(DockedContent, e.Content, dockTo);
                break;

            case DockTo.Center:
                Dock(null, e.Content, dockTo);
                break;
            }
            parent.CheckConsistency();
        }
Exemple #4
0
 /// <summary>
 /// Function called when dragged window leaves already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 public void DockDragLeave(object sender, DockDragDropEventArgs e)
 {
     DockIconsLayer.RemoveChild(m_dockTabIcon);
     if (m_dockPreviewShape != null)
     {
         DockIconsLayer.RemoveChild(m_dockPreviewShape);
         m_dockPreviewShape = null;
     }
     DockIconsLayer.CloseIfEmpty();
 }
Exemple #5
0
        void FloatingWindow_MouseMove(object sender, MouseEventArgs e)
        {
            Point pos = e.GetPosition(this);

            if (!m_validPosition)
            {
                // this is workaround for not using pInvoke for getting the position.
                // when the draging starts, the e.GetPosition doesn't give proper values, but instead returns (0,0)
                if (pos != new Point(0, 0))
                {
                    m_lastMousePos  = e.GetPosition(Owner);
                    m_validPosition = true;
                }
            }
            if (IsMouseCaptured && m_validPosition)
            {
                Topmost = true;
                pos     = e.GetPosition(Owner);
                if (!m_dragging)
                {
                    if ((m_lastMousePos - pos).Length > 2)
                    {
                        m_dragging = true;
                    }
                }
                if (m_dragging)
                {
                    Left           = Left + pos.X - m_lastMousePos.X;
                    Top            = Top + pos.Y - m_lastMousePos.Y;
                    m_lastMousePos = pos;
                    List <IDockable>      dockOver = Root.FindElementsAt(e);
                    DockDragDropEventArgs args     = new DockDragDropEventArgs(DockedContent, e);
                    foreach (IDockable dockable in m_dockOver)
                    {
                        if (!dockOver.Contains(dockable))
                        {
                            dockable.DockDragLeave(this, args);
                        }
                    }
                    foreach (IDockable dockable in dockOver)
                    {
                        if (!m_dockOver.Contains(dockable))
                        {
                            dockable.DockDragEnter(this, args);
                        }
                    }
                    foreach (IDockable dockable in dockOver)
                    {
                        dockable.DockDragOver(this, args);
                    }
                    m_dockOver = dockOver;
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Function called when dragged window is moved over already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragOver(object sender, DockDragDropEventArgs e)
        {
            Point pos = e.MouseEventArgs.GetPosition(this);
            bool  b   = m_dockTabIcon.HitTest(pos);

            if (b && !m_dockTabIcon.Highlight)
            {
                m_dockTabIcon.Highlight = b;
                DockIconsLayer.RemoveChild(m_dockPreviewShape);
                m_dockPreviewShape = null;
                Window    owner = Window.GetWindow(this);
                Rectangle rect  = new Rectangle();
                rect.Fill          = Brushes.RoyalBlue;
                rect.Opacity       = 0.3;
                m_dockPreviewShape = rect;
                double space = 2;
                Point  p     = PointFromScreen(PointToScreen(new Point(space, space)));
                Canvas c     = new Canvas();
                c.SnapsToDevicePixels = true;
                c.Width  = DockedContent.ActualWidth;
                c.Height = DockedContent.ActualHeight;
                Canvas.SetLeft(c, p.X);
                Canvas.SetTop(c, p.Y);
                m_dockPreviewShape.Width  = DockedContent.ActualWidth - space * 2;
                m_dockPreviewShape.Height = DockedContent.ActualHeight - 20 - space * 2;
                Canvas.SetLeft(m_dockPreviewShape, 0);
                Canvas.SetTop(m_dockPreviewShape, 0);
                c.Children.Add(m_dockPreviewShape);

                rect         = new Rectangle();
                rect.Fill    = Brushes.RoyalBlue;
                rect.Opacity = 0.3;
                rect.Width   = Math.Min(DockedContent.ActualWidth / 4, 50);
                rect.Height  = 20;
                Canvas.SetLeft(rect, 0);
                Canvas.SetTop(rect, DockedContent.ActualHeight - 20 - space * 2);
                c.Children.Add(rect);
                m_dockPreviewShape = c;

                DockIconsLayer.InsertChild(0, m_dockPreviewShape);
            }
            else if (!b)
            {
                if (m_dockPreviewShape != null)
                {
                    DockIconsLayer.RemoveChild(m_dockPreviewShape);
                    m_dockPreviewShape = null;
                }
                m_dockTabIcon.Highlight = false;
            }
        }
Exemple #7
0
        /// <summary>
        /// Function called when dragged window enters already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragEnter(object sender, DockDragDropEventArgs e)
        {
            Point center          = new Point(ActualWidth / 2, ActualHeight / 2);
            ResourceDictionary rd = new ResourceDictionary();

            rd.Source = new Uri("/Atf.Gui.Wpf;component/Resources/DockIcons.xaml", UriKind.Relative);
            if (m_dockTabIcon == null)
            {
                m_dockTabIcon = new DockIcon((Style)rd["DockTabIcon"], Root.DockIconSize);
            }
            m_dockTabIcon.Offset    = new Point(center.X - Root.DockIconSize.Width / 2, center.Y - Root.DockIconSize.Height / 2);
            m_dockTabIcon.Highlight = false;
            DockIconsLayer.AddChild(m_dockTabIcon);
        }
Exemple #8
0
 /// <summary>
 /// Function called when dragged window is dropped over already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 public void DockDrop(object sender, DockDragDropEventArgs e)
 {
     if (e.Content is TabLayout)
     {
         foreach (DockContent subContent in ((TabLayout)e.Content).Children)
         {
             subContent.Settings.DockState = DockState.Floating;
         }
     }
     else
     {
         ((DockContent)e.Content).Settings.DockState = DockState.Floating;
     }
     Dock(null, e.Content, DockTo.Center);
 }
Exemple #9
0
        /// <summary>
        /// Function called when dragged window leaves already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragLeave(object sender, DockDragDropEventArgs e)
        {
            DockIconsLayer dockIconLayer = Root.DockIconsLayer;

            dockIconLayer.RemoveChild(m_dockLeftIcon);
            dockIconLayer.RemoveChild(m_dockRightIcon);
            dockIconLayer.RemoveChild(m_dockTopIcon);
            dockIconLayer.RemoveChild(m_dockBottomIcon);
            dockIconLayer.RemoveChild(m_dockTabIcon);
            if (m_dockPreviewShape != null)
            {
                Root.DockIconsLayer.RemoveChild(m_dockPreviewShape);
                m_dockPreviewShape = null;
            }
            dockIconLayer.CloseIfEmpty();
        }
Exemple #10
0
        /// <summary>
        /// Function called when dragged window enters already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragEnter(object sender, DockDragDropEventArgs e)
        {
            Point center = new Point(ActualWidth / 2, ActualHeight / 2);
            int space = (int)Root.DockIconSize.Width / 4;
            ResourceDictionary rd = new ResourceDictionary();
            rd.Source = new Uri("/Atf.Gui.Wpf;component/Resources/DockIcons.xaml", UriKind.Relative);
            if (m_dockLeftIcon == null)
            {
                m_dockLeftIcon = new DockIcon((Style)rd["DockLeftIcon"], Root.DockIconSize);
                m_dockRightIcon = new DockIcon((Style)rd["DockRightIcon"], Root.DockIconSize);
                m_dockTopIcon = new DockIcon((Style)rd["DockTopIcon"], Root.DockIconSize);
                m_dockBottomIcon = new DockIcon((Style)rd["DockBottomIcon"], Root.DockIconSize);
                m_dockTabIcon = new DockIcon((Style)rd["DockTabIcon"], Root.DockIconSize);
            }
            Window owner = Window.GetWindow(this);
            Point offset = ((UIElement)Root).PointFromScreen(PointToScreen(new Point(0, 0)));
            m_dockLeftIcon.Offset = new Point(offset.X + center.X - Root.DockIconSize.Width / 2 - Root.DockIconSize.Width - space, offset.Y + center.Y - Root.DockIconSize.Height / 2);
            m_dockRightIcon.Offset = new Point(offset.X + center.X + Root.DockIconSize.Width / 2 + space, offset.Y + center.Y - Root.DockIconSize.Height / 2);
            m_dockTopIcon.Offset = new Point(offset.X + center.X - Root.DockIconSize.Width / 2, offset.Y + center.Y - Root.DockIconSize.Height / 2 - Root.DockIconSize.Height - space);
            m_dockBottomIcon.Offset = new Point(offset.X + center.X - Root.DockIconSize.Width / 2, offset.Y + center.Y + Root.DockIconSize.Height / 2 + space);
            m_dockTabIcon.Offset = new Point(offset.X + center.X - Root.DockIconSize.Width / 2, offset.Y + center.Y - Root.DockIconSize.Height / 2);

            DockIconsLayer dockIconLayer = Root.DockIconsLayer;
            dockIconLayer.AddChild(m_dockLeftIcon);
            dockIconLayer.AddChild(m_dockRightIcon);
            dockIconLayer.AddChild(m_dockTopIcon);
            dockIconLayer.AddChild(m_dockBottomIcon);
            dockIconLayer.AddChild(m_dockTabIcon);
        }
Exemple #11
0
 /// <summary>
 /// Function called when dragged window is moved over already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 void IDockable.DockDragOver(object sender, DockDragDropEventArgs e)
 {
     DockTo? previousDockPreview = m_dockPreview;
     m_dockPreview = null;
     Point pos = e.MouseEventArgs.GetPosition(this);
     if (GridLayout != null)
     {
         //if (GridLayout.Children.Count > 1)
         {
             m_dockLeftIcon.Highlight = m_dockLeftIcon.HitTest(pos);
             m_dockRightIcon.Highlight = m_dockRightIcon.HitTest(pos);
             m_dockTopIcon.Highlight = m_dockTopIcon.HitTest(pos);
             m_dockBottomIcon.Highlight = m_dockBottomIcon.HitTest(pos);
             m_dockPreview = m_dockLeftIcon.Highlight ? DockTo.Left : m_dockPreview;
             m_dockPreview = m_dockRightIcon.Highlight ? DockTo.Right : m_dockPreview;
             m_dockPreview = m_dockTopIcon.Highlight ? DockTo.Top : m_dockPreview;
             m_dockPreview = m_dockBottomIcon.Highlight ? DockTo.Bottom : m_dockPreview;
         }
     }
     else
     {
         m_dockTabIcon.Highlight = m_dockTabIcon.HitTest(pos);
         m_dockPreview = m_dockTabIcon.Highlight ? DockTo.Center : m_dockPreview;
     }
     if (m_dockPreview != null)
     {
         if (previousDockPreview != m_dockPreview)
         {
             DockIconsLayer.RemoveChild(m_dockPreviewShape);
             m_dockPreviewShape = null;
             Window owner = Window.GetWindow(this);
             Rectangle rect = new Rectangle();
             rect.Fill = Brushes.RoyalBlue;
             rect.Opacity = 0.3;
             FrameworkElement fe = rect;
             double space = 2;
             Point p = new Point(space, space);
             ContentSettings contentSettings = (e.Content is TabLayout) ? ((TabLayout)e.Content).Children[0].Settings : ((DockContent)e.Content).Settings;
             double width = Math.Max(Math.Min(contentSettings.Size.Width, ActualWidth / 2), ActualWidth / 5);
             double height = Math.Max(Math.Min(contentSettings.Size.Height, ActualHeight / 2), ActualHeight / 5);
             double ratioWidth = width / ActualWidth;
             double ratioHeight = height / ActualHeight;
             switch (m_dockPreview)
             {
                 case DockTo.Left:
                     fe.Width = ActualWidth * ratioWidth - space * 2;
                     fe.Height = ActualHeight - space * 2;
                     Canvas.SetLeft(fe, p.X);
                     Canvas.SetTop(fe, p.Y);
                     break;
                 case DockTo.Right:
                     fe.Width = ActualWidth * ratioWidth - space * 2;
                     fe.Height = ActualHeight - space * 2;
                     Canvas.SetLeft(fe, p.X + ActualWidth * (1 - ratioWidth));
                     Canvas.SetTop(fe, p.Y);
                     break;
                 case DockTo.Top:
                     fe.Width = ActualWidth - space * 2;
                     fe.Height = ActualHeight * ratioHeight - space * 2;
                     Canvas.SetLeft(fe, p.X);
                     Canvas.SetTop(fe, p.Y);
                     break;
                 case DockTo.Bottom:
                     fe.Width = ActualWidth - space * 2;
                     fe.Height = ActualHeight * ratioHeight - space * 2;
                     Canvas.SetLeft(fe, p.X);
                     Canvas.SetTop(fe, p.Y + ActualHeight * (1 - ratioHeight));
                     break;
                 case DockTo.Center:
                     fe.Width = ActualWidth - space * 2;
                     fe.Height = ActualHeight - space * 2;
                     Canvas.SetLeft(fe, p.X);
                     Canvas.SetTop(fe, p.Y);
                     break;
             }
             DockIconsLayer.InsertChild(0, fe);
             m_dockPreviewShape = fe;
         }
     }
     else
     {
         if (m_dockPreviewShape != null)
         {
             DockIconsLayer.RemoveChild(m_dockPreviewShape);
             m_dockPreviewShape = null;
         }
     }
 }
Exemple #12
0
 /// <summary>
 /// Function called when dragged window leaves already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 void IDockable.DockDragLeave(object sender, DockDragDropEventArgs e)
 {
     DockIconsLayer.RemoveChild(m_dockLeftIcon);
     DockIconsLayer.RemoveChild(m_dockRightIcon);
     DockIconsLayer.RemoveChild(m_dockTopIcon);
     DockIconsLayer.RemoveChild(m_dockBottomIcon);
     DockIconsLayer.RemoveChild(m_dockTabIcon);
     if (m_dockPreviewShape != null)
     {
         DockIconsLayer.RemoveChild(m_dockPreviewShape);
         m_dockPreviewShape = null;
     }
     DockIconsLayer.CloseIfEmpty();
 }
Exemple #13
0
 /// <summary>
 /// Function called when dragged window is dropped over already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 void IDockable.DockDrop(object sender, DockDragDropEventArgs e)
 {
     if (e.Content is TabLayout)
     {
         foreach (DockContent subContent in ((TabLayout)e.Content).Children)
         {
             subContent.Settings.DockState = DockState.Docked;
         }
     }
     else
     {
         ContentSettings contentSettings = (e.Content is TabLayout) ? ((TabLayout)e.Content).Children[0].Settings : ((DockContent)e.Content).Settings;
         contentSettings.DockState = DockState.Docked;
     }
     ((IDockLayout)this).Dock(null, e.Content, (DockTo)m_dockPreview);
 }
Exemple #14
0
        /// <summary>
        /// Function called when dragged window is moved over already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragOver(object sender, DockDragDropEventArgs e)
        {
            DockTo?previousDockPreview = m_dockPreview;

            m_dockPreview = null;
            Point pos = e.MouseEventArgs.GetPosition(Root);

            m_dockLeftIcon.Highlight   = m_dockLeftIcon.HitTest(pos);
            m_dockRightIcon.Highlight  = m_dockRightIcon.HitTest(pos);
            m_dockTopIcon.Highlight    = m_dockTopIcon.HitTest(pos);
            m_dockBottomIcon.Highlight = m_dockBottomIcon.HitTest(pos);
            m_dockTabIcon.Highlight    = m_dockTabIcon.HitTest(pos);

            m_dockPreview = m_dockLeftIcon.Highlight ? DockTo.Left : m_dockPreview;
            m_dockPreview = m_dockRightIcon.Highlight ? DockTo.Right : m_dockPreview;
            m_dockPreview = m_dockTopIcon.Highlight ? DockTo.Top : m_dockPreview;
            m_dockPreview = m_dockBottomIcon.Highlight ? DockTo.Bottom : m_dockPreview;
            m_dockPreview = m_dockTabIcon.Highlight ? DockTo.Center : m_dockPreview;

            if (m_dockPreview != null)
            {
                if (previousDockPreview != m_dockPreview)
                {
                    Root.DockIconsLayer.RemoveChild(m_dockPreviewShape);
                    m_dockPreviewShape = null;
                    Window    owner = Window.GetWindow(this);
                    Rectangle rect  = new Rectangle();
                    rect.Fill    = Brushes.RoyalBlue;
                    rect.Opacity = 0.3;
                    FrameworkElement fe              = rect;
                    double           space           = 2;
                    Point            p               = Root.PointFromScreen(PointToScreen(new Point(space, space)));
                    ContentSettings  contentSettings = (e.Content is TabLayout) ? ((TabLayout)e.Content).Children[0].Settings : ((DockContent)e.Content).Settings;
                    double           width           = Math.Max(Math.Min(contentSettings.Size.Width, ActualWidth / 2), ActualWidth / 5);
                    double           height          = Math.Max(Math.Min(contentSettings.Size.Height, ActualHeight / 2), ActualHeight / 5);
                    double           ratioWidth      = width / ActualWidth;
                    double           ratioHeight     = height / ActualHeight;
                    switch (m_dockPreview)
                    {
                    case DockTo.Left:
                        fe.Width  = ActualWidth * ratioWidth - space * 2;
                        fe.Height = ActualHeight - space * 2;
                        Canvas.SetLeft(fe, p.X);
                        Canvas.SetTop(fe, p.Y);
                        break;

                    case DockTo.Right:
                        fe.Width  = ActualWidth * ratioWidth - space * 2;
                        fe.Height = ActualHeight - space * 2;
                        Canvas.SetLeft(fe, p.X + ActualWidth * (1 - ratioWidth));
                        Canvas.SetTop(fe, p.Y);
                        break;

                    case DockTo.Top:
                        fe.Width  = ActualWidth - space * 2;
                        fe.Height = ActualHeight * ratioHeight - space * 2;
                        Canvas.SetLeft(fe, p.X);
                        Canvas.SetTop(fe, p.Y);
                        break;

                    case DockTo.Bottom:
                        fe.Width  = ActualWidth - space * 2;
                        fe.Height = ActualHeight * ratioHeight - space * 2;
                        Canvas.SetLeft(fe, p.X);
                        Canvas.SetTop(fe, p.Y + ActualHeight * (1 - ratioHeight));
                        break;

                    case DockTo.Center:
                        Canvas c = new Canvas();
                        c.SnapsToDevicePixels = true;
                        c.Width  = ActualWidth;
                        c.Height = ActualHeight;
                        Canvas.SetLeft(c, p.X);
                        Canvas.SetTop(c, p.Y);
                        fe.Width  = ActualWidth - space * 2;
                        fe.Height = ActualHeight - 20 - space * 2;
                        Canvas.SetLeft(fe, 0);
                        Canvas.SetTop(fe, 0);
                        c.Children.Add(fe);

                        rect         = new Rectangle();
                        rect.Fill    = Brushes.RoyalBlue;
                        rect.Opacity = 0.3;
                        rect.Width   = Math.Min(ActualWidth / 4, 50);
                        rect.Height  = 20;
                        Canvas.SetLeft(rect, 0);
                        Canvas.SetTop(rect, ActualHeight - 20 - space * 2);
                        c.Children.Add(rect);
                        fe = c;
                        break;
                    }
                    Root.DockIconsLayer.InsertChild(0, fe);
                    m_dockPreviewShape = fe;
                }
            }
            else
            {
                if (m_dockPreviewShape != null)
                {
                    Root.DockIconsLayer.RemoveChild(m_dockPreviewShape);
                    m_dockPreviewShape = null;
                }
            }
        }
Exemple #15
0
 /// <summary>
 /// Function called when dragged window enters already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 void IDockable.DockDragEnter(object sender, DockDragDropEventArgs e)
 {
     Point center = new Point(ActualWidth / 2, ActualHeight / 2);
     int space = (int)DockIconSize.Width / 4;
     ResourceDictionary rd = new ResourceDictionary();
     rd.Source = new Uri("/Atf.Gui.Wpf;component/Resources/DockIcons.xaml", UriKind.Relative);
     if (m_dockLeftIcon == null)
     {
         m_dockLeftIcon = new DockIcon((Style)rd["DockLeftIcon"], DockIconSize);
         m_dockRightIcon = new DockIcon((Style)rd["DockRightIcon"], DockIconSize);
         m_dockTopIcon = new DockIcon((Style)rd["DockTopIcon"], DockIconSize);
         m_dockBottomIcon = new DockIcon((Style)rd["DockBottomIcon"], DockIconSize);
         m_dockTabIcon = new DockIcon((Style)rd["DockTabIcon"], DockIconSize);
     }
     m_dockLeftIcon.Offset = new Point(space, center.Y - DockIconSize.Height / 2);
     m_dockRightIcon.Offset = new Point(ActualWidth - DockIconSize.Width - space, center.Y - DockIconSize.Height / 2);
     m_dockTopIcon.Offset = new Point(center.X - DockIconSize.Width / 2, space);
     m_dockBottomIcon.Offset = new Point(center.X - DockIconSize.Width / 2, ActualHeight - DockIconSize.Height - space);
     m_dockTabIcon.Offset = new Point(center.X - DockIconSize.Width / 2, center.Y - DockIconSize.Height / 2);
     if (GridLayout != null)
     {
         //if (GridLayout.Children.Count > 1)
         {
             DockIconsLayer.AddChild(m_dockLeftIcon);
             DockIconsLayer.AddChild(m_dockRightIcon);
             DockIconsLayer.AddChild(m_dockTopIcon);
             DockIconsLayer.AddChild(m_dockBottomIcon);
         }
     }
     else
     {
         DockIconsLayer.AddChild(m_dockTabIcon);
     }
 }
Exemple #16
0
 public void DockDragLeave(object sender, DockDragDropEventArgs e)
 {
     DockIconsLayer.RemoveChild(m_dockTabIcon);
     if (m_dockPreviewShape != null)
     {
         DockIconsLayer.RemoveChild(m_dockPreviewShape);
         m_dockPreviewShape = null;				
     }
     DockIconsLayer.CloseIfEmpty();
 }
Exemple #17
0
 public void DockDragEnter(object sender, DockDragDropEventArgs e)
 {
     Point center = new Point(ActualWidth / 2, ActualHeight / 2);
     ResourceDictionary rd = new ResourceDictionary();
     rd.Source = new Uri("/Atf.Gui.Wpf;component/Resources/DockIcons.xaml", UriKind.Relative);
     if (m_dockTabIcon == null)
     {
         m_dockTabIcon = new DockIcon((Style)rd["DockTabIcon"], Root.DockIconSize);
     }
     m_dockTabIcon.Offset = new Point(center.X - Root.DockIconSize.Width / 2, center.Y - Root.DockIconSize.Height / 2);
     m_dockTabIcon.Highlight = false;
     DockIconsLayer.AddChild(m_dockTabIcon);
 }
Exemple #18
0
 void FloatingWindow_MouseMove(object sender, MouseEventArgs e)
 {
     Point pos = e.GetPosition(this);
     if (!m_validPosition)
     {
         // this is workaround for not using pInvoke for getting the position. 
         // when the draging starts, the e.GetPosition doesn't give proper values, but instead returns (0,0)
         if(pos != new Point(0, 0))
         {
             m_lastMousePos = e.GetPosition(Owner);
             m_validPosition = true;
         }
     }
     if (IsMouseCaptured && m_validPosition)
     {
         Topmost = true;
         pos = e.GetPosition(Owner);
         if (!m_dragging)
         {
             if ((m_lastMousePos - pos).Length > 2)
             {
                 m_dragging = true;
             }
         }
         if(m_dragging)
         {
             Left = Left + pos.X - m_lastMousePos.X;
             Top = Top + pos.Y - m_lastMousePos.Y;
             m_lastMousePos = pos;
             List<IDockable> dockOver = Root.FindElementsAt(e);
             DockDragDropEventArgs args = new DockDragDropEventArgs(DockedContent, e);
             foreach (IDockable dockable in m_dockOver)
             {
                 if (!dockOver.Contains(dockable))
                 {
                     dockable.DockDragLeave(this, args);
                 }
             }
             foreach (IDockable dockable in dockOver)
             {
                 if (!m_dockOver.Contains(dockable))
                 {
                     dockable.DockDragEnter(this, args);
                 }
             }
             foreach (IDockable dockable in dockOver)
             {
                 dockable.DockDragOver(this, args);
             }
             m_dockOver = dockOver;
         }
     }
 }
Exemple #19
0
 void FloatingWindow_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (IsMouseCaptured)
     {
         ReleaseMouseCapture();
         Topmost = false;
         m_validPosition = false;
         m_dragging = false;
         bool dropped = false;
         DockDragDropEventArgs args = new DockDragDropEventArgs(DockedContent, e);
         foreach (IDockable dockable in m_dockOver)
         {
             dockable.DockDragLeave(this, args);
             if (!dropped && dockable.DockPreview != null)
             {
                 Content = null;
                 DockedContent = null;
                 dropped = true;
                 dockable.DockDrop(this, args);
             }					
         }
         m_dockOver = new List<IDockable>();
         if (dropped)
         {
             Owner.Focus();
             Owner.Activate();
             Close();
         }
         else
         {
             Focus();
         }
     }
 }
Exemple #20
0
        /// <summary>
        /// Function called when dragged window is moved over already docked window</summary>
        /// <param name="sender">Dockable window being dragged</param>
        /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
        public void DockDragOver(object sender, DockDragDropEventArgs e)
        {
            DockTo? previousDockPreview = m_dockPreview;
            m_dockPreview = null;
            Point pos = e.MouseEventArgs.GetPosition(Root);

            m_dockLeftIcon.Highlight = m_dockLeftIcon.HitTest(pos);
            m_dockRightIcon.Highlight = m_dockRightIcon.HitTest(pos);
            m_dockTopIcon.Highlight = m_dockTopIcon.HitTest(pos);
            m_dockBottomIcon.Highlight = m_dockBottomIcon.HitTest(pos);
            m_dockTabIcon.Highlight = m_dockTabIcon.HitTest(pos);

            m_dockPreview = m_dockLeftIcon.Highlight ? DockTo.Left : m_dockPreview;
            m_dockPreview = m_dockRightIcon.Highlight ? DockTo.Right : m_dockPreview;
            m_dockPreview = m_dockTopIcon.Highlight ? DockTo.Top : m_dockPreview;
            m_dockPreview = m_dockBottomIcon.Highlight ? DockTo.Bottom : m_dockPreview;
            m_dockPreview = m_dockTabIcon.Highlight ? DockTo.Center : m_dockPreview;

            if (m_dockPreview != null)
            {
                if (previousDockPreview != m_dockPreview)
                {
                    Root.DockIconsLayer.RemoveChild(m_dockPreviewShape);
                    m_dockPreviewShape = null;
                    Window owner = Window.GetWindow(this);
                    Rectangle rect = new Rectangle();
                    rect.Fill = Brushes.RoyalBlue;
                    rect.Opacity = 0.3;
                    FrameworkElement fe = rect;
                    double space = 2;
                    Point p = Root.PointFromScreen(PointToScreen(new Point(space, space)));
                    ContentSettings contentSettings = (e.Content is TabLayout) ? ((TabLayout)e.Content).Children[0].Settings : ((DockContent)e.Content).Settings;
                    double width = Math.Max(Math.Min(contentSettings.Size.Width, ActualWidth / 2), ActualWidth / 5);
                    double height = Math.Max(Math.Min(contentSettings.Size.Height, ActualHeight / 2), ActualHeight / 5);
                    double ratioWidth = width / ActualWidth;
                    double ratioHeight = height / ActualHeight;
                    switch (m_dockPreview)
                    {
                        case DockTo.Left:
                            fe.Width = ActualWidth * ratioWidth - space * 2;
                            fe.Height = ActualHeight - space * 2;
                            Canvas.SetLeft(fe, p.X);
                            Canvas.SetTop(fe, p.Y);
                            break;
                        case DockTo.Right:
                            fe.Width = ActualWidth * ratioWidth - space * 2;
                            fe.Height = ActualHeight - space * 2;
                            Canvas.SetLeft(fe, p.X + ActualWidth * (1 - ratioWidth));
                            Canvas.SetTop(fe, p.Y);
                            break;
                        case DockTo.Top:
                            fe.Width = ActualWidth - space * 2;
                            fe.Height = ActualHeight * ratioHeight - space * 2;
                            Canvas.SetLeft(fe, p.X);
                            Canvas.SetTop(fe, p.Y);
                            break;
                        case DockTo.Bottom:
                            fe.Width = ActualWidth - space * 2;
                            fe.Height = ActualHeight * ratioHeight - space * 2;
                            Canvas.SetLeft(fe, p.X);
                            Canvas.SetTop(fe, p.Y + ActualHeight * (1 - ratioHeight));
                            break;
                        case DockTo.Center:
                            Canvas c = new Canvas();
                            c.SnapsToDevicePixels = true;
                            c.Width = ActualWidth;
                            c.Height = ActualHeight;
                            Canvas.SetLeft(c, p.X);
                            Canvas.SetTop(c, p.Y);
                            fe.Width = ActualWidth - space * 2;
                            fe.Height = ActualHeight - 20 - space * 2;
                            Canvas.SetLeft(fe, 0);
                            Canvas.SetTop(fe, 0);
                            c.Children.Add(fe);

                            rect = new Rectangle();
                            rect.Fill = Brushes.RoyalBlue;
                            rect.Opacity = 0.3;
                            rect.Width = Math.Min(ActualWidth / 4, 50);
                            rect.Height = 20;
                            Canvas.SetLeft(rect, 0);
                            Canvas.SetTop(rect, ActualHeight - 20 - space * 2);
                            c.Children.Add(rect);
                            fe = c;
                            break;
                    }
                    Root.DockIconsLayer.InsertChild(0, fe);
                    m_dockPreviewShape = fe;
                }
            }
            else
            {
                if (m_dockPreviewShape != null)
                {
                    Root.DockIconsLayer.RemoveChild(m_dockPreviewShape);
                    m_dockPreviewShape = null;
                }
            }
        }
Exemple #21
0
        public void DockDragOver(object sender, DockDragDropEventArgs e)
        {
            Point pos = e.MouseEventArgs.GetPosition(this);
            bool b = m_dockTabIcon.HitTest(pos);
            if (b && !m_dockTabIcon.Highlight)
            {
                m_dockTabIcon.Highlight = b;
                DockIconsLayer.RemoveChild(m_dockPreviewShape);
                m_dockPreviewShape = null;
                Window owner = Window.GetWindow(this);
                Rectangle rect = new Rectangle();
                rect.Fill = Brushes.RoyalBlue;
                rect.Opacity = 0.3;
                m_dockPreviewShape = rect;
                double space = 2;
                Point p = PointFromScreen(PointToScreen(new Point(space, space)));
                Canvas c = new Canvas();
                c.SnapsToDevicePixels = true;
                c.Width = DockedContent.ActualWidth;
                c.Height = DockedContent.ActualHeight;
                Canvas.SetLeft(c, p.X);
                Canvas.SetTop(c, p.Y);
                m_dockPreviewShape.Width = DockedContent.ActualWidth - space * 2;
                m_dockPreviewShape.Height = DockedContent.ActualHeight - 20 - space * 2;
                Canvas.SetLeft(m_dockPreviewShape, 0);
                Canvas.SetTop(m_dockPreviewShape, 0);
                c.Children.Add(m_dockPreviewShape);

                rect = new Rectangle();
                rect.Fill = Brushes.RoyalBlue;
                rect.Opacity = 0.3;
                rect.Width = Math.Min(DockedContent.ActualWidth / 4, 50);
                rect.Height = 20;
                Canvas.SetLeft(rect, 0);
                Canvas.SetTop(rect, DockedContent.ActualHeight - 20 - space * 2);
                c.Children.Add(rect);
                m_dockPreviewShape = c;

                DockIconsLayer.InsertChild(0, m_dockPreviewShape);
            }
            else if(!b)
            {
                if (m_dockPreviewShape != null)
                {
                    DockIconsLayer.RemoveChild(m_dockPreviewShape);
                    m_dockPreviewShape = null;
                }
                m_dockTabIcon.Highlight = false;				
            }
        }
Exemple #22
0
 /// <summary>
 /// Function called when dragged window leaves already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 public void DockDragLeave(object sender, DockDragDropEventArgs e)
 {
     DockIconsLayer dockIconLayer = Root.DockIconsLayer;
     dockIconLayer.RemoveChild(m_dockLeftIcon);
     dockIconLayer.RemoveChild(m_dockRightIcon);
     dockIconLayer.RemoveChild(m_dockTopIcon);
     dockIconLayer.RemoveChild(m_dockBottomIcon);
     dockIconLayer.RemoveChild(m_dockTabIcon);
     if (m_dockPreviewShape != null)
     {
         Root.DockIconsLayer.RemoveChild(m_dockPreviewShape);
         m_dockPreviewShape = null;
     }
     dockIconLayer.CloseIfEmpty();
 }
Exemple #23
0
 public void DockDrop(object sender, DockDragDropEventArgs e)
 {
     if (e.Content is TabLayout)
     {
         foreach (DockContent subContent in ((TabLayout)e.Content).Children)
         {
             subContent.Settings.DockState = DockState.Floating;
         }
     }
     else
     {
         ((DockContent)e.Content).Settings.DockState = DockState.Floating;
     }
     Dock(null, e.Content, DockTo.Center);
 }
Exemple #24
0
 /// <summary>
 /// Function called when dragged window is dropped over already docked window</summary>
 /// <param name="sender">Dockable window being dragged</param>
 /// <param name="e">Drag and drop arguments when window is dropped to be docked to dockpanel</param>
 public void DockDrop(object sender, DockDragDropEventArgs e)
 {
     DockPanel parent = Root;
     DockTo dockTo = (DockTo)m_dockPreview;
     if (e.Content is TabLayout)
     {
         foreach (DockContent subContent in ((TabLayout)e.Content).Children)
         {
             ContentSettings contentSettings = subContent.Settings;
             contentSettings.DockState = DockState.Docked;
         }
     }
     else
     {
         ContentSettings contentSettings = ((DockContent)e.Content).Settings;
         contentSettings.DockState = DockState.Docked;
     }
     switch (dockTo)
     {
         case DockTo.Left:
         case DockTo.Right:
         case DockTo.Top:
         case DockTo.Bottom:
             ((IDockLayout)Parent).Dock(DockedContent, e.Content, dockTo);
             break;
         case DockTo.Center:
             Dock(null, e.Content, dockTo);
             break;
     }
     parent.CheckConsistency();
 }