コード例 #1
0
        // get the selected range object
        protected HtmlTextRange GetTextRange()
        {
            // define the selected range object
            HtmlSelection selection;
            HtmlTextRange range = null;

            try
            {
                // calculate the text range based on user selection
                selection = GetDomDocument().selection;
                if (IsStatedTag(selection.type, SELECT_TYPE_TEXT) || IsStatedTag(selection.type, SELECT_TYPE_NONE))
                {
                    range = selection.createRange() as HtmlTextRange;
                }
            }
            catch (Exception)
            {
                // have unknown error so set return to null
                range = null;
            }

            return(range);
        } // GetTextRange
コード例 #2
0
 internal Range(mshtml.IHTMLTxtRange range)
 {
     msHtmlTxRange = range;
 }
コード例 #3
0
ファイル: HtmlDocument.cs プロジェクト: TomRom27/LectioDivina
 internal Range(mshtml.IHTMLTxtRange range)
 {
     msHtmlTxRange = range;
 }
コード例 #4
0
ファイル: Editor.cs プロジェクト: aAmitSengar/WindowsEditor
 /// <summary>
 /// Executes the execCommand on the selected range (given the range)
 /// </summary>
 private void ExecuteCommandRange(mshtmlTextRange range, string command, object data)
 {
     try
     {
         if (!range.IsNull())
         {
             // 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);
     }
 }
コード例 #5
0
ファイル: Editor.cs プロジェクト: aAmitSengar/WindowsEditor
        /// <summary>
        /// Executes the queryCommandState on the selected range (given the range)
        /// </summary>
        private bool ExecuteCommandQuery(mshtmlTextRange range, string command, bool isEnabled = false)
        {
            // set the initial state as false
            bool retValue = false;

            try
            {
                if (!range.IsNull())
                {
                    // ensure command is a valid command and then enabled for the selection
                    if (range.queryCommandSupported(command))
                    {
                        if (isEnabled)
                        {
                            retValue = range.queryCommandEnabled(command);
                        }
                        else
                        {
                            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;
        }