Ejemplo n.º 1
0
        /// <summary>
        /// Pre-create window buttons
        /// </summary>
        private UIElement GenerateWindowButtons()
        {
            // Buttons
            _minimizeButton        = new WindowMinimizeButton();
            _minimizeButton.Click += new RoutedEventHandler(OnButtonMinimize_Click);

            _restoreButton        = new WindowRestoreButton();
            _restoreButton.Click += new RoutedEventHandler(OnButtonRestore_Click);
            _restoreButton.Margin = new Thickness(-1, 0, 0, 0);

            _maximizeButton        = new WindowMaximizeButton();
            _maximizeButton.Click += new RoutedEventHandler(OnButtonMaximize_Click);
            _maximizeButton.Margin = new Thickness(-1, 0, 0, 0);

            _closeButton        = new WindowCloseButton();
            _closeButton.Click += new RoutedEventHandler(OnButtonClose_Click);
            _closeButton.Margin = new Thickness(-1, 0, 0, 0);

            // put buttons into StackPanel
            StackPanel buttonsStackPanel = new StackPanel();

            buttonsStackPanel.Orientation = Orientation.Horizontal;
            buttonsStackPanel.Children.Add(_minimizeButton);
            buttonsStackPanel.Children.Add(_restoreButton);
            buttonsStackPanel.Children.Add(_maximizeButton);
            buttonsStackPanel.Children.Add(_closeButton);

            return(buttonsStackPanel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pre-create window buttons
        /// </summary>
        private UIElement GenerateWindowButtons()
        {
            // Buttons
            _minimizeButton = new WindowMinimizeButton();
            _minimizeButton.Click += new RoutedEventHandler(OnButtonMinimize_Click);

            _restoreButton = new WindowRestoreButton();
            _restoreButton.Click += new RoutedEventHandler(OnButtonRestore_Click);
            _restoreButton.Margin = new Thickness(-1, 0, 0, 0);

            _maximizeButton = new WindowMaximizeButton();
            _maximizeButton.Click += new RoutedEventHandler(OnButtonMaximize_Click);
            _maximizeButton.Margin = new Thickness(-1, 0, 0, 0);

            _closeButton = new WindowCloseButton();
            _closeButton.Click += new RoutedEventHandler(OnButtonClose_Click);
            _closeButton.Margin = new Thickness(-1, 0, 0, 0);

            // put buttons into StackPanel
            StackPanel buttonsStackPanel = new StackPanel();
            buttonsStackPanel.Orientation = Orientation.Horizontal;
            buttonsStackPanel.Children.Add(_minimizeButton);
            buttonsStackPanel.Children.Add(_restoreButton);
            buttonsStackPanel.Children.Add(_maximizeButton);
            buttonsStackPanel.Children.Add(_closeButton);

            return buttonsStackPanel;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Pre-defined controls of the window
        /// </summary>
        protected void InitializeContentControls()
        {
            this.WindowStyle = WindowStyle.None;
            base.Background  = Brushes.Transparent;

            //
            // Buttons
            _minimizeButton        = new WindowMinimizeButton();
            _minimizeButton.Click += new RoutedEventHandler(OnButtonMinimize_Click);

            _restoreButton        = new WindowRestoreButton();
            _restoreButton.Click += new RoutedEventHandler(OnButtonRestore_Click);
            _restoreButton.Margin = new Thickness(-1, 0, 0, 0);

            _maximizeButton        = new WindowMaximizeButton();
            _maximizeButton.Click += new RoutedEventHandler(OnButtonMaximize_Click);
            _maximizeButton.Margin = new Thickness(-1, 0, 0, 0);

            _closeButton        = new WindowCloseButton();
            _closeButton.Click += new RoutedEventHandler(OnButtonClose_Click);
            _closeButton.Margin = new Thickness(-1, 0, 0, 0);

            // put buttons into StackPanel
            StackPanel buttonsStackPanel = new StackPanel();

            buttonsStackPanel.Orientation = Orientation.Horizontal;
            buttonsStackPanel.Children.Add(_minimizeButton);
            buttonsStackPanel.Children.Add(_restoreButton);
            buttonsStackPanel.Children.Add(_maximizeButton);
            buttonsStackPanel.Children.Add(_closeButton);

            // put stack into border
            Border buttonsBorder = new Border();

            buttonsBorder.BorderThickness = new Thickness(0, 1, 0, 0);
            buttonsBorder.BorderBrush     = new SolidColorBrush(new Color()
            {
                R = 118, G = 124, B = 132, A = 255
            });
            buttonsBorder.VerticalAlignment   = VerticalAlignment.Top;
            buttonsBorder.Child               = buttonsStackPanel;
            buttonsBorder.VerticalAlignment   = VerticalAlignment.Top;
            buttonsBorder.HorizontalAlignment = HorizontalAlignment.Right;

            //
            // Caption
            _captionControl                      = new Border();
            _captionControl.MouseMove           += new System.Windows.Input.MouseEventHandler(OnWindowDragMove);
            _captionControl.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(OnCaptionBarClick);
            DockPanel.SetDock(_captionControl, Dock.Top);

            //
            // Window
            _contentWindowBackgroundBorder            = new Border();
            _contentWindowBackgroundBorder.Background = Brushes.White;

            DockPanel windowDockPanel = new DockPanel();

            windowDockPanel.Children.Add(_captionControl);
            windowDockPanel.Children.Add(_contentWindowBackgroundBorder);

            // all wrap into grid
            _contentWindowBorder = new Border();

            Grid topGrid = new Grid();

            topGrid.Children.Add(windowDockPanel);
            topGrid.Children.Add(_contentWindowBorder);
            topGrid.Children.Add(buttonsBorder);

            base.Content = topGrid;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Pre-defined controls of the window
        /// </summary>
        protected void InitializeContentControls()
        {
            this.WindowStyle = WindowStyle.None;
            base.Background = Brushes.Transparent;

            //
            // Buttons
            _minimizeButton = new WindowMinimizeButton();
            _minimizeButton.Click += new RoutedEventHandler(OnButtonMinimize_Click);

            _restoreButton = new WindowRestoreButton();
            _restoreButton.Click += new RoutedEventHandler(OnButtonRestore_Click);
            _restoreButton.Margin = new Thickness(-1, 0, 0, 0);

            _maximizeButton = new WindowMaximizeButton();
            _maximizeButton.Click += new RoutedEventHandler(OnButtonMaximize_Click);
            _maximizeButton.Margin = new Thickness(-1, 0, 0, 0);

            _closeButton = new WindowCloseButton();
            _closeButton.Click += new RoutedEventHandler(OnButtonClose_Click);
            _closeButton.Margin = new Thickness(-1, 0, 0, 0);

            // put buttons into StackPanel
            StackPanel buttonsStackPanel = new StackPanel();
            buttonsStackPanel.Orientation = Orientation.Horizontal;
            buttonsStackPanel.Children.Add(_minimizeButton);
            buttonsStackPanel.Children.Add(_restoreButton);
            buttonsStackPanel.Children.Add(_maximizeButton);
            buttonsStackPanel.Children.Add(_closeButton);

            // put stack into border
            Border buttonsBorder = new Border();
            buttonsBorder.BorderThickness = new Thickness(0, 1, 0, 0);
            buttonsBorder.BorderBrush = new SolidColorBrush(new Color() { R = 118, G = 124, B = 132, A = 255 });
            buttonsBorder.VerticalAlignment = VerticalAlignment.Top;
            buttonsBorder.Child = buttonsStackPanel;
            buttonsBorder.VerticalAlignment = VerticalAlignment.Top;
            buttonsBorder.HorizontalAlignment = HorizontalAlignment.Right;

            //
            // Caption
            _captionControl = new Border();
            _captionControl.MouseMove += new System.Windows.Input.MouseEventHandler(OnWindowDragMove);
            _captionControl.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(OnCaptionBarClick);
            DockPanel.SetDock(_captionControl, Dock.Top);

            //
            // Window
            _contentWindowBackgroundBorder = new Border();
            _contentWindowBackgroundBorder.Background = Brushes.White;
            
            DockPanel windowDockPanel = new DockPanel();
            windowDockPanel.Children.Add(_captionControl);
            windowDockPanel.Children.Add(_contentWindowBackgroundBorder);

            // all wrap into grid
            _contentWindowBorder = new Border();

            Grid topGrid = new Grid();
            topGrid.Children.Add(windowDockPanel);
            topGrid.Children.Add(_contentWindowBorder);
            topGrid.Children.Add(buttonsBorder);

            base.Content = topGrid;
        }