Пример #1
0
        public static void ExecuteCommandHtmlDoc(IHTMLDocument2 htmlDoc, HtmlCommand command, object data)
        {
            try
            {
                if (htmlDoc.IsNull())
                {
                    return;
                }

                // ensure command is valid and enabled
                if (!htmlDoc.queryCommandSupported(command.Name()))
                {
                    return;
                }

                if (!htmlDoc.queryCommandEnabled(command.Name()))
                {
                    return;
                }

                htmlDoc.execCommand(command.Name(), false, data);
            }
            catch (RemotingException) { }
            catch (UnauthorizedAccessException) { }
        }
Пример #2
0
        public static object QueryValueHtmlDoc(IHTMLDocument2 htmlDoc, HtmlCommand command)
        {
            try
            {
                if (htmlDoc.IsNull())
                {
                    return(null);
                }

                // ensure command is valid and enabled
                if (!htmlDoc.queryCommandSupported(command.Name()))
                {
                    return(null);
                }

                if (!htmlDoc.queryCommandEnabled(command.Name()))
                {
                    return(null);
                }

                return(htmlDoc.queryCommandValue(command.Name()));
            }
            catch (RemotingException) { }
            catch (UnauthorizedAccessException) { }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Executes the execCommand on the selected document.
        /// Only affects the currently selected range.
        /// </summary>
        public static void ExecuteCommand(HtmlCommand command, object data)
        {
            var htmlDoc = ContentUtils.GetFocusedHtmlDoc();

            if (!htmlDoc.IsNull())
            {
                ExecuteCommandHtmlDoc(htmlDoc, command, data);
            }
        }
Пример #4
0
        public static object ExecuteQuery(HtmlCommand command)
        {
            var htmlDoc = ContentUtils.GetFocusedHtmlDoc();

            if (!htmlDoc.IsNull())
            {
                return(QueryValueHtmlDoc(htmlDoc, command));
            }

            return(null);
        }