├── .gitignore
├── App.xaml
├── App.xaml.cs
├── Assets
├── LargeTile.scale-100.png
├── LargeTile.scale-125.png
├── LargeTile.scale-150.png
├── LargeTile.scale-200.png
├── LargeTile.scale-400.png
├── LockScreenLogo.scale-200.png
├── SmallTile.scale-100.png
├── SmallTile.scale-125.png
├── SmallTile.scale-150.png
├── SmallTile.scale-200.png
├── SmallTile.scale-400.png
├── SplashScreen.scale-100.png
├── SplashScreen.scale-125.png
├── SplashScreen.scale-150.png
├── SplashScreen.scale-200.png
├── SplashScreen.scale-400.png
├── Square150x150Logo.scale-100.png
├── Square150x150Logo.scale-125.png
├── Square150x150Logo.scale-150.png
├── Square150x150Logo.scale-200.png
├── Square150x150Logo.scale-400.png
├── Square44x44Logo.altform-lightunplated_targetsize-16.png
├── Square44x44Logo.altform-lightunplated_targetsize-24.png
├── Square44x44Logo.altform-lightunplated_targetsize-256.png
├── Square44x44Logo.altform-lightunplated_targetsize-32.png
├── Square44x44Logo.altform-lightunplated_targetsize-48.png
├── Square44x44Logo.altform-unplated_targetsize-16.png
├── Square44x44Logo.altform-unplated_targetsize-24.png
├── Square44x44Logo.altform-unplated_targetsize-256.png
├── Square44x44Logo.altform-unplated_targetsize-32.png
├── Square44x44Logo.altform-unplated_targetsize-48.png
├── Square44x44Logo.scale-100.png
├── Square44x44Logo.scale-125.png
├── Square44x44Logo.scale-150.png
├── Square44x44Logo.scale-200.png
├── Square44x44Logo.scale-400.png
├── Square44x44Logo.targetsize-16.png
├── Square44x44Logo.targetsize-24.png
├── Square44x44Logo.targetsize-24_altform-unplated.png
├── Square44x44Logo.targetsize-256.png
├── Square44x44Logo.targetsize-32.png
├── Square44x44Logo.targetsize-48.png
├── StoreLogo.backup.png
├── StoreLogo.scale-100.png
├── StoreLogo.scale-125.png
├── StoreLogo.scale-150.png
├── StoreLogo.scale-200.png
├── StoreLogo.scale-400.png
├── Wide310x150Logo.scale-100.png
├── Wide310x150Logo.scale-125.png
├── Wide310x150Logo.scale-150.png
├── Wide310x150Logo.scale-200.png
├── Wide310x150Logo.scale-400.png
├── rtf-icon.png
└── txt-icon.png
├── BasePage.xaml
├── BasePage.xaml.cs
├── Converters
├── BooleanToVisibility.cs
├── IntToTextWrapping.cs
├── IntToThickness.cs
└── SettingsConverters.cs
├── Dialogs
├── AboutDialog.xaml
├── AboutDialog.xaml.cs
├── ImageOptionsDialog.xaml
└── ImageOptionsDialog.xaml.cs
├── Helpers
├── ResourceHelper.cs
└── RichEditHelpers.cs
├── LICENSE
├── Package.appxmanifest
├── Properties
├── AssemblyInfo.cs
└── Default.rd.xml
├── README.md
├── Strings
├── de-DE
│ └── Resources.resw
├── en-GB
│ └── Resources.resw
├── en-US
│ └── Resources.resw
└── pt-PT
│ └── Resources.resw
├── TowPad.csproj
├── TowPad.sln
├── UserControls
├── SettingsBlockControl.xaml
├── SettingsBlockControl.xaml.cs
├── SettingsDisplayControl.xaml
└── SettingsDisplayControl.xaml.cs
├── ViewModels
├── RecentlyUsedViewModel.cs
├── Settings
│ ├── SettingsViewModel.cs
│ └── ViewModel.cs
└── WhatsNewItemViewModel.cs
├── Views
├── HomePage.xaml
├── HomePage.xaml.cs
├── MainPage.xaml
├── MainPage.xaml.cs
└── Settings
│ ├── SettingsPage.xaml
│ └── SettingsPage.xaml.cs
└── privacy-policy.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/App.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
27 |
28 |
35 |
36 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Toolkit.Uwp.UI.Helpers;
2 | using Rich_Text_Editor.ViewModels;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Runtime.InteropServices.WindowsRuntime;
8 | using Windows.ApplicationModel;
9 | using Windows.ApplicationModel.Activation;
10 | using Windows.ApplicationModel.Core;
11 | using Windows.ApplicationModel.Resources;
12 | using Windows.Foundation;
13 | using Windows.Foundation.Collections;
14 | using Windows.Storage;
15 | using Windows.Storage.Streams;
16 | using Windows.UI.Xaml;
17 | using Windows.UI.Xaml.Controls;
18 | using Windows.UI.Xaml.Controls.Primitives;
19 | using Windows.UI.Xaml.Data;
20 | using Windows.UI.Xaml.Input;
21 | using Windows.UI.Xaml.Media;
22 | using Windows.UI.Xaml.Navigation;
23 |
24 | namespace Rich_Text_Editor
25 | {
26 | ///
27 | /// Provides application-specific behavior to supplement the default Application class.
28 | ///
29 | sealed partial class App : Application
30 | {
31 | ///
32 | /// Initializes the singleton application object. This is the first line of authored code
33 | /// executed, and as such is the logical equivalent of main() or WinMain().
34 | ///
35 |
36 | public static SettingsViewModel SViewModel { get; private set; }
37 | public static List Tips { get; private set; }
38 |
39 | public App()
40 | {
41 | InitializeComponent();
42 | Suspending += OnSuspending;
43 |
44 | SViewModel = new();
45 | Tips = new();
46 | }
47 |
48 | ///
49 | /// Invoked when the application is launched normally by the end user. Other entry points
50 | /// will be used such as when the application is launched to open a specific file.
51 | ///
52 | /// Details about the launch request and process.
53 | protected override void OnLaunched(LaunchActivatedEventArgs e)
54 | {
55 | // Do not repeat app initialization when the Window already has content,
56 | // just ensure that the window is active
57 | if (Window.Current.Content is not Frame rootFrame)
58 | {
59 | // Create a Frame to act as the navigation context and navigate to the first page
60 | rootFrame = new Frame();
61 |
62 | rootFrame.NavigationFailed += OnNavigationFailed;
63 |
64 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
65 | {
66 | //TODO: Load state from previously suspended application
67 | }
68 |
69 | // Place the frame in the current Window
70 | Window.Current.Content = rootFrame;
71 | }
72 |
73 | if (!e.PrelaunchActivated)
74 | {
75 | CoreApplication.EnablePrelaunch(true);
76 |
77 | switch (SViewModel.Theme)
78 | {
79 | case 0:
80 | rootFrame.RequestedTheme = ElementTheme.Light;
81 | break;
82 | case 1:
83 | rootFrame.RequestedTheme = ElementTheme.Dark;
84 | break;
85 | case 2:
86 | rootFrame.RequestedTheme = ElementTheme.Default;
87 | break;
88 | }
89 |
90 | if (rootFrame.Content == null)
91 | {
92 | // When the navigation stack isn't restored navigate to the first page,
93 | // configuring the new page by passing required information as a navigation
94 | // parameter
95 | rootFrame.Navigate(typeof(BasePage), e.Arguments);
96 | }
97 | // Ensure the current window is active
98 | Window.Current.Activate();
99 | }
100 | }
101 |
102 | ///
103 | /// Invoked when Navigation to a certain page fails
104 | ///
105 | /// The Frame which failed navigation
106 | /// Details about the navigation failure
107 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
108 | {
109 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
110 | }
111 |
112 | ///
113 | /// Invoked when application execution is being suspended. Application state is saved
114 | /// without knowing whether the application will be terminated or resumed with the contents
115 | /// of memory still intact.
116 | ///
117 | /// The source of the suspend request.
118 | /// Details about the suspend request.
119 | private void OnSuspending(object sender, SuspendingEventArgs e)
120 | {
121 | var deferral = e?.SuspendingOperation?.GetDeferral();
122 | //TODO: Save application state and stop any background activity
123 | deferral?.Complete();
124 | }
125 |
126 | protected override void OnFileActivated(FileActivatedEventArgs args)
127 | {
128 | // TODO: Handle file activation
129 | // The number of files received is args.Files.Size
130 | // The name of the first file is args.Files[0].Name
131 | if (Window.Current.Content is not Frame)
132 | {
133 | Frame rootFrame = new();
134 |
135 | rootFrame.Navigate(typeof(BasePage));
136 | Window.Current.Content = rootFrame;
137 | Window.Current.Activate();
138 |
139 | BasePage.Current.Tabs.TabItems.RemoveAt(0);
140 | }
141 |
142 | BasePage.Current?.OpenFilesWithArgs(args);
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/Assets/LargeTile.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/LargeTile.scale-100.png
--------------------------------------------------------------------------------
/Assets/LargeTile.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/LargeTile.scale-125.png
--------------------------------------------------------------------------------
/Assets/LargeTile.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/LargeTile.scale-150.png
--------------------------------------------------------------------------------
/Assets/LargeTile.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/LargeTile.scale-200.png
--------------------------------------------------------------------------------
/Assets/LargeTile.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/LargeTile.scale-400.png
--------------------------------------------------------------------------------
/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/Assets/SmallTile.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SmallTile.scale-100.png
--------------------------------------------------------------------------------
/Assets/SmallTile.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SmallTile.scale-125.png
--------------------------------------------------------------------------------
/Assets/SmallTile.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SmallTile.scale-150.png
--------------------------------------------------------------------------------
/Assets/SmallTile.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SmallTile.scale-200.png
--------------------------------------------------------------------------------
/Assets/SmallTile.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SmallTile.scale-400.png
--------------------------------------------------------------------------------
/Assets/SplashScreen.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SplashScreen.scale-100.png
--------------------------------------------------------------------------------
/Assets/SplashScreen.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SplashScreen.scale-125.png
--------------------------------------------------------------------------------
/Assets/SplashScreen.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SplashScreen.scale-150.png
--------------------------------------------------------------------------------
/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/Assets/SplashScreen.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/SplashScreen.scale-400.png
--------------------------------------------------------------------------------
/Assets/Square150x150Logo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square150x150Logo.scale-100.png
--------------------------------------------------------------------------------
/Assets/Square150x150Logo.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square150x150Logo.scale-125.png
--------------------------------------------------------------------------------
/Assets/Square150x150Logo.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square150x150Logo.scale-150.png
--------------------------------------------------------------------------------
/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/Assets/Square150x150Logo.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square150x150Logo.scale-400.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-unplated_targetsize-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-unplated_targetsize-16.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-unplated_targetsize-24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-unplated_targetsize-24.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-unplated_targetsize-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-unplated_targetsize-256.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-unplated_targetsize-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-unplated_targetsize-32.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.altform-unplated_targetsize-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.altform-unplated_targetsize-48.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.scale-100.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.scale-125.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.scale-150.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.scale-400.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.targetsize-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.targetsize-16.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.targetsize-24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.targetsize-24.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.targetsize-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.targetsize-256.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.targetsize-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.targetsize-32.png
--------------------------------------------------------------------------------
/Assets/Square44x44Logo.targetsize-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Square44x44Logo.targetsize-48.png
--------------------------------------------------------------------------------
/Assets/StoreLogo.backup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/StoreLogo.backup.png
--------------------------------------------------------------------------------
/Assets/StoreLogo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/StoreLogo.scale-100.png
--------------------------------------------------------------------------------
/Assets/StoreLogo.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/StoreLogo.scale-125.png
--------------------------------------------------------------------------------
/Assets/StoreLogo.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/StoreLogo.scale-150.png
--------------------------------------------------------------------------------
/Assets/StoreLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/StoreLogo.scale-200.png
--------------------------------------------------------------------------------
/Assets/StoreLogo.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/StoreLogo.scale-400.png
--------------------------------------------------------------------------------
/Assets/Wide310x150Logo.scale-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Wide310x150Logo.scale-100.png
--------------------------------------------------------------------------------
/Assets/Wide310x150Logo.scale-125.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Wide310x150Logo.scale-125.png
--------------------------------------------------------------------------------
/Assets/Wide310x150Logo.scale-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Wide310x150Logo.scale-150.png
--------------------------------------------------------------------------------
/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/Assets/Wide310x150Logo.scale-400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/Wide310x150Logo.scale-400.png
--------------------------------------------------------------------------------
/Assets/rtf-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/rtf-icon.png
--------------------------------------------------------------------------------
/Assets/txt-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itsWindows11/TowPad/057657caa541e41ca307e5f02d56f4ef27d1201f/Assets/txt-icon.png
--------------------------------------------------------------------------------
/BasePage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices.WindowsRuntime;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.ApplicationModel.Core;
9 | using Windows.Foundation;
10 | using Windows.Foundation.Collections;
11 | using Windows.Storage;
12 | using Windows.UI;
13 | using Windows.UI.Core.Preview;
14 | using Windows.UI.ViewManagement;
15 | using Windows.UI.Xaml;
16 | using Windows.UI.Xaml.Controls;
17 | using Windows.UI.Xaml.Controls.Primitives;
18 | using Windows.UI.Xaml.Data;
19 | using Windows.UI.Xaml.Input;
20 | using Windows.UI.Xaml.Media;
21 | using Windows.UI.Xaml.Navigation;
22 |
23 | // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
24 |
25 | namespace Rich_Text_Editor
26 | {
27 | ///
28 | /// An empty page that can be used on its own or navigated to within a Frame.
29 | ///
30 | public sealed partial class BasePage : Page
31 | {
32 | public static BasePage Current;
33 |
34 | public bool _openDialog;
35 |
36 | public BasePage()
37 | {
38 | InitializeComponent();
39 |
40 | Current = this;
41 |
42 | if (Tabs.TabItems.Count == 0)
43 | CreateNewTab(false);
44 |
45 | var appViewTitleBar = ApplicationView.GetForCurrentView().TitleBar;
46 |
47 | appViewTitleBar.ButtonBackgroundColor = Colors.Transparent;
48 | appViewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
49 |
50 | var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
51 | coreTitleBar.ExtendViewIntoTitleBar = true;
52 |
53 | Window.Current.SetTitleBar(CustomDragRegion);
54 |
55 | coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;
56 |
57 | // Keep tabs open if the root frame navigated elsewhere
58 | NavigationCacheMode = NavigationCacheMode.Enabled;
59 |
60 | (CompactOverlayBtn.Content as FontIcon).Glyph = ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay ? "\uEE49" : "\uEE47";
61 |
62 | SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += OnCloseRequest;
63 | }
64 |
65 | private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
66 | {
67 | if (_openDialog)
68 | {
69 | e.Handled = true;
70 | return;
71 | }
72 |
73 | _openDialog = true;
74 |
75 | if (Tabs.TabItems.Count == 1)
76 | {
77 | if (!(((Tabs.SelectedItem as TabViewItem).Content as Frame).Content as MainPage).saved)
78 | {
79 | e.Handled = true;
80 | _ = (((Tabs.SelectedItem as TabViewItem).Content as Frame).Content as MainPage).ShowUnsavedDialog();
81 | }
82 | } else if (Tabs.TabItems.Count > 1)
83 | {
84 | int unsavedItemsCount = 0;
85 |
86 | foreach (TabViewItem item in Tabs.TabItems.Cast())
87 | {
88 | if (!((item.Content as Frame).Content as MainPage).saved)
89 | unsavedItemsCount++;
90 | }
91 |
92 | if (unsavedItemsCount > 0)
93 | {
94 | e.Handled = true;
95 |
96 | ContentDialog confirmationDialog = new()
97 | {
98 | Title = "Save",
99 | Content = $"There are unsaved changes to {(unsavedItemsCount > 1 ? "multiple documents" : "a document")}, want to save them?",
100 | CloseButtonText = "Cancel and save changes",
101 | CloseButtonStyle = Resources["AccentButtonStyle"] as Style,
102 | PrimaryButtonText = "Close app",
103 | };
104 |
105 | // Allow the dialog to be opened again
106 | confirmationDialog.CloseButtonClick += (s, e) => _openDialog = false;
107 |
108 | ContentDialogResult result = await confirmationDialog.ShowAsync();
109 |
110 | if (result == ContentDialogResult.Primary)
111 | await ApplicationView.GetForCurrentView().TryConsolidateAsync();
112 | }
113 | }
114 | }
115 |
116 | private void CoreTitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
117 | => CustomDragRegion.Height = ShellTitlebarInset.Height = sender.Height;
118 |
119 | public void TabView_AddTabButtonClick(TabView sender, object args)
120 | {
121 | CreateNewTab();
122 | }
123 |
124 | public void CreateNewTab(bool selectTab = true, string tabName = null, object parameter = null)
125 | {
126 | TabViewItem newTab = new();
127 |
128 | Frame frame = new();
129 |
130 | newTab.Content = frame;
131 | newTab.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource()
132 | {
133 | Symbol = Symbol.Document
134 | };
135 |
136 | newTab.Header = tabName ?? $"Text document {Tabs.TabItems.Count + 1}";
137 |
138 | newTab.Style = Resources["TabViewItemStyle1"] as Style;
139 |
140 | frame.Navigate(typeof(MainPage), parameter);
141 |
142 | Tabs.TabItems.Add(newTab);
143 |
144 | if (selectTab)
145 | Tabs.SelectedItem = newTab;
146 | }
147 |
148 | public async void TabView_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args)
149 | {
150 | sender.TabItems.Remove(args.Tab);
151 |
152 | if (sender.TabItems.Count < 1)
153 | await ApplicationView.GetForCurrentView().TryConsolidateAsync();
154 | }
155 |
156 | private async void CompactOverlayBtn_Click(object sender, RoutedEventArgs e)
157 | {
158 | if (sender is Button button)
159 | {
160 | if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay)
161 | {
162 | await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
163 | (button.Content as FontIcon).Glyph = "\uEE49";
164 | button.Margin = new(10, 5, 195, 10);
165 | }
166 | else
167 | {
168 | ViewModePreferences preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
169 | preferences.CustomSize = new Windows.Foundation.Size(400, 400);
170 | await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);
171 | (button.Content as FontIcon).Glyph = "\uEE47";
172 | button.Margin = new(10, 5, 70, 10);
173 | }
174 | }
175 | }
176 |
177 | public void OpenFilesWithArgs(FileActivatedEventArgs args)
178 | {
179 | foreach (var item in args.Files)
180 | {
181 | StorageFile file = item as StorageFile;
182 |
183 | CreateNewTab(tabName: file.Name, parameter: file);
184 | }
185 | }
186 |
187 | #region TabView keyboard accelerators
188 | private void NavigateToNumberedTabKeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
189 | {
190 | int tabToSelect = 0;
191 |
192 | switch (sender.Key)
193 | {
194 | case Windows.System.VirtualKey.Number1:
195 | case Windows.System.VirtualKey.NumberPad1:
196 | tabToSelect = 0;
197 | break;
198 | case Windows.System.VirtualKey.Number2:
199 | case Windows.System.VirtualKey.NumberPad2:
200 | tabToSelect = 1;
201 | break;
202 | case Windows.System.VirtualKey.Number3:
203 | case Windows.System.VirtualKey.NumberPad3:
204 | tabToSelect = 2;
205 | break;
206 | case Windows.System.VirtualKey.Number4:
207 | case Windows.System.VirtualKey.NumberPad4:
208 | tabToSelect = 3;
209 | break;
210 | case Windows.System.VirtualKey.Number5:
211 | case Windows.System.VirtualKey.NumberPad5:
212 | tabToSelect = 4;
213 | break;
214 | case Windows.System.VirtualKey.Number6:
215 | case Windows.System.VirtualKey.NumberPad6:
216 | tabToSelect = 5;
217 | break;
218 | case Windows.System.VirtualKey.Number7:
219 | case Windows.System.VirtualKey.NumberPad7:
220 | tabToSelect = 6;
221 | break;
222 | case Windows.System.VirtualKey.Number8:
223 | case Windows.System.VirtualKey.NumberPad8:
224 | tabToSelect = 7;
225 | break;
226 | case Windows.System.VirtualKey.Number9:
227 | case Windows.System.VirtualKey.NumberPad9:
228 | // Select the last tab
229 | tabToSelect = Tabs.TabItems.Count - 1;
230 | break;
231 | }
232 |
233 | // Only select the tab if it is in the list
234 | if (tabToSelect < Tabs.TabItems.Count)
235 | {
236 | Tabs.SelectedIndex = tabToSelect;
237 | }
238 | }
239 |
240 | #endregion
241 | }
242 | }
243 |
--------------------------------------------------------------------------------
/Converters/BooleanToVisibility.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml;
7 | using Windows.UI.Xaml.Data;
8 |
9 | namespace Rich_Text_Editor.Converters
10 | {
11 | public class BooleanToVisibility : IValueConverter
12 | {
13 | public bool Reverse { get; set; }
14 | public object Convert(object value, Type targetType, object parameter, string language)
15 | {
16 | bool boolean = (bool)value;
17 |
18 | if (Reverse)
19 | {
20 | return boolean ? Visibility.Collapsed : Visibility.Visible;
21 | }
22 |
23 | return boolean ? Visibility.Visible : Visibility.Collapsed;
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, string language)
27 | {
28 | return null;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Converters/IntToTextWrapping.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml;
7 | using Windows.UI.Xaml.Data;
8 |
9 | namespace Rich_Text_Editor.Converters
10 | {
11 | public class IntToTextWrapping : IValueConverter
12 | {
13 | public bool Reverse { get; set; }
14 |
15 | public object Convert(object value, Type targetType, object parameter, string language)
16 | {
17 | int val = (int)value;
18 |
19 | if (Reverse)
20 | {
21 | return val;
22 | }
23 |
24 | return val switch
25 | {
26 | 0 => TextWrapping.NoWrap,
27 | 1 => TextWrapping.Wrap,
28 | 2 => TextWrapping.WrapWholeWords,
29 | _ => TextWrapping.NoWrap,
30 | };
31 | }
32 |
33 | public object ConvertBack(object value, Type targetType, object parameter, string language)
34 | {
35 | return null;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Converters/IntToThickness.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Windows.UI.Xaml;
7 | using Windows.UI.Xaml.Data;
8 |
9 | namespace Rich_Text_Editor.Converters
10 | {
11 | public class IntToThickness : IValueConverter
12 | {
13 | public bool Reverse { get; set; }
14 |
15 | public object Convert(object value, Type targetType, object parameter, string language)
16 | {
17 | int val = (int)value;
18 |
19 | if (Reverse)
20 | {
21 | return val;
22 | }
23 |
24 | return new Thickness(val);
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, string language)
28 | {
29 | return null;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Converters/SettingsConverters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Windows.UI.Xaml;
3 | using Windows.UI.Xaml.Data;
4 |
5 | #nullable enable
6 |
7 | namespace Rich_Text_Editor.Converters
8 | {
9 | ///
10 | /// The generic base implementation of a value converter.
11 | ///
12 | /// The source type.
13 | /// The target type.
14 | public abstract class ValueConverter
15 | : IValueConverter
16 | {
17 | ///
18 | /// Converts a source value to the target type.
19 | ///
20 | ///
21 | ///
22 | public TTarget? Convert(TSource? value)
23 | {
24 | return Convert(value, null, null);
25 | }
26 |
27 | ///
28 | /// Converts a target value back to the source type.
29 | ///
30 | ///
31 | ///
32 | public TSource? ConvertBack(TTarget? value)
33 | {
34 | return ConvertBack(value, null, null);
35 | }
36 |
37 | ///
38 | /// Modifies the source data before passing it to the target for display in the UI.
39 | ///
40 | ///
41 | ///
42 | ///
43 | ///
44 | ///
45 | public object? Convert(object? value, Type? targetType, object? parameter, string? language)
46 | {
47 | // CastExceptions will occur when invalid value, or target type provided.
48 | return Convert((TSource?)value, parameter, language);
49 | }
50 |
51 | ///
52 | /// Modifies the target data before passing it to the source object. This method is called only in TwoWay bindings.
53 | ///
54 | ///
55 | ///
56 | ///
57 | ///
58 | ///
59 | public object? ConvertBack(object? value, Type? targetType, object? parameter, string? language)
60 | {
61 | // CastExceptions will occur when invalid value, or target type provided.
62 | return ConvertBack((TTarget?)value, parameter, language);
63 | }
64 |
65 | ///
66 | /// Converts a source value to the target type.
67 | ///
68 | ///
69 | ///
70 | ///
71 | ///
72 | protected virtual TTarget? Convert(TSource? value, object? parameter, string? language)
73 | {
74 | throw new NotSupportedException();
75 | }
76 |
77 | ///
78 | /// Converts a target value back to the source type.
79 | ///
80 | ///
81 | ///
82 | ///
83 | ///
84 | protected virtual TSource? ConvertBack(TTarget? value, object? parameter, string? language)
85 | {
86 | throw new NotSupportedException();
87 | }
88 | }
89 |
90 | ///
91 | /// The base class for converting instances of type T to object and vice versa.
92 | ///
93 | public abstract class ToObjectConverter
94 | : ValueConverter
95 | {
96 | ///
97 | /// Converts a source value to the target type.
98 | ///
99 | ///
100 | ///
101 | ///
102 | ///
103 | protected override object? Convert(T? value, object? parameter, string? language)
104 | {
105 | return value;
106 | }
107 |
108 | ///
109 | /// Converts a target value back to the source type.
110 | ///
111 | ///
112 | ///
113 | ///
114 | ///
115 | protected override T? ConvertBack(object? value, object? parameter, string? language)
116 | {
117 | return (T?)value;
118 | }
119 | }
120 |
121 | ///
122 | /// Converts a boolean to and from a visibility value.
123 | ///
124 | public class InverseBooleanConverter
125 | : ValueConverter
126 | {
127 | ///
128 | /// Converts a source value to the target type.
129 | ///
130 | ///
131 | ///
132 | ///
133 | ///
134 | protected override bool Convert(bool value, object? parameter, string? language)
135 | {
136 | return !value;
137 | }
138 |
139 | ///
140 | /// Converts a target value back to the source type.
141 | ///
142 | ///
143 | ///
144 | ///
145 | ///
146 | protected override bool ConvertBack(bool value, object? parameter, string? language)
147 | {
148 | return !value;
149 | }
150 | }
151 |
152 | public class NullToTrueConverter
153 | : ValueConverter