| ofs | hex dump | ascii |
|---|
| 0000 | 4f 54 54 4f 00 0c 00 80 00 03 00 40 43 46 46 20 db b8 19 c2 00 00 0f cc 00 00 e4 e3 44 53 49 47 | OTTO.......@CFF.............DSIG |
| 0020 | cd 29 bb 0a 00 01 d8 f0 00 00 04 00 47 50 4f 53 ee b5 60 1c 00 00 f4 b0 00 00 cd 84 47 53 55 42 | .)..........GPOS..`.........GSUB |
| 0040 | ea e1 bf 70 00 01 c2 34 00 00 10 10 4f 53 2f 32 cc 28 29 15 00 00 01 30 00 00 00 60 63 6d 61 70 | ...p...4....OS/2.()....0...`cmap |
| 0060 | 2b ed 7e 09 00 00 09 d0 00 00 05 dc 68 65 61 64 03 b4 ca 0a 00 00 00 cc 00 00 00 36 68 68 65 61 | +.~.........head...........6hhea |
| 0080 | 1b 4b 0f ab 00 00 01 04 00 00 00 24 68 6d 74 78 39 c8 21 2d 00 01 d2 44 00 00 06 ac 6d 61 78 70 | .K.........$hmtx9.!-...D....maxp |
| 00a0 | 01 ab 50 00 00 00 01 28 00 00 00 06 6e 61 6d 65 cc 7f a4 58 00 00 01 90 00 00 08 3f 70 6f 73 74 | ..P....(....name...X.......?post |
| 00c0 | fe c1 00 a7 00 00 0f ac 00 00 00 20 00 01 00 00 00 01 01 89 d3 54 7d a3 5f 0f 3c f5 00 03 0d 05 | .....................T}._.<..... |
| 00e0 | 00 00 00 00 cb 6a ba 9c 00 00 00 00 cb 6a ba 9c fd 85 fc cb 10 40 0c 81 00 03 00 03 00 02 00 00 | .....j.......j.......@.......... |
| 0100 | 00 00 00 00 00 01 00 00 0a 49 fd 44 02 9b 10 64 fd 85 fc cc 10 40 03 e8 00 9e ff a4 00 00 00 00 | .........I.D...d.....@.......... |
| 0120 | 00 00 00 00 00 00 01 ab 00 00 50 00 01 ab 00 00 00 02 06 ba 02 58 00 05 00 04 09 1d 08 77 00 00 | ..........P..........X.......w.. |
| 0140 | 01 d3 09 1d 08 77 00 00 06 36 00 a6 02 ed 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 af 40 00 | .....w...6....................@. |
| 0160 | 20 6b 00 00 00 00 00 00 00 00 44 75 72 6f 00 21 00 20 fb 04 0a 49 fd 44 02 9b 0b 97 04 09 00 00 | .k........Duro.!.....I.D........ |
| 0180 | 00 13 00 00 00 00 06 f5 09 1a 00 00 00 20 00 0c 00 00 00 23 01 aa 00 01 00 00 00 00 00 00 00 46 | ...................#...........F |
| 01a0 | 00 00 00 01 00 00 00 00 00 01 00 05 00 46 00 01 00 00 00 00 00 02 00 0b 00 4b 00 01 00 00 00 00 | .............F...........K...... |
| 01c0 | 00 03 00 32 00 56 00 01 00 00 00 00 00 04 00 11 00 88 00 01 00 00 00 00 00 05 00 29 00 99 00 01 | ...2.V.....................).... |
| 01e0 | 00 00 00 00 00 06 00 0c 00 c2 00 01 00 00 00 00 00 07 00 21 00 ce 00 01 00 00 00 00 00 08 00 08 | ...................!............ |
| 0200 | 00 ef 00 01 00 00 00 00 00 09 00 08 00 f7 00 01 00 00 00 00 00 0a 00 01 00 ff 00 01 00 00 00 00 | ................................ |
| 0220 | 00 0b 00 10 01 00 00 01 00 00 00 00 00 0c 00 01 00 ff 00 01 00 00 00 00 00 0d 01 1a 01 10 00 01 | ................................ |
| 0240 | 00 00 00 00 00 0e 00 10 01 00 00 01 00 00 00 00 00 10 00 05 00 46 00 01 00 00 00 00 00 11 00 0b | .....................F.......... |
| 0260 | 00 4b 00 01 00 00 00 00 00 12 00 0d 02 2a 00 03 00 01 04 09 00 00 00 8c 02 37 00 03 00 01 04 09 | .K...........*...........7...... |
| 0280 | 00 01 00 16 02 c3 00 03 00 01 04 09 00 02 00 16 02 d9 00 03 00 01 04 09 00 03 00 64 02 ef 00 03 | ...........................d.... |
| 02a0 | 00 01 04 09 00 04 00// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
namespace Tango.Scripting.Editors.Rendering
{
/// <summary>
/// VisualLineElement that represents a piece of text and is a clickable link.
/// </summary>
public class VisualLineLinkText : VisualLineText
{
/// <summary>
/// Gets/Sets the URL that is navigated to when the link is clicked.
/// </summary>
public Uri NavigateUri { get; set; }
/// <summary>
/// Gets/Sets the window name where the URL will be opened.
/// </summary>
public string TargetName { get; set; }
/// <summary>
/// Gets/Sets whether the user needs to press Control to click the link.
/// The default value is true.
/// </summary>
public bool RequireControlModifierForClick { get; set; }
/// <summary>
/// Creates a visual line text element with the specified length.
/// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its
/// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string.
/// </summary>
public VisualLineLinkText(VisualLine parentVisualLine, int length) : base(parentVisualLine, length)
{
this.RequireControlModifierForClick = true;
}
/// <inheritdoc/>
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
this.TextRunProperties.SetForegroundBrush(context.TextView.LinkTextForegroundBrush);
this.TextRunProperties.SetBackgroundBrush(context.TextView.LinkTextBackgroundBrush);
this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
return base.CreateTextRun(startVisualColumn, context);
}
/// <summary>
/// Gets whether the link is currently clickable.
/// </summary>
/// <remarks>Returns true when control is pressed; or when
/// <see cref="RequireControlModifierForClick"/> is disabled.</remarks>
protected bool LinkIsClickable()
{
if (NavigateUri == null)
return false;
if (RequireControlModifierForClick)
return (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
else
return true;
}
/// <inheritdoc/>
protected internal override void OnQueryCursor(QueryCursorEventArgs e)
{
if (LinkIsClickable()) {
e.Handled = true;
e.Cursor = Cursors.Hand;
}
}
/// <inheritdoc/>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "I've seen Process.Start throw undocumented exceptions when the mail client / web browser is installed incorrectly")]
protected internal override void OnMouseDown(MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left && !e.Handled && LinkIsClickable()) {
RequestNavigateEventArgs args = new RequestNavigateEventArgs(this.NavigateUri, this.TargetName);
args.RoutedEvent = Hyperlink.RequestNavigateEvent;
FrameworkElement element = e.Source as FrameworkElement;
if (element != null) {
// allow user code to handle the navigation request
element.RaiseEvent(args);
}
if (!args.Handled) {
try {
Process.Start(this.NavigateUri.ToString());
} catch {
// ignore all kinds of errors during web browser start
}
}
e.Handled = true;
}
}
/// <inheritdoc/>
protected override VisualLineText CreateInstance(int length)
{
return new VisualLineLinkText(ParentVisualLine, length) {
NavigateUri = this.NavigateUri,
TargetName = this.TargetName,
RequireControlModifierForClick = this.RequireControlModifierForClick
};
}
}
}
|