Beispiel #1
0
 /// <summary>
 ///		Called when a combo box is changed that will fire the events.
 /// </summary>
 /// <param name="window">The window holding the combo box that was changed.</param>
 internal void OnChange(OfficeWindow window)
 {
     if (Change != null)
     {
         Change(this, window);
     }
 }
Beispiel #2
0
        /// <summary>
        ///		Hears button clicks for any custom CommandBarComboBox.
        ///		<seealso cref="Microsoft.Office._CommandBarComboBoxEvents_ChangeEventHandler"/>
        /// </summary>
        /// <param name="Ctrl">The combo box that was changed.</param>
        private void combo_Change(CommandBarComboBox Ctrl)
        {
            ToolbarComboBox control = (ToolbarComboBox)controlControlMap[Ctrl.Tag];
            OfficeWindow    window  = (OfficeWindow)controlWindowMap[Ctrl.Tag];

            control.OnChange(window);
        }
Beispiel #3
0
        /// <summary>
        ///		Applies the toolbars to the given window.
        /// </summary>
        /// <param name="window">The window to apply to.</param>
        internal void Apply(OfficeWindow window)
        {
            CommandBars bars = window.CommandBars;

            foreach (Toolbar toolbar in toolbars.Values)
            {
                CommandBar commandbar = null;
                try
                {
                    commandbar = bars[toolbar.Caption];
                }
                catch
                {
                }
                if (commandbar == null)
                {
                    commandbar = bars.Add(toolbar.Caption, toolbar.Position, false, true);
                }
                else
                {
                }
                toolbar.Apply(window, commandbar);
                manager.RegisterCommandBar(commandbar, window, toolbar);
            }
        }
Beispiel #4
0
        /// <summary>
        ///		Hears button clicks for any custom CommandBarButtons.
        ///		<seealso cref="Microsoft.Office._CommandBarButtonEvents_ClickEventHandler"/>
        /// </summary>
        /// <param name="Ctrl">The control that was clicked.</param>
        /// <param name="CancelDefault">Whether to cancel the default action.</param>
        private void button_Click(CommandBarButton Ctrl, ref bool CancelDefault)
        {
            ToolbarButton control = (ToolbarButton)controlControlMap[Ctrl.Tag];
            OfficeWindow  window  = (OfficeWindow)controlWindowMap[Ctrl.Tag];

            control.OnClick(window);
        }
Beispiel #5
0
 /// <summary>
 ///		Called when a CommandBarButton created from this control is clicked. Fires
 ///		the event.
 /// </summary>
 /// <param name="window">The window holding the control that was clicked.</param>
 internal void OnClick(OfficeWindow window)
 {
     if (Click != null)
     {
         Click(this, window);
     }
 }
Beispiel #6
0
        /// <summary>
        ///		Occurs when a new window has been opened.
        /// </summary>
        /// <remarks>
        ///		Applies the necessary user interface to the window.
        /// </remarks>
        /// <param name="window">The window that has just opened.</param>
        protected void OnWindowOpen(OfficeWindow window)
        {
            Toolbars bars = GetWindowToolbars(window);

            bars.Apply(window);
            if (WindowOpen != null)
            {
                WindowOpen(window);
            }
        }
Beispiel #7
0
 public override bool GetValue(OfficeWindow window)
 {
     foreach (BooleanValue value in values)
     {
         if (value.GetValue(window))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #8
0
 /// <summary>
 ///		Applies combo box specific settings to the control.
 /// </summary>
 /// <param name="window">The window holding the control.</param>
 /// <param name="control">The control proxy.</param>
 private void InternalApply(OfficeWindow window, CommandBarComboBox control)
 {
     control.Style           = style;
     control.DropDownLines   = dropDownLines;
     control.DropDownWidth   = dropDownWidth;
     control.ListHeaderCount = headerCount;
     control.Clear();
     foreach (string item in items)
     {
         control.AddItem(item, System.Reflection.Missing.Value);
     }
 }
Beispiel #9
0
        /// <summary>
        ///		Returns the proxy object in the given window.
        /// </summary>
        /// <param name="window">The window to search through.</param>
        /// <returns>A CommandBarControl that was created from this control on the given window.</returns>
        public CommandBarControl GetCommandBarControl(OfficeWindow window)
        {
            CommandBarControls controls = Parent.FindCommandBarControls(window);

            foreach (CommandBarControl control in controls)
            {
                if (control.Tag.StartsWith(InternalTag + "#"))
                {
                    return(control);
                }
            }
            return(null);
        }
Beispiel #10
0
        /// <summary>
        ///		Finds the CommandBar in the windows that was created from this toolbar.
        /// </summary>
        /// <param name="window">The Window to look in.</param>
        /// <returns>The found CommandBar.</returns>
        public CommandBar GetCommandBar(OfficeWindow window)
        {
            CommandBars bars = window.CommandBars;

            try
            {
                CommandBar bar = bars[Caption];
                return(bar);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #11
0
 /// <summary>
 ///		Applies settings to the control proxy.
 /// </summary>
 /// <param name="window">The window holding the proxy.</param>
 /// <param name="control">The control proxy.</param>
 internal virtual void Apply(OfficeWindow window, CommandBarControl control)
 {
     control.Caption    = caption;
     control.Visible    = visible.GetValue(window);
     control.Enabled    = enabled.GetValue(window);
     control.Priority   = priority;
     control.BeginGroup = beginGroup;
     if (tip != null)
     {
         control.TooltipText = tip;
     }
     else
     {
         control.TooltipText = caption;
     }
 }
Beispiel #12
0
        /// <summary>
        ///		Registers a new command bar control.
        /// </summary>
        /// <remarks>
        ///		The UI manager will begin listening out for events happening to this control
        ///		and dispatch them to the correct listeners.
        /// </remarks>
        /// <param name="control">The CommandBarControl created.</param>
        /// <param name="window">The OfficeWindow holding the control.</param>
        /// <param name="tcontrol">The ToolbarControl that the control was created from.</param>
        internal void RegisterCommandBarControl(CommandBarControl control, OfficeWindow window, ToolbarControl tcontrol)
        {
            if (!controlControlMap.Contains(control.Tag))
            {
                controlControlMap[control.Tag] = tcontrol;
            }
            else
            {
                CommandBarControl oldcontrol = (CommandBarControl)controlProxyMap[control.Tag];
                UnbindControl(oldcontrol);
#if (COMRELEASE)
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oldcontrol);
#endif
            }
            BindControl(control);
            controlProxyMap[control.Tag]  = control;
            controlWindowMap[control.Tag] = window;
        }
Beispiel #13
0
        /// <summary>
        ///		Applies this menu to the given CommandBarControls.
        /// </summary>
        /// <param name="window">The window holding the controls.</param>
        /// <param name="controls">The control set to apply to.</param>
        protected void Apply(OfficeWindow window, CommandBarControls controls)
        {
            IList toadd = new ArrayList(this.controls);

            foreach (CommandBarControl control in controls)
            {
                if (control.Tag.StartsWith("UIManager_"))
                {
                    string         thetag   = control.Tag.Substring(0, control.Tag.IndexOf("#"));
                    ToolbarControl tcontrol = (ToolbarControl)controlMap[thetag];
                    if (tcontrol != null)
                    {
                        tcontrol.Apply(window, control);
                        OfficeUIManager.RegisterCommandBarControl(control, window, tcontrol);
                        toadd.Remove(tcontrol);
                    }
                }
            }
            foreach (ToolbarControl tcontrol in toadd)
            {
                object newpos = System.Reflection.Missing.Value;
                if (tcontrol.Before != null)
                {
                    int pos = 0;
                    foreach (CommandBarControl findcontrol in controls)
                    {
                        pos++;
                        if (findcontrol.Caption == tcontrol.Before)
                        {
                            newpos = pos;
                        }
                    }
                }
                CommandBarControl control = controls.Add(tcontrol.Type, 1, System.Reflection.Missing.Value, newpos, true);
                control.Tag      = tcontrol.InternalTag + "#" + NEXT_TAG;
                control.OnAction = "!<" + OfficeUIManager.AddinProgID + ">";
                NEXT_TAG++;
                tcontrol.Apply(window, control);
                OfficeUIManager.RegisterCommandBarControl(control, window, tcontrol);
            }
        }
Beispiel #14
0
        /// <summary>
        ///		Occurs when a window has been closed.
        /// </summary>
        /// <remarks>
        ///		Unregisters and toolbar buttons on the window and releases their COM objects.
        /// </remarks>
        /// <param name="window"></param>
        protected void OnWindowClose(OfficeWindow window)
        {
            if (WindowClose != null)
            {
                WindowClose(window);
            }
            foreach (string tag in controlControlMap.Keys)
            {
                if (controlControlMap[tag] == window)
                {
                    controlControlMap.Remove(tag);
                    controlWindowMap.Remove(tag);
                    CommandBarControl control = (CommandBarControl)controlProxyMap[tag];
                    UnbindControl(control);
#if (COMRELEASE)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(control);
#endif
                    controlProxyMap.Remove(tag);
                }
            }
        }
Beispiel #15
0
 /// <summary>
 ///		Applies this toolbar to the given CommandBar.
 /// </summary>
 /// <param name="window">The window that the CommandBar belongs to.</param>
 /// <param name="commandbar"></param>
 internal void Apply(OfficeWindow window, CommandBar commandbar)
 {
     commandbar.Enabled  = enabled.GetValue(window);
     commandbar.RowIndex = rowIndex;
     commandbar.Visible  = visible.GetValue(window);
     if (left >= 0)
     {
         commandbar.Left = left;
     }
     else if (right >= 0)
     {
         commandbar.Left = (window.Width - commandbar.Width) - right;
     }
     if (top >= 0)
     {
         commandbar.Top = top;
     }
     else if (bottom >= 0)
     {
         commandbar.Top = (window.Height - commandbar.Height) - bottom;
     }
     Apply(window, commandbar.Controls);
 }
Beispiel #16
0
 /// <summary>
 ///		Finds the CommandBarControls for a given OfficeWindow that maps to this toolbar.
 /// </summary>
 /// <param name="window">The window to search through.</param>
 /// <returns>The CommandBarControls that contains controls that map to the controls that this toolbar contains.</returns>
 internal override CommandBarControls FindCommandBarControls(OfficeWindow window)
 {
     return(GetCommandBar(window).Controls);
 }
Beispiel #17
0
        /// <summary>
        ///		Finds the CommandBarControls that matches this ToolbarPopup instance on the given window.
        /// </summary>
        /// <param name="window">The window to look in.</param>
        /// <returns>The CommandBarControls instance.</returns>
        internal virtual CommandBarControls FindCommandBarControls(OfficeWindow window)
        {
            CommandBarPopup proxy = (CommandBarPopup)GetCommandBarControl(window);

            return(proxy.Controls);
        }
Beispiel #18
0
 /// <summary>
 ///		Registers a newly created command bar with the UI manager.
 /// </summary>
 /// <param name="bar">The CommandBar created.</param>
 /// <param name="window">The OfficeWindow the command bar was created on.</param>
 /// <param name="toolbar">The Toolbar that the command bar was created from.</param>
 internal void RegisterCommandBar(CommandBar bar, OfficeWindow window, Toolbar toolbar)
 {
 }
Beispiel #19
0
 /// <summary>
 ///		This method should return the Toolbars that need to be applied to a given
 ///		OfficeWindow.
 /// </summary>
 /// <remarks>
 ///		Managers for particular office applications should define this method.
 /// </remarks>
 /// <param name="window">A window that has just opened.</param>
 /// <returns>The Toolbars to apply to the window.</returns>
 protected abstract Toolbars GetWindowToolbars(OfficeWindow window);
Beispiel #20
0
 /// <summary>
 ///		Applys any particular popup settings to the control.
 /// </summary>
 /// <param name="window">The window holding the control.</param>
 /// <param name="control">The popup control.</param>
 private void InternalApply(OfficeWindow window, CommandBarPopup control)
 {
     Apply(window, control.Controls);
 }
Beispiel #21
0
 /// <summary>
 ///		Applies specific button settings to the control proxy.
 /// </summary>
 /// <param name="window">The window holding the proxy.</param>
 /// <param name="control">The proxy control.</param>
 private void InternalApply(OfficeWindow window, CommandBarButton control)
 {
     control.State = state;
     control.Style = style;
 }
Beispiel #22
0
 /// <summary>
 ///		Applies settings to the given control.
 /// </summary>
 /// <param name="window">The window holding the control.</param>
 /// <param name="control">The proxy control.</param>
 internal override void Apply(OfficeWindow window, CommandBarControl control)
 {
     base.Apply(window, control);
     InternalApply(window, control as CommandBarComboBox);
 }
Beispiel #23
0
 /// <summary>
 ///		Returns the value for the given window.
 /// </summary>
 /// <param name="window">The window.</param>
 /// <returns>True or false depending on the window.</returns>
 public virtual bool GetValue(OfficeWindow window)
 {
     return(normal);
 }