예제 #1
0
    private static void CloseApplicationExecuted(object sender, ExecutedRoutedEventArgs args)
    {
        RibbonWindow window = sender as RibbonWindow;

        if (window != null)
        {
            MessageBox.Show("Not closing 2!");
            args.Handled = true;
        }
    }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the DiagramVM class.
 /// </summary>
 public ThemeStyleViewModel(RibbonWindow demo)
 {
     View = demo;
     //Initialize the Nodes collection.
     this.Nodes = new ObservableCollection <NodeViewModel>();
     //Initialize the Connectors collection
     this.Connectors = new ObservableCollection <ConnectorViewModel>();
     AddNodes();
     AddConnectors();
 }
        private static void RestoreWindowCanExecute(object sender, CanExecuteRoutedEventArgs args)
        {
            RibbonWindow rw = sender as RibbonWindow;

            if (rw != null &&
                rw.WindowState != WindowState.Normal)
            {
                args.CanExecute = true;
            }
        }
예제 #4
0
        /// <summary>
        ///   Callback for mouse down.  Captures/Releases the mouse depending on whether
        ///   the tab group was clicked.
        /// </summary>
        /// <param name="e">The event data.</param>
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            if (e.ClickCount == 1 || e.ChangedButton == MouseButton.Right)
            {
                this.CaptureMouse();
                if (this.IsMouseCaptured)
                {
                    // Though we have already checked this state, our call to CaptureMouse
                    // could also end up changing the state, so we check it again.
                    if (e.ButtonState != MouseButtonState.Pressed)
                    {
                        // Release capture since we decided not to press the button.
                        this.ReleaseMouseCapture();
                    }
                }
                e.Handled = true;
            }
            else if (e.ClickCount == 2 && e.ChangedButton == MouseButton.Left)
            {
                // On DoubleClick maximize/restore the window
                RibbonWindow ribbonWindow = Window.GetWindow(this) as RibbonWindow;
                if (ribbonWindow != null)
                {
#if RIBBON_IN_FRAMEWORK
                    if (SystemCommands.MaximizeWindowCommand.CanExecute(null, ribbonWindow))
                    {
                        SystemCommands.MaximizeWindowCommand.Execute(/*parameter*/ null, /* target*/ ribbonWindow);
                        e.Handled = true;
                    }
                    else if (SystemCommands.RestoreWindowCommand.CanExecute(null, ribbonWindow))
                    {
                        SystemCommands.RestoreWindowCommand.Execute(/*parameter*/ null, /* target*/ ribbonWindow);
                        e.Handled = true;
                    }
#else
                    if (Microsoft.Windows.Shell.SystemCommands.MaximizeWindowCommand.CanExecute(null, ribbonWindow))
                    {
                        Microsoft.Windows.Shell.SystemCommands.MaximizeWindowCommand.Execute(/*parameter*/ null, /* target*/ ribbonWindow);
                        e.Handled = true;
                    }
                    else if (Microsoft.Windows.Shell.SystemCommands.RestoreWindowCommand.CanExecute(null, ribbonWindow))
                    {
                        Microsoft.Windows.Shell.SystemCommands.RestoreWindowCommand.Execute(/*parameter*/ null, /* target*/ ribbonWindow);
                        e.Handled = true;
                    }
#endif
                }
            }

            base.OnMouseDown(e);
        }
        private static void CloseWindowExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            RibbonWindow rw = sender as RibbonWindow;

            if (rw != null)
            {
#if RIBBON_IN_FRAMEWORK
                SystemCommands.CloseWindow(rw);
#else
                Microsoft.Windows.Shell.SystemCommands.CloseWindow(rw);
#endif
                args.Handled = true;
            }
        }
예제 #6
0
        /// <summary>
        /// Updates the <see cref="RibbonWindow.DocumentName"/> property.
        /// </summary>
        private void UpdateDocumentName()
        {
            RibbonWindow window = (RibbonWindow)ActiproSoftware.Windows.Media.VisualTreeHelperExtended.GetAncestor(this, typeof(RibbonWindow));

            if (window != null)
            {
                if (currentDocumentData != null)
                {
                    window.DocumentName = currentDocumentData.FilenameWithoutExtension;
                }
                else
                {
                    window.DocumentName = null;
                }
            }
        }
        public static void SaveState(RibbonWindow ribbonWindow, Ribbon ribbon)
        {
            #region Create the QuickAccessToolbarButtonCollection
            QuickAccessToolbarButtonCollection buttons = new QuickAccessToolbarButtonCollection();
            foreach (RibbonButton rButton in ribbon.QuickAccessToolBar.Items)
            {
                QuickAccessToolbarButton qaButton = new QuickAccessToolbarButton()
                {
                    Label  = rButton.Label,
                    KeyTip = rButton.KeyTip,
                    //ToolTip = rButton.ToolTip,
                    ToolTipDescription = rButton.ToolTipDescription,
                    //QuickAccessToolBarId = rButton.QuickAccessToolBarId,
                    Name = rButton.Name,
                    //CommandBinding = BindingOperations.GetBinding(rButton, RibbonButton.CommandProperty)
                };

                if (string.IsNullOrEmpty(qaButton.Name) && rButton.QuickAccessToolBarId is string)
                {
                    qaButton.Name = rButton.QuickAccessToolBarId as string;
                }

                if (rButton.LargeImageSource != null)
                {
                    qaButton.LargeImageSource = rButton.LargeImageSource.ToString();
                }
                if (rButton.SmallImageSource != null)
                {
                    qaButton.SmallImageSource = rButton.SmallImageSource.ToString();
                }

                buttons.Add(qaButton);
            }
            #endregion

            Settings.Current.RibbonIsMinimized           = ribbon.IsMinimized;
            Settings.Current.ShowQuickAccessToolBarOnTop = ribbon.ShowQuickAccessToolBarOnTop;

            XmlSerializer bf = new XmlSerializer(typeof(QuickAccessToolbarButtonCollection));
            using (StringWriter sw = new StringWriter())
            {
                bf.Serialize(sw, buttons);

                Settings.Current.RibbonQuickAccessToolBar = sw.ToString();
            }
        }
예제 #8
0
        /// <summary>
        /// Method to execute backStageExitCommand.
        /// </summary>
        /// <param name="parameter">Specifies the object parameter.</param>
        private void ExecuteBackStageExitCommand(object parameter)
        {
            Touch touchDemosView = parameter as Touch;

            if (touchDemosView != null)
            {
                touchDemosView.Close();
            }
            else if ((ribbon.Parent as FrameworkElement).Parent as RibbonWindow != null)
            {
                RibbonWindow window = (ribbon.Parent as FrameworkElement).Parent as RibbonWindow;
                if (window != null)
                {
                    window.Close();
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Method to execute backStageExitCommand.
        /// </summary>
        /// <param name="parameter">Specifies the object parameter.</param>
        public void ExecuteBackStageExitCommand(object parameter)
        {
            ModelTab modelTabDemosView = parameter as ModelTab;

            if (modelTabDemosView != null)
            {
                modelTabDemosView.Close();
            }
            else if ((ribbon.Parent as FrameworkElement).Parent as RibbonWindow != null)
            {
                RibbonWindow window = (ribbon.Parent as FrameworkElement).Parent as RibbonWindow;
                if (window != null)
                {
                    window.Close();
                }
            }
        }
예제 #10
0
        /// <summary>
        ///   Callback for mouse up, releases mouse capture and sends click notifications.
        /// </summary>
        /// <param name="e">The event data.</param>
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            if (this.IsMouseCaptured)
            {
                this.ReleaseMouseCapture();
                if (IsMouseOver)
                {
                    if (e.ChangedButton == MouseButton.Left && this.Ribbon != null)
                    {
                        // Selects the first tab in this contextual group.
                        this.Ribbon.NotifyMouseClickedOnContextualTabGroup(this);
                        e.Handled = true;
                    }
                    else if (e.ChangedButton == MouseButton.Right)
                    {
                        // Show SystemMenu
                        RibbonWindow ribbonWindow = Window.GetWindow(this) as RibbonWindow;
                        if (ribbonWindow != null)
                        {
#if RIBBON_IN_FRAMEWORK
                            if (SystemCommands.ShowSystemMenuCommand.CanExecute(null, ribbonWindow))
                            {
                                SystemCommands.ShowSystemMenuCommand.Execute(/*parameter*/ null, /* target*/ ribbonWindow);
                                e.Handled = true;
                            }
#else
                            if (Microsoft.Windows.Shell.SystemCommands.ShowSystemMenuCommand.CanExecute(null, ribbonWindow))
                            {
                                Microsoft.Windows.Shell.SystemCommands.ShowSystemMenuCommand.Execute(/*parameter*/ null, /* target*/ ribbonWindow);
                                e.Handled = true;
                            }
#endif
                        }
                    }
                }
            }

            base.OnMouseUp(e);
        }
        private static void SystemMenuExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            RibbonWindow rw = sender as RibbonWindow;

            if (rw != null)
            {
                // For right-clicks, display the system menu from the point of the mouse click.
                // For left-clicks, display the system menu in the top-left corner of the client area.
                Point devicePoint;
                MouseButtonEventArgs e = args.Parameter as MouseButtonEventArgs;
                if (e != null)
                {
                    // This is the right-click handler.  The presence of a MouseButtonEventArgs as args.Parameter
                    // indicates we are handling right-click.
                    devicePoint = rw.PointToScreen(e.GetPosition(rw));
                }
                else if (rw._clientAreaBorder != null)
                {
                    // This is the left-click handler.  We can only handle it correctly if the _clientAreaBorder
                    // template part is defined, because that is where we want to position the system menu.
                    devicePoint = rw._clientAreaBorder.PointToScreen(new Point(0, 0));
                }
                else
                {
                    // We can't handle this correctly, so exit.
                    return;
                }

                CompositionTarget compositionTarget = PresentationSource.FromVisual(rw).CompositionTarget;
#if RIBBON_IN_FRAMEWORK
                SystemCommands.ShowSystemMenu(rw, compositionTarget.TransformFromDevice.Transform(devicePoint));
#else
                Microsoft.Windows.Shell.SystemCommands.ShowSystemMenu(rw, compositionTarget.TransformFromDevice.Transform(devicePoint));
#endif
                args.Handled = true;
            }
        }
예제 #12
0
        public static void LoadState(RibbonWindow ribbonWindow, Ribbon ribbon)
        {
            ribbon.IsMinimized = Settings.Current.RibbonIsMinimized;
            ribbon.ShowQuickAccessToolBarOnTop = Settings.Current.ShowQuickAccessToolBarOnTop;
            #region Load the QuickAccessToolbarButtonCollection
            try
            {
                if (!string.IsNullOrEmpty(Settings.Current.RibbonQuickAccessToolBar))
                {
                    QuickAccessToolbarButtonCollection buttons = null;

                    XmlSerializer bf = new XmlSerializer(typeof(QuickAccessToolbarButtonCollection));
                    using (StringReader sr = new StringReader(Settings.Current.RibbonQuickAccessToolBar))
                    {
                        buttons = (QuickAccessToolbarButtonCollection)bf.Deserialize(sr);
                    }

                    if (buttons != null)
                    {
                        foreach (QuickAccessToolbarButton qaButton in buttons)
                        {
                            RibbonButton ribbonElem = ribbonWindow.FindName(qaButton.Name) as RibbonButton;

                            RibbonButton rButton = new RibbonButton()
                            {
                                Label  = qaButton.Label,
                                KeyTip = qaButton.KeyTip,
                                //ToolTip = qaButton.ToolTip,
                                ToolTipDescription   = qaButton.ToolTipDescription,
                                QuickAccessToolBarId = qaButton.QuickAccessToolBarId,
                                Name = qaButton.Name
                            };

                            if (!string.IsNullOrEmpty(qaButton.LargeImageSource))
                            {
                                rButton.LargeImageSource = new BitmapImage(new Uri(qaButton.LargeImageSource));
                            }
                            if (!string.IsNullOrEmpty(qaButton.SmallImageSource))
                            {
                                rButton.SmallImageSource = new BitmapImage(new Uri(qaButton.SmallImageSource));
                            }

                            if (ribbonElem != null && ribbonElem.Command != null)
                            {
                                rButton.Command = ribbonElem.Command;
                            }
                            else
                            {
                                // Noch im Applicationmenü suchen
                                RibbonApplicationMenuItem ribbonMenuItem = ribbon.ApplicationMenu.FindName(qaButton.Name) as RibbonApplicationMenuItem;

                                if (ribbonMenuItem != null)
                                {
                                    rButton.Command = ribbonMenuItem.Command;
                                }
                            }
                            ribbon.QuickAccessToolBar.Items.Add(rButton);
                        }
                    }
                }
            }
            catch
            {
                // Ignorieren, falls die Toolbar nicht geladen werden kann.
            }
            #endregion
        }
예제 #13
0
 /// <summary>
 /// Creates a new instance and binds it to <paramref name="window"/>
 /// </summary>
 public WindowSizing(RibbonWindow window)
 {
     this.window = window;
 }
예제 #14
0
        private void ribbonUXToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RibbonWindow ribbonWindow = new RibbonWindow();

            ribbonWindow.Show();
        }
예제 #15
0
        /// <summary>
        /// Creates a new instance and binds it to <paramref name="window"/>
        /// </summary>
        public WindowSizing(RibbonWindow window)
        {
            this.window = window;

            this.window.StateChanged += this.HandleWindowStateChanged;
        }
예제 #16
0
        /// <summary>
        /// Creates a new instance and binds it to <paramref name="window"/>
        /// </summary>
        public WindowSizing(RibbonWindow window)
        {
            this.window = window;

            this.window.StateChanged += this.HandleWindowStateChanged;
        }
        private static void OnTitleChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RibbonWindow rw = d as RibbonWindow;

            rw.OnTitleChanged(null);
        }