예제 #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Dynamically adds a menu item to a context menu.
        /// </summary>
        /// <param name="owner">The owner of the context menu.</param>
        /// <param name="menu">The menu to update.</param>
        internal static void AddCustomMenuItem(object owner, RibbonControls.Menu menu)
        {
            string customButtonLabel = "Programmatically-Added Menu Item";

            // Determine if there is a Custom menu item already in the menu
            bool hasCustomItem = false;

            foreach (object childObj in menu.Items)
            {
                if ((childObj is RibbonControls.Button) && (((RibbonControls.Button)childObj).Label == customButtonLabel))
                {
                    hasCustomItem = true;
                    break;
                }
            }

            // If the custom item hasn't been added to this context menu...
            if (!hasCustomItem)
            {
                // Add a separator and a custom button... normally the button would have a command assigned too
                menu.Items.Add(new RibbonControls.Separator());
                RibbonControls.Button newButton = new RibbonControls.Button();
                newButton.Label  = customButtonLabel;
                newButton.Click += new EventHandler <RibbonControls.ExecuteRoutedEventArgs>(OnCustomMenuItemClicked);
                newButton.Tag    = new WeakReference(owner);
                menu.Items.Add(newButton);
            }
        }
예제 #2
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs before a popup is opened.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnPopupButtonPopupOpening(object sender, RoutedEventArgs e)
        {
            // Insert random content into the popup
            RibbonControls.PopupButton popupOwner = (RibbonControls.PopupButton)sender;
            if (new Random().NextDouble() < 0.65)
            {
                // Create a menu
                RibbonControls.Menu menu = new RibbonControls.Menu();
                for (int index = 0; index < 3; index++)
                {
                    RibbonControls.Button button = new RibbonControls.Button();
                    button.Label = String.Format("Dynamically created menu item #{0}, created at {1}", index + 1, DateTime.Now);
                    menu.Items.Add(button);
                }
                popupOwner.PopupContent = menu;
            }
            else
            {
                // Create alternate content, the Actipro logo
                StackPanel panel = new StackPanel();
                panel.Children.Add(new TextBlock(new Run("Anything can be placed in a popup")));
                panel.Children.Add(new ActiproSoftware.Windows.Controls.ActiproLogo());
                popupOwner.PopupContent = panel;
            }
        }
예제 #3
0
        /// <summary>
        /// Occurs when the <see cref="RoutedCommand"/> is executed.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RibbonControls.ExecuteRoutedEventArgs"/> that contains the event data.</param>
        private static void OnCustomMenuItemClicked(object sender, RibbonControls.ExecuteRoutedEventArgs e)
        {
            e.Handled = true;
            RibbonControls.Button button   = (RibbonControls.Button)sender;
            WeakReference         ownerRef = (WeakReference)button.Tag;

            MessageBox.Show(String.Format("You clicked the programmatically-added menu item for: {0}", ownerRef.Target));
        }
        /// <summary>
        /// Updates the spell check context menu items.
        /// </summary>
        private void UpdateSpellCheckContextMenuItems()
        {
            // Process items for spell-checking if SpellCheck.IsEnabled = true
            if ((this.ContextMenu != null) && (this.ContextMenu.ItemsSource == null))
            {
                RibbonControls.Menu menu = null;
                if (this.ContextMenu.Items.Count > 0)
                {
                    // Get an existing menu
                    menu = this.ContextMenu.Items[0] as RibbonControls.Menu;
                    if ((menu != null) && (!"SpellingErrors".Equals(menu.Tag)))
                    {
                        menu = null;
                    }
                }

                if (menu != null)
                {
                    // Clear the items
                    menu.Items.Clear();
                }
                else
                {
                    // Create a new menu
                    menu     = new RibbonControls.Menu();
                    menu.Tag = "SpellingErrors";
                    this.ContextMenu.Items.Insert(0, menu);
                }

                // If spell check is enabled...
                if (this.SpellCheck.IsEnabled)
                {
                    // Get the spelling error at the caret
                    SpellingError error = this.GetSpellingError(this.CaretPosition);
                    if (error != null)
                    {
                        // Add suggestion items
                        foreach (string suggestion in error.Suggestions)
                        {
                            RibbonControls.Button button = new RibbonControls.Button();
                            button.Command          = EditingCommands.CorrectSpellingError;
                            button.CommandParameter = suggestion;
                            button.Label            = suggestion;
                            menu.Items.Add(button);
                        }

                        // Add separator
                        if (menu.Items.Count > 0)
                        {
                            menu.Items.Add(new RibbonControls.Separator());
                        }
                    }
                }

                // Update visibility
                menu.Visibility = (this.SpellCheck.IsEnabled && (menu.Items.Count > 0) ? Visibility.Visible : Visibility.Collapsed);
            }
        }
예제 #5
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates a random child control.
        /// </summary>
        /// <param name="seed">The seed for the random generator.</param>
        private Control CreateRandomChildControl(int seed)
        {
            string[] commonLabels = new string[] { "Blank Page", "Bookmark", "Chart", "Cover Page", "Cross Reference", "Drop-Cap", "Equation", "Footer", "Header" };
            int      randomIndex  = Math.Min(commonLabels.Length - 1, (int)Math.Floor(new Random(seed * DateTime.Now.Millisecond).NextDouble() * commonLabels.Length));

            string label           = commonLabels[randomIndex];
            string imageSourceBase = "/Images/Icons/" + commonLabels[randomIndex].Replace(" ", String.Empty).Replace("-", String.Empty);

            RibbonControls.Button button = new RibbonControls.Button();
            button.Label            = label;
            button.ImageSourceSmall = new BitmapImage(new Uri(imageSourceBase + "16.png", UriKind.Relative));
            button.ImageSourceLarge = new BitmapImage(new Uri(imageSourceBase + "32.png", UriKind.Relative));

            return(button);
        }
예제 #6
0
		void IComponentConnector.Connect(int connectionId, object target)
		{
			switch (connectionId)
			{
				case 1:
					button_0 = (ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target;
					button_0.Click += new EventHandler<ExecuteRoutedEventArgs>(method9);
					break;
				case 2:
					((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(buttonOpen_Click);
					break;
				case 3:
					((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(buttonSave_Click);
					break;
				case 4:
					((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(buttonReanalyze_Click);
					break;
				case 5:
					((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(buttonWheel_Click);
					break;
				case 6:
					this.group_0 = (Group)target;
					break;
				case 7:
					((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(method2);
					break;
				case 8:
					this.dockSite = (DockSite)target;
					break;
				case 9:
					this.toolWindow = (ToolWindow)target;
					break;
				case 10:
					this.noScrollTreeView = (NoScrollTreeView)target;
					break;
				case 11:
					this.toolWindow1 = (ToolWindow)target;
					break;
				case 12:
					this.toolWindow2 = (ToolWindow)target;
					break;
				case 13:
					this.toolWindow3 = (ToolWindow)target;
					break;
				case 14:
					((System.Windows.Controls.Button)target).Click += button0_Click;
					break;
				case 15:
					((System.Windows.Controls.Button)target).Click += button1_Click;
					break;
				case 16:
					((System.Windows.Controls.Button)target).Click += button2_Click;
					break;
				case 17:
					((System.Windows.Controls.Button)target).Click += button3_Click;
					break;
				case 18:
					((System.Windows.Controls.Button)target).Click += button4_Click;
					break;
				default:
					this._isInitialized = true;
					break;
			}
		}
예제 #7
0
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.button_0        = (ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target;
                this.button_0.Click += new EventHandler <ExecuteRoutedEventArgs>(this.method_9);
                break;

            case 2:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(this.method_11);
                break;

            case 3:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(this.method_12);
                break;

            case 4:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(this.method_13);
                break;

            case 5:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(this.method_15);
                break;

            case 6:
                this.group_0 = (Group)target;
                break;

            case 7:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(this.method_2);
                break;

            case 8:
                this.dockSite_0 = (DockSite)target;
                break;

            case 9:
                this.toolWindow_0 = (ToolWindow)target;
                break;

            case 10:
                this.noScrollTreeView_0 = (NoScrollTreeView)target;
                break;

            case 11:
                this.toolWindow_1 = (ToolWindow)target;
                break;

            case 12:
                this.toolWindow_2 = (ToolWindow)target;
                break;

            case 13:
                this.toolWindow_3 = (ToolWindow)target;
                break;

            case 14:
                ((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_4);
                break;

            case 15:
                ((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_5);
                break;

            case 16:
                ((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_8);
                break;

            case 17:
                ((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_6);
                break;

            case 18:
                ((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_7);
                break;

            default:
                this.bool_1 = true;
                break;
            }
        }
예제 #8
0
		void IComponentConnector.Connect(int connectionId, object target)
		{
			switch (connectionId)
			{
			case 1:
				this.button_0 = (ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target;
				this.button_0.Click += new EventHandler<ExecuteRoutedEventArgs>(this.method_9);
				break;
			case 2:
				((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(this.method_11);
				break;
			case 3:
				((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(this.method_12);
				break;
			case 4:
				((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(this.method_13);
				break;
			case 5:
				((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(this.method_15);
				break;
			case 6:
				this.group_0 = (Group)target;
				break;
			case 7:
				((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler<ExecuteRoutedEventArgs>(this.method_2);
				break;
			case 8:
				this.dockSite_0 = (DockSite)target;
				break;
			case 9:
				this.toolWindow_0 = (ToolWindow)target;
				break;
			case 10:
				this.noScrollTreeView_0 = (NoScrollTreeView)target;
				break;
			case 11:
				this.toolWindow_1 = (ToolWindow)target;
				break;
			case 12:
				this.toolWindow_2 = (ToolWindow)target;
				break;
			case 13:
				this.toolWindow_3 = (ToolWindow)target;
				break;
			case 14:
				((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_4);
				break;
			case 15:
				((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_5);
				break;
			case 16:
				((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_8);
				break;
			case 17:
				((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_6);
				break;
			case 18:
				((System.Windows.Controls.Button)target).Click += new RoutedEventHandler(this.method_7);
				break;
			default:
				this.bool_1 = true;
				break;
			}
		}
예제 #9
0
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                button_0        = (ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target;
                button_0.Click += new EventHandler <ExecuteRoutedEventArgs>(method9);
                break;

            case 2:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(buttonOpen_Click);
                break;

            case 3:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(buttonSave_Click);
                break;

            case 4:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(buttonReanalyze_Click);
                break;

            case 5:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(buttonWheel_Click);
                break;

            case 6:
                this.group_0 = (Group)target;
                break;

            case 7:
                ((ActiproSoftware.Windows.Controls.Ribbon.Controls.Button)target).Click += new EventHandler <ExecuteRoutedEventArgs>(method2);
                break;

            case 8:
                this.dockSite = (DockSite)target;
                break;

            case 9:
                this.toolWindow = (ToolWindow)target;
                break;

            case 10:
                this.noScrollTreeView = (NoScrollTreeView)target;
                break;

            case 11:
                this.toolWindow1 = (ToolWindow)target;
                break;

            case 12:
                this.toolWindow2 = (ToolWindow)target;
                break;

            case 13:
                this.toolWindow3 = (ToolWindow)target;
                break;

            case 14:
                ((System.Windows.Controls.Button)target).Click += button0_Click;
                break;

            case 15:
                ((System.Windows.Controls.Button)target).Click += button1_Click;
                break;

            case 16:
                ((System.Windows.Controls.Button)target).Click += button2_Click;
                break;

            case 17:
                ((System.Windows.Controls.Button)target).Click += button3_Click;
                break;

            case 18:
                ((System.Windows.Controls.Button)target).Click += button4_Click;
                break;

            default:
                this._isInitialized = true;
                break;
            }
        }
예제 #10
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs when a screen tip is opening.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnScreenTipOpening(object sender, RoutedEventArgs e)
        {
            // Dynamically generate the screen tip description here
            RibbonControls.Button button = (RibbonControls.Button)sender;
            button.ScreenTipDescription = "This description was generated dynamically at " + DateTime.Now.ToString() + ".";
        }