From 5f8dd7b926a756effedce33e64826ccae79b1a59 Mon Sep 17 00:00:00 2001 From: Nadya Todorova Date: Wed, 18 Sep 2024 15:14:25 +0300 Subject: [PATCH 01/12] Spreadsheet-Document the new HyperlinkClicked event --- controls/spreadsheet/events.md | 48 +++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/controls/spreadsheet/events.md b/controls/spreadsheet/events.md index 01851604d..ad1a472b6 100644 --- a/controls/spreadsheet/events.md +++ b/controls/spreadsheet/events.md @@ -154,13 +154,59 @@ End Sub * **ActivePresenterChanged**: Occurs when the active presenter is changed. +* **HyperlinkClicked**: Occurs when a hyperlink in the document gets clicked. The event allows you to either cancel or replace the navigation logic. HyperlinkClicked event can be used as a confirmation from the end-user whether to proceed or not with opening a hyperlink due to security reasons. + +#### Example 3: Using the HyperlinkClicked event to implement confirmation for the clicked links in the document + +{{source=..\SamplesCS\Spreadsheet\Events.cs region=HyperlinkClickedEvent}} +{{source=..\SamplesVB\Spreadsheet\Events.vb region=HyperlinkClickedEvent}} +````C# +private void ActiveWorksheetEditor_HyperlinkClicked(object sender, Telerik.WinControls.Hyperlinks.HyperlinkClickedEventArgs e) +{ + if (e.URL.EndsWith("exe")) + { + e.Handled = true; + MessageBoxResult Result = System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed?", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question); + + if (Result == MessageBoxResult.Yes) + { + Process.Start(new ProcessStartInfo() + { + FileName = e.URL, + UseShellExecute = true + }); + } + } +} + +```` +````VB.NET +Private Sub ActiveWorksheetEditor_HyperlinkClicked(ByVal sender As Object, ByVal e As Telerik.WinControls.Hyperlinks.HyperlinkClickedEventArgs) + If e.URL.EndsWith("exe") Then + e.Handled = True + Dim Result As MessageBoxResult = System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed?", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question) + + If Result = MessageBoxResult.Yes Then + Process.Start(New ProcessStartInfo() With { + .FileName = e.URL, + .UseShellExecute = True + }) + End If + End If +End Sub + +```` + +{{endregion}} + + >The events related to selection in RadSpreadsheet are described in the [Working with UI Selection]({%slug radspreadsheet-ui-working-with-selection%}) topic. ## Cells Events * **CellPropertyChanged**: Occurs when a property of a cell is changed. The event arguments are of type **CellPropertyChangedEventArgs** and expose information about the exact property that was changed as well as the affected cell range. **Example 3** demonstrates how you can use the event to get a notification when the users change the fill of a cell. -#### Example 3: Using the CellPropertyChangedEvent +#### Example 4: Using the CellPropertyChangedEvent {{source=..\SamplesCS\Spreadsheet\Events.cs region=radspreadsheet-events_3}} {{source=..\SamplesVB\Spreadsheet\Events.vb region=radspreadsheet-events_3}} From a2324e4455d9cb9b3fa7f4259756abd9c721efd4 Mon Sep 17 00:00:00 2001 From: Nadya Todorova Date: Wed, 18 Sep 2024 16:33:07 +0300 Subject: [PATCH 02/12] update-richtexteditor-events --- controls/richtexteditor/events.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/controls/richtexteditor/events.md b/controls/richtexteditor/events.md index d87eaf7bf..41de3a6a1 100644 --- a/controls/richtexteditor/events.md +++ b/controls/richtexteditor/events.md @@ -87,11 +87,17 @@ The __RadRichTextEditor__ control raises the following specific events: * An __EventArgs__ object. -* __HyperlinkClicked__ - occurs when the current page has changed. The event handler receives two arguments: - +* __HyperlinkClicked__ - Occurs when the users clicks on a hyperlink in the current document. The event allows you to either cancel or replace the navigation logic. HyperlinkClicked event can be used as a confirmation from the end-user whether to proceed or not with opening a hyperlink due to security reasons. The event handler receives two arguments: + * The sender argument contains the __RadRichTextEditor__. This argument is of type object, but can be cast to the __RadRichTextEditor__ type. - * A __HyperlinkClickedEventArgs__ object. This argument allows you to access the URL and the target of the hyperlink. + * A __HyperlinkClickedEventArgs__ object. This argument allows you to access the following properties: + - __Handled__: Get or set a value indicating whether the event is handled. + - __HyperlinkTarget__: Gets the target hyperlink. + - __URL__: Gets the URL of the hyperlink. + - __IsTrustedUrl__: Gets a value tha indicates if the URL passes the validation. If the URL is not trusted, the hyperlink will not be opened. Set this property to true to open the hyperlink. + + The default hyperlink navigation can be cancelled by setting either the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. This is helpful when you need to validate the clicked hyperlink and prevent it from navigating to an unsecure link or process. For more information see [Hyperlink]({%slug winforms/richtexteditor-/features/hyperlink%}) article. * __IsReadOnlyChanged__ - occurs when __IsReadOnly__ value has changed. The event handler receives two arguments: From e23dc0c7ad00ceba8c06cd4a59199e7978df645f Mon Sep 17 00:00:00 2001 From: Nadya Todorova Date: Thu, 19 Sep 2024 14:28:23 +0300 Subject: [PATCH 03/12] add-HyperlinkClickedEvent-in-richtexteditor --- controls/richtexteditor/features/hyperlink.md | 65 +++++++++++++++--- .../richtexteditor-features-hyperlink002.png | Bin 5378 -> 0 bytes 2 files changed, 57 insertions(+), 8 deletions(-) delete mode 100644 controls/richtexteditor/features/images/richtexteditor-features-hyperlink002.png diff --git a/controls/richtexteditor/features/hyperlink.md b/controls/richtexteditor/features/hyperlink.md index e8b83524c..364a480cf 100644 --- a/controls/richtexteditor/features/hyperlink.md +++ b/controls/richtexteditor/features/hyperlink.md @@ -53,8 +53,10 @@ Dim info As New HyperlinkInfo() With {.NavigateUri = "http://www.telerik.com", . Me.radRichTextEditor1.InsertHyperlink(info, "RichTextBox demo") ```` + {{endregion}} + A link to a bookmark is inserted by specifying the bookmark's name as **NavigateUri** and setting the **IsAnchor** property to *true*: {{source=..\SamplesCS\RichTextEditor\Features\HyperlinkCode.cs region=remove}} @@ -81,7 +83,7 @@ You can also use the overloaded methods for inserting a hyperlink: * public void __InsertHyperlink__(HyperlinkInfo hyperlinkInfo, StyleDefinition hyperlinkStyle) - create a hyperlink from the currently selected part of the document and change the style of the text to the style passed as second argument. -Removing a hyperlink (and keeping the part of the document that the hyperlink spanned) can be done by positioning the caret in the hyperlink and invoking. +Removing a hyperlink (and keeping the part of the document that the hyperlink spanned) can be done by positioning the caret in the hyperlink and invoking: {{source=..\SamplesCS\RichTextEditor\Features\HyperlinkCode.cs region=remove}} {{source=..\SamplesVB\RichTextEditor\Features\HyperlinkCode.vb region=remove}} @@ -205,7 +207,7 @@ Next link ## Other Customization Options -__ToolTip__ +### ToolTip By default, hyperlinks take a fixed string as a tool tip. The default format is: @@ -214,20 +216,67 @@ By default, hyperlinks take a fixed string as a tool tip. The default format is: You have control over it using the __HyperlinkToolTipFormatString__ of **RadRichTextEditor**, which will set the format for all hyperlinks in the document. -__HyperlinkClicked__ +### HyperlinkClicked event + +When a hyperlink is clicked, the __HyperlinkClicked__ event of __RadRichTextEditor__ is fired. The sender of the event is the document element, which you have clicked, e.g. a **Span**, an **Image**, **InlineUIContainer**, etc. The __HyperlinkClickedEventArgs__ provide the possibility either to cancel or replace the navigation action. This is helpful when you need to validate the clicked hyperlink and prevent it from navigating to an unsecure address or from starting a local process. + +With the 2024 Q4 release, the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be cancelled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. + +Here is an example of using the HyperlinkClicked event prompting that the clicked hyperlink might be unsafe and allows to cancel the navigation process upon receiving the end user confirmation: + +{{source=..\SamplesCS\RichTextEditor\Features\HyperlinkCode.cs region=HyperlinkClickedEvent}} +{{source=..\SamplesVB\RichTextEditor\Features\HyperlinkCode.vb region=HyperlinkClickedEvent}} + +````C# +void radRichTextEditor1_HyperlinkClicked(object sender, HyperlinkClickedEventArgs e) +{ + var link = e.URL; + if (link.EndsWith("exe")) + { + e.Handled = true; MessageBoxResult Result = System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (Result == MessageBoxResult.Yes) + { + Process.Start(new ProcessStartInfo() + { + FileName = link, + UseShellExecute = true + }); + } + } +} + + +```` +````VB.NET +Private Sub radRichTextEditor1_HyperlinkClicked(ByVal sender As Object, ByVal e As HyperlinkClickedEventArgs) + Dim link = e.URL + + If link.EndsWith("exe") Then + e.Handled = True + Dim Result As MessageBoxResult = System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question) + If Result = MessageBoxResult.Yes Then + Process.Start(New ProcessStartInfo() With { + .FileName = link, + .UseShellExecute = True + }) + End If + End If +End Sub -When you click on a hyperlink, the __HyperlinkClicked__ event of __RadRichTextEditor__ is fired. The sender of the event is the document element, which you have clicked, e.g. a **Span**, an **Image**, **InlineUIContainer**, etc. The event args on the other hand, provide the possibility to mark the event as handled and prevent the default action. Custom logic can also be implemented depending on the __HyperlinkTarget__ and __URL__, which are also visible as properties of the event args. -![WinForms RadRichTextEditor Hyperlink Click Even Handler](images/richtexteditor-features-hyperlink002.png) +```` + +{{endregion}} + -## HyperlinkNavigationMode +### HyperlinkNavigationMode -This property allows you to control what action should trigger the opening of a hyperlink. The possible options are: +The __HyperlinkNavigationMode__ allows you to control what action should trigger the opening of a hyperlink. The possible options are: * **CtrlClick**: Triggers the hyperlink when users hold the Ctrl key and click on the hyperlink. * **Click**: Triggers the hyperlink when users click on the hyperlink. -#### Change the default hyperlink navigation mode +Below is demonstrated how to change the default hyperlink navigation mode: {{source=..\SamplesCS\RichTextEditor\Features\HyperlinkCode.cs region=HyperlinkMode}} {{source=..\SamplesVB\RichTextEditor\Features\HyperlinkCode.vb region=HyperlinkMode}} diff --git a/controls/richtexteditor/features/images/richtexteditor-features-hyperlink002.png b/controls/richtexteditor/features/images/richtexteditor-features-hyperlink002.png deleted file mode 100644 index 0e44d1be86341096f83301ab683a215f60477d36..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5378 zcmZ8l2{e>%+n<-HM50o*p-q3;iWyR535{Kt8OClb8T&tbq!J~KHE9UhnK70a${r$X zMUUOsx3MoX_MUJ0zwdj#^L@{`&T}u<@4lAbecktS&J$^5aF2^af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KK$2T1ES(1oW&20$U1aMU&{xAwl4jO>g*BB{Cj;m(~6xF z6_)KKSCfh2HZSX-RBdEZ>t7B@7IR_ruQIRDX{O4OGzzaS1Q_!+kNjhXr6OHlkM(L^!G`_%N%uV{8+u4M?oZHRUswpLcw zL)Aua*CM<0wvhgwrL@YGRN|D|+Y%nQaEy6QuT|5}BC*s7W4PmSq)I(QBDR07kY=c< zl+q*S+KP0o=?LCw)WRX$fHJdu##7J;rSvWE8oo$Y@XzR5jX zkZewPH$mAabo=LsTN9m7E&SHI6${HmZ^}1Lyj;x&xwpxzDCKZfW_`a+i|JyDvp6e1 t`Ptx6^$=72{}sOQPyhYn^Y4~p{iwfk!_>m?RNJ2kZA}A>B6Ztm{{yq?_iF$E From bbc2eec91c340991a542cf6c7145e18ec349fb0b Mon Sep 17 00:00:00 2001 From: Nadya Todorova Date: Thu, 19 Sep 2024 14:48:18 +0300 Subject: [PATCH 04/12] Update events.md --- controls/richtexteditor/events.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/controls/richtexteditor/events.md b/controls/richtexteditor/events.md index 41de3a6a1..34d37e48d 100644 --- a/controls/richtexteditor/events.md +++ b/controls/richtexteditor/events.md @@ -89,15 +89,13 @@ The __RadRichTextEditor__ control raises the following specific events: * __HyperlinkClicked__ - Occurs when the users clicks on a hyperlink in the current document. The event allows you to either cancel or replace the navigation logic. HyperlinkClicked event can be used as a confirmation from the end-user whether to proceed or not with opening a hyperlink due to security reasons. The event handler receives two arguments: - * The sender argument contains the __RadRichTextEditor__. This argument is of type object, but can be cast to the __RadRichTextEditor__ type. + * The sender argument contains the __Span__ containing the hyperlink's content. This argument is of type object, but can be cast to the __Span__ type. * A __HyperlinkClickedEventArgs__ object. This argument allows you to access the following properties: - __Handled__: Get or set a value indicating whether the event is handled. - __HyperlinkTarget__: Gets the target hyperlink. - __URL__: Gets the URL of the hyperlink. - - __IsTrustedUrl__: Gets a value tha indicates if the URL passes the validation. If the URL is not trusted, the hyperlink will not be opened. Set this property to true to open the hyperlink. - - The default hyperlink navigation can be cancelled by setting either the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. This is helpful when you need to validate the clicked hyperlink and prevent it from navigating to an unsecure link or process. For more information see [Hyperlink]({%slug winforms/richtexteditor-/features/hyperlink%}) article. + - __IsTrustedUrl__: Gets a value tha indicates if the URL passes the validation. If the URL is not trusted, the hyperlink will not be opened. Set this property to true to open the hyperlink. For more information see [Hyperlink]({%slug winforms/richtexteditor-/features/hyperlink%}) article. * __IsReadOnlyChanged__ - occurs when __IsReadOnly__ value has changed. The event handler receives two arguments: From b68432aa68b49d47f199cb4cdb980e697325cd0f Mon Sep 17 00:00:00 2001 From: Nadya Todorova Date: Thu, 19 Sep 2024 15:15:32 +0300 Subject: [PATCH 05/12] HyperlinkClicked event for RadPdfViewer --- controls/pdfviewer/features/annotations.md | 198 +++++++++++++-------- 1 file changed, 122 insertions(+), 76 deletions(-) diff --git a/controls/pdfviewer/features/annotations.md b/controls/pdfviewer/features/annotations.md index 843b84ae3..f090ded4c 100644 --- a/controls/pdfviewer/features/annotations.md +++ b/controls/pdfviewer/features/annotations.md @@ -1,25 +1,25 @@ ---- -title: Annotations -page_title: Annotations - WinForms PdfViewer Control -description: WinForms PdfViewer supports Link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. -slug: winforms/pdfviewer/annotations -tags: annotations -published: True -position: 0 ---- - -# Annotations -__RadPdfViewer__ supports link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. In addition, if there are links pointing to bookmarks in the same document, the view port will be scrolled to the destination specified in the link. - -The current API includes the following members, which allow customization of the default behavior or implementing custom logic: - -* __AnnotationClicked__ event of __RadPdfViewer__: This event is fired when you click on an annotation such as a hyperlink. It comes handy when you want to detect or even cancel the opening of a web page. The __AnnotationEventArgs__ contain the Annotation as property and the Link itself has information of its Action, i.e. if it is a UriAction. Handling the event in the following manner will not only show the Uri of each clicked link as the text of a MessageBox, but will also cancel the default behavior. - -#### AnnotationClicked Event Handler - -{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=AnnotationClicked}} -{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=AnnotationClicked}} - +--- +title: Annotations +page_title: Annotations - WinForms PdfViewer Control +description: WinForms PdfViewer supports Link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. +slug: winforms/pdfviewer/annotations +tags: annotations +published: True +position: 0 +--- + +# Annotations +__RadPdfViewer__ supports link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. In addition, if there are links pointing to bookmarks in the same document, the view port will be scrolled to the destination specified in the link. + +The current API includes the following members, which allow customization of the default behavior or implementing custom logic: + +* __AnnotationClicked__ event of __RadPdfViewer__: This event is fired when you click on an annotation such as a hyperlink. It comes handy when you want to detect or even cancel the opening of a web page. The __AnnotationEventArgs__ contain the Annotation as property and the Link itself has information of its Action, i.e. if it is a UriAction. Handling the event in the following manner will not only show the Uri of each clicked link as the text of a MessageBox, but will also cancel the default behavior. + +#### AnnotationClicked Event Handler + +{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=AnnotationClicked}} +{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=AnnotationClicked}} + ````C# private void radPdfViewer1_AnnotationClicked(object sender, Telerik.Windows.Documents.Fixed.Model.Annotations.EventArgs.AnnotationEventArgs e) @@ -37,8 +37,8 @@ private void radPdfViewer1_AnnotationClicked(object sender, Telerik.Windows.Docu MessageBox.Show(a.Uri.ToString()); e.Handled = true; } - -```` + +```` ````VB.NET Private Sub radPdfViewer1_AnnotationClicked(sender As Object, e As Telerik.Windows.Documents.Fixed.Model.Annotations.EventArgs.AnnotationEventArgs) Dim l As Telerik.Windows.Documents.Fixed.Model.Annotations.Link = TryCast(e.Annotation, Telerik.Windows.Documents.Fixed.Model.Annotations.Link) @@ -52,18 +52,64 @@ Private Sub radPdfViewer1_AnnotationClicked(sender As Object, e As Telerik.Windo MessageBox.Show(a.Uri.ToString()) e.Handled = True End Sub - -```` - -{{endregion}} - -* __Annotations__ property of __RadFixedDocument__ – A collection which returns all annotations in the document. For example you can retrieve all links using the following code: - -#### Get Annotation Links - -{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=GetAllLinks}} -{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=GetAllLinks}} - + +```` + +{{endregion}} + +* __HyperlinkClicked__ event of RadPdfViewer: This event is similar to AnnotationClicked, but it is raised only when you click on the hyperlink type annotations. It allows you to cancel the navigation to the associated URI or to modify the click action. The HyperlinkClickedEventArgs gives access to the URL, which can be manually checked if it is trusted. The navigation can be canceled by either setting the __Handled__ property of the event args to _true_ or the __IsTrustedUrl__ property to _false_. Below is an example of using this event to prompt that the clicked hyperlink might be unsafe and provide the opportunity to cancel the navigation process upon receiving the end user confirmation: + +#### HyperlinkClicked Event Handler + +{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=HyperlinkClicked}} +{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=HyperlinkClicked}} + +````C# +private void RadPdfViewer1_HyperlinkClicked(object sender, Telerik.WinControls.Hyperlinks.HyperlinkClickedEventArgs e) +{ + var link = e.URL; + if (link.EndsWith("exe")) + { + e.Handled = true; MessageBoxResult Result = System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (Result == MessageBoxResult.Yes) + { + Process.Start(new ProcessStartInfo() + { + FileName = link, + UseShellExecute = true + }); + } + } +} + +```` +````VB.NET +Private Sub RadPdfViewer1_HyperlinkClicked(sender As Object, e As HyperlinkClickedEventArgs) + Dim link = e.URL + If link.EndsWith("exe") Then + e.Handled = True + Dim Result As MessageBoxResult = System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question) + If Result = MessageBoxResult.Yes Then + Process.Start(New ProcessStartInfo() With { + .FileName = link, + .UseShellExecute = True + }) + End If + End If +End Sub + +```` + +{{endregion}} + + +* __Annotations__ property of __RadFixedDocument__ – A collection which returns all annotations in the document. For example you can retrieve all links using the following code: + +#### Get Annotation Links + +{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=GetAllLinks}} +{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=GetAllLinks}} + ````C# private IEnumerable GetAllLinks(Telerik.Windows.Documents.Fixed.Model.RadFixedDocument document) @@ -77,8 +123,8 @@ private IEnumerable GetA } } } - -```` + +```` ````VB.NET Private Iterator Function GetAllLinks(document As Telerik.Windows.Documents.Fixed.Model.RadFixedDocument) As IEnumerable(Of Telerik.Windows.Documents.Fixed.Model.Annotations.Link) For Each a As Telerik.Windows.Documents.Fixed.Model.Annotations.Annotation In document.Annotations @@ -88,18 +134,18 @@ Private Iterator Function GetAllLinks(document As Telerik.Windows.Documents.Fixe End If Next End Function - -```` - -{{endregion}} - -The bookmarks in terms of “docx bookmarks” are not explicitly saved in PDF files. They are persisted only if there are Link annotations to them, so you can use the snippet below to retrieve all destinations that have links to them: - -#### Get Annotation Bookmarks - -{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=Bookmarks}} -{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=Bookmarks}} - + +```` + +{{endregion}} + +The bookmarks in terms of “docx bookmarks” are not explicitly saved in PDF files. They are persisted only if there are Link annotations to them, so you can use the snippet below to retrieve all destinations that have links to them: + +#### Get Annotation Bookmarks + +{{source=..\SamplesCS\PdfViewer\PdfAnnotations.cs region=Bookmarks}} +{{source=..\SamplesVB\PdfViewer\PdfAnnotations.vb region=Bookmarks}} + ````C# private IEnumerable GetAllBookmarks(Telerik.Windows.Documents.Fixed.Model.RadFixedDocument document) @@ -113,8 +159,8 @@ private IEnumerable Date: Thu, 19 Sep 2024 15:18:57 +0300 Subject: [PATCH 06/12] Update hyperlink.md --- controls/richtexteditor/features/hyperlink.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controls/richtexteditor/features/hyperlink.md b/controls/richtexteditor/features/hyperlink.md index 364a480cf..c08a0b706 100644 --- a/controls/richtexteditor/features/hyperlink.md +++ b/controls/richtexteditor/features/hyperlink.md @@ -220,7 +220,7 @@ You have control over it using the __HyperlinkToolTipFormatString__ of **RadRich When a hyperlink is clicked, the __HyperlinkClicked__ event of __RadRichTextEditor__ is fired. The sender of the event is the document element, which you have clicked, e.g. a **Span**, an **Image**, **InlineUIContainer**, etc. The __HyperlinkClickedEventArgs__ provide the possibility either to cancel or replace the navigation action. This is helpful when you need to validate the clicked hyperlink and prevent it from navigating to an unsecure address or from starting a local process. -With the 2024 Q4 release, the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be cancelled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. +With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be cancelled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. Here is an example of using the HyperlinkClicked event prompting that the clicked hyperlink might be unsafe and allows to cancel the navigation process upon receiving the end user confirmation: From 4a3dc9621d898b239b105588742e9670937973b0 Mon Sep 17 00:00:00 2001 From: Nadya Todorova <48494959+nade7o@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:20:58 +0300 Subject: [PATCH 07/12] Update annotations.md --- controls/pdfviewer/features/annotations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controls/pdfviewer/features/annotations.md b/controls/pdfviewer/features/annotations.md index f090ded4c..64c17c30f 100644 --- a/controls/pdfviewer/features/annotations.md +++ b/controls/pdfviewer/features/annotations.md @@ -57,7 +57,7 @@ End Sub {{endregion}} -* __HyperlinkClicked__ event of RadPdfViewer: This event is similar to AnnotationClicked, but it is raised only when you click on the hyperlink type annotations. It allows you to cancel the navigation to the associated URI or to modify the click action. The HyperlinkClickedEventArgs gives access to the URL, which can be manually checked if it is trusted. The navigation can be canceled by either setting the __Handled__ property of the event args to _true_ or the __IsTrustedUrl__ property to _false_. Below is an example of using this event to prompt that the clicked hyperlink might be unsafe and provide the opportunity to cancel the navigation process upon receiving the end user confirmation: +* __HyperlinkClicked__ event of RadPdfViewer: This event is similar to AnnotationClicked, but it is raised only when you click on the hyperlink type annotations. It allows you to cancel the navigation to the associated URI or to modify the click action. The HyperlinkClickedEventArgs gives access to the URL, which can be manually checked if it is trusted. With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. If needed, the navigation can be canceled by either setting the __Handled__ property of the event args to _true_ or the __IsTrustedUrl__ property to _false_. Below is an example of using this event to prompt that the clicked hyperlink might be unsafe and provide the opportunity to cancel the navigation process upon receiving the end user confirmation: #### HyperlinkClicked Event Handler @@ -204,4 +204,4 @@ End Sub * [Getting Started]({%slug winforms/pdfviewer/getting-started%}) * [Logical Structure]({%slug winforms/pdfviewer/structure/logical-structure%}) * [Visual Structure]({%slug winforms/pdfviewer/structure/visual-structure%}) -* [Properties, Methods and Events]({%slug winforms/pdfviewer/properties-methods-and-events%}) \ No newline at end of file +* [Properties, Methods and Events]({%slug winforms/pdfviewer/properties-methods-and-events%}) From 6ac9d044f22f3e7ae3f931245ac911387b8b2000 Mon Sep 17 00:00:00 2001 From: Nadya Todorova <48494959+nade7o@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:33:27 +0300 Subject: [PATCH 08/12] Update spreadsheet-events.md --- controls/spreadsheet/events.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controls/spreadsheet/events.md b/controls/spreadsheet/events.md index ad1a472b6..ded36f4c1 100644 --- a/controls/spreadsheet/events.md +++ b/controls/spreadsheet/events.md @@ -154,7 +154,8 @@ End Sub * **ActivePresenterChanged**: Occurs when the active presenter is changed. -* **HyperlinkClicked**: Occurs when a hyperlink in the document gets clicked. The event allows you to either cancel or replace the navigation logic. HyperlinkClicked event can be used as a confirmation from the end-user whether to proceed or not with opening a hyperlink due to security reasons. +* **HyperlinkClicked**: Occurs when a hyperlink in the document gets clicked. The event allows you to either cancel or replace the navigation logic. HyperlinkClicked event can be used as a confirmation from the end-user whether to proceed or not with opening a hyperlink due to security reasons. + With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be cancelled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. #### Example 3: Using the HyperlinkClicked event to implement confirmation for the clicked links in the document From a6a54b90e59242f953e18d347f41d05e9e894fde Mon Sep 17 00:00:00 2001 From: Dinko Krastev Date: Fri, 20 Sep 2024 15:26:09 +0300 Subject: [PATCH 09/12] Update annotations.md --- controls/pdfviewer/features/annotations.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/controls/pdfviewer/features/annotations.md b/controls/pdfviewer/features/annotations.md index 64c17c30f..616785148 100644 --- a/controls/pdfviewer/features/annotations.md +++ b/controls/pdfviewer/features/annotations.md @@ -1,7 +1,7 @@ --- title: Annotations page_title: Annotations - WinForms PdfViewer Control -description: WinForms PdfViewer supports Link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. +description: WinForms PdfViewer supports Link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigate to the respective address. slug: winforms/pdfviewer/annotations tags: annotations published: True @@ -9,11 +9,12 @@ position: 0 --- # Annotations -__RadPdfViewer__ supports link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. In addition, if there are links pointing to bookmarks in the same document, the view port will be scrolled to the destination specified in the link. -The current API includes the following members, which allow customization of the default behavior or implementing custom logic: +__RadPdfViewer__ supports link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, and navigate to the respective address. In addition, if there are links pointing to bookmarks in the same document, the view port will be scrolled to the destination specified in the link. -* __AnnotationClicked__ event of __RadPdfViewer__: This event is fired when you click on an annotation such as a hyperlink. It comes handy when you want to detect or even cancel the opening of a web page. The __AnnotationEventArgs__ contain the Annotation as property and the Link itself has information of its Action, i.e. if it is a UriAction. Handling the event in the following manner will not only show the Uri of each clicked link as the text of a MessageBox, but will also cancel the default behavior. +The current API includes the following members, which allow customization of the default behavior or implementation of custom logic: + +* __AnnotationClicked__ event of __RadPdfViewer__: This event is fired when you click on an annotation such as a hyperlink. It comes in handy when you want to detect or even cancel the opening of a web page. The __AnnotationEventArgs__ contains the Annotation as property and the Link itself has information of its Action, i.e. if it is a UriAction. Handling the event in the following manner will not only show the Uri of each clicked link as the text of a MessageBox but will also cancel the default behavior. #### AnnotationClicked Event Handler @@ -103,7 +104,7 @@ End Sub {{endregion}} -* __Annotations__ property of __RadFixedDocument__ – A collection which returns all annotations in the document. For example you can retrieve all links using the following code: +* __Annotations__ property of __RadFixedDocument__ – A collection which returns all annotations in the document. For example, you can retrieve all links using the following code: #### Get Annotation Links @@ -175,7 +176,7 @@ End Function {{endregion}} -In this way it would be possible to create some UI that contains all bookmarks. Then, you could implement the same action as the one being executed when a hyperlink is clicked, i.e. scroll the document to the specific place in the document where the destination of the link is placed. The following code can be used for this purpose – navigating to a specific destination: +In this way, creating some UI containing all bookmarks would be possible. Then, you could implement the same action as the one being executed when a hyperlink is clicked, i.e. scroll the document to the specific place in the document where the destination of the link is placed. The following code can be used for this purpose – navigating to a specific destination: #### Navigate to Destination @@ -199,7 +200,7 @@ End Sub {{endregion}} -# See Also +## See Also * [Getting Started]({%slug winforms/pdfviewer/getting-started%}) * [Logical Structure]({%slug winforms/pdfviewer/structure/logical-structure%}) From 070c974f4a95ed4f9ab20f123a74cc9fd6a151a2 Mon Sep 17 00:00:00 2001 From: Dinko Krastev Date: Fri, 20 Sep 2024 15:28:40 +0300 Subject: [PATCH 10/12] Update hyperlink.md --- controls/richtexteditor/features/hyperlink.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/controls/richtexteditor/features/hyperlink.md b/controls/richtexteditor/features/hyperlink.md index c08a0b706..979dc0164 100644 --- a/controls/richtexteditor/features/hyperlink.md +++ b/controls/richtexteditor/features/hyperlink.md @@ -1,7 +1,7 @@ --- title: Hyperlink page_title: Hyperlink - WinForms RichTextEditor Control -description: WinForms RichTextEditor supports having a hyperlink span several paragraphs and being able to embed all kind of elements inside hyperlinks, e.g. images, tables and table elements. +description: WinForms RichTextEditor supports having a hyperlink span several paragraphs and being able to embed all kinds of elements inside hyperlinks, e.g. images, tables, and table elements. slug: winforms/richtexteditor-/features/hyperlink tags: hyperlink published: True @@ -15,13 +15,13 @@ The following functionality is supported in the __RadRichTextEditor__: * having a hyperlink span several paragraphs; -* being able to embed all kind of elements inside hyperlinks, e.g. images, tables and table elements; +* being able to embed all kinds of elements inside hyperlinks, e.g. images, tables, and table elements; * making bookmarks in the document the targets of hyperlinks. The classes that encapsulate the functionality of hyperlinks are [HyperlinkInfo](#hyperlinkinfo),[HyperlinkRangeStart and HyperlinkRangeEnd](#hyperlinkrangestart-and-hyperlinkrangeend). -[Other customization options](#othercustomizationoptions) include setting the tool tip format and detecting the click of hyperlinks. +[Other customization options](#othercustomizationoptions) include setting the tooltip format and detecting the click of hyperlinks. ## HyperlinkInfo @@ -174,7 +174,7 @@ The result (`Ctrl` + `Click` to follow): ![WinForms RadRichTextEditor Hyperlink Review](images/richtexteditor-features-hyperlink001.png) -You will also need to use **HyperlinkRangeStart** and **HyperlinkRangeEnd**, if you are using hyperlinks for the implementation of a custom logic and want to get all hyperlinks from the document, manipulate the properties of the **HyperlinkInfo** or the whole part of the document that is included in the hyperlink. +You will also need to use **HyperlinkRangeStart** and **HyperlinkRangeEnd**, if you are using hyperlinks for the implementation of custom logic and want to get all hyperlinks from the document, manipulate the properties of the **HyperlinkInfo** or the whole part of the document that is included in the hyperlink. For instance, here is how you can delete all hyperlinks in the document and replace them with some text: @@ -209,18 +209,18 @@ Next link ### ToolTip -By default, hyperlinks take a fixed string as a tool tip. The default format is: +By default, hyperlinks take a fixed string as a tooltip. The default format is: ->note "{0}{1} to follow link" - The first parameter is the URL, the second is "Ctrl + Click" which is taken from the localization file. +>note "{0}{1} to follow link" - The first parameter is the URL, and the second is "Ctrl + Click" which is taken from the localization file. > You have control over it using the __HyperlinkToolTipFormatString__ of **RadRichTextEditor**, which will set the format for all hyperlinks in the document. ### HyperlinkClicked event -When a hyperlink is clicked, the __HyperlinkClicked__ event of __RadRichTextEditor__ is fired. The sender of the event is the document element, which you have clicked, e.g. a **Span**, an **Image**, **InlineUIContainer**, etc. The __HyperlinkClickedEventArgs__ provide the possibility either to cancel or replace the navigation action. This is helpful when you need to validate the clicked hyperlink and prevent it from navigating to an unsecure address or from starting a local process. +When a hyperlink is clicked, the __HyperlinkClicked__ event of __RadRichTextEditor__ is fired. The sender of the event is the document element, that you have clicked, e.g. a **Span**, an **Image**, **InlineUIContainer**, etc. The __HyperlinkClickedEventArgs__ provides the possibility either to cancel or replace the navigation action. This is helpful when you need to validate the clicked hyperlink and prevent it from navigating to an unsecured address or from starting a local process. -With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be cancelled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. +With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be canceled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. Here is an example of using the HyperlinkClicked event prompting that the clicked hyperlink might be unsafe and allows to cancel the navigation process upon receiving the end user confirmation: @@ -294,7 +294,7 @@ Me.radRichTextEditor1.HyperlinkNavigationMode = Telerik.WinForms.Documents.UI.Hy {{endregion}} -# See Also +## See Also * [Document Elements]({%slug winforms/richtexteditor-/document-elements%}) From 50e9c7b94700dcbb572f49e17872d23e0e26f8de Mon Sep 17 00:00:00 2001 From: Dinko Krastev Date: Fri, 20 Sep 2024 15:29:38 +0300 Subject: [PATCH 11/12] Update events.md --- controls/spreadsheet/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controls/spreadsheet/events.md b/controls/spreadsheet/events.md index ded36f4c1..c214628a9 100644 --- a/controls/spreadsheet/events.md +++ b/controls/spreadsheet/events.md @@ -155,7 +155,7 @@ End Sub * **ActivePresenterChanged**: Occurs when the active presenter is changed. * **HyperlinkClicked**: Occurs when a hyperlink in the document gets clicked. The event allows you to either cancel or replace the navigation logic. HyperlinkClicked event can be used as a confirmation from the end-user whether to proceed or not with opening a hyperlink due to security reasons. - With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be cancelled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. + With the 2024 Q3 (2024.3.924), the default navigation behavior of the hyperlinks is to automatically open only valid and trusted addresses. The hyperlink navigation can be canceled by either setting the __Handled__ property of the HyperlinkClickedEventArgs to _true_ or __IsTrustedUrl__ to _false_. #### Example 3: Using the HyperlinkClicked event to implement confirmation for the clicked links in the document From 88c48701a7fa87c11eb06c758232200ad6fec967 Mon Sep 17 00:00:00 2001 From: Dinko Krastev Date: Fri, 20 Sep 2024 15:33:25 +0300 Subject: [PATCH 12/12] Update events.md