コード例 #1
0
        void IHelpService.AddContextAttribute(string name, string value, HelpKeywordType keywordType)
        {
            if (_ServiceProvider != null)
            {
                IVsUserContext userContext = GetUserContext();
                if (userContext != null)
                {
                    VSUSERCONTEXTATTRIBUTEUSAGE usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
                    switch (keywordType)
                    {
                    case HelpKeywordType.F1Keyword:
                        usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
                        break;

                    case HelpKeywordType.GeneralKeyword:
                        usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Lookup;
                        break;

                    case HelpKeywordType.FilterKeyword:
                        usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter;
                        break;
                    }
                    NativeMethods.ThrowOnFailure(userContext.AddAttribute(usage, name, value));
                    NotifyContextChange(userContext);
                }
            }
        }
コード例 #2
0
		public void AddContextAttribute(string name, string value, HelpKeywordType keywordType)
		{
			switch (keywordType) {
				case HelpKeywordType.F1Keyword:
					f1Keyword = value;
					return;
				case HelpKeywordType.GeneralKeyword:
					generalKeyword = value;
					return;
			}
		}
コード例 #3
0
        public void AddContextAttribute(string name, string value, HelpKeywordType keywordType)
        {
            switch (keywordType)
            {
            case HelpKeywordType.F1Keyword:
                f1Keyword = value;
                return;

            case HelpKeywordType.GeneralKeyword:
                generalKeyword = value;
                return;
            }
        }
コード例 #4
0
        /// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.AddContextAttribute"]/*' />
        /// <devdoc>
        ///     Adds a context attribute to the document.  Context attributes are used
        ///     to provide context-sensitive help to users.  The designer host will
        ///     automatically add context attributes from available help attributes
        ///     on selected components and properties.  This method allows you to
        ///     further customize the context-sensitive help.
        /// </devdoc>
        public virtual void AddContextAttribute(string name, string value, HelpKeywordType keywordType)
        {
            if (provider == null)
            {
                return;
            }

            // First, get our context and update the attribute.
            //
            IVsUserContext cxt = GetUserContext();

            if (cxt != null)
            {
                tagVsUserContextAttributeUsage usage = tagVsUserContextAttributeUsage.VSUC_Usage_LookupF1;

                switch (keywordType)
                {
                case HelpKeywordType.F1Keyword:
                    usage = tagVsUserContextAttributeUsage.VSUC_Usage_LookupF1;
                    break;

                case HelpKeywordType.GeneralKeyword:
                    usage = tagVsUserContextAttributeUsage.VSUC_Usage_Lookup;
                    break;

                case HelpKeywordType.FilterKeyword:
                    usage = tagVsUserContextAttributeUsage.VSUC_Usage_Filter;
                    break;
                }

                cxt.AddAttribute(usage, name, value);

                // Then notify the shell that it has been updated.
                //
                NotifyContextChange(cxt);
            }
        }
コード例 #5
0
        /// <devdoc>
        ///     Adds a context attribute to the document.  Context attributes are used
        ///     to provide context-sensitive help to users.  The designer host will
        ///     automatically add context attributes from available help attributes
        ///     on selected components and properties.  This method allows you to
        ///     further customize the context-sensitive help.
        /// </devdoc>
        void IHelpService.AddContextAttribute(string name, string value, HelpKeywordType keywordType)
        {
            if (provider == null)
            {
                return;
            }

            // First, get our context and update the attribute.
            //
            IVsUserContext cxt = GetUserContext();

            if (cxt != null)
            {
                VSUSERCONTEXTATTRIBUTEUSAGE usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;

                switch (keywordType)
                {
                case HelpKeywordType.F1Keyword:
                    usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
                    break;

                case HelpKeywordType.GeneralKeyword:
                    usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Lookup;
                    break;

                case HelpKeywordType.FilterKeyword:
                    usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter;
                    break;
                }

                NativeMethods.ThrowOnFailure(cxt.AddAttribute(usage, name, value));

                // Then notify the shell that it has been updated.
                //
                NotifyContextChange(cxt);
            }
        }
コード例 #6
0
ファイル: HelpService.cs プロジェクト: sunpander/VSDT
    void IHelpService.AddContextAttribute(string name, string value, HelpKeywordType keywordType)
    {
      if (_ServiceProvider != null)
      {
        IVsUserContext userContext = GetUserContext();
        if (userContext != null)
        {
          VSUSERCONTEXTATTRIBUTEUSAGE usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
          switch (keywordType)
          {
            case HelpKeywordType.F1Keyword:
              usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
              break;

            case HelpKeywordType.GeneralKeyword:
              usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Lookup;
              break;

            case HelpKeywordType.FilterKeyword:
              usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter;
              break;
          }
          NativeMethods.ThrowOnFailure(userContext.AddAttribute(usage, name, value));
          NotifyContextChange(userContext);
        }
      }
    }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
ファイル: HelpService.cs プロジェクト: hesam/SketchSharp
        /// <devdoc>
        ///     Adds a context attribute to the document.  Context attributes are used
        ///     to provide context-sensitive help to users.  The designer host will
        ///     automatically add context attributes from available help attributes
        ///     on selected components and properties.  This method allows you to
        ///     further customize the context-sensitive help.
        /// </devdoc>
        void IHelpService.AddContextAttribute(string name, string value, HelpKeywordType keywordType) {

            if (provider == null) {
                return;
            }

            // First, get our context and update the attribute.
            //
            IVsUserContext cxt = GetUserContext();

            if (cxt != null) {

                VSUSERCONTEXTATTRIBUTEUSAGE usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
                
                switch (keywordType) {
                    case HelpKeywordType.F1Keyword:
                        usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1;
                        break;
                    case HelpKeywordType.GeneralKeyword:
                        usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Lookup;
                        break;
                    case HelpKeywordType.FilterKeyword:
                        usage = VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter;
                        break;
                }
                
                NativeMethods.ThrowOnFailure( cxt.AddAttribute(usage, name, value) );

                // Then notify the shell that it has been updated.
                //
                NotifyContextChange(cxt);
            }
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        /// <summary>
        /// Pushes the help context into the help service for the current set of selected objects.
        /// </summary>
        private void UpdateHelpKeyword(bool tryLater)
        {
            if (!(GetService(typeof(IHelpService)) is IHelpService helpService))
            {
                if (tryLater)
                {
                    // we don't have an help service YET, we need to wait for it...
                    // hook up to the application.idle event
                    // yes this is UGLY but we don't have a choice, vs is always returning a UserContext, so even if we manage to instanciate the HelpService beforehand and class pushcontext on it (trying to stack up help context in the helpservice to be flushed when we get the documentactivation event we just don't know if that's going to work or not... so we just wait...) :(((
                    Windows.Forms.Application.Idle += new EventHandler(ApplicationIdle);
                }
                return;
            }

            // If there is an old set of context attributes, remove them.
            if (_contextAttributes != null)
            {
                foreach (string s in _contextAttributes)
                {
                    helpService.RemoveContextAttribute("Keyword", s);
                }
                _contextAttributes = null;
            }

            // Clear the selection keyword
            helpService.RemoveContextAttribute("Selection", s_selectionKeywords[_contextKeyword]);
            // Get a list of unique class names.
            Debug.Assert(_selection != null, "Should be impossible to update the help context before configuring the selection hash");
            bool baseComponentSelected = false;

            if (_selection.Count == 0)
            {
                baseComponentSelected = true;
            }
            else if (_selection.Count == 1)
            {
                if (GetService(typeof(IDesignerHost)) is IDesignerHost host && _selection.Contains(host.RootComponent))
                {
                    baseComponentSelected = true;
                }
            }
            _contextAttributes = new string[_selection.Count];

            for (int i = 0; i < _selection.Count; i++)
            {
                object s           = _selection[i];
                string helpContext = TypeDescriptor.GetClassName(s);
                HelpKeywordAttribute contextAttr = (HelpKeywordAttribute)TypeDescriptor.GetAttributes(s)[typeof(HelpKeywordAttribute)];
                if (contextAttr != null && !contextAttr.IsDefaultAttribute())
                {
                    helpContext = contextAttr.HelpKeyword;
                }
                _contextAttributes[i] = helpContext;
            }

            // And push them into the help context as keywords.
            HelpKeywordType selectionType = baseComponentSelected ? HelpKeywordType.GeneralKeyword : HelpKeywordType.F1Keyword;

            foreach (string helpContext in _contextAttributes)
            {
                helpService.AddContextAttribute("Keyword", helpContext, selectionType);
            }

            // 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 = _selection.Count;

            if (count == 1 && baseComponentSelected)
            {
                count--;
            }
            _contextKeyword = (short)Math.Min(count, s_selectionKeywords.Length - 1);
            helpService.AddContextAttribute("Selection", s_selectionKeywords[_contextKeyword], HelpKeywordType.FilterKeyword);
        }