Exemplo n.º 1
0
        /// <summary>
        /// Add a panel to the display grid.
        /// </summary>
        private void AddPanelToDisplay(object sender, RoutedEventArgs args)
        {
            GridSplitter     gridSplitter;
            IRegisteredPanel nextPanel = (IRegisteredPanel)sender;

            // Add the next panel
            ((UserControl)nextPanel).SetValue(Grid.RowProperty, ContentAreaGrid.RowDefinitions.Count);
            ContentAreaGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            ContentAreaGrid.Children.Add((UserControl)nextPanel);

            // Add a GridSplitter
            gridSplitter = new GridSplitter()
            {
                Height = 4.0d, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 3, 0, 3), Background = new SolidColorBrush(Colors.Transparent)
            };
            gridSplitter.SetValue(Grid.RowProperty, ContentAreaGrid.RowDefinitions.Count);
            gridSplitter.SetValue(Grid.ColumnProperty, 0);
            ContentAreaGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            ContentAreaGrid.Children.Add(gridSplitter);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Remove a panel from the display grid.
        /// </summary>
        private void RemovePanelFromDisplay(object sender, RoutedEventArgs args)
        {
            // Removed Panel
            IRegisteredPanel removedPanel = (IRegisteredPanel)sender;

            // Remove the Panel
            for (int i = 0; i < ContentAreaGrid.Children.Count; i++)
            {
                if (ContentAreaGrid.Children[i] == sender)
                {
                    // Remove the Panel and the GridSplitter after it
                    ContentAreaGrid.Children.RemoveAt(i);
                    ContentAreaGrid.Children.RemoveAt(i);

                    // Remove two Row Definitions
                    ContentAreaGrid.RowDefinitions.RemoveAt(i);
                    ContentAreaGrid.RowDefinitions.RemoveAt(i);

                    // Re-index the Children's Row Indexes
                    for (int j = 0; j < ContentAreaGrid.Children.Count; j++)
                    {
                        ContentAreaGrid.Children[j].SetValue(Grid.RowProperty, j);
                    }

                    break;
                }
            }

            // Ensure the menu item is unchecked
            for (int i = 0; i < menAvailablePanels.Items.Count; i++)
            {
                System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)menAvailablePanels.Items[i];
                string menuItemLabel = (string)(((Label)(menuItem.Header)).Content);

                if (menuItemLabel.Equals(removedPanel.Title) && menuItem.IsChecked)
                {
                    menuItem.IsChecked = false;
                }
            }
        }