コード例 #1
0
        /// <summary>
        /// Keeps a reference to the dragging panel.
        /// </summary>
        /// <param name="sender">The dragging panel.</param>
        /// <param name="args">Drag event args.</param>
        private void DragDockPanel_DragStarted(object sender, DragEventArgs args)
        {
            DragDockPanel panel = sender as DragDockPanel;

            // Keep reference to dragging panel
            this.draggingPanel = panel;
        }
コード例 #2
0
        /// <summary>
        /// Prepares a panel for the UI. Override for hooking custom events.
        /// </summary>
        /// <param name="panel">The panel to prepare.</param>
        protected virtual void PreparePanel(DragDockPanel panel)
        {
            // Hook up panel events
            panel.DragStarted +=
                new DragEventHander(this.DragDockPanel_DragStarted);
            panel.DragFinished +=
                new DragEventHander(this.DragDockPanel_DragFinished);
            panel.DragMoved +=
                new DragEventHander(this.DragDockPanel_DragMoved);
            panel.Maximized +=
                new EventHandler(this.DragDockPanel_Maximized);
            panel.Restored +=
                new EventHandler(this.DragDockPanel_Restored);

            if (panel.PanelState == PanelState.Maximized)
            {
                this.maximizedPanel = panel;

                foreach (DragDockPanel dragDockPanel in this.panels)
                {
                    if (panel != dragDockPanel)
                    {
                        dragDockPanel.Minimize();
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Maximises a panel.
        /// </summary>
        /// <param name="sender">the panel to maximise.</param>
        /// <param name="e">Event args.</param>
        private void DragDockPanel_Maximized(object sender, EventArgs e)
        {
            DragDockPanel maximizedPanel =
                sender as DragDockPanel;

            // Store max'ed panel
            this.maximizedPanel = maximizedPanel;

            // Loop through children to disable dragging
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel =
                    child as DragDockPanel;

                panel.DraggingEnabled = false;

                if (panel != this.maximizedPanel)
                {
                    panel.Minimize();
                }
            }

            // Update sizes and layout
            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #4
0
        /// <summary>
        /// Drops the dragging panel.
        /// </summary>
        /// <param name="sender">The dragging panel.</param>
        /// <param name="args">Drag event args.</param>
        private void DragDockPanel_DragFinished(object sender, DragEventArgs args)
        {
            // Set dragging panel back to null
            this.draggingPanel = null;

            // Update the layout (to reset all panel positions)
            this.UpdatePanelLayout();
        }
コード例 #5
0
        /// <summary>
        /// Unprepares a drag dock panel.
        /// </summary>
        /// <param name="element">The source drag dock panel.</param>
        /// <param name="item">The source item.</param>
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            base.ClearContainerForItemOverride(element, item);
            DragDockPanel panel = element as DragDockPanel;

            this.UnpreparePanel(panel);
            this.panels.Remove(panel);
            this.SetRowsAndColumns(this.GetOrderedPanels());
            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #6
0
        /// <summary>
        /// Shuffles the panels around.
        /// </summary>
        /// <param name="sender">The dragging panel.</param>
        /// <param name="args">Drag event args.</param>
        private void DragDockPanel_DragMoved(object sender, DragEventArgs args)
        {
            Point mousePosInHost =
                args.MouseEventArgs.GetPosition(this);

            int currentRow =
                (int)Math.Floor(mousePosInHost.Y /
                                (this.ActualHeight / (double)this.rows));

            int currentColumn =
                (int)Math.Floor(mousePosInHost.X /
                                (this.ActualWidth / (double)this.columns));

            // Stores the panel we will swap with
            DragDockPanel swapPanel = null;

            // Loop through children to see if there is a panel to swap with
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel = child as DragDockPanel;

                // If the panel is not the dragging panel and is in the current row
                // or current column... mark it as the panel to swap with
                if (panel != this.draggingPanel &&
                    Grid.GetColumn(panel) == currentColumn &&
                    Grid.GetRow(panel) == currentRow)
                {
                    swapPanel = panel;
                    break;
                }
            }

            // If there is a panel to swap with
            if (swapPanel != null)
            {
                // Store the new row and column
                int draggingPanelNewColumn = Grid.GetColumn(swapPanel);
                int draggingPanelNewRow    = Grid.GetRow(swapPanel);

                // Update the swapping panel row and column
                Grid.SetColumn(swapPanel, Grid.GetColumn(this.draggingPanel));
                Grid.SetRow(swapPanel, Grid.GetRow(this.draggingPanel));

                // Update the dragging panel row and column
                Grid.SetColumn(this.draggingPanel, draggingPanelNewColumn);
                Grid.SetRow(this.draggingPanel, draggingPanelNewRow);

                // Animate the layout to the new positions
                this.AnimatePanelLayout();
            }
        }
コード例 #7
0
 /// <summary>
 /// Unprepares a panel for the UI. Override for hooking custom events.
 /// </summary>
 /// <param name="panel">The panel to prepare.</param>
 protected virtual void UnpreparePanel(DragDockPanel panel)
 {
     // Hook up panel events
     panel.DragStarted -=
         new DragEventHander(this.DragDockPanel_DragStarted);
     panel.DragFinished -=
         new DragEventHander(this.DragDockPanel_DragFinished);
     panel.DragMoved -=
         new DragEventHander(this.DragDockPanel_DragMoved);
     panel.Maximized -=
         new EventHandler(this.DragDockPanel_Maximized);
     panel.Restored -=
         new EventHandler(this.DragDockPanel_Restored);
 }
コード例 #8
0
        /// <summary>
        /// Puts all of the panel back to a grid view.
        /// </summary>
        /// <param name="sender">The minimising panel.</param>
        /// <param name="e">Event args.</param>
        private void DragDockPanel_Restored(object sender, EventArgs e)
        {
            // Set max'ed panel to null
            this.maximizedPanel = null;

            // Loop through children to disable dragging
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel =
                    child as DragDockPanel;
                panel.Restore();
                panel.DraggingEnabled = true;
            }

            // Update sizes and layout
            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #9
0
        /// <summary>
        /// Pepares a drag dock panel.
        /// </summary>
        /// <param name="element">The drag dock panel.</param>
        /// <param name="item">The source item.</param>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            DragDockPanel panel = element as DragDockPanel;

            if (panel.Style == null && this.DefaultPanelStyle != null)
            {
                panel.Style = this.DefaultPanelStyle;
            }

            Dictionary <int, DragDockPanel> orderedPanels = this.GetOrderedPanels();

            orderedPanels.Add(this.panels.Count, panel);
            this.panels.Add(panel);
            this.PreparePanel(panel);
            this.SetRowsAndColumns(orderedPanels);
            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #10
0
        /// <summary>
        /// Updates the layout when in design mode.
        /// </summary>
        /// <param name="sender">The drag dock panel host.</param>
        /// <param name="e">Event Args.</param>
        private void DragDockPanelHost_LayoutUpdated(object sender, EventArgs e)
        {
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                Dictionary <int, DragDockPanel> orderedPanels = new Dictionary <int, DragDockPanel>();

                for (int i = 0; i < this.panels.Count; i++)
                {
                    if (this.panels[i].GetType() == typeof(DragDockPanel))
                    {
                        DragDockPanel panel = (DragDockPanel)this.panels[i];
                        orderedPanels.Add(i, panel);
                    }
                }

                this.SetRowsAndColumns(orderedPanels);
                this.UpdatePanelLayout();
            }
        }
コード例 #11
0
        /// <summary>
        /// Gets the panels in order.
        /// </summary>
        /// <returns>The ordered panels.</returns>
        private Dictionary <int, DragDockPanel> GetOrderedPanels()
        {
            Dictionary <int, DragDockPanel> orderedPanels = new Dictionary <int, DragDockPanel>();
            List <DragDockPanel>            addedPanels   = new List <DragDockPanel>();

            for (int i = 0; i < this.panels.Count; i++)
            {
                DragDockPanel lowestPanel = null;
                foreach (DragDockPanel panel in this.panels)
                {
                    if (!addedPanels.Contains(panel) && (lowestPanel == null || ((Grid.GetRow(panel) * this.columns) + Grid.GetColumn(panel) < (Grid.GetRow(lowestPanel) * this.columns) + Grid.GetColumn(lowestPanel))))
                    {
                        lowestPanel = panel;
                    }
                }

                addedPanels.Add(lowestPanel);
                orderedPanels.Add(i, lowestPanel);
            }

            return(orderedPanels);
        }
コード例 #12
0
        /// <summary>
        /// Maximises a panel.
        /// </summary>
        /// <param name="sender">the panel to maximise.</param>
        /// <param name="e">Event args.</param>
        private void DragDockPanel_Maximized(object sender, EventArgs e)
        {
            DragDockPanel maximizedPanel =
                sender as DragDockPanel;

            // Store max'ed panel
            this.maximizedPanel = maximizedPanel;

            // Loop through children to disable dragging
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel =
                    child as DragDockPanel;

                panel.DraggingEnabled = false;

                if (panel != this.maximizedPanel)
                {
                    panel.Minimize();
                }
            }

            // Update sizes and layout
            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #13
0
ファイル: DragDockPanelHost.cs プロジェクト: backlune/SPLE
        /// <summary>
        /// Prepares a panel for the UI. Override for hooking custom events.
        /// </summary>
        /// <param name="panel">The panel to prepare.</param>
        protected virtual void PreparePanel(DragDockPanel panel)
        {
            // Hook up panel events
            panel.DragStarted +=
                new DragEventHander(this.DragDockPanel_DragStarted);
            panel.DragFinished +=
                new DragEventHander(this.DragDockPanel_DragFinished);
            panel.DragMoved +=
                new DragEventHander(this.DragDockPanel_DragMoved);
            panel.Maximized +=
                new EventHandler(this.DragDockPanel_Maximized);
            panel.Restored +=
                new EventHandler(this.DragDockPanel_Restored);
            panel.PanelDoubleClicked +=
                new EventHandler(this.DragDockPanel_DoubleClicked);

            if (panel.PanelState == PanelState.Maximized)
            {
                this.maximizedPanel = panel;
            }
        }
コード例 #14
0
ファイル: Window1.g.cs プロジェクト: backlune/SPLE
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     
     #line 14 "..\..\Window1.xaml"
     ((DigiFlare.DigiTweet.UI.Window1)(target)).Closed += new System.EventHandler(this.window_Closed);
     
     #line default
     #line hidden
     
     #line 15 "..\..\Window1.xaml"
     ((DigiFlare.DigiTweet.UI.Window1)(target)).StateChanged += new System.EventHandler(this.window_StateChanged);
     
     #line default
     #line hidden
     return;
     case 2:
     this.LoginView = ((System.Windows.Controls.Grid)(target));
     return;
     case 3:
     this.ucLogin = ((DigiFlare.DigiTweet.UI.LoginControl)(target));
     return;
     case 4:
     this.MainView = ((System.Windows.Controls.Grid)(target));
     return;
     case 5:
     this.Background = ((System.Windows.Shapes.Rectangle)(target));
     return;
     case 6:
     this.MainPane = ((System.Windows.Controls.DockPanel)(target));
     return;
     case 7:
     this.HeaderPane = ((System.Windows.Controls.Grid)(target));
     return;
     case 8:
     this.HeaderBackg = ((System.Windows.Shapes.Rectangle)(target));
     return;
     case 9:
     this.HeaderBackgShd = ((System.Windows.Shapes.Rectangle)(target));
     return;
     case 10:
     this.Title = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 11:
     this.txtLoading = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 12:
     this.Home = ((System.Windows.Controls.Button)(target));
     
     #line 66 "..\..\Window1.xaml"
     this.Home.Click += new System.Windows.RoutedEventHandler(this.btnHome_Click);
     
     #line default
     #line hidden
     return;
     case 13:
     this.Tweet = ((System.Windows.Controls.Button)(target));
     
     #line 73 "..\..\Window1.xaml"
     this.Tweet.Click += new System.Windows.RoutedEventHandler(this.btnTweet_Click);
     
     #line default
     #line hidden
     return;
     case 14:
     this.Tweets = ((System.Windows.Controls.Button)(target));
     
     #line 78 "..\..\Window1.xaml"
     this.Tweets.Click += new System.Windows.RoutedEventHandler(this.btnTweets_Click);
     
     #line default
     #line hidden
     return;
     case 15:
     this.Reply = ((System.Windows.Controls.Button)(target));
     
     #line 79 "..\..\Window1.xaml"
     this.Reply.Click += new System.Windows.RoutedEventHandler(this.btnReplies_Click);
     
     #line default
     #line hidden
     return;
     case 16:
     this.DM = ((System.Windows.Controls.Button)(target));
     
     #line 80 "..\..\Window1.xaml"
     this.DM.Click += new System.Windows.RoutedEventHandler(this.btnDirectMessages_Click);
     
     #line default
     #line hidden
     return;
     case 17:
     this.Profile = ((System.Windows.Controls.Button)(target));
     
     #line 81 "..\..\Window1.xaml"
     this.Profile.Click += new System.Windows.RoutedEventHandler(this.btnProfile_Click);
     
     #line default
     #line hidden
     return;
     case 18:
     this.btnRefresh = ((System.Windows.Controls.Button)(target));
     
     #line 85 "..\..\Window1.xaml"
     this.btnRefresh.Click += new System.Windows.RoutedEventHandler(this.btnRefresh_Click);
     
     #line default
     #line hidden
     return;
     case 19:
     this.Options = ((System.Windows.Controls.Button)(target));
     
     #line 86 "..\..\Window1.xaml"
     this.Options.Click += new System.Windows.RoutedEventHandler(this.btnOptions_Click);
     
     #line default
     #line hidden
     return;
     case 20:
     this.Logout = ((System.Windows.Controls.Button)(target));
     
     #line 87 "..\..\Window1.xaml"
     this.Logout.Click += new System.Windows.RoutedEventHandler(this.btnLogout_Click);
     
     #line default
     #line hidden
     return;
     case 21:
     this.SliderPane = ((System.Windows.Controls.Grid)(target));
     return;
     case 22:
     this.SlideLeftGrid = ((System.Windows.Controls.Grid)(target));
     return;
     case 23:
     this.txtTweet = ((System.Windows.Controls.TextBox)(target));
     
     #line 116 "..\..\Window1.xaml"
     this.txtTweet.KeyDown += new System.Windows.Input.KeyEventHandler(this.txtTweet_KeyDown);
     
     #line default
     #line hidden
     return;
     case 24:
     this.txtUrl = ((System.Windows.Controls.TextBox)(target));
     return;
     case 25:
     this.btnTinyUrl = ((System.Windows.Controls.Button)(target));
     
     #line 125 "..\..\Window1.xaml"
     this.btnTinyUrl.Click += new System.Windows.RoutedEventHandler(this.btnTinyUrl_Click);
     
     #line default
     #line hidden
     return;
     case 26:
     this.btnTwitPic = ((System.Windows.Controls.Button)(target));
     
     #line 128 "..\..\Window1.xaml"
     this.btnTwitPic.Click += new System.Windows.RoutedEventHandler(this.btnTwitPic_Click);
     
     #line default
     #line hidden
     return;
     case 27:
     this.btnSend = ((System.Windows.Controls.Button)(target));
     
     #line 135 "..\..\Window1.xaml"
     this.btnSend.Click += new System.Windows.RoutedEventHandler(this.btnSend_Click);
     
     #line default
     #line hidden
     return;
     case 28:
     this.btnCloseSlider = ((System.Windows.Controls.Button)(target));
     
     #line 137 "..\..\Window1.xaml"
     this.btnCloseSlider.Click += new System.Windows.RoutedEventHandler(this.btnCloseSlider_Click);
     
     #line default
     #line hidden
     return;
     case 29:
     this.ContentPane = ((System.Windows.Controls.Grid)(target));
     return;
     case 30:
     this.ddphMain = ((Blacklight.Controls.DragDockPanelHost)(target));
     return;
     case 31:
     this.ddpAllTweets = ((Blacklight.Controls.DragDockPanel)(target));
     return;
     case 32:
     this.txtTweetsLoading = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 33:
     this.icAllTweets = ((DigiFlare.DigiTweet.UI.TweetsPanelControl)(target));
     return;
     case 34:
     this.ddpReplies = ((Blacklight.Controls.DragDockPanel)(target));
     return;
     case 35:
     this.txtRepliesLoading = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 36:
     this.icAllReplies = ((DigiFlare.DigiTweet.UI.TweetsPanelControl)(target));
     return;
     case 37:
     this.ddpDirectMessages = ((Blacklight.Controls.DragDockPanel)(target));
     return;
     case 38:
     this.txtDirectMessagesLoading = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 39:
     this.icDirectMessages = ((System.Windows.Controls.ItemsControl)(target));
     return;
     case 44:
     this.ddpProfile = ((Blacklight.Controls.DragDockPanel)(target));
     return;
     case 45:
     
     #line 327 "..\..\Window1.xaml"
     ((System.Windows.Controls.Image)(target)).ContextMenuOpening += new System.Windows.Controls.ContextMenuEventHandler(this.ProfileAvatar_ContextMenuOpening);
     
     #line default
     #line hidden
     return;
     case 46:
     this.btnFollow = ((System.Windows.Controls.Button)(target));
     
     #line 332 "..\..\Window1.xaml"
     this.btnFollow.Click += new System.Windows.RoutedEventHandler(this.btnFollow_Click);
     
     #line default
     #line hidden
     return;
     case 47:
     this.txtUserProfileUrl = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 48:
     this.icUserTweets = ((DigiFlare.DigiTweet.UI.TweetsPanelControl)(target));
     return;
     case 49:
     this.ddpCategories = ((Blacklight.Controls.DragDockPanel)(target));
     return;
     case 50:
     this.tcCategories = ((System.Windows.Controls.TabControl)(target));
     return;
     case 51:
     this.txtFriendsLoading = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 52:
     this.icFriends = ((System.Windows.Controls.ItemsControl)(target));
     return;
     case 54:
     this.tabFavourites = ((System.Windows.Controls.TabItem)(target));
     return;
     case 55:
     this.icAllFavourites = ((DigiFlare.DigiTweet.UI.TweetsPanelControl)(target));
     return;
     case 56:
     this.tabEdit = ((System.Windows.Controls.TabItem)(target));
     return;
     case 57:
     this.txtCategoryName = ((System.Windows.Controls.TextBox)(target));
     return;
     case 58:
     this.lbFollowing = ((System.Windows.Controls.ListBox)(target));
     return;
     case 59:
     this.txtCategoryColor = ((System.Windows.Controls.TextBox)(target));
     return;
     case 60:
     this.btnColorPicker = ((System.Windows.Controls.Button)(target));
     
     #line 562 "..\..\Window1.xaml"
     this.btnColorPicker.Click += new System.Windows.RoutedEventHandler(this.btnColorPicker_Click);
     
     #line default
     #line hidden
     return;
     case 61:
     this.btnSaveCategory = ((System.Windows.Controls.Button)(target));
     
     #line 569 "..\..\Window1.xaml"
     this.btnSaveCategory.Click += new System.Windows.RoutedEventHandler(this.btnSaveCategory_Click);
     
     #line default
     #line hidden
     return;
     case 62:
     this.ddpSearch = ((Blacklight.Controls.DragDockPanel)(target));
     return;
     case 63:
     this.tbSearch = ((System.Windows.Controls.TextBox)(target));
     
     #line 594 "..\..\Window1.xaml"
     this.tbSearch.KeyDown += new System.Windows.Input.KeyEventHandler(this.tbSearch_KeyDown);
     
     #line default
     #line hidden
     return;
     case 64:
     this.btnSearch = ((System.Windows.Controls.Button)(target));
     
     #line 597 "..\..\Window1.xaml"
     this.btnSearch.Click += new System.Windows.RoutedEventHandler(this.btnSearch_Click);
     
     #line default
     #line hidden
     return;
     case 65:
     this.tcSearches = ((System.Windows.Controls.TabControl)(target));
     return;
     }
     this._contentLoaded = true;
 }
コード例 #15
0
        /// <summary>
        /// Animates the panel sizes
        /// </summary>
        private void AnimatePanelSizes()
        {
            double determinedWidth = (double)this.columns * (this.minimizedColumnWidth + 30);
            double aw = this.ActualWidth;
            double ah = this.ActualHeight;


            #region determine width of the app
            determinedWidth = 0;
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel = (DragDockPanel)child;
                panel.UpdateLayout();
                determinedWidth += panel.ActualWidth < this.minimizedColumnWidth ? this.minimizedColumnWidth : panel.ActualWidth;
            }
            aw = determinedWidth;
            #endregion

            if (CancelPanelResizingAnimation)
            {
                aw = determinedWidth;
            }
            else
            {
                aw = this.ActualWidth;
            }

            if (double.IsInfinity(aw) || double.IsNaN(aw) || aw == 0)
            {
                return;
            }

            // If there is not a maxmized panel...
            if (this.maximizedPanel == null)
            {
                // Animate the panel sizes to row / column sizes
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    double width  = (aw / (double)this.columns) - panel.Margin.Left - panel.Margin.Right;
                    double height = (ah / (double)this.rows) - panel.Margin.Top - panel.Margin.Bottom;

                    if (width < 0)
                    {
                        width = 0;
                    }

                    if (height < 0)
                    {
                        height = 0;
                    }

                    panel.AnimateSize(
                        width,
                        height);
                }
            }
            else
            {
                // Loop through the children
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel =
                        (DragDockPanel)child;

                    // Set the size of the non
                    // maximized children
                    if (panel != this.maximizedPanel)
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = (this.ActualHeight / (double)(this.panels.Count - 1)) - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = (this.ActualWidth / (double)(this.panels.Count - 1)) - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                    else
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.ActualWidth - this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = this.ActualHeight - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = this.ActualWidth - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.ActualHeight - this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Prepares a panel for the UI. Override for hooking custom events.
        /// </summary>
        /// <param name="panel">The panel to prepare.</param>
        protected virtual void PreparePanel(DragDockPanel panel)
        {
            // Hook up panel events
            panel.DragStarted +=
                new DragEventHander(this.DragDockPanel_DragStarted);
            panel.DragFinished +=
                new DragEventHander(this.DragDockPanel_DragFinished);
            panel.DragMoved +=
                new DragEventHander(this.DragDockPanel_DragMoved);
            panel.Maximized +=
                new EventHandler(this.DragDockPanel_Maximized);
            panel.Restored +=
                new EventHandler(this.DragDockPanel_Restored);

            if (panel.PanelState == PanelState.Maximized)
            {
                this.maximizedPanel = panel;

                foreach (DragDockPanel dragDockPanel in this.panels)
                {
                    if (panel != dragDockPanel)
                    {
                        dragDockPanel.Minimize();
                    }
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Unprepares a panel for the UI. Override for hooking custom events.
        /// </summary>
        /// <param name="panel">The panel to prepare.</param>
        protected virtual void UnpreparePanel(DragDockPanel panel)
        {
            if (panel.PanelState == PanelState.Maximized)
            {
                this.DragDockPanel_Restored(null, null);
            }

            // Hook up panel events
            panel.DragStarted -=
                new DragEventHander(this.DragDockPanel_DragStarted);
            panel.DragFinished -=
                new DragEventHander(this.DragDockPanel_DragFinished);
            panel.DragMoved -=
                new DragEventHander(this.DragDockPanel_DragMoved);
            panel.Maximized -=
                new EventHandler(this.DragDockPanel_Maximized);
            panel.Restored -=
                new EventHandler(this.DragDockPanel_Restored);
        }
コード例 #18
0
ファイル: DragDockPanelHost.cs プロジェクト: backlune/SPLE
        /// <summary>
        /// Removes a panel from the host.
        /// </summary>
        /// <param name="panel">The panel to remove.</param>
        public void RemovePanel(DragDockPanel panel)
        {
            Dictionary<int, DragDockPanel> orderedPanels = new Dictionary<int, DragDockPanel>();
            List<int> indexes = new List<int>();

            // Loop through children to order them according to their
            // current row and column...
            foreach (UIElement child in this.Children)
            {
                DragDockPanel childPanel = (DragDockPanel)child;

                orderedPanels.Add(
                    (Grid.GetRow(childPanel) * this.columns) + Grid.GetColumn(childPanel),
                    childPanel);

                indexes.Add((Grid.GetRow(childPanel) * this.columns) + Grid.GetColumn(childPanel));
            }

            orderedPanels.Remove((Grid.GetRow(panel) * this.columns) + Grid.GetColumn(panel));
            indexes.Remove((Grid.GetRow(panel) * this.columns) + Grid.GetColumn(panel));
            this.Children.Remove(panel);

            Dictionary<int, DragDockPanel> reorderedPanels = new Dictionary<int, DragDockPanel>();

            for (int i = 0; i < indexes.Count; i++)
            {
                reorderedPanels.Add(i, orderedPanels[indexes[i]]);
            }

            this.SetRowsAndColumns(reorderedPanels);

            if (this.maximizedPanel == panel || reorderedPanels.Count == 1)
            {
                reorderedPanels[0].PanelState = PanelState.Restored;
                this.maximizedPanel = null;

                foreach (UIElement child in this.Children)
                {
                    DragDockPanel childPanel = (DragDockPanel)child;
                    childPanel.DraggingEnabled = true;
                }
            }

            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #19
0
        /// <summary>
        /// Animates the panel sizes
        /// </summary>
        private void AnimatePanelSizes()
        {
            if (double.IsInfinity(this.ActualWidth) || double.IsNaN(this.ActualWidth) || this.ActualWidth == 0)
            {
                return;
            }

            // If there is not a maxmized panel...
            if (this.maximizedPanel == null)
            {
                // Animate the panel sizes to row / column sizes
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    double width  = (this.ActualWidth / (double)this.columns) - panel.Margin.Left - panel.Margin.Right;
                    double height = (this.ActualHeight / (double)this.rows) - panel.Margin.Top - panel.Margin.Bottom;

                    if (width < 0)
                    {
                        width = 0;
                    }

                    if (height < 0)
                    {
                        height = 0;
                    }

                    panel.AnimateSize(
                        width,
                        height);
                }
            }
            else
            {
                // Loop through the children
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel =
                        (DragDockPanel)child;

                    // Set the size of the non
                    // maximized children
                    if (panel != this.maximizedPanel)
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = (this.ActualHeight / (double)(this.panels.Count - 1)) - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = (this.ActualWidth / (double)(this.panels.Count - 1)) - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newWidth = newHeight = 0;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                    else
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.ActualWidth - this.minimizedColumnWidth - panel.Margin.Left - panel.Margin.Right;
                        double newHeight = this.ActualHeight - panel.Margin.Top - panel.Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = this.ActualWidth - panel.Margin.Left - panel.Margin.Right;
                            newHeight = this.ActualHeight - this.minimizedRowHeight - panel.Margin.Top - panel.Margin.Bottom;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newWidth  = this.ActualWidth - panel.Margin.Right - panel.Margin.Left;
                            newHeight = this.ActualHeight - panel.Margin.Bottom - panel.Margin.Top;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        panel.AnimateSize(
                            newWidth,
                            newHeight);
                    }
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// Drops the dragging panel.
        /// </summary>
        /// <param name="sender">The dragging panel.</param>
        /// <param name="args">Drag event args.</param>
        private void DragDockPanel_DragFinished(object sender, DragEventArgs args)
        {
            // Set dragging panel back to null
            this.draggingPanel = null;

            // Update the layout (to reset all panel positions)
            this.UpdatePanelLayout();
        }
コード例 #21
0
        /// <summary>
        /// Keeps a reference to the dragging panel.
        /// </summary>
        /// <param name="sender">The dragging panel.</param>
        /// <param name="args">Drag event args.</param>
        private void DragDockPanel_DragStarted(object sender, DragEventArgs args)
        {
            DragDockPanel panel = sender as DragDockPanel;

            // Keep reference to dragging panel
            this.draggingPanel = panel;
        }
コード例 #22
0
        /// <summary>
        /// Updates the panel layout without animation
        /// This does size and position without animation
        /// </summary>
        private void UpdatePanelLayout()
        {
            if (double.IsInfinity(this.ActualWidth) || double.IsNaN(this.ActualWidth) || this.ActualWidth == 0)
            {
                return;
            }

            // If we are not in max'ed panel mode...
            if (this.maximizedPanel == null)
            {
                // Layout children as per rows and columns
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    Canvas.SetLeft(
                        panel,
                        (Grid.GetColumn(panel) * (this.ActualWidth / (double)this.columns)));

                    Canvas.SetTop(
                        panel,
                        (Grid.GetRow(panel) * (this.ActualHeight / (double)this.rows)));

                    double width  = (this.ActualWidth / (double)this.columns) - panel.Margin.Left - panel.Margin.Right;
                    double height = (this.ActualHeight / (double)this.rows) - panel.Margin.Top - panel.Margin.Bottom;

                    if (width < 0)
                    {
                        width = 0;
                    }

                    if (height < 0)
                    {
                        height = 0;
                    }

                    panel.Width  = width;
                    panel.Height = height;
                }
            }
            else
            {
                Dictionary <int, DragDockPanel> orderedPanels = new Dictionary <int, DragDockPanel>();

                // Loop through children to order them according to their
                // current row and column...
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    orderedPanels.Add(
                        (Grid.GetRow(panel) * this.columns) + Grid.GetColumn(panel),
                        panel);
                }

                // Set initial top of minimized panels to 0
                double currentOffset = 0.0;

                // For each of the panels (as ordered in the grid)
                for (int i = 0; i < orderedPanels.Count; i++)
                {
                    // If the current panel is not the maximized panel
                    if (orderedPanels[i] != this.maximizedPanel)
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.minimizedColumnWidth - orderedPanels[i].Margin.Left - orderedPanels[i].Margin.Right;
                        double newHeight = (this.ActualHeight / (double)(this.panels.Count - 1)) - orderedPanels[i].Margin.Top - orderedPanels[i].Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = (this.ActualWidth / (double)(this.panels.Count - 1)) - orderedPanels[i].Margin.Left - orderedPanels[i].Margin.Right;
                            newHeight = this.minimizedRowHeight - orderedPanels[i].Margin.Top - orderedPanels[i].Margin.Bottom;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newWidth  = 0;
                            newHeight = 0;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        // Set the size of the panel
                        orderedPanels[i].Width  = newWidth;
                        orderedPanels[i].Height = newHeight;

                        double newX = 0;
                        double newY = currentOffset;
                        #region determin new docking coordinates
                        if (this.minimizedPosition.Equals(MinimizedPositions.Right))
                        {
                            newX = this.ActualWidth - this.minimizedColumnWidth;
                            newY = currentOffset;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Left))
                        {
                            newX = 0;
                            newY = currentOffset;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Bottom))
                        {
                            newX = currentOffset;
                            newY = this.ActualHeight - this.minimizedRowHeight;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newX = currentOffset;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newX = this.ActualWidth / 2;
                            newY = this.ActualHeight / 2;
                        }
                        #endregion

                        // Set the position of the panel
                        Canvas.SetLeft(orderedPanels[i], newX);
                        Canvas.SetTop(orderedPanels[i], newY);

                        if (this.minimizedPosition.Equals(MinimizedPositions.Left) || this.minimizedPosition.Equals(MinimizedPositions.Right))
                        {
                            // Increment current top
                            currentOffset += this.ActualHeight / (double)(this.panels.Count - 1);
                        }
                        else
                        {
                            // Increment current left
                            currentOffset += this.ActualWidth / (double)(this.panels.Count - 1);
                        }
                    }
                    else
                    {
                        #region determine new width & height depending on docking axis
                        double newWidth  = this.ActualWidth - this.minimizedColumnWidth - orderedPanels[i].Margin.Left - orderedPanels[i].Margin.Right;
                        double newHeight = this.ActualHeight - orderedPanels[i].Margin.Top - orderedPanels[i].Margin.Bottom;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Bottom) || this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newWidth  = this.ActualWidth - orderedPanels[i].Margin.Left - orderedPanels[i].Margin.Right;
                            newHeight = this.ActualHeight - this.minimizedRowHeight - orderedPanels[i].Margin.Top - orderedPanels[i].Margin.Bottom;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newWidth  = this.ActualWidth - orderedPanels[i].Margin.Right - orderedPanels[i].Margin.Left;
                            newHeight = this.ActualHeight - orderedPanels[i].Margin.Bottom - orderedPanels[i].Margin.Top;
                        }
                        #endregion

                        if (newHeight < 0)
                        {
                            newHeight = 0;
                        }

                        if (newWidth < 0)
                        {
                            newWidth = 0;
                        }

                        // Set the size of the panel
                        orderedPanels[i].Width  = newWidth;
                        orderedPanels[i].Height = newHeight;

                        #region determine new docking position
                        double newX = 0;
                        double newY = 0;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Right))
                        {
                            newX = 0;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Left))
                        {
                            newX = this.minimizedColumnWidth;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Bottom))
                        {
                            newX = 0;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newX = 0;
                            newY = this.minimizedRowHeight;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newX = 0;
                            newY = 0;
                        }
                        #endregion

                        // Set the position of the panel
                        Canvas.SetLeft(orderedPanels[i], newX);
                        Canvas.SetTop(orderedPanels[i], newY);
                    }
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Puts all of the panel back to a grid view.
        /// </summary>
        /// <param name="sender">The minimising panel.</param>
        /// <param name="e">Event args.</param>
        private void DragDockPanel_Restored(object sender, EventArgs e)
        {
            // Set max'ed panel to null
            this.maximizedPanel = null;

            // Loop through children to disable dragging
            foreach (UIElement child in this.panels)
            {
                DragDockPanel panel =
                    child as DragDockPanel;
                panel.Restore();
                panel.DraggingEnabled = true;
            }

            // Update sizes and layout
            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }
コード例 #24
0
        /// <summary>
        /// Animate the panel positions
        /// </summary>
        private void AnimatePanelLayout()
        {
            if (double.IsInfinity(this.ActualWidth) || double.IsNaN(this.ActualWidth) || this.ActualWidth == 0)
            {
                return;
            }

            // If we are not in max'ed panel mode...
            if (this.maximizedPanel == null)
            {
                // Loop through children and size to row and columns
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    if (panel != this.draggingPanel)
                    {
                        panel.AnimatePosition(
                            (Grid.GetColumn(panel) * (this.ActualWidth / (double)this.columns)),
                            (Grid.GetRow(panel) * (this.ActualHeight / (double)this.rows)));
                    }
                }
            }
            else
            {
                Dictionary <int, DragDockPanel> orderedPanels = new Dictionary <int, DragDockPanel>();

                // Loop through children to order them according to their
                // current row and column...
                foreach (UIElement child in this.panels)
                {
                    DragDockPanel panel = (DragDockPanel)child;

                    orderedPanels.Add(
                        (Grid.GetRow(panel) * this.columns) + Grid.GetColumn(panel),
                        panel);
                }

                // Set initial top of minimized panels to 0
                double currentOffset = 0.0;

                // For each of the panels (as ordered in the grid)
                for (int i = 0; i < orderedPanels.Count; i++)
                {
                    // If the current panel is not the maximized panel
                    if (orderedPanels[i] != this.maximizedPanel)
                    {
                        double newX = 0;
                        double newY = currentOffset;
                        #region determin new docking coordinates
                        if (this.minimizedPosition.Equals(MinimizedPositions.Right))
                        {
                            newX = this.ActualWidth - this.minimizedColumnWidth;
                            newY = currentOffset;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Left))
                        {
                            newX = 0;
                            newY = currentOffset;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Bottom))
                        {
                            newX = currentOffset;
                            newY = this.ActualHeight - this.minimizedRowHeight;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newX = currentOffset;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newX = this.ActualWidth / 2;
                            newY = this.ActualHeight / 2;
                        }
                        #endregion

                        // Animate the position
                        orderedPanels[i].AnimatePosition(
                            newX,
                            newY);

                        if (this.minimizedPosition.Equals(MinimizedPositions.Left) || this.minimizedPosition.Equals(MinimizedPositions.Right))
                        {
                            // Increment current top
                            currentOffset += this.ActualHeight / (double)(this.panels.Count - 1);
                        }
                        else
                        {
                            // Increment current left
                            currentOffset += this.ActualWidth / (double)(this.panels.Count - 1);
                        }
                    }
                    else
                    {
                        #region determine new docking position
                        double newX = 0;
                        double newY = 0;
                        if (this.minimizedPosition.Equals(MinimizedPositions.Right))
                        {
                            newX = 0;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Left))
                        {
                            newX = this.minimizedColumnWidth;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Bottom))
                        {
                            newX = 0;
                            newY = 0;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.Top))
                        {
                            newX = 0;
                            newY = this.minimizedRowHeight;
                        }
                        else if (this.minimizedPosition.Equals(MinimizedPositions.None))
                        {
                            newX = 0;
                            newY = 0;
                        }
                        #endregion
                        // Animate maximized panel
                        orderedPanels[i].AnimatePosition(newX, newY);
                    }
                }
            }
        }
コード例 #25
0
ファイル: DragDockPanelHost.cs プロジェクト: backlune/SPLE
        /// <summary>
        /// Adds a panel to the host.
        /// </summary>
        /// <param name="panel">The panel to add.</param>
        public void AddPanel(DragDockPanel panel)
        {
            Dictionary<int, DragDockPanel> orderedPanels = this.GetOrderedPanels();

            orderedPanels.Add(this.Children.Count, panel);
            this.Children.Add(panel);
            this.PreparePanel(panel);
            this.SetRowsAndColumns(orderedPanels);

            this.AnimatePanelSizes();
            this.AnimatePanelLayout();
        }