├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
└── TimsWpfControls
├── TimsWpfControls.sln
├── TimsWpfControls
├── AssemblyInfo.cs
├── Controls
│ ├── ArcSegment.cs
│ ├── CircularProgressBar.cs
│ ├── DataGridIntellisenseTextboxColumn.cs
│ ├── FileSelectionTextbox.cs
│ ├── IntellisenseTextBox.cs
│ └── MultiSelectionComboBox
│ │ ├── AddedItemEventArgs.cs
│ │ ├── AddingItemEventArgs.cs
│ │ ├── BuiltInStringToObjectParser.cs
│ │ ├── ICompareObjectToString.cs
│ │ ├── IParseStringToObject.cs
│ │ ├── MultiSelectionComboBox.cs
│ │ └── SelectedItemsOrderType.cs
├── Converter
│ ├── ColorToSolidColorBrushConverter.cs
│ ├── DataGridIsNewRowToVisibilityConverter.cs
│ ├── EnumLocalizedDescriptionConverter.cs
│ ├── EnumToBoolConverter.cs
│ ├── EnumToItemSourceConverter.cs
│ ├── InvertBoolConverter.cs
│ ├── NotNullToVisibilityConverter.cs
│ ├── NullImageConverter.cs
│ ├── PercentageToGridLengthConverter.cs
│ └── SolidColorBrushToColorConverter.cs
├── ExtensionMethods
│ ├── NumericExtensions.cs
│ └── StringExtensions.cs
├── Helper
│ ├── BindingHelper.cs
│ ├── DataContextProxy.cs
│ ├── DialogHelper.cs
│ ├── FileHelper.cs
│ ├── MultiSelectorHelper.cs
│ ├── SolidAccentsLibaryThemeProvider.cs
│ ├── ThemingHelper.cs
│ └── TreeHelper.cs
├── Lang
│ ├── AccentColorNames.Designer.cs
│ ├── AccentColorNames.de-DE.resx
│ ├── AccentColorNames.resx
│ ├── FileSelectionTextBox.Designer.cs
│ ├── FileSelectionTextBox.de-DE.resx
│ ├── FileSelectionTextBox.resx
│ ├── MultiSelectionComboBox.Designer.cs
│ ├── MultiSelectionComboBox.de.resx
│ ├── MultiSelectionComboBox.resx
│ ├── ValidationMessages.Designer.cs
│ ├── ValidationMessages.de-DE.resx
│ └── ValidationMessages.resx
├── Model
│ ├── BaseClass.cs
│ ├── LocalizedDescriptionAttribute.cs
│ └── RelayCommand.cs
├── PushBinding
│ ├── FreezableBinding.cs
│ ├── PushBinding.cs
│ ├── PushBindingCollection.cs
│ └── PushBindingManager.cs
├── Themes
│ ├── ArcSegment.xaml
│ ├── CircularProgressBar.xaml
│ ├── FileSelectionTextBox.xaml
│ ├── Generic.xaml
│ ├── IntellisenseTextBox.xaml
│ ├── MultiSelectionComboBox.xaml
│ ├── ScrollViewerWin10.xaml
│ └── TimsStyles.xaml
├── TimsWpfControls.csproj
└── Validation
│ ├── CollectionNotEmptyAttribute.cs
│ └── GreaterThanAttribute.cs
└── TimsWpfControls_Demo
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Model
├── DemoProperty.cs
├── DemoPropertyTemplateSelector.cs
├── Gender.cs
├── MainViewModel.cs
├── Person.cs
└── SelectableProperty.cs
├── TimsWpfControls_Demo.csproj
└── Views
├── BoolToEnumConverterExample.xaml
├── BoolToEnumConverterExample.xaml.cs
├── ExampleViewBase.xaml
├── ExampleViewBase.xaml.cs
├── FileSelectionTextBoxExample.xaml
├── FileSelectionTextBoxExample.xaml.cs
├── IntellisenseTextBoxExample.xaml
├── IntellisenseTextBoxExample.xaml.cs
├── MultiselectionComboBox.xaml
├── MultiselectionComboBox.xaml.cs
├── RadialProgressExample.xaml
├── RadialProgressExample.xaml.cs
├── ThemeManger.xaml
└── ThemeManger.xaml.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.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 | # JustCode is a .NET coding add-in
131 | .JustCode
132 |
133 | # TeamCity is a build add-in
134 | _TeamCity*
135 |
136 | # DotCover is a Code Coverage Tool
137 | *.dotCover
138 |
139 | # AxoCover is a Code Coverage Tool
140 | .axoCover/*
141 | !.axoCover/settings.json
142 |
143 | # Visual Studio code coverage results
144 | *.coverage
145 | *.coveragexml
146 |
147 | # NCrunch
148 | _NCrunch_*
149 | .*crunch*.local.xml
150 | nCrunchTemp_*
151 |
152 | # MightyMoose
153 | *.mm.*
154 | AutoTest.Net/
155 |
156 | # Web workbench (sass)
157 | .sass-cache/
158 |
159 | # Installshield output folder
160 | [Ee]xpress/
161 |
162 | # DocProject is a documentation generator add-in
163 | DocProject/buildhelp/
164 | DocProject/Help/*.HxT
165 | DocProject/Help/*.HxC
166 | DocProject/Help/*.hhc
167 | DocProject/Help/*.hhk
168 | DocProject/Help/*.hhp
169 | DocProject/Help/Html2
170 | DocProject/Help/html
171 |
172 | # Click-Once directory
173 | publish/
174 |
175 | # Publish Web Output
176 | *.[Pp]ublish.xml
177 | *.azurePubxml
178 | # Note: Comment the next line if you want to checkin your web deploy settings,
179 | # but database connection strings (with potential passwords) will be unencrypted
180 | *.pubxml
181 | *.publishproj
182 |
183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
184 | # checkin your Azure Web App publish settings, but sensitive information contained
185 | # in these scripts will be unencrypted
186 | PublishScripts/
187 |
188 | # NuGet Packages
189 | *.nupkg
190 | # NuGet Symbol Packages
191 | *.snupkg
192 | # The packages folder can be ignored because of Package Restore
193 | **/[Pp]ackages/*
194 | # except build/, which is used as an MSBuild target.
195 | !**/[Pp]ackages/build/
196 | # Uncomment if necessary however generally it will be regenerated when needed
197 | #!**/[Pp]ackages/repositories.config
198 | # NuGet v3's project.json files produces more ignorable files
199 | *.nuget.props
200 | *.nuget.targets
201 |
202 | # Microsoft Azure Build Output
203 | csx/
204 | *.build.csdef
205 |
206 | # Microsoft Azure Emulator
207 | ecf/
208 | rcf/
209 |
210 | # Windows Store app package directories and files
211 | AppPackages/
212 | BundleArtifacts/
213 | Package.StoreAssociation.xml
214 | _pkginfo.txt
215 | *.appx
216 | *.appxbundle
217 | *.appxupload
218 |
219 | # Visual Studio cache files
220 | # files ending in .cache can be ignored
221 | *.[Cc]ache
222 | # but keep track of directories ending in .cache
223 | !?*.[Cc]ache/
224 |
225 | # Others
226 | ClientBin/
227 | ~$*
228 | *~
229 | *.dbmdl
230 | *.dbproj.schemaview
231 | *.jfm
232 | *.pfx
233 | *.publishsettings
234 | orleans.codegen.cs
235 |
236 | # Including strong name files can present a security risk
237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
238 | #*.snk
239 |
240 | # Since there are multiple workflows, uncomment next line to ignore bower_components
241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
242 | #bower_components/
243 |
244 | # RIA/Silverlight projects
245 | Generated_Code/
246 |
247 | # Backup & report files from converting an old project file
248 | # to a newer Visual Studio version. Backup files are not needed,
249 | # because we have git ;-)
250 | _UpgradeReport_Files/
251 | Backup*/
252 | UpgradeLog*.XML
253 | UpgradeLog*.htm
254 | ServiceFabricBackup/
255 | *.rptproj.bak
256 |
257 | # SQL Server files
258 | *.mdf
259 | *.ldf
260 | *.ndf
261 |
262 | # Business Intelligence projects
263 | *.rdl.data
264 | *.bim.layout
265 | *.bim_*.settings
266 | *.rptproj.rsuser
267 | *- [Bb]ackup.rdl
268 | *- [Bb]ackup ([0-9]).rdl
269 | *- [Bb]ackup ([0-9][0-9]).rdl
270 |
271 | # Microsoft Fakes
272 | FakesAssemblies/
273 |
274 | # GhostDoc plugin setting file
275 | *.GhostDoc.xml
276 |
277 | # Node.js Tools for Visual Studio
278 | .ntvs_analysis.dat
279 | node_modules/
280 |
281 | # Visual Studio 6 build log
282 | *.plg
283 |
284 | # Visual Studio 6 workspace options file
285 | *.opt
286 |
287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
288 | *.vbw
289 |
290 | # Visual Studio LightSwitch build output
291 | **/*.HTMLClient/GeneratedArtifacts
292 | **/*.DesktopClient/GeneratedArtifacts
293 | **/*.DesktopClient/ModelManifest.xml
294 | **/*.Server/GeneratedArtifacts
295 | **/*.Server/ModelManifest.xml
296 | _Pvt_Extensions
297 |
298 | # Paket dependency manager
299 | .paket/paket.exe
300 | paket-files/
301 |
302 | # FAKE - F# Make
303 | .fake/
304 |
305 | # CodeRush personal settings
306 | .cr/personal
307 |
308 | # Python Tools for Visual Studio (PTVS)
309 | __pycache__/
310 | *.pyc
311 |
312 | # Cake - Uncomment if you are using it
313 | # tools/**
314 | # !tools/packages.config
315 |
316 | # Tabs Studio
317 | *.tss
318 |
319 | # Telerik's JustMock configuration file
320 | *.jmconfig
321 |
322 | # BizTalk build output
323 | *.btp.cs
324 | *.btm.cs
325 | *.odx.cs
326 | *.xsd.cs
327 |
328 | # OpenCover UI analysis results
329 | OpenCover/
330 |
331 | # Azure Stream Analytics local run output
332 | ASALocalRun/
333 |
334 | # MSBuild Binary and Structured Log
335 | *.binlog
336 |
337 | # NVidia Nsight GPU debugger configuration file
338 | *.nvuser
339 |
340 | # MFractors (Xamarin productivity tool) working folder
341 | .mfractor/
342 |
343 | # Local History for Visual Studio
344 | .localhistory/
345 |
346 | # BeatPulse healthcheck temp database
347 | healthchecksdb
348 |
349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
350 | MigrationBackup/
351 |
352 | # Ionide (cross platform F# VS Code tools) working folder
353 | .ionide/
354 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Tim
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TimsWpfControls
2 | Some missing WPF Controls that integrates with MahApps.Metro
3 |
4 | > **ATTENTION** This libary may not be production ready
5 |
6 | ## MahApps-Integration
7 | Whenever a control is implemented in MahApps it will be removed here. Please Stay tuned if you use this library.
8 |
9 | ## Disclaimer
10 | This libary is provided without any warrenty. It will change to whatever I need, so there might be some breaking changes when you update.
11 |
12 | ## BaseClass
13 | The `BaseClass` implements `INotifyPropertyChanged, INotifyPropertyChanging, INotifyDataErrorInfo` and can be used to autmatically set and validate any property.
14 | This class will be deleted once the WindowsCommunityToolkit-MVVM package is available and provides the same functionallity.
15 |
16 |
17 | ## Converters
18 |
19 | ### EnumToBool Converter
20 | This converter can be used to bind an `enum` to a group of `RadioButtons`
21 |
22 | Consider the following `enum` in your Model:
23 | ```c#
24 | public enum Gender
25 | {
26 | Female,
27 | Male,
28 | Diverse
29 | }
30 | ```
31 |
32 | In your XAML define these namespaces:
33 | ```xaml
34 | xmlns:timsConverter="clr-namespace:TimsWpfControls.Converter;assembly=TimsWpfControls"
35 | xmlns:model="MyApp.MyModel"
36 | ```
37 |
38 | And here is your group of `RadioButtons`
39 |
40 | ```xaml
41 |
42 |
45 |
48 |
51 |
52 | ```
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29709.97
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimsWpfControls", "TimsWpfControls\TimsWpfControls.csproj", "{36D58E2D-90FC-4201-AAC7-613439D4470D}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimsWpfControls_Demo", "TimsWpfControls_Demo\TimsWpfControls_Demo.csproj", "{2F70D8D7-6324-434A-8AB0-2B3D68185CDA}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {36D58E2D-90FC-4201-AAC7-613439D4470D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {36D58E2D-90FC-4201-AAC7-613439D4470D}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {36D58E2D-90FC-4201-AAC7-613439D4470D}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {36D58E2D-90FC-4201-AAC7-613439D4470D}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {2F70D8D7-6324-434A-8AB0-2B3D68185CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {2F70D8D7-6324-434A-8AB0-2B3D68185CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {2F70D8D7-6324-434A-8AB0-2B3D68185CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {2F70D8D7-6324-434A-8AB0-2B3D68185CDA}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {11E149C8-9661-4B83-9BF7-DF676FE54792}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Markup;
3 |
4 | [assembly: ThemeInfo(
5 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
6 | //(used if a resource is not found in the page,
7 | // or application resource dictionaries)
8 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
9 | //(used if a resource is not found in the page,
10 | // app, or any theme specific resource dictionaries)
11 | )]
12 |
13 |
14 | [assembly: XmlnsPrefix(@"https://github.com/timunie/TimsWpfControls", "timsWpf")]
15 | [assembly: XmlnsDefinition(@"https://github.com/timunie/TimsWpfControls", "TimsWpfControls")]
16 | [assembly: XmlnsDefinition(@"https://github.com/timunie/TimsWpfControls", "TimsWpfControls.Converter")]
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/ArcSegment.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Media;
9 | using TimsWpfControls.ExtensionMethods;
10 |
11 | namespace TimsWpfControls
12 | {
13 | public class ArcSegment : Control
14 | {
15 | static ArcSegment()
16 | {
17 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ArcSegment), new FrameworkPropertyMetadata(typeof(ArcSegment)));
18 | }
19 |
20 | private PathFigure PART_ArcSegment;
21 |
22 | public static readonly DependencyProperty StartDegreesProperty = DependencyProperty.Register("StartDegrees", typeof(double), typeof(ArcSegment), new FrameworkPropertyMetadata(-90d, FrameworkPropertyMetadataOptions.AffectsRender));
23 | public static readonly DependencyProperty SweepDegreesProperty = DependencyProperty.Register("SweepDegrees", typeof(double), typeof(ArcSegment), new FrameworkPropertyMetadata(0d, FrameworkPropertyMetadataOptions.AffectsRender));
24 | public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register("StrokeThickness", typeof(double), typeof(ArcSegment), new FrameworkPropertyMetadata(5d, FrameworkPropertyMetadataOptions.AffectsRender));
25 | public static readonly DependencyProperty IsFilledProperty = DependencyProperty.Register("IsFilled", typeof(bool), typeof(ArcSegment), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
26 |
27 | public double StartDegrees
28 | {
29 | get { return (double)GetValue(StartDegreesProperty); }
30 | set { SetValue(StartDegreesProperty, value); }
31 | }
32 |
33 |
34 | public double SweepDegrees
35 | {
36 | get { return (double)GetValue(SweepDegreesProperty); }
37 | set { SetValue(SweepDegreesProperty, value); }
38 | }
39 |
40 |
41 | public double StrokeThickness
42 | {
43 | get { return (double)GetValue(StrokeThicknessProperty); }
44 | set { SetValue(StrokeThicknessProperty, value); }
45 | }
46 |
47 | public bool IsFilled
48 | {
49 | get { return (bool)GetValue(IsFilledProperty); }
50 | set { SetValue(IsFilledProperty, value); }
51 | }
52 |
53 | private void UpdateArcSegment()
54 | {
55 | if (PART_ArcSegment is null) return;
56 |
57 | // degrees to radians conversion
58 | double startRadians = StartDegrees * Math.PI / 180.0;
59 | double sweepRadians = SweepDegrees * Math.PI / 180.0;
60 |
61 | // x and y radius
62 | double dx = (ActualWidth - StrokeThickness) / 2;
63 | double dy = (ActualHeight - StrokeThickness) / 2;
64 |
65 | dx = dx < 0 ? 0 : dx;
66 | dy = dy < 0 ? 0 : dy;
67 |
68 | Size EllipseSize = new Size(dx, dy);
69 |
70 | // determine the start point
71 | Point StartPoint = new Point(ActualWidth / 2 + Math.Cos(startRadians) * dx,
72 | ActualHeight / 2 + Math.Sin(startRadians) * dy);
73 |
74 | // determine the end point
75 | Point EndPoint = new Point(ActualWidth / 2 + Math.Cos(startRadians + sweepRadians) * dx,
76 | ActualHeight / 2 + Math.Sin(startRadians + sweepRadians) * dy);
77 |
78 | // draw the arc
79 | bool isLargeArc = Math.Abs(SweepDegrees) > 180;
80 | SweepDirection sweepDirection = SweepDegrees < 0 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise;
81 |
82 | PART_ArcSegment.Segments.Clear();
83 | PART_ArcSegment.StartPoint = StartPoint;
84 | if (SweepDegrees.ApproximateEqualTo(360))
85 | {
86 | EndPoint = new Point(ActualWidth / 2 + Math.Cos(startRadians + Math.PI) * dx,
87 | ActualHeight / 2 + Math.Sin(startRadians + Math.PI) * dy);
88 | PART_ArcSegment.Segments.Add(new System.Windows.Media.ArcSegment(EndPoint, EllipseSize, 0, false, sweepDirection, true));
89 | PART_ArcSegment.Segments.Add(new System.Windows.Media.ArcSegment(StartPoint, EllipseSize, 0, true, sweepDirection, true));
90 | }
91 | else if (SweepDegrees.ApproximateEqualTo(0))
92 | {
93 | // Do not draw anyting if there is nothing to see
94 | }
95 | else
96 | {
97 | PART_ArcSegment.Segments.Add(new System.Windows.Media.ArcSegment(EndPoint, EllipseSize, 0, isLargeArc, sweepDirection, true));
98 | if (IsFilled)
99 | {
100 | PART_ArcSegment.Segments.Add(new LineSegment(new Point(dx + StrokeThickness / 2, dy + StrokeThickness / 2), true));
101 | PART_ArcSegment.Segments.Add(new LineSegment(StartPoint, true));
102 | }
103 | }
104 | }
105 |
106 |
107 | public override void OnApplyTemplate()
108 | {
109 | base.OnApplyTemplate();
110 |
111 | PART_ArcSegment = (PathFigure)GetTemplateChild(nameof(PART_ArcSegment));
112 | }
113 |
114 | protected override void OnRender(DrawingContext drawingContext)
115 | {
116 | UpdateArcSegment();
117 | base.OnRender(drawingContext);
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/MultiSelectionComboBox/AddedItemEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace TimsWpfControls
10 | {
11 | ///
12 | /// Provides data for the
13 | ///
14 | public class AddedItemEventArgs : RoutedEventArgs
15 | {
16 | ///
17 | /// Initializes a new instance of the class.
18 | ///
19 | /// The AddedItemEvent/param>
20 | /// The source object
21 | /// The added object
22 | /// The target where the should be added
23 | public AddedItemEventArgs(RoutedEvent routedEvent,
24 | object source,
25 | object addedItem,
26 | IList targetList) : base(routedEvent, source)
27 | {
28 | AddedItem = addedItem;
29 | TargetList = targetList;
30 | }
31 |
32 | ///
33 | /// Gets the added item
34 | ///
35 | public object AddedItem { get; }
36 |
37 | ///
38 | /// Gets the where the was added to
39 | ///
40 | public IList TargetList { get; }
41 | }
42 |
43 | ///
44 | /// RoutedEventHandler used for the .
45 | ///
46 | public delegate void AddedItemEventArgsHandler(object sender, AddedItemEventArgs args);
47 | }
48 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/MultiSelectionComboBox/AddingItemEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Globalization;
4 | using System.Windows;
5 |
6 | namespace TimsWpfControls
7 | {
8 | ///
9 | /// Provides data for the
10 | ///
11 | public class AddingItemEventArgs : RoutedEventArgs
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The AddingItemEvent/param>
17 | /// The source object
18 | /// The input string to parse
19 | /// The parsed object
20 | /// if the is accepted otherwise /param>
21 | /// The target where the should be added
22 | /// the target to which the should be converted to
23 | /// the string format which can be used to control the
24 | /// the culture which can be used to control the
25 | /// The used parser
26 | public AddingItemEventArgs(RoutedEvent routedEvent,
27 | object source,
28 | string input,
29 | object parsedObject,
30 | bool accepted,
31 | IList targetList,
32 | Type targetType,
33 | string stringFormat,
34 | CultureInfo culture,
35 | IParseStringToObject parser) : base(routedEvent, source)
36 | {
37 | Input = input;
38 | ParsedObject = parsedObject;
39 | Accepted = accepted;
40 | TargetList = targetList;
41 | TargetType = targetType;
42 | StringFormat = stringFormat;
43 | Culture = culture;
44 | Parser = parser;
45 | }
46 |
47 | ///
48 | /// The Textinput to parse
49 | ///
50 | public string Input { get; }
51 |
52 | ///
53 | /// Gets or sets the parsed object to add. You can override it
54 | ///
55 | public object ParsedObject { get; set; }
56 |
57 | ///
58 | /// Gets the string format which can be used to control the
59 | ///
60 | public string StringFormat { get; }
61 |
62 | ///
63 | /// Gets the culture which can be used to control the
64 | ///
65 | public CultureInfo Culture { get; }
66 |
67 | ///
68 | /// Gets the -Instance which was used to parse the to the
69 | ///
70 | public IParseStringToObject Parser { get; }
71 |
72 | ///
73 | /// Gets the target to which the should be converted to
74 | ///
75 | public Type TargetType { get; }
76 |
77 | ///
78 | /// Gets the where the should be added
79 | ///
80 | public IList TargetList { get; }
81 |
82 | ///
83 | /// Gets or sets wether the is accepted and can be added
84 | ///
85 | public bool Accepted { get; set; }
86 | }
87 |
88 | ///
89 | /// RoutedEventHandler used for the .
90 | ///
91 | public delegate void AddingItemEventArgsHandler(object sender, AddingItemEventArgs args);
92 | }
93 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/MultiSelectionComboBox/BuiltInStringToObjectParser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace TimsWpfControls
11 | {
12 | ///
13 | /// This class is a helper class for the .
14 | /// It uses the for the elements . If you need more control
15 | /// over the conversion you should create your own class which implements
16 | ///
17 | public class BuiltInStringToObjectParser : IParseStringToObject
18 | {
19 | private static BuiltInStringToObjectParser instance;
20 | public static BuiltInStringToObjectParser Instance => instance ??= new BuiltInStringToObjectParser();
21 |
22 | public bool TryCreateObjectFromString(string input, out object result, CultureInfo culture = null, string stringFormat = null, Type targetType = null)
23 | {
24 | try
25 | {
26 | // If the input is null the result is also null
27 | if (input is null)
28 | {
29 | result = null;
30 | return true;
31 | }
32 |
33 | // If we don't know the target type we cannot convert in this class. Either provide the target type or roll your own class implementing IParseStringToObject
34 | if (targetType is null)
35 | {
36 | result = null;
37 | return false;
38 | }
39 |
40 | var typeConverter = TypeDescriptor.GetConverter(targetType);
41 |
42 | if (!(typeConverter is null))
43 | {
44 | result = typeConverter.ConvertFromString(null, culture ?? CultureInfo.InvariantCulture, input);
45 | return true;
46 | }
47 | else
48 | {
49 | result = null;
50 | return false;
51 | }
52 | }
53 | catch
54 | {
55 | result = null;
56 | return false;
57 | }
58 | }
59 |
60 |
61 | ///
62 | /// Tries to get the elemts for a given
63 | ///
64 | /// Any collection of elements
65 | /// the elements
66 | public Type GetElementType(IEnumerable list)
67 | {
68 | if (list is null)
69 | {
70 | return null;
71 | }
72 |
73 | var listType = list.GetType();
74 |
75 | if (listType.IsGenericType)
76 | {
77 | return listType.GetGenericArguments().FirstOrDefault();
78 | }
79 | else
80 | {
81 | return listType.GetElementType();
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/MultiSelectionComboBox/ICompareObjectToString.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Markup;
7 |
8 | namespace TimsWpfControls
9 | {
10 | ///
11 | /// Defines a function that is used to check if a given string represents a given object of any type.
12 | ///
13 | public interface ICompareObjectToString
14 | {
15 | ///
16 | /// Checks if the given input string matches to the given object
17 | ///
18 | /// The string to compare
19 | /// The object to compare
20 | /// The used to check if the string matches
21 | /// The string format to apply
22 | /// true if the string represents the object, otherwise false.
23 | public bool CheckIfStringMatchesObject(string input, object objectToCompare, StringComparison stringComparison, string stringFormat);
24 | }
25 |
26 | [MarkupExtensionReturnType(typeof(DefaultObjectToStringComparer))]
27 | public class DefaultObjectToStringComparer : MarkupExtension, ICompareObjectToString
28 | {
29 | ///
30 | public bool CheckIfStringMatchesObject(string input, object objectToCompare, StringComparison stringComparison, string stringFormat)
31 | {
32 | if (input is null)
33 | {
34 | return objectToCompare is null;
35 | }
36 |
37 | if (objectToCompare is null)
38 | {
39 | return false;
40 | }
41 |
42 | string objectText;
43 | if (string.IsNullOrEmpty(stringFormat))
44 | {
45 | objectText = objectToCompare.ToString();
46 | }
47 | else if (stringFormat.Contains('{') && stringFormat.Contains('}'))
48 | {
49 | objectText = string.Format(stringFormat, objectToCompare);
50 | }
51 | else
52 | {
53 | objectText = string.Format($"{{0:{stringFormat}}}", objectToCompare);
54 | }
55 |
56 | return input.Equals(objectText, stringComparison);
57 | }
58 |
59 | ///
60 | public override object ProvideValue(IServiceProvider serviceProvider)
61 | {
62 | return this;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/MultiSelectionComboBox/IParseStringToObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TimsWpfControls
9 | {
10 |
11 | ///
12 | /// This interfaces is used to parse a string to any object.
13 | ///
14 | public interface IParseStringToObject
15 | {
16 | ///
17 | /// Parses the given input to an object of the given type.
18 | ///
19 | /// The input string to parse
20 | /// The object if successful, otherwise null
21 | /// The culture which should be used to parse. This parameter is optional
22 | /// The string format to apply. This parameter is optional
23 | /// the to which the input should be converted to. This parameter is optional
24 | /// if converting successful, otherwise
25 | bool TryCreateObjectFromString(string input, out object result, CultureInfo culture = null, string stringFormat = null, Type targetType = null);
26 | }
27 | }
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Controls/MultiSelectionComboBox/SelectedItemsOrderType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace TimsWpfControls
8 | {
9 | ///
10 | /// Defines how the selected Items should be arranged for display
11 | ///
12 | public enum SelectedItemsOrderType
13 | {
14 | ///
15 | /// Displays the selected items in the same order as they were selected
16 | ///
17 | SelectedOrder,
18 |
19 | ///
20 | /// Displays the selected items in the same order as they are stored in the ItemsSource
21 | ///
22 | ItemsSourceOrder
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/ColorToSolidColorBrushConverter.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Converters;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Media;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class ColorToSolidColorBrushConverter : MarkupConverter
13 | {
14 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value is Color color)
17 | {
18 | return new SolidColorBrush(color);
19 | }
20 | return null;
21 | }
22 |
23 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | if (value is SolidColorBrush brush)
26 | {
27 | return brush.Color;
28 | }
29 | return Colors.Transparent;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/DataGridIsNewRowToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Data;
9 |
10 | namespace TimsWpfControls
11 | {
12 | public class DataGridIsNewRowToVisibilityConverter : IValueConverter
13 | {
14 | private static DataGridIsNewRowToVisibilityConverter _Instance;
15 | public static DataGridIsNewRowToVisibilityConverter Instance => _Instance ??= new();
16 |
17 | object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
18 | {
19 | return value == CollectionView.NewItemPlaceholder ? Visibility.Collapsed : Visibility.Visible;
20 | }
21 |
22 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
23 | {
24 | throw new NotSupportedException();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/EnumLocalizedDescriptionConverter.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Converters;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using TimsWpfControls.Model;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class EnumLocalizedDescriptionConverter : MarkupConverter
13 | {
14 | EnumLocalizedDescriptionConverter _Instance;
15 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (!(value is Enum inputEnum))
18 | {
19 | return null;
20 | }
21 |
22 | if (inputEnum.GetType().GetField(inputEnum.ToString()).GetCustomAttributes(false).OfType().FirstOrDefault() is LocalizedDescriptionAttribute descriptionAttribute)
23 | {
24 | return descriptionAttribute.Description;
25 | }
26 | else
27 | {
28 | return inputEnum.ToString();
29 | }
30 | }
31 |
32 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
33 | {
34 | throw new NotSupportedException();
35 | }
36 |
37 | public override object ProvideValue(IServiceProvider serviceProvider)
38 | {
39 | return _Instance ??= new EnumLocalizedDescriptionConverter();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/EnumToBoolConverter.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Converters;
2 | using System;
3 | using System.Globalization;
4 | using System.Windows.Data;
5 |
6 | namespace TimsWpfControls.Converter
7 | {
8 | [ValueConversion(typeof(Enum), typeof(bool), ParameterType = typeof(Enum))]
9 | public class EnumToBoolConverter : MarkupConverter
10 | {
11 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12 | {
13 | return value?.Equals(parameter);
14 | }
15 |
16 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | return (bool)value == true ? parameter : Binding.DoNothing;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/EnumToItemSourceConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 | using System.Windows.Markup;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class EnumToItemSourceConverter : MarkupExtension, IValueConverter
13 | {
14 | static EnumToItemSourceConverter _Instance;
15 |
16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | if (value is Enum)
19 | {
20 | return Enum.GetValues(value.GetType());
21 | }
22 | throw new ArgumentException("the provided value is not a valid Enum");
23 | }
24 |
25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
26 | {
27 | throw new NotSupportedException();
28 | }
29 |
30 | public override object ProvideValue(IServiceProvider serviceProvider)
31 | {
32 | return _Instance ??= new EnumToItemSourceConverter();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/InvertBoolConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace TimsWpfControls.Converter
10 | {
11 | [ValueConversion(typeof(bool), typeof(bool))]
12 | public class InvertBoolConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value is bool val)
17 | {
18 | return !val;
19 | }
20 | throw new ArgumentException("value is not a bool.");
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | if (value is bool val)
26 | {
27 | return !val;
28 | }
29 | throw new ArgumentException("value is not a bool.");
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/NotNullToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Converters;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class NotNullToVisibilityConverter : MarkupConverter
13 | {
14 | static NotNullToVisibilityConverter instance;
15 |
16 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17 | {
18 | return value == null ? Visibility.Collapsed : Visibility.Visible;
19 | }
20 |
21 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | throw new NotSupportedException();
24 | }
25 |
26 | public override object ProvideValue(IServiceProvider serviceProvider)
27 | {
28 | return instance ??= new NotNullToVisibilityConverter();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/NullImageConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 | using System.Windows;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class NullImageConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | return value is null ? DependencyProperty.UnsetValue : value;
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20 | {
21 | throw new NotImplementedException();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/PercentageToGridLengthConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Data;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class PercentageToGridLengthConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 |
17 | bool inverse = (parameter as string)?.ToLowerInvariant() == "true";
18 |
19 | if (value is double @double)
20 | {
21 | if (inverse)
22 | {
23 | @double = 1 - @double;
24 | }
25 | return new GridLength(@double, GridUnitType.Star);
26 | }
27 |
28 | throw new NotImplementedException();
29 | }
30 |
31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
32 | {
33 | throw new NotImplementedException();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Converter/SolidColorBrushToColorConverter.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Converters;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Media;
9 |
10 | namespace TimsWpfControls.Converter
11 | {
12 | public class SolidColorBrushToColorConverter : MarkupConverter
13 | {
14 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | if (value is SolidColorBrush brush)
17 | {
18 | return brush.Color;
19 | }
20 | return Colors.Transparent;
21 | }
22 |
23 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24 | {
25 | if (value is Color color)
26 | {
27 | return new SolidColorBrush(color);
28 | }
29 | return null;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/ExtensionMethods/NumericExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TimsWpfControls.ExtensionMethods
4 | {
5 | public static class NumericExtensions
6 | {
7 | ///
8 | /// Checks if two double values are "equal enough"
9 | ///
10 | /// The value to compare
11 | /// The value to compare to
12 | /// The tolerance. Default: 1e-5
13 | ///
14 | public static bool ApproximateEqualTo(this double value, double ValueToCompare, double MaxDeviation = 1e-5)
15 | {
16 | if (double.IsNaN(value) || double.IsNaN(ValueToCompare))
17 | {
18 | return value == ValueToCompare;
19 | }
20 | else
21 | {
22 | return Math.Abs(value - ValueToCompare) <= MaxDeviation;
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/ExtensionMethods/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace TimsWpfControls.ExtensionMethods
5 | {
6 | public static class StringExtensions
7 | {
8 | internal static string GetStringToTheRight(this string input, int CaretIndex, char StopCharacter)
9 | {
10 | var StartIndex = input.LastIndexOf(StopCharacter, CaretIndex - 1);
11 | if (StartIndex < 0) StartIndex = 0;
12 | return input[StartIndex..CaretIndex].Trim(StopCharacter).TrimStart();
13 | }
14 |
15 | internal static string GetStringToTheRight(this string input, int CaretIndex, char[] StopCharacters)
16 | {
17 | int StartIndex = -1;
18 |
19 | for (int i = 0; i < StopCharacters.Length; i++)
20 | {
21 | var StartIndexTemp = input.LastIndexOf(StopCharacters[i], CaretIndex - 1);
22 | if (StartIndexTemp > StartIndex) StartIndex = StartIndexTemp;
23 | }
24 |
25 | if (StartIndex < 0) StartIndex = 0;
26 | return input[StartIndex..CaretIndex].Trim(StopCharacters).TrimStart();
27 | }
28 |
29 | internal static string GetStringToTheRight(this string input, int CaretIndex, string[] StopCharacters)
30 | {
31 | int StartIndex = -1;
32 |
33 | for (int i = 0; i < StopCharacters.Length; i++)
34 | {
35 | var StartIndexTemp = input.LastIndexOf(StopCharacters[i], CaretIndex - 1, StringComparison.Ordinal);
36 | if (StartIndexTemp > StartIndex) StartIndex = StartIndexTemp;
37 | }
38 |
39 | if (StartIndex < 0) StartIndex = 0;
40 | var result = input[StartIndex..CaretIndex].TrimStart();
41 |
42 | foreach (var str in StopCharacters)
43 | {
44 | if (result.StartsWith(str, StringComparison.Ordinal))
45 | {
46 | result = result.Remove(0, str.Length);
47 | }
48 | }
49 | return result;
50 | }
51 |
52 | internal static string GetStringToTheRight(this string input, int CaretIndex, object StopCharacters)
53 | {
54 | return StopCharacters switch
55 | {
56 | char[] charArray => input.GetStringToTheRight(CaretIndex, charArray),
57 | string[] stringArray => input.GetStringToTheRight(CaretIndex, stringArray),
58 | string str => input.GetStringToTheRight(CaretIndex, str.ToCharArray()),
59 | _ => throw new ArgumentException("StopCharacters must either be char[], string[] or string")
60 | };
61 | }
62 |
63 | public static string ReplaceFirst(this string text, string search, string replace, StringComparison stringComparison = StringComparison.Ordinal)
64 | {
65 | int pos = text.IndexOf(search, stringComparison);
66 | if (pos < 0)
67 | {
68 | return text;
69 | }
70 | return text.Substring(0, pos) + replace + text[(pos + search.Length)..];
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/BindingHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace TimsWpfControls.Helper
10 | {
11 | public static class BindingHelper
12 | {
13 | private static readonly DependencyProperty DummyProperty = DependencyProperty.RegisterAttached(
14 | "Dummy",
15 | typeof(object),
16 | typeof(DependencyObject),
17 | new UIPropertyMetadata(null));
18 |
19 | public static object Eval(object source, string expression)
20 | {
21 | Binding binding = new Binding(expression) { Source = source };
22 | return Eval(binding);
23 | }
24 |
25 | public static object Eval(object source, string expression, string format)
26 | {
27 | Binding binding = new Binding(expression) { Source = source, StringFormat=format };
28 | return Eval(binding);
29 | }
30 |
31 | public static object Eval(Binding binding, object source)
32 | {
33 | if (binding is null) throw new ArgumentNullException(nameof(binding));
34 |
35 | Binding newBinding = new Binding()
36 | {
37 | Source = source,
38 | AsyncState = binding.AsyncState,
39 | BindingGroupName = binding.BindingGroupName,
40 | BindsDirectlyToSource = binding.BindsDirectlyToSource,
41 | Path = binding.Path,
42 | Converter = binding.Converter,
43 | ConverterCulture = binding.ConverterCulture,
44 | ConverterParameter = binding.ConverterParameter,
45 | FallbackValue = binding.FallbackValue,
46 | IsAsync = binding.IsAsync,
47 | Mode = BindingMode.OneWay,
48 | StringFormat = binding.StringFormat,
49 | TargetNullValue = binding.TargetNullValue
50 | };
51 | return Eval(newBinding);
52 | }
53 |
54 | public static object Eval(Binding binding, DependencyObject dependencyObject = null)
55 | {
56 | dependencyObject ??= new DependencyObject();
57 | BindingOperations.SetBinding(dependencyObject, DummyProperty, binding);
58 | return dependencyObject.GetValue(DummyProperty);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/DataContextProxy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 |
8 | namespace TimsWpfControls
9 | {
10 | ///
11 | /// This is a simple Binding Proxy to get rid of the FindAnchestor issues.
12 | /// Idea taken from here: https://code.4noobz.net/wpf-mvvm-proxy-binding/
13 | ///
14 | public class DataContextProxy : Freezable
15 | {
16 | #region Overrides of Freezable
17 |
18 | protected override Freezable CreateInstanceCore()
19 | {
20 | return new DataContextProxy();
21 | }
22 |
23 | #endregion
24 |
25 | ///
26 | /// Gets or Sets the Data which you want to bind to.
27 | ///
28 | public object Data
29 | {
30 | get { return (object)GetValue(DataProperty); }
31 | set { SetValue(DataProperty, value); }
32 | }
33 |
34 | public static readonly DependencyProperty DataProperty = DependencyProperty.Register(nameof(Data), typeof(object), typeof(DataContextProxy), new UIPropertyMetadata(null));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/DialogHelper.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using MahApps.Metro.Controls.Dialogs;
3 | using System;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 |
8 | namespace TimsWpfControls
9 | {
10 | public static class DialogHelper
11 | {
12 | public static async Task ShowErrorMessage(Exception e, string Header = "Error")
13 | {
14 | MetroWindow window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive);
15 | if (window is null)
16 | {
17 | MessageBox.Show(e.Message, Header);
18 | }
19 | else
20 | {
21 | await window.ShowMessageAsync(Header, e.Message, MessageDialogStyle.Affirmative);
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/FileHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using TimsWpfControls.ExtensionMethods;
10 |
11 | namespace TimsWpfControls.Helper
12 | {
13 | public static class FileHelper
14 | {
15 | public static bool IsFullyQualifiedAdvanced(string fileName)
16 | {
17 | try
18 | {
19 | if (string.IsNullOrEmpty(fileName)) return false;
20 | return IsFullyQualifiedAdvanced(new Uri(fileName));
21 | }
22 | catch
23 | {
24 | return false;
25 | }
26 | }
27 |
28 | public static bool IsFullyQualifiedAdvanced(Uri uri)
29 | {
30 | try
31 | {
32 | return uri.Host == Dns.GetHostEntry(uri.Host).HostName;
33 | }
34 | catch
35 | {
36 | return false;
37 | }
38 | }
39 |
40 |
41 | public static string GetFullyQualifiedAdvanced(string fileName)
42 | {
43 | try
44 | {
45 | var uri = new Uri(fileName);
46 |
47 | if (!uri.IsUnc)
48 | {
49 | return fileName;
50 | }
51 | else if (IsFullyQualifiedAdvanced(uri))
52 | {
53 | return fileName;
54 | }
55 | else
56 | {
57 | return fileName.ReplaceFirst(uri.Host, Dns.GetHostEntry(uri.Host).HostName);
58 | }
59 | }
60 | catch
61 | {
62 | return null;
63 | }
64 | }
65 |
66 |
67 | [DllImport("mpr.dll")]
68 | static extern int WNetGetUniversalNameA(string lpLocalPath, int dwInfoLevel, IntPtr lpBuffer, ref int lpBufferSize);
69 |
70 | // I think max length for UNC is actually 32,767
71 | public static string LocalPathToUNC(string localPath, int maxLen = 2000)
72 | {
73 | IntPtr lpBuff;
74 |
75 | // Allocate the memory
76 | try
77 | {
78 | lpBuff = Marshal.AllocHGlobal(maxLen);
79 | }
80 | catch (OutOfMemoryException)
81 | {
82 | return null;
83 | }
84 |
85 | try
86 | {
87 | int res = WNetGetUniversalNameA(localPath, 1, lpBuff, ref maxLen);
88 |
89 | if (res != 0)
90 | return GetFullyQualifiedAdvanced(localPath);
91 |
92 | // lpbuff is a structure, whose first element is a pointer to the UNC name (just going to be lpBuff + sizeof(int))
93 | var result = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(lpBuff));
94 |
95 | return GetFullyQualifiedAdvanced(result);
96 | }
97 | catch (Exception)
98 | {
99 | return null;
100 | }
101 | finally
102 | {
103 | Marshal.FreeHGlobal(lpBuff);
104 | }
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/SolidAccentsLibaryThemeProvider.cs:
--------------------------------------------------------------------------------
1 | using ControlzEx.Theming;
2 | using MahApps.Metro.Controls;
3 | using MahApps.Metro.Theming;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Globalization;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Media;
11 |
12 | namespace TimsWpfControls.Helper
13 | {
14 | public class SolidAccentsLibaryThemeProvider : LibraryThemeProvider
15 |
16 | {
17 | public static readonly SolidAccentsLibaryThemeProvider DefaultInstance = new SolidAccentsLibaryThemeProvider();
18 |
19 | ///
20 | public SolidAccentsLibaryThemeProvider() : base(true)
21 | {
22 | }
23 |
24 | public override void FillColorSchemeValues(Dictionary values, RuntimeThemeColorValues colorValues)
25 | {
26 | if (values is null) throw new ArgumentNullException(nameof(values));
27 | if (colorValues is null) throw new ArgumentNullException(nameof(colorValues));
28 |
29 | if (colorValues.Options.UseHSL)
30 | {
31 | Color background = (Color)ColorConverter.ConvertFromString(colorValues.Options.BaseColorScheme.Values["MahApps.Colors.ThemeBackground"]);
32 | Color foreground = (Color)ColorConverter.ConvertFromString(colorValues.Options.BaseColorScheme.Values["MahApps.Colors.ThemeForeground"]);
33 | Color accent = colorValues.AccentBaseColor;
34 | double factor = colorValues.Options.BaseColorScheme.Name == "Dark" ? 0.1 : 0.2;
35 |
36 | var accentHsv = new HSVColor(accent);
37 | var backgroundHsv = new HSVColor(background);
38 | var foregroundHsv = new HSVColor(foreground);
39 |
40 | values.Add("MahApps.Colors.AccentBase", accent.ToString(CultureInfo.InvariantCulture));
41 | values.Add("MahApps.Colors.Accent", GetAccentedColor(accentHsv, backgroundHsv, factor * 1).ToString(CultureInfo.InvariantCulture));
42 | values.Add("MahApps.Colors.Accent2", GetAccentedColor(accentHsv, backgroundHsv, factor * 2).ToString(CultureInfo.InvariantCulture));
43 | values.Add("MahApps.Colors.Accent3", GetAccentedColor(accentHsv, backgroundHsv, factor * 3).ToString(CultureInfo.InvariantCulture));
44 | values.Add("MahApps.Colors.Accent4", GetAccentedColor(accentHsv, backgroundHsv, factor * 4).ToString(CultureInfo.InvariantCulture));
45 |
46 | values.Add("MahApps.Colors.Highlight", GetAccentedColor(accentHsv, foregroundHsv, factor).ToString(CultureInfo.InvariantCulture));
47 | values.Add("MahApps.Colors.IdealForeground", colorValues.IdealForegroundColor.ToString(CultureInfo.InvariantCulture));
48 | }
49 | else
50 | {
51 | values.Add("MahApps.Colors.AccentBase", colorValues.AccentBaseColor.ToString());
52 | values.Add("MahApps.Colors.Accent", colorValues.AccentColor80.ToString());
53 | values.Add("MahApps.Colors.Accent2", colorValues.AccentColor60.ToString());
54 | values.Add("MahApps.Colors.Accent3", colorValues.AccentColor40.ToString());
55 | values.Add("MahApps.Colors.Accent4", colorValues.AccentColor20.ToString());
56 |
57 | values.Add("MahApps.Colors.Highlight", colorValues.HighlightColor.ToString());
58 | values.Add("MahApps.Colors.IdealForeground", colorValues.IdealForegroundColor.ToString());
59 | }
60 |
61 | }
62 |
63 | public override string GetThemeGeneratorParametersContent()
64 | {
65 | return MahAppsLibraryThemeProvider.DefaultInstance.GetThemeGeneratorParametersContent();
66 | }
67 |
68 | public override string GetThemeTemplateContent()
69 | {
70 | return MahAppsLibraryThemeProvider.DefaultInstance.GetThemeTemplateContent();
71 | }
72 |
73 | private static Color GetAccentedColor (HSVColor accentBase, HSVColor background, double percentage)
74 | {
75 | double newSaturation = accentBase.Saturation + (background.Saturation - accentBase.Saturation) * percentage;
76 | double newValue = accentBase.Value + (background.Value - accentBase.Value) * percentage;
77 |
78 | return new HSVColor(accentBase.Hue, newSaturation, newValue).ToColor();
79 | }
80 |
81 |
82 | }
83 | }
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/ThemingHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Resources;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Media;
11 |
12 | namespace TimsWpfControls
13 | {
14 | public static class ThemingHelper
15 | {
16 | static Dictionary _AccentColorNamesDictionary;
17 | public static Dictionary AccentColorNamesDictionary
18 | {
19 | get
20 | {
21 | if (_AccentColorNamesDictionary == null)
22 | {
23 | _AccentColorNamesDictionary = new Dictionary();
24 | var rm = new ResourceManager(typeof(Lang.AccentColorNames));
25 | var resourceSet = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
26 | foreach (var entry in resourceSet.OfType())
27 | {
28 | try
29 | {
30 | var color = (Color)ColorConverter.ConvertFromString(entry.Key.ToString());
31 | _AccentColorNamesDictionary.Add(color, entry.Value.ToString());
32 | }
33 | catch (Exception)
34 | {
35 | Console.WriteLine(entry.Key.ToString() + " is not a valid color-key");
36 | }
37 | }
38 | }
39 | return _AccentColorNamesDictionary;
40 | }
41 | set { _AccentColorNamesDictionary = value; }
42 | }
43 |
44 |
45 | static ObservableCollection _AccentColorsPalette;
46 | public static ObservableCollection AccentColorsPalette
47 | {
48 | get
49 | {
50 | if (_AccentColorsPalette == null)
51 | {
52 | _AccentColorsPalette = new ObservableCollection(
53 | AccentColorNamesDictionary
54 | .OrderBy(x => x.Value)
55 | .Select(x => x.Key));
56 |
57 | return _AccentColorsPalette;
58 | }
59 | return _AccentColorsPalette;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Helper/TreeHelper.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls.Primitives;
9 |
10 | namespace TimsWpfControls.Helper
11 | {
12 | public static class TreeHelper
13 | {
14 | public static bool IsDescendantOf(this DependencyObject node, DependencyObject reference)
15 | {
16 | bool success = false;
17 |
18 | DependencyObject curr = node;
19 |
20 | while (curr != null)
21 | {
22 | if (curr == reference)
23 | {
24 | success = true;
25 | break;
26 | }
27 |
28 | if (curr is Popup popup)
29 | {
30 | curr = popup;
31 |
32 | if (popup != null)
33 | {
34 | // Try the poup Parent
35 | curr = popup.Parent;
36 |
37 | // Otherwise fall back to placement target
38 | if (curr == null)
39 | {
40 | curr = popup.PlacementTarget;
41 | }
42 | }
43 | }
44 | else // Otherwise walk tree
45 | {
46 | curr = curr.GetParentObject();
47 | }
48 |
49 | }
50 |
51 | return success;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/AccentColorNames.de-DE.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Kobalt
122 |
123 |
124 | Blau
125 |
126 |
127 | Smaragdgrün
128 |
129 |
130 | Blaugrün
131 |
132 |
133 | Cyanblau
134 |
135 |
136 | Grün
137 |
138 |
139 | Lila
140 |
141 |
142 | Stahl
143 |
144 |
145 | Indigo
146 |
147 |
148 | Olivgrün
149 |
150 |
151 | Malvenfarbe
152 |
153 |
154 | Braun
155 |
156 |
157 | Braungrau
158 |
159 |
160 | Ockergelb
161 |
162 |
163 | Karmesinrot
164 |
165 |
166 | Limone
167 |
168 |
169 | Violett
170 |
171 |
172 | Magenta
173 |
174 |
175 | Rot
176 |
177 |
178 | Bernstein
179 |
180 |
181 | Rosa
182 |
183 |
184 | Orange
185 |
186 |
187 | Gelb
188 |
189 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/AccentColorNames.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Amber
122 |
123 |
124 | Blue
125 |
126 |
127 | Brown
128 |
129 |
130 | Cobalt
131 |
132 |
133 | Crimson
134 |
135 |
136 | Cyan
137 |
138 |
139 | Emerald
140 |
141 |
142 | Green
143 |
144 |
145 | Indigo
146 |
147 |
148 | Lime
149 |
150 |
151 | Magenta
152 |
153 |
154 | Mauve
155 |
156 |
157 | Olive
158 |
159 |
160 | Orange
161 |
162 |
163 | Pink
164 |
165 |
166 | Purple
167 |
168 |
169 | Red
170 |
171 |
172 | Sienna
173 |
174 |
175 | Steel
176 |
177 |
178 | Taupe
179 |
180 |
181 | Teal
182 |
183 |
184 | Violet
185 |
186 |
187 | Yellow
188 |
189 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/FileSelectionTextBox.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TimsWpfControls.Lang {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class FileSelectionTextBox {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal FileSelectionTextBox() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | public static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimsWpfControls.Lang.FileSelectionTextBox", typeof(FileSelectionTextBox).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | public static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to Any File (*.*)|*.*.
65 | ///
66 | public static string FilterAnyFile {
67 | get {
68 | return ResourceManager.GetString("FilterAnyFile", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to Select a file.
74 | ///
75 | public static string SelectFile {
76 | get {
77 | return ResourceManager.GetString("SelectFile", resourceCulture);
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/FileSelectionTextBox.de-DE.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Wähle eine Datei
122 |
123 |
124 | Alle Dateien (*.*)|*.*
125 |
126 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/FileSelectionTextBox.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | text/microsoft-resx
90 |
91 |
92 | 1.3
93 |
94 |
95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
96 |
97 |
98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
99 |
100 |
101 | Select a file
102 |
103 |
104 | Any File (*.*)|*.*
105 |
106 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/MultiSelectionComboBox.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TimsWpfControls.Lang {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class MultiSelectionComboBox {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal MultiSelectionComboBox() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | public static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimsWpfControls.Lang.MultiSelectionComboBox", typeof(MultiSelectionComboBox).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | public static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to Reset Text.
65 | ///
66 | public static string ResetTextToSelectedItems {
67 | get {
68 | return ResourceManager.GetString("ResetTextToSelectedItems", resourceCulture);
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/MultiSelectionComboBox.de.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Text zurücksetzen
122 |
123 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/MultiSelectionComboBox.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | text/microsoft-resx
90 |
91 |
92 | 1.3
93 |
94 |
95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
96 |
97 |
98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
99 |
100 |
101 | Reset Text
102 | This text is shown on the popup overlay if the text is userdefined.
103 |
104 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/ValidationMessages.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TimsWpfControls.Lang {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class ValidationMessages {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal ValidationMessages() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimsWpfControls.Lang.ValidationMessages", typeof(ValidationMessages).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to The collection "{0}" may not be empty.
65 | ///
66 | internal static string CollectionMayNotBeEmpty {
67 | get {
68 | return ResourceManager.GetString("CollectionMayNotBeEmpty", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to The Filename of "{0}" is not fully qualified.
74 | ///
75 | internal static string FilenameIsNotFullyQualified {
76 | get {
77 | return ResourceManager.GetString("FilenameIsNotFullyQualified", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Looks up a localized string similar to "{0}" must be greater than {1}.
83 | ///
84 | internal static string PropertyMustBeGreaterThanMessage {
85 | get {
86 | return ResourceManager.GetString("PropertyMustBeGreaterThanMessage", resourceCulture);
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/ValidationMessages.de-DE.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | "{0}" muss größer als {1} sein
122 |
123 |
124 | Der Dateiname für "{0}" ist nicht vollständig definiert
125 |
126 |
127 | Die Auflistung "{0}" darf nicht leer sein
128 |
129 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Lang/ValidationMessages.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | text/microsoft-resx
90 |
91 |
92 | 1.3
93 |
94 |
95 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
96 |
97 |
98 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
99 |
100 |
101 | "{0}" must be greater than {1}
102 |
103 |
104 | The Filename of "{0}" is not fully qualified
105 |
106 |
107 | The collection "{0}" may not be empty
108 |
109 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Model/LocalizedDescriptionAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Resources;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace TimsWpfControls.Model
10 | {
11 |
12 |
13 | public class LocalizedDescriptionAttribute : DescriptionAttribute
14 | {
15 | private readonly ResourceManager resourceManager;
16 | private readonly string resourceKey;
17 |
18 | ///
19 | /// Creates a new LocalizedDescription-Attribute
20 | ///
21 | /// the Key of the the resourcestring to lookup
22 | /// the type of the ResourceDictionary where the data is stored
23 | public LocalizedDescriptionAttribute(string resourceKey, Type resourceType)
24 | {
25 | this.resourceKey = resourceKey;
26 | this.resourceManager = new ResourceManager(resourceType);
27 | }
28 |
29 | public override string Description
30 | {
31 | get
32 | {
33 | string description = resourceManager.GetString(resourceKey);
34 | return string.IsNullOrWhiteSpace(description) ? resourceKey : description;
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/TimsWpfControls/TimsWpfControls/Model/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace TimsWpfControls.Model
5 | {
6 | [Obsolete ("Use any other MVVM Toolkit instead, e.g.: Microsoft.Toolkit.Mvvm")]
7 | public class RelayCommand : ICommand
8 | {
9 | private Action