├── .gitattributes
├── .gitignore
├── Directory.Build.props
├── LICENSE.md
├── ModernWpf Community Toolkit.sln
├── ModernWpf.Toolkit.SampleApp
├── App.xaml
├── App.xaml.cs
├── Assets
│ ├── NotificationAssets
│ │ └── Sunny-Square.png
│ └── Photos
│ │ └── WestSeattleView.jpg
├── EmojiUIElementInline.cs
├── InitialContent.md
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── ModernWpf.Toolkit.SampleApp.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ └── DesignTimeResources.xaml
└── app.manifest
├── ModernWpf.Toolkit.UI.Controls.Markdown
├── CodeBlockFormatter.cs
├── Inlines
│ ├── CodeUIElementInline.cs
│ └── IUIElementInline.cs
├── MarkdownTextBlock
│ ├── CodeBlockResolvingEventArgs.cs
│ ├── EmojiInlineResolvingEventArgs.cs
│ ├── ImageResolvingDeferral.cs
│ ├── ImageResolvingEventArgs.cs
│ ├── LinkClickedEventArgs.cs
│ ├── MarkdownRenderedEventArgs.cs
│ ├── MarkdownTextBlock.Dimensions.cs
│ ├── MarkdownTextBlock.Events.cs
│ ├── MarkdownTextBlock.Methods.cs
│ ├── MarkdownTextBlock.Properties.cs
│ ├── MarkdownTextBlock.cs
│ └── MarkdownTextBlock.xaml
├── ModernWpf.Toolkit.UI.Controls.Markdown.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Render
│ ├── BlockCollectionRenderContext.cs
│ ├── ICodeBlockResolver.cs
│ ├── IEmojiInlineResolver.cs
│ ├── IImageResolver.cs
│ ├── ILinkRegister.cs
│ ├── InlineRenderContext.cs
│ ├── MarkdownRenderer.Blocks.cs
│ ├── MarkdownRenderer.Dimensions.cs
│ ├── MarkdownRenderer.Inlines.cs
│ ├── MarkdownRenderer.Properties.cs
│ ├── MarkdownRenderer.cs
│ ├── RenderContext.cs
│ └── RenderContextIncorrectException.cs
├── SelectableTextBlock.cs
└── Themes
│ └── Generic.xaml
├── ModernWpf.Toolkit.UI.Controls
├── Eyedropper
│ ├── Eyedropper.Logic.cs
│ ├── Eyedropper.Properties.cs
│ ├── Eyedropper.cs
│ ├── Eyedropper.xaml
│ ├── EyedropperColorChangedEventArgs.cs
│ ├── EyedropperToolButton.Properties.cs
│ ├── EyedropperToolButton.cs
│ └── EyedropperToolButton.xaml
├── FontIconEx.cs
├── ModernWpf.Toolkit.UI.Controls.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SimpleWrapPanel
│ ├── SimpleWrapPanel.Data.cs
│ ├── SimpleWrapPanel.cs
│ └── StretchChild.cs
└── Themes
│ └── Generic.xaml
├── ModernWpf.Toolkit.UI
├── Converters
│ ├── BoolNegationConverter.cs
│ ├── BoolToObjectConverter.cs
│ ├── BoolToVisibilityConverter.cs
│ ├── CollectionVisibilityConverter.cs
│ ├── ConverterTools.cs
│ ├── DoubleToObjectConverter.cs
│ ├── DoubleToVisibilityConverter.cs
│ ├── EmptyCollectionToObjectConverter.cs
│ ├── EmptyObjectToObjectConverter.cs
│ ├── EmptyStringToObjectConverter.cs
│ ├── FileSizeToFriendlyStringConverter.cs
│ ├── FormatStringConverter.cs
│ ├── StringFormatConverter.cs
│ ├── StringVisibilityConverter.cs
│ ├── TypeToObjectConverter.cs
│ └── VisibilityToBoolConverter.cs
├── Deferred
│ └── TypedEventHandlerExtensions.cs
├── DependencyPropertyChangedCallback.cs
├── Extensions
│ ├── DependencyObjectExtensions.cs
│ ├── DispatcherTimerExtensions.cs
│ ├── FrameworkElement
│ │ └── FrameworkElementExtensions.RelativeAncestor.cs
│ ├── Markup
│ │ ├── Abstract
│ │ │ └── TextIconExtension.cs
│ │ ├── BitmapIconExtension.cs
│ │ ├── BitmapIconSourceExtension.cs
│ │ ├── EnumValuesExtension.cs
│ │ ├── FontIconExtension.cs
│ │ ├── FontIconSourceExtension.cs
│ │ ├── NullableBool.cs
│ │ ├── SymbolIconExtension.cs
│ │ └── SymbolIconSourceExtension.cs
│ ├── Media
│ │ ├── MatrixExtensions.cs
│ │ ├── MatrixHelperEx.cs
│ │ ├── RotateTransformExtensions.cs
│ │ ├── ScaleTransformExtensions.cs
│ │ ├── SkewTransformExtensions.cs
│ │ └── TranslateTransformExtensions.cs
│ ├── ScrollViewer
│ │ ├── Enums
│ │ │ ├── Axis.cs
│ │ │ └── VisualProperty.cs
│ │ ├── ScrollViewerExtensions.Properties.cs
│ │ └── ScrollViewerExtensions.cs
│ ├── TextBoxMask
│ │ ├── TextBoxMask.Properties.cs
│ │ └── TextBoxMask.cs
│ ├── TextBoxRegEx
│ │ ├── TextBoxRegex.Data.cs
│ │ ├── TextBoxRegex.Properties.cs
│ │ └── TextBoxRegex.cs
│ └── Tree
│ │ ├── LogicalTree.cs
│ │ └── VisualTree.cs
├── Helpers
│ ├── BindableValueHolder.cs
│ ├── CompositionTargetHelper.cs
│ ├── DependencyPropertyWatcher.cs
│ └── GraphicsHelper.cs
├── ModernWpf.Toolkit.UI.csproj
├── Properties
│ └── AssemblyInfo.cs
└── ThemeResources
│ ├── Dark.xaml
│ ├── HighContrast.xaml
│ ├── Light.xaml
│ └── ToolkitThemeDictionary.cs
├── ModernWpf.Toolkit
├── Converters.cs
├── Deferred
│ ├── DeferredCancelEventArgs.cs
│ ├── DeferredEventArgs.cs
│ ├── EventDeferral.cs
│ └── EventHandlerExtensions.cs
├── Extensions
│ ├── PointExtensions.cs
│ ├── SizeExtensions.cs
│ └── StringExtensions.cs
├── Helpers
│ ├── ColorHelper.cs
│ └── WeakEventListener.cs
├── ModernWpf.Toolkit.csproj
├── Properties
│ └── AssemblyInfo.cs
└── Structures
│ ├── HslColor.cs
│ └── HsvColor.cs
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0.1.0
4 | ModernWpf.Toolkit
5 | MIT
6 | https://github.com/ModernWpf-Community/ModernWpfCommunityToolkit
7 | https://github.com/ModernWpf-Community/ModernWpfCommunityToolkit
8 | MIT
9 | git
10 | $(MSBuildThisFileDirectory)localpackages
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) .NET Foundation and Contributors
4 | All rights reserved.
5 |
6 | Copyright (c) 2020 Shankar
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is
13 | furnished to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in all
16 | copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | SOFTWARE.
25 |
--------------------------------------------------------------------------------
/ModernWpf Community Toolkit.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30128.36
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernWpf.Toolkit.SampleApp", "ModernWpf.Toolkit.SampleApp\ModernWpf.Toolkit.SampleApp.csproj", "{C9D2DBC9-FAD7-4923-9A70-44435C6F31E2}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernWpf.Toolkit.UI.Controls", "ModernWpf.Toolkit.UI.Controls\ModernWpf.Toolkit.UI.Controls.csproj", "{5A197E07-36CE-41C6-AB80-B4886D9FAB14}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernWpf.Toolkit", "ModernWpf.Toolkit\ModernWpf.Toolkit.csproj", "{E094D380-B238-4252-99E0-BA2F10EDEB51}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernWpf.Toolkit.UI", "ModernWpf.Toolkit.UI\ModernWpf.Toolkit.UI.csproj", "{DB1F7DC6-5FC7-4987-816E-65E66BAD7154}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernWpf.Toolkit.UI.Controls.Markdown", "ModernWpf.Toolkit.UI.Controls.Markdown\ModernWpf.Toolkit.UI.Controls.Markdown.csproj", "{EE62AF2F-FB8B-472D-AF17-3F62F588A41F}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {C9D2DBC9-FAD7-4923-9A70-44435C6F31E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {C9D2DBC9-FAD7-4923-9A70-44435C6F31E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {C9D2DBC9-FAD7-4923-9A70-44435C6F31E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {C9D2DBC9-FAD7-4923-9A70-44435C6F31E2}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {5A197E07-36CE-41C6-AB80-B4886D9FAB14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {5A197E07-36CE-41C6-AB80-B4886D9FAB14}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {5A197E07-36CE-41C6-AB80-B4886D9FAB14}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {5A197E07-36CE-41C6-AB80-B4886D9FAB14}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {E094D380-B238-4252-99E0-BA2F10EDEB51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {E094D380-B238-4252-99E0-BA2F10EDEB51}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {E094D380-B238-4252-99E0-BA2F10EDEB51}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {E094D380-B238-4252-99E0-BA2F10EDEB51}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {DB1F7DC6-5FC7-4987-816E-65E66BAD7154}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {DB1F7DC6-5FC7-4987-816E-65E66BAD7154}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {DB1F7DC6-5FC7-4987-816E-65E66BAD7154}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {DB1F7DC6-5FC7-4987-816E-65E66BAD7154}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {EE62AF2F-FB8B-472D-AF17-3F62F588A41F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {EE62AF2F-FB8B-472D-AF17-3F62F588A41F}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {EE62AF2F-FB8B-472D-AF17-3F62F588A41F}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {EE62AF2F-FB8B-472D-AF17-3F62F588A41F}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | GlobalSection(ExtensibilityGlobals) = postSolution
47 | SolutionGuid = {4D2E5882-F819-4EB6-BE25-227B22BE1804}
48 | EndGlobalSection
49 | EndGlobal
50 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace ModernWpf.Toolkit.SampleApp
4 | {
5 | public partial class App : Application
6 | {
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/Assets/NotificationAssets/Sunny-Square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModernWpf-Community/ModernWpfCommunityToolkit/8bbe2231087575df182a7740839b92e917fa711b/ModernWpf.Toolkit.SampleApp/Assets/NotificationAssets/Sunny-Square.png
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/Assets/Photos/WestSeattleView.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModernWpf-Community/ModernWpfCommunityToolkit/8bbe2231087575df182a7740839b92e917fa711b/ModernWpf.Toolkit.SampleApp/Assets/Photos/WestSeattleView.jpg
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/EmojiUIElementInline.cs:
--------------------------------------------------------------------------------
1 | using Emoji.Wpf;
2 | using ModernWpf.Toolkit.UI.Controls.Markdown.Inlines;
3 |
4 | namespace ModernWpf.Toolkit.SampleApp
5 | {
6 | public class EmojiUIElementInline : EmojiInline, IUIElementInline
7 | {
8 | public string GetUIContentString() => Text;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using ModernWpf.Toolkit.UI.Controls;
2 | using System;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Windows;
6 | using System.Windows.Documents;
7 | using System.Windows.Media;
8 |
9 | namespace ModernWpf.Toolkit.SampleApp
10 | {
11 | public partial class MainWindow : Window
12 | {
13 | public MainWindow()
14 | {
15 | InitializeComponent();
16 | Loaded += MainWindow_Loaded;
17 | MDbox.LinkClicked += MDbox_LinkClicked;
18 | MDbox.ImageClicked += MDbox_ImageClicked;
19 | MDbox.CodeBlockResolving += MDbox_CodeBlockResolving;
20 | MDbox.EmojiInlineResolving += MDbox_EmojiInlineResolving;
21 | MDbox.MarkdownRendered += MDbox_MarkdownRendered;
22 | }
23 |
24 | private void MDbox_MarkdownRendered(object sender, MarkdownRenderedEventArgs e)
25 | {
26 | if (e.Exception == null && MDbox.Text != null)
27 | {
28 | Debug.WriteLine("Rendered yay!");
29 | }
30 | }
31 |
32 | private void MDbox_EmojiInlineResolving(object sender, EmojiInlineResolvingEventArgs e)
33 | {
34 | try
35 | {
36 | double fontSize = Math.Max(16.0, MDbox.FontSize);
37 | e.EmojiInline = new EmojiUIElementInline { Text = e.EmojiString, FontSize = fontSize, FallbackBrush = MDbox.Foreground };
38 | e.Handled = true;
39 | }
40 | catch
41 | {
42 | e.EmojiInline = null;
43 | e.Handled = false;
44 | }
45 | }
46 |
47 | private void MDbox_CodeBlockResolving(object sender, CodeBlockResolvingEventArgs e)
48 | {
49 | if (e.CodeLanguage == "CUSTOM")
50 | {
51 | e.Handled = true;
52 | e.InlineCollection.Add(new Run { Foreground = new SolidColorBrush(Colors.Red), Text = e.Text, FontWeight = FontWeights.Bold });
53 | }
54 | }
55 |
56 | private void MDbox_ImageClicked(object sender, LinkClickedEventArgs e)
57 | {
58 | if (!Uri.TryCreate(e.Link, UriKind.Absolute, out Uri result))
59 | {
60 | MessageBox.Show("Masked relative Images needs to be manually handled.");
61 | }
62 | else
63 | {
64 | var psi = new ProcessStartInfo()
65 | {
66 | FileName = e.Link,
67 | UseShellExecute = true
68 | };
69 | Process.Start(psi);
70 | }
71 | }
72 |
73 | private void MDbox_LinkClicked(object sender, LinkClickedEventArgs e)
74 | {
75 | if (!Uri.TryCreate(e.Link, UriKind.Absolute, out Uri result))
76 | {
77 | MessageBox.Show("Masked relative links needs to be manually handled.");
78 | }
79 | else
80 | {
81 | var psi = new ProcessStartInfo()
82 | {
83 | FileName = e.Link,
84 | UseShellExecute = true
85 | };
86 | Process.Start(psi);
87 | }
88 | }
89 |
90 | private void MainWindow_Loaded(object sender, RoutedEventArgs e)
91 | {
92 | string initialmd = GetInitialMD();
93 | EditorBox.Text = initialmd;
94 | }
95 |
96 | private string GetInitialMD()
97 | {
98 | return File.ReadAllText("InitialContent.md");
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/ModernWpf.Toolkit.SampleApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net5.0-windows10.0.18362.0;netcoreapp3.1;net462
6 | true
7 | latest
8 | app.manifest
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Always
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | MSBuild:Compile
28 | Designer
29 | True
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | Always
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/Properties/DesignTimeResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.SampleApp/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 |
55 | PerMonitor
56 | true
57 |
58 |
59 |
60 |
61 |
62 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.UI.Controls.Markdown/Inlines/CodeUIElementInline.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Documents;
4 |
5 | namespace ModernWpf.Toolkit.UI.Controls.Markdown.Inlines
6 | {
7 | internal class CodeUIElementInline : InlineUIContainer, IUIElementInline
8 | {
9 | public CodeUIElementInline()
10 | {
11 | }
12 |
13 | ///
14 | /// Redeclare the Child property to prevent it from being serialized.
15 | ///
16 | public new Border Child
17 | {
18 | get => base.Child as Border;
19 | internal set => base.Child = value;
20 | }
21 |
22 | public string Text
23 | {
24 | get => (string)GetValue(TextProperty);
25 | set => SetValue(TextProperty, value);
26 | }
27 |
28 | public static readonly DependencyProperty TextProperty =
29 | DependencyProperty.Register(
30 | nameof(Text),
31 | typeof(string),
32 | typeof(CodeUIElementInline),
33 | new PropertyMetadata(""));
34 |
35 | protected override bool ShouldSerializeProperty(DependencyProperty dp)
36 | => dp.Name == nameof(Text) && base.ShouldSerializeProperty(dp);
37 |
38 | protected bool ShouldSerializeChild() => false;
39 |
40 | public string GetUIContentString() => Text;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.UI.Controls.Markdown/Inlines/IUIElementInline.cs:
--------------------------------------------------------------------------------
1 | namespace ModernWpf.Toolkit.UI.Controls.Markdown.Inlines
2 | {
3 | public interface IUIElementInline
4 | {
5 | string GetUIContentString();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.UI.Controls.Markdown/MarkdownTextBlock/CodeBlockResolvingEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Windows.Documents;
7 |
8 | namespace ModernWpf.Toolkit.UI.Controls
9 | {
10 | ///
11 | /// Arguments for the event when a Code Block is being rendered.
12 | ///
13 | public class CodeBlockResolvingEventArgs : EventArgs
14 | {
15 | internal CodeBlockResolvingEventArgs(InlineCollection inlineCollection, string text, string codeLanguage)
16 | {
17 | InlineCollection = inlineCollection;
18 | Text = text;
19 | CodeLanguage = codeLanguage;
20 | }
21 |
22 | ///
23 | /// Gets the language of the Code Block, as specified by ```{Language} on the first line of the block,
24 | /// e.g.
25 | /// ```C#
26 | /// public void Method();
27 | /// ```
28 | ///
29 | public string CodeLanguage { get; }
30 |
31 | ///
32 | /// Gets the raw code block text
33 | ///
34 | public string Text { get; }
35 |
36 | ///
37 | /// Gets Collection to add formatted Text to.
38 | ///
39 | public InlineCollection InlineCollection { get; }
40 |
41 | ///
42 | /// Gets or sets a value indicating whether this event was handled successfully.
43 | ///
44 | public bool Handled { get; set; } = false;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.UI.Controls.Markdown/MarkdownTextBlock/EmojiInlineResolvingEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Documents;
3 |
4 | namespace ModernWpf.Toolkit.UI.Controls
5 | {
6 | ///
7 | /// Arguments for the event which is called when a emoji needs to be resolved to a .
8 | ///
9 | public class EmojiInlineResolvingEventArgs : EventArgs
10 | {
11 | internal EmojiInlineResolvingEventArgs(string emojiString)
12 | {
13 | EmojiString = emojiString;
14 | }
15 |
16 | ///
17 | /// Gets the emoji string in the markdown document.
18 | ///
19 | public string EmojiString { get; }
20 |
21 | ///
22 | /// Gets or sets a value indicating whether this event was handled successfully.
23 | ///
24 | public bool Handled { get; set; }
25 |
26 | ///
27 | /// Gets or sets the emoji inline to display in the .
28 | ///
29 | public Inline EmojiInline { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.UI.Controls.Markdown/MarkdownTextBlock/ImageResolvingDeferral.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ModernWpf.Toolkit.UI.Controls
4 | {
5 | public sealed class ImageResolvingDeferral
6 | {
7 | private readonly Action _handler;
8 |
9 | internal ImageResolvingDeferral(Action handler)
10 | {
11 | _handler = handler ?? throw new ArgumentNullException(nameof(handler));
12 | }
13 |
14 | public void Complete()
15 | {
16 | _handler();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ModernWpf.Toolkit.UI.Controls.Markdown/MarkdownTextBlock/ImageResolvingEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 | using System.Windows.Media;
10 |
11 | namespace ModernWpf.Toolkit.UI.Controls
12 | {
13 | ///
14 | /// Arguments for the event which is called when a url needs to be resolved to a .
15 | ///
16 | public class ImageResolvingEventArgs : EventArgs
17 | {
18 | private readonly IList> _deferrals;
19 |
20 | internal ImageResolvingEventArgs(string url, string tooltip)
21 | {
22 | _deferrals = new List>();
23 | Url = url;
24 | Tooltip = tooltip;
25 | }
26 |
27 | ///
28 | /// Gets the url of the image in the markdown document.
29 | ///
30 | public string Url { get; }
31 |
32 | ///
33 | /// Gets the tooltip of the image in the markdown document.
34 | ///
35 | public string Tooltip { get; }
36 |
37 | ///
38 | /// Gets or sets a value indicating whether this event was handled successfully.
39 | ///
40 | public bool Handled { get; set; }
41 |
42 | ///
43 | /// Gets or sets the image to display in the .
44 | ///
45 | public ImageSource Image { get; set; }
46 |
47 | ///
48 | /// Informs the that the event handler might run asynchronously.
49 | ///
50 | /// Deferral
51 | public ImageResolvingDeferral GetDeferral()
52 | {
53 | var task = new TaskCompletionSource