コード例 #1
0
        /// <summary>
        /// Determines the value of the command
        /// </summary>
        private object QueryCommandRange(mshtmlTextRange range, string command)
        {
            object retValue = null;
            if (range != null)
            {
                try
                {
                    // ensure command is a valid command and then enabled for the selection
                    if (range.queryCommandSupported(command))
                    {
                        if (range.queryCommandEnabled(command))
                        {
                            retValue = range.queryCommandValue(command);
                        }
                    }
                }
                catch (Exception)
                {
                    // have unknown error so set return to null
                    retValue = null;
                }
            }

            // return the obtained value
            return retValue;
        }
コード例 #2
0
        /// <summary>
        /// Executes the queryCommandState on the selected range (given the range)
        /// </summary>
        private bool ExecuteCommandQuery(mshtmlTextRange range, string command)
        {
            // set the initial state as false
            bool retValue = false;

            try
            {
                if (range != null)
                {
                    // ensure command is a valid command and then enabled for the selection
                    if (range.queryCommandSupported(command))
                    {
                        if (range.queryCommandEnabled(command))
                        {
                            // mark the selection with the appropriate tag
                            retValue = range.queryCommandState(command);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Unknown error so inform user
                throw new HtmlEditorException("Unknown MSHTML Error.", command, ex);
            }

            // return the value
            return retValue;
        }
コード例 #3
0
 /// <summary>
 /// Executes the execCommand on the selected range (given the range)
 /// </summary>
 private void ExecuteCommandRange(mshtmlTextRange range, string command, object data)
 {
     try
     {
         if (range != null)
         {
             // ensure command is a valid command and then enabled for the selection
             if (range.queryCommandSupported(command))
             {
                 if (range.queryCommandEnabled(command))
                 {
                     // mark the selection with the appropriate tag
                     range.execCommand(command, false, data);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         // Unknown error so inform user
         throw new HtmlEditorException("Unknown MSHTML Error.", command, ex);
     }
 }
コード例 #4
0
ファイル: HtmlEditor.cs プロジェクト: tewuapple/WinHtmlEditor
        } // QueryCommandRange

        /// <summary>
        /// Determines the value of the command
        /// </summary>
        private object QueryCommandRange(mshtmlTextRange range, string command)
        {
            object retValue = null;
            try
            {
                if (!range.IsNull() && !range.text.IsNullOrEmpty())
                {
                    // ensure command is a valid command and then enabled for the selection
                    if (range.queryCommandSupported(command))
                    {
                        if (range.queryCommandEnabled(command))
                        {
                            retValue = range.queryCommandValue(command);
                        }
                    }
                }
                else
                {
                    retValue = QueryCommandDocument(command);
                }
            }
            catch (Exception)
            {
                // have unknown error so set return to null
                retValue = null;
            }
            // return the obtained value
            return retValue;

        } //QueryCommandRange