Esempio n. 1
0
 /// <summary>
 /// Sets the help context into the help service for this property page.
 /// </summary>
 private void SetHelpContext()
 {
     if (this.pageSite != null)
     {
         System.IServiceProvider sp = this.pageSite as System.IServiceProvider;
         if (sp != null)
         {
             IHelpService helpService = sp.GetService(typeof(IHelpService)) as IHelpService;
             if (helpService != null)
             {
                 helpService.AddContextAttribute("Keyword", String.Empty, HelpKeywordType.F1Keyword);
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        ///  Creates a new tab order control that displays the tab order
        ///  UI for a form.
        /// </summary>
        public TabOrder(IDesignerHost host)
        {
            this.host = host;

            // Determine a font for us to use.
            //
            IUIService uisvc = (IUIService)host.GetService(typeof(IUIService));

            if (uisvc != null)
            {
                tabFont = (Font)uisvc.Styles["DialogFont"];
            }
            else
            {
                tabFont = DefaultFont;
            }

            tabFont = new Font(tabFont, FontStyle.Bold);

            // And compute the proper highlight dimensions.
            //
            selSize = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;

            // Colors and brushes...
            //
            drawString         = new StringBuilder(12);
            highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            highlightPen       = new Pen(SystemColors.Highlight);

            // The decimal separator
            //
            NumberFormatInfo formatInfo = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (formatInfo != null)
            {
                decimalSep = formatInfo.NumberDecimalSeparator;
            }
            else
            {
                decimalSep = ".";
            }

            tabProperties = new Hashtable();

            // Set up a NULL brush so we never try to invalidate the control.  This is
            // more efficient for what we're doing
            //
            SetStyle(ControlStyles.Opaque, true);

            // We're an overlay on top of the form
            //
            IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService));

            Debug.Assert(os != null, "No overlay service -- tab order UI cannot be shown");
            if (os != null)
            {
                os.PushOverlay(this);
            }

            // Push a help keyword so the help system knows we're in place.
            //
            IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService));

            if (hs != null)
            {
                hs.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }

            commands = new MenuCommand[]
            {
                new MenuCommand(new EventHandler(OnKeyCancel),
                                MenuCommands.KeyCancel),

                new MenuCommand(new EventHandler(OnKeyDefault),
                                MenuCommands.KeyDefaultAction),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeyMoveUp),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeyMoveDown),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeyMoveLeft),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeyMoveRight),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeySelectNext),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeySelectPrevious),
            };

            newCommands = new MenuCommand[]
            {
                new MenuCommand(new EventHandler(OnKeyDefault),
                                MenuCommands.KeyTabOrderSelect),
            };

            IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (mcs != null)
            {
                foreach (MenuCommand mc in newCommands)
                {
                    mcs.AddCommand(mc);
                }
            }

            // We also override keyboard, menu and mouse handlers.  Our override relies on the
            // above array of menu commands, so this must come after we initialize the array.
            //
            IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (ehs != null)
            {
                ehs.PushHandler(this);
            }

            // We sync add, remove and change events so we remain in sync with any nastiness that the
            // form may pull on us.
            //
            IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (cs != null)
            {
                cs.ComponentAdded   += new ComponentEventHandler(OnComponentAddRemove);
                cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddRemove);
                cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
            }
        }
        private void addKeyword(object sender, EventArgs e)
        {
            IHelpService hs = (IHelpService)this.Control.Site.GetService(typeof(IHelpService));

            hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword);
        }
Esempio n. 4
0
 private void UpdateHelpAttributes(IHelpService helpSvc, GridEntry entry, bool addAsF1) {
     if (entry == null) {
        return;
     }
     
     UpdateHelpAttributes(helpSvc, entry.ParentGridEntry, false);
     string helpKeyword = entry.HelpKeyword;
     if (helpKeyword != null) {
        helpSvc.AddContextAttribute("Keyword", helpKeyword, addAsF1 ? HelpKeywordType.F1Keyword : HelpKeywordType.GeneralKeyword);
     }
 }
        /// <include file='doc\SelectionService.uex' path='docs/doc[@for="SelectionService.UpdateHelpContext"]/*' />
        /// <devdoc>
        ///     Pushes the help context into the help service for the
        ///     current set of selected objects.
        /// </devdoc>
        private void UpdateHelpContext()
        {
            IHelpService helpService = (IHelpService)host.GetService(typeof(IHelpService));
            IEnumerator  e;

            if (helpService == null)
            {
                return;
            }

            // If there is an old set of context attributes, remove them.
            //
            if (contextAttributes != null && contextAttributes.Keys.Count > 0)
            {
                e = contextAttributes.Keys.GetEnumerator();

                while (e.MoveNext())
                {
                    helpService.RemoveContextAttribute("Keyword", (string)e.Current);
                }
                contextAttributes.Clear();
            }

            IComponent rootComponent = host.RootComponent;
            IDesigner  baseDesigner  = null;

            if (rootComponent != null)
            {
                baseDesigner = host.GetDesigner(rootComponent);
                if (baseDesigner != null)
                {
                    helpService.RemoveContextAttribute("Keyword", "Designer_" + baseDesigner.GetType().FullName);
                }
            }

            // Clear the selection keyword
            //
            helpService.RemoveContextAttribute("Selection", selectionKeywords[contextKeyword]);

            if (contextAttributes == null)
            {
                contextAttributes = new Hashtable();
            }

            // Get a list of unique class names.
            //
            e = selectionsByComponent.Values.GetEnumerator();

            bool baseComponentSelected = false;

            if (rootComponent != null && (selectionsByComponent.Count == 0 || (selectionsByComponent.Count == 1 && selectionsByComponent[rootComponent] != null)))
            {
                baseComponentSelected = true;
            }

            while (e.MoveNext())
            {
                SelectionItem s = (SelectionItem)e.Current;
                contextAttributes[s.component.GetType().FullName] = null;
            }

            // And push them into the help context as keywords.
            //
            e = contextAttributes.Keys.GetEnumerator();
            HelpKeywordType selectionType = baseComponentSelected ? HelpKeywordType.GeneralKeyword : HelpKeywordType.F1Keyword;

            while (e.MoveNext())
            {
                helpService.AddContextAttribute("Keyword", (string)e.Current, selectionType);
            }

            // Now add the form designer context as well
            //
            if (baseDesigner != null)
            {
                helpService.AddContextAttribute("Keyword", "Designer_" + baseDesigner.GetType().FullName,
                                                baseComponentSelected ? HelpKeywordType.F1Keyword : HelpKeywordType.GeneralKeyword);
            }

            // Now add the appropriate selection keyword.  Note that we do not count
            // the base component as being selected if it is the only thing selected.
            //
            int count = SelectionCount;

            if (rootComponent != null && count == 1 && selectionsByComponent[rootComponent] != null)
            {
                count--;
            }
            contextKeyword = (short)Math.Min(count, selectionKeywords.Length - 1);
            helpService.AddContextAttribute("Selection", selectionKeywords[contextKeyword], HelpKeywordType.FilterKeyword);
        }
        private void UpdateHelpKeyword(bool tryLater)
        {
            IHelpService service = this.GetService(typeof(IHelpService)) as IHelpService;

            if (service == null)
            {
                if (tryLater)
                {
                    Application.Idle += new EventHandler(this.ApplicationIdle);
                }
            }
            else
            {
                if (this._contextAttributes != null)
                {
                    foreach (string str in this._contextAttributes)
                    {
                        service.RemoveContextAttribute("Keyword", str);
                    }
                    this._contextAttributes = null;
                }
                service.RemoveContextAttribute("Selection", SelectionKeywords[this._contextKeyword]);
                bool flag = false;
                if (this._selection.Count == 0)
                {
                    flag = true;
                }
                else if (this._selection.Count == 1)
                {
                    IDesignerHost host = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
                    if ((host != null) && this._selection.Contains(host.RootComponent))
                    {
                        flag = true;
                    }
                }
                this._contextAttributes = new string[this._selection.Count];
                for (int i = 0; i < this._selection.Count; i++)
                {
                    object component = this._selection[i];
                    string className = TypeDescriptor.GetClassName(component);
                    HelpKeywordAttribute attribute = (HelpKeywordAttribute)TypeDescriptor.GetAttributes(component)[typeof(HelpKeywordAttribute)];
                    if ((attribute != null) && !attribute.IsDefaultAttribute())
                    {
                        className = attribute.HelpKeyword;
                    }
                    this._contextAttributes[i] = className;
                }
                HelpKeywordType keywordType = flag ? HelpKeywordType.GeneralKeyword : HelpKeywordType.F1Keyword;
                foreach (string str3 in this._contextAttributes)
                {
                    service.AddContextAttribute("Keyword", str3, keywordType);
                }
                int count = this._selection.Count;
                if ((count == 1) && flag)
                {
                    count--;
                }
                this._contextKeyword = (short)Math.Min(count, SelectionKeywords.Length - 1);
                service.AddContextAttribute("Selection", SelectionKeywords[this._contextKeyword], HelpKeywordType.FilterKeyword);
            }
        }
        public TabOrder(IDesignerHost host)
        {
            this.host = host;
            IUIService service = (IUIService)host.GetService(typeof(IUIService));

            if (service != null)
            {
                this.tabFont = (Font)service.Styles["DialogFont"];
            }
            else
            {
                this.tabFont = Control.DefaultFont;
            }
            this.tabFont            = new Font(this.tabFont, FontStyle.Bold);
            this.selSize            = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;
            this.drawString         = new StringBuilder(12);
            this.highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            this.highlightPen       = new Pen(SystemColors.Highlight);
            NumberFormatInfo format = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (format != null)
            {
                this.decimalSep = format.NumberDecimalSeparator;
            }
            else
            {
                this.decimalSep = ".";
            }
            this.tabProperties = new Hashtable();
            base.SetStyle(ControlStyles.Opaque, true);
            IOverlayService service2 = (IOverlayService)host.GetService(typeof(IOverlayService));

            if (service2 != null)
            {
                service2.PushOverlay(this);
            }
            IHelpService service3 = (IHelpService)host.GetService(typeof(IHelpService));

            if (service3 != null)
            {
                service3.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }
            this.commands    = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveUp), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveDown), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveLeft), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveRight), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeySelectNext), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeySelectPrevious) };
            this.newCommands = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyTabOrderSelect) };
            IMenuCommandService service4 = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (service4 != null)
            {
                foreach (MenuCommand command in this.newCommands)
                {
                    service4.AddCommand(command);
                }
            }
            IEventHandlerService service5 = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (service5 != null)
            {
                service5.PushHandler(this);
            }
            IComponentChangeService service6 = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (service6 != null)
            {
                service6.ComponentAdded   += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentRemoved += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
        }