├── .gitignore ├── Digimezzo.Foundation.Core ├── Digimezzo.Foundation.Core.csproj ├── Helpers │ ├── HSLColor.cs │ ├── NameValue.cs │ ├── OperationResult.cs │ └── Taskbar.cs ├── IO │ ├── Actions.cs │ ├── ProcessExecutable.cs │ └── WindowsPaths.cs ├── Logging │ ├── LogClient.cs │ ├── LogEntry.cs │ └── LogLevel.cs ├── Packaging │ ├── ExternalComponent.cs │ ├── Package.cs │ ├── PackageCreator.cs │ └── PackagerConfiguration.xml ├── Properties │ └── AssemblyInfo.cs ├── Settings │ ├── BaseSettings.xml │ ├── SettingChangedEventArgs.cs │ ├── SettingEntry.cs │ └── SettingsClient.cs ├── SharedAssemblyInfo.cs ├── Utils │ ├── CryptographyUtils.cs │ ├── DateTimeUtils.cs │ ├── EnvironmentUtils.cs │ ├── FileUtils.cs │ ├── ImageUtils.cs │ ├── ResourceUtils.cs │ ├── StringUtils.cs │ ├── ValidationUtils.cs │ ├── VisualTreeUtils.cs │ └── WindowUtils.cs └── Win32 │ ├── ABE.cs │ ├── ABM.cs │ ├── ABS.cs │ ├── APPBARDATA.cs │ ├── AccentPolicy.cs │ ├── AccentState.cs │ ├── FileOperationFlags.cs │ ├── FileOperationType.cs │ ├── GWL.cs │ ├── NativeMethods.cs │ ├── RECT.cs │ ├── SHFILEOPSTRUCT.cs │ ├── SHFileOperationReturnCode.cs │ ├── WS.cs │ ├── WSEX.cs │ ├── WindowCompositionAttribute.cs │ └── WindowCompositionAttributeData.cs ├── Digimezzo.Foundation.WPF.Demo ├── App.config ├── App.xaml ├── App.xaml.cs ├── Digimezzo.Foundation.WPF.Demo.csproj ├── MainWindow.xaml ├── MainWindow.xaml.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Digimezzo.Foundation.WPF ├── Base │ ├── BorderlessWindowBase.cs │ ├── Constants.cs │ ├── FontIconBase.cs │ ├── MaterialButtonBase.cs │ ├── PropertyChangedBase.cs │ └── SliderBase.cs ├── Controls │ ├── FontIcons.cs │ ├── LabelToLower.cs │ ├── LabelToUpper.cs │ ├── MaterialCircularProgressBar.cs │ ├── MaterialComboBox.cs │ ├── MaterialDateBox.cs │ ├── MaterialFlatButton.cs │ ├── MaterialFloatingActionButton.cs │ ├── MaterialMiniFloatingActionButton.cs │ ├── MaterialRaisedButton.cs │ ├── MaterialTextBox.cs │ ├── MaterialToggleSwitch.cs │ ├── MultiPanePanel.cs │ ├── MultiSelectListBox.cs │ ├── PageIndicator.cs │ ├── Pivot.cs │ ├── ProgressRing.cs │ ├── Ripple.cs │ ├── SlidingContentControl.cs │ ├── SplitView.cs │ ├── UWPSliderHorizontal.cs │ ├── UWPSliderHorizontalBottom.cs │ ├── UWPSliderVertical.cs │ ├── VirtualizingWrapPanel.cs │ ├── Windows10BorderlessWindow.cs │ ├── Windows10SliderHorizontal.cs │ ├── Windows10SliderVertical.cs │ ├── Windows10ToggleSwitch.cs │ ├── Windows8BorderlessWindow.cs │ ├── Windows8SliderHorizontal.cs │ ├── Windows8SliderVertical.cs │ └── Windows8ToggleSwitch.cs ├── Converters │ ├── AddValueConverter.cs │ ├── BooleanToCollapsedConverter.cs │ ├── BooleanToVisibilityConverter.cs │ ├── EnumConverter.cs │ ├── InvertingBooleanConverter.cs │ ├── MaterialCircularProgressBar │ │ ├── ArcEndPointConverter.cs │ │ ├── ArcSizeConverter.cs │ │ ├── LargeArcConverter.cs │ │ ├── LocalEx.cs │ │ ├── NotZeroConverter.cs │ │ ├── RotateTransformCentreConverter.cs │ │ ├── RotateTransformConverter.cs │ │ └── StartPointConverter.cs │ ├── NullToCollapsedConverter.cs │ ├── NullToVisibleConverter.cs │ ├── ResizeModeMinMaxButtonVisibilityConverter.cs │ ├── SolidColorBrushToColorConverter.cs │ ├── StringToLowerConverter.cs │ └── StringToUpperConverter.cs ├── Digimezzo.Foundation.WPF.csproj ├── Effects │ ├── FeatheringEffect.cs │ ├── FeatheringEffect.fx │ └── FeatheringEffect.ps ├── Extensions │ └── StringExtensions.cs ├── Fonts │ ├── MaterialIcons-Regular.ttf │ ├── Roboto-Thin.ttf │ ├── fontawesome-webfont.ttf │ └── segmdl2.ttf ├── Licenses │ ├── MahApps.Metro.txt │ └── MaterialDesignInXamlToolkit.txt ├── Native │ ├── Constants.cs │ ├── Enums.cs │ ├── NativeMethods.cs │ └── Structs.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Themes │ ├── FontIcons.xaml │ ├── Generic.xaml │ ├── LabelToLower.xaml │ ├── LabelToUpper.xaml │ ├── MaterialCircularProgressBar.xaml │ ├── MaterialComboBox.xaml │ ├── MaterialDateBox.xaml │ ├── MaterialFlatButton.xaml │ ├── MaterialFloatingActionButton.xaml │ ├── MaterialMiniFloatingActionButton.xaml │ ├── MaterialRaisedButton.xaml │ ├── MaterialTextBox.xaml │ ├── MaterialToggleSwitch.xaml │ ├── MultiPanePanel.xaml │ ├── PageIndicator.xaml │ ├── Pivot.xaml │ ├── ProgressRing.xaml │ ├── Ripple.xaml │ ├── SlidingContentControl.xaml │ ├── SplitView.xaml │ ├── UWPSliderHorizontal.xaml │ ├── UWPSliderHorizontalBottom.xaml │ ├── UWPSliderVertical.xaml │ ├── Windows10BorderlessWindow.xaml │ ├── Windows10SliderHorizontal.xaml │ ├── Windows10SliderVertical.xaml │ ├── Windows10ToggleSwitch.xaml │ ├── Windows8BorderlessWindow.xaml │ ├── Windows8SliderHorizontal.xaml │ ├── Windows8SliderVertical.xaml │ └── Windows8ToggleSwitch.xaml └── Utils │ ├── AnimationUtils.cs │ ├── UriUtils.cs │ └── VisualTreeUtils.cs ├── Foundation.png ├── Foundation.sln ├── Foundation.svg ├── Foundation_small.png ├── LICENSE └── README.md /Digimezzo.Foundation.Core/Digimezzo.Foundation.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F376CCCA-325F-4533-934D-A9C4A7CFC69B} 8 | Library 9 | Properties 10 | Digimezzo.Foundation.Core 11 | Digimezzo.Foundation.Core 12 | v4.7.2 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 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 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Helpers/NameValue.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Helpers 2 | { 3 | /// 4 | /// A helper object containing a name and a value 5 | /// 6 | public class NameValue 7 | { 8 | private string name; 9 | private int value; 10 | 11 | public string Name 12 | { 13 | get { return this.name; } 14 | set { this.name = value; } 15 | } 16 | 17 | public int Value 18 | { 19 | get { return this.value; } 20 | set { this.value = value; } 21 | } 22 | 23 | public override string ToString() 24 | { 25 | return this.Name.ToString(); 26 | } 27 | 28 | public override bool Equals(object obj) 29 | { 30 | if (obj == null || !GetType().Equals(obj.GetType())) 31 | { 32 | return false; 33 | } 34 | 35 | return this.Value == ((NameValue)obj).Value; 36 | } 37 | 38 | public override int GetHashCode() 39 | { 40 | return this.Value.GetHashCode(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Helpers/OperationResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Digimezzo.Foundation.Core.Helpers 7 | { 8 | /// 9 | /// A helper object to use as a result of a function 10 | /// 11 | public class OperationResult 12 | { 13 | private List messages; 14 | 15 | public bool Result { get; set; } 16 | 17 | public OperationResult() 18 | { 19 | this.messages = new List(); 20 | } 21 | 22 | public void AddMessage(string iMessage) 23 | { 24 | this.messages.Add(iMessage); 25 | } 26 | 27 | public string GetFirstMessage() 28 | { 29 | if (this.messages.Count > 0) 30 | { 31 | return this.messages.First(); 32 | } 33 | else 34 | { 35 | return string.Empty; 36 | } 37 | } 38 | 39 | public string GetMessages() 40 | { 41 | 42 | StringBuilder sb = new StringBuilder(); 43 | 44 | foreach (string item in this.messages) 45 | { 46 | sb.AppendLine(item + Environment.NewLine); 47 | } 48 | 49 | return sb.ToString(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Helpers/Taskbar.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.Core.Win32; 2 | using System; 3 | using System.Drawing; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace Digimezzo.Foundation.Core.Helpers 7 | { 8 | public enum TaskbarPosition 9 | { 10 | Unknown = -1, 11 | Left, 12 | Top, 13 | Right, 14 | Bottom, 15 | } 16 | 17 | /// 18 | /// See https://winsharp93.wordpress.com/2009/06/29/find-out-size-and-position-of-the-taskbar/ 19 | /// 20 | public class Taskbar 21 | { 22 | private const string ClassName = "Shell_TrayWnd"; 23 | 24 | /// 25 | /// Gets a Rectangle representing the bounds of the Windows Taskbar 26 | /// 27 | public Rectangle Bounds { get; private set; } 28 | 29 | /// 30 | /// Gets the Windows Taskbar position on the screen 31 | /// 32 | public TaskbarPosition Position { get; private set; } 33 | 34 | /// 35 | /// Gets the location of the Taskbar on the screen 36 | /// 37 | public Point Location => this.Bounds.Location; 38 | 39 | /// 40 | /// Gets the size of the Windows Taskbar 41 | /// 42 | public Size Size => this.Bounds.Size; 43 | 44 | /// 45 | /// Gets if the Windows Taskbar is set always on top (Somehow always returns false under Windows 7) 46 | /// 47 | public bool AlwaysOnTop { get; private set; } 48 | 49 | /// 50 | /// Gets if the Windows Taskbar is set to auto hide 51 | /// 52 | public bool AutoHide { get; private set; } 53 | 54 | public Taskbar() 55 | { 56 | IntPtr taskbarHandle = NativeMethods.FindWindow(Taskbar.ClassName, null); 57 | 58 | APPBARDATA data = new APPBARDATA(); 59 | data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)); 60 | data.hWnd = taskbarHandle; 61 | IntPtr result = NativeMethods.SHAppBarMessage(ABM.GetTaskbarPos, ref data); 62 | if (result == IntPtr.Zero) 63 | throw new InvalidOperationException(); 64 | 65 | this.Position = (TaskbarPosition)data.uEdge; 66 | this.Bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom); 67 | 68 | data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)); 69 | result = NativeMethods.SHAppBarMessage(ABM.GetState, ref data); 70 | int state = result.ToInt32(); 71 | this.AlwaysOnTop = (state & ABS.AlwaysOnTop) == ABS.AlwaysOnTop; 72 | this.AutoHide = (state & ABS.Autohide) == ABS.Autohide; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/IO/Actions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Digimezzo.Foundation.Core.IO 4 | { 5 | public static class Actions 6 | { 7 | public static void TryOpenLink(string url) 8 | { 9 | try 10 | { 11 | // Try to open the link in the Default Browser 12 | System.Diagnostics.Process.Start(url); 13 | } 14 | catch (Exception) 15 | { 16 | // If that didn't work, try to open it in Internet Explorer 17 | try 18 | { 19 | System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("IExplore.exe", url); 20 | System.Diagnostics.Process.Start(startInfo); 21 | startInfo = null; 22 | } 23 | catch (Exception) 24 | { 25 | // If opening in Internet Explorer didn't work, throw an exception which should be caught and logged. 26 | throw; 27 | } 28 | } 29 | } 30 | 31 | public static void TryOpenMail(string emailAddress) 32 | { 33 | try 34 | { 35 | System.Diagnostics.Process.Start("mailto://" + emailAddress); 36 | } 37 | catch (Exception) 38 | { 39 | throw; 40 | } 41 | } 42 | 43 | public static void TryOpenPath(string path) 44 | { 45 | try 46 | { 47 | System.Diagnostics.Process.Start(path); 48 | } 49 | catch (Exception) 50 | { 51 | throw; 52 | } 53 | } 54 | 55 | public static void TryViewInExplorer(string path) 56 | { 57 | try 58 | { 59 | System.Diagnostics.Process.Start("explorer.exe", "/select, \"" + path + "\""); 60 | } 61 | catch (Exception) 62 | { 63 | throw; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/IO/ProcessExecutable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Digimezzo.Foundation.Core.IO 5 | { 6 | public static class ProcessExecutable 7 | { 8 | /// 9 | /// Gets the folder of the process executable 10 | /// 11 | /// 12 | public static string ExecutionFolder() 13 | { 14 | return System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); 15 | } 16 | 17 | /// 18 | /// Gets the name of the process executable 19 | /// 20 | /// 21 | public static string Name() 22 | { 23 | return Assembly.GetEntryAssembly().GetName().Name; 24 | } 25 | 26 | /// 27 | /// Get the assembly version of the process executable 28 | /// 29 | /// 30 | public static Version AssemblyVersion() 31 | { 32 | Assembly asm = Assembly.GetEntryAssembly(); 33 | AssemblyName an = asm.GetName(); 34 | 35 | return an.Version; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/IO/WindowsPaths.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Digimezzo.Foundation.Core.IO 4 | { 5 | public static class WindowsPaths 6 | { 7 | /// 8 | /// Gets the user's AppData\Local directory. 9 | /// 10 | /// User's AppData\Local directory. 11 | public static string LocalAppData() 12 | { 13 | return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); 14 | } 15 | 16 | /// 17 | /// Gets the user's AppData\Roaming directory. 18 | /// 19 | /// User's AppData\Roaming directory. 20 | public static string AppData() 21 | { 22 | return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Logging/LogEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Logging 2 | { 3 | public class LogEntry 4 | { 5 | public string TimeStamp { get; set; } 6 | public string Level { get; set; } 7 | public string CallerFilePath { get; set; } 8 | public string CallerMemberName { get; set; } 9 | public int CallerLineNumber { get; set; } 10 | public string Message { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Logging/LogLevel.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Logging 2 | { 3 | public enum LogLevel 4 | { 5 | Info = 1, 6 | Warning = 2, 7 | Error = 3 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Packaging/ExternalComponent.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Packaging 2 | { 3 | public class ExternalComponent 4 | { 5 | private string name; 6 | private string description; 7 | private string url; 8 | private string licenseUrl; 9 | 10 | public string Name 11 | { 12 | get { return name; } 13 | set { name = value; } 14 | } 15 | 16 | public string Description 17 | { 18 | get { return description; } 19 | set { description = value; } 20 | } 21 | 22 | public string Url 23 | { 24 | get { return url; } 25 | set { url = value; } 26 | } 27 | 28 | public string LicenseUrl 29 | { 30 | get { return licenseUrl; } 31 | set { licenseUrl = value; } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Packaging/Package.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Digimezzo.Foundation.Core.Packaging 4 | { 5 | public class Package 6 | { 7 | private string name { get; set; } 8 | private Version version { get; set; } 9 | 10 | public string Name 11 | { 12 | get 13 | { 14 | return this.name; 15 | } 16 | } 17 | 18 | public Version Version 19 | { 20 | get 21 | { 22 | return this.version; 23 | } 24 | } 25 | 26 | public string UnformattedVersion 27 | { 28 | get 29 | { 30 | // {0}: Major Version, 31 | // {1}: Minor Version, 32 | // {2}: Build Number, 33 | // {3}: Revision 34 | return string.Format("{0}.{1}.{2}.{3}", this.version.Major, this.version.Minor, this.version.Build, this.version.Revision); 35 | } 36 | } 37 | 38 | public string FormattedVersion 39 | { 40 | get 41 | { 42 | // {0}: Major Version, 43 | // {1}: Minor Version, 44 | // {2}: Build Number, 45 | // {3}: Revision 46 | 47 | if (this.version.Build != 0) 48 | { 49 | return string.Format("{0}.{1}.{2} (Build {3})", this.version.Major, this.version.Minor, this.version.Build, this.version.Revision); 50 | } 51 | else 52 | { 53 | return string.Format("{0}.{1} (Build {2})", this.version.Major, this.version.Minor, this.version.Revision); 54 | } 55 | } 56 | } 57 | 58 | public string FormattedVersionNoBuild 59 | { 60 | get 61 | { 62 | // {0}: Major Version, 63 | // {1}: Minor Version, 64 | // {2}: Build Number, 65 | // {3}: Revision 66 | 67 | if (this.version.Build != 0) 68 | { 69 | return string.Format("{0}.{1}.{2}", this.version.Major, this.version.Minor, this.version.Build, this.version.Revision); 70 | } 71 | else 72 | { 73 | return string.Format("{0}.{1}", this.version.Major, this.version.Minor, this.version.Revision); 74 | } 75 | } 76 | } 77 | 78 | public string FormattedVersionNoBuildWithLabel 79 | { 80 | get 81 | { 82 | string versionType = this.Version.Revision.ToString().Substring(0, 1); 83 | string versionTypeNumber = this.Version.Revision.ToString().Substring(1, 3).TrimStart(new Char[] { '0' }); 84 | string returnValue = string.Empty; 85 | 86 | switch (versionType) 87 | { 88 | case "1": 89 | returnValue = $"{this.FormattedVersionNoBuild} (Preview {versionTypeNumber})"; 90 | break; 91 | case "2": 92 | returnValue = $"{this.FormattedVersionNoBuild} (Beta {versionTypeNumber})"; 93 | break; 94 | case "3": 95 | returnValue = $"{this.FormattedVersionNoBuild} (Release Candidate {versionTypeNumber})"; 96 | break; 97 | case "4": 98 | returnValue = $"{this.FormattedVersionNoBuild} (Release)"; 99 | break; 100 | default: 101 | returnValue = this.FormattedVersionNoBuild; 102 | break; 103 | } 104 | 105 | return returnValue; 106 | } 107 | } 108 | 109 | public string Filename 110 | { 111 | get 112 | { 113 | return string.Format("{0} {1}", this.name, this.FormattedVersionNoBuildWithLabel); 114 | } 115 | } 116 | 117 | public string InstallableFileExtension 118 | { 119 | get 120 | { 121 | return ".msi"; 122 | } 123 | } 124 | 125 | public string PortableFileExtension 126 | { 127 | get 128 | { 129 | return ".zip"; 130 | } 131 | } 132 | 133 | public string UpdateFileExtension 134 | { 135 | get 136 | { 137 | return ".update"; 138 | } 139 | } 140 | 141 | public Package(string name, Version version) 142 | { 143 | this.name = name; 144 | this.version = version; 145 | } 146 | 147 | public bool IsOlder(Package referencePackage) 148 | { 149 | return this.version < referencePackage.version; 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Packaging/PackagerConfiguration.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | folder/subfolder/ 6 | https://www.mywebsite.com/updateapi.php?function=addversion 7 | 8 | 9 | C:\Temp\Applicationname 10 | 11 | C:\Program Files (x86)\WiX Toolset v3.10\bin 12 | 13 | 14 | 15 | Directory1 16 | Directory2 17 | 18 | 19 | Application.exe 20 | Application.exe.config 21 | Changelog.txt 22 | Library1.dll 23 | Library2.dll 24 | Library3.dll 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Digimezzo.Foundation.Core")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | //[assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Digimezzo.Foundation.Core")] 13 | //[assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f376ccca-325f-4533-934d-a9c4a7cfc69b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | //[assembly: AssemblyVersion("1.0.0.0")] 36 | //[assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Settings/BaseSettings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 9 | 10 | 11 | 0 12 | 13 | 14 | False 15 | 16 | 17 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Settings/SettingChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Digimezzo.Foundation.Core.Settings 4 | { 5 | public class SettingChangedEventArgs : EventArgs 6 | { 7 | public SettingEntry Entry { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Settings/SettingEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Settings 2 | { 3 | public class SettingEntry 4 | { 5 | public string Namespace { get; set; } 6 | public string Name { get; set; } 7 | public object Value { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/SharedAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyCompany("Digimezzo")] 4 | [assembly: AssemblyCopyright("Copyright Digimezzo © 2018")] 5 | [assembly: AssemblyVersion("1.0.0.0")] 6 | [assembly: AssemblyFileVersion("1.0.0.0")] 7 | [assembly: AssemblyInformationalVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/CryptographyUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace Digimezzo.Foundation.Core.Utils 4 | { 5 | public static class CryptographyUtils 6 | { 7 | /// 8 | /// Creates a MD5 hash for a given string 9 | /// 10 | /// The string to hash 11 | /// The MD5 hash of the given string 12 | public static string MD5Hash(string str) 13 | { 14 | string strHash = null; 15 | 16 | using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) 17 | { 18 | byte[] arrHash = md5.ComputeHash(Encoding.UTF8.GetBytes(str)); 19 | var sb = new StringBuilder(); 20 | for (int i = 0; i <= arrHash.Length - 1; i++) 21 | { 22 | sb.Append(arrHash[i].ToString("x2")); 23 | } 24 | 25 | strHash = sb.ToString(); 26 | } 27 | 28 | return strHash; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/DateTimeUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace Digimezzo.Foundation.Core.Utils 5 | { 6 | public static class DateTimeUtils 7 | { 8 | /// 9 | /// Converts a DateTime to Unix time 10 | /// 11 | /// The DateTime to convert to Unix time 12 | /// The Unix time for the given DateTime 13 | public static long ConvertToUnixTime(DateTime dateTime) 14 | { 15 | DateTime referenceTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 16 | return (long)(dateTime.ToUniversalTime() - referenceTime).TotalSeconds; 17 | } 18 | 19 | /// 20 | /// Validates a date, taking leap years into account. 21 | /// 22 | /// The year of the date to validate 23 | /// The month of the date to validate 24 | /// The day of the date to validate 25 | /// True if the date is valid 26 | public static bool IsValidDate(int year, int month, int day) 27 | { 28 | DateTime dateValue; 29 | 30 | if (DateTime.TryParseExact($"{year}-{month.ToString("D2")}-{day.ToString("D2")}", "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue)) 31 | { 32 | return true; 33 | } 34 | 35 | return false; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/EnvironmentUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Management; 5 | 6 | namespace Digimezzo.Foundation.Core.Utils 7 | { 8 | public static class EnvironmentUtils 9 | { 10 | /// 11 | /// Gets the "friendly" Windows version using WMI 12 | /// 13 | /// The "friendly" Windows version 14 | public static string GetFriendlyWindowsVersion() 15 | { 16 | object nameObject = null; 17 | string name = null; 18 | 19 | try 20 | { 21 | nameObject = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast() 22 | select x.GetPropertyValue("Caption")).FirstOrDefault(); 23 | 24 | name = nameObject != null ? nameObject.ToString() : "Unknown"; 25 | } 26 | catch (Exception) 27 | { 28 | name = "Unknown"; 29 | } 30 | 31 | return name; 32 | } 33 | 34 | /// 35 | /// Gets the internal Windows version using Environment.OSVersion 36 | /// 37 | /// the internal Windows version 38 | public static string GetInternalWindowsVersion() 39 | { 40 | return Environment.OSVersion.VersionString; 41 | } 42 | 43 | /// 44 | /// Gets if the Operating System is Windows 10 45 | /// 46 | /// True if Windows 10 47 | public static bool IsWindows10() 48 | { 49 | // IMPORTANT: Windows 8.1. and Windows 10 will ONLY admit their real version if your program's manifest 50 | // claims to be compatible. Otherwise they claim to be Windows 8. See the first comment on: 51 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833%28v=vs.85%29.aspx 52 | 53 | bool returnValue = false; 54 | 55 | // Get Operating system information 56 | OperatingSystem os = Environment.OSVersion; 57 | 58 | // Get the Operating system version information 59 | Version vi = os.Version; 60 | 61 | // Pre-NT versions of Windows are PlatformID.Win32Windows. We're not interested in those. 62 | 63 | if (os.Platform == PlatformID.Win32NT) 64 | { 65 | if (vi.Major == 10) 66 | { 67 | returnValue = true; 68 | } 69 | } 70 | 71 | return returnValue; 72 | } 73 | 74 | /// 75 | /// Uses the process name to determine if there is exactly 1 instance of that process running. 76 | /// 77 | /// The process name 78 | /// True if there is exactly 1 instance running 79 | public static bool IsSingleInstance(string processName) 80 | { 81 | Process[] pName = Process.GetProcessesByName(processName); 82 | 83 | if ((pName.Length > 1 | pName.Length == 0)) 84 | { 85 | return false; 86 | } 87 | else 88 | { 89 | return true; 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/ResourceUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Media; 3 | 4 | namespace Digimezzo.Foundation.Core.Utils 5 | { 6 | public static class ResourceUtils 7 | { 8 | /// 9 | /// Gets a string resource for the current application 10 | /// 11 | /// The resource's name 12 | /// The resources string content 13 | public static string GetString(string resourceName) 14 | { 15 | object resource = Application.Current.TryFindResource(resourceName); 16 | return resource == null ? resourceName : resource.ToString(); 17 | } 18 | 19 | /// 20 | /// Gets a Geometry resource for the current application 21 | /// 22 | /// The resource's name 23 | /// The resources Geometry content 24 | /// 25 | public static Geometry GetGeometry(string resourceName) 26 | { 27 | return (Geometry)Application.Current.TryFindResource(resourceName); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/StringUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Digimezzo.Foundation.Core.Utils 5 | { 6 | public static class StringUtils 7 | { 8 | /// 9 | /// Makes the first character of a string uppercase 10 | /// 11 | /// The input string 12 | /// The input string with the first character in uppercase 13 | public static string FirstCharToUpper(string input) 14 | { 15 | if (String.IsNullOrEmpty(input)) return input; 16 | return input.First().ToString().ToUpper() + input.Substring(1); 17 | } 18 | 19 | /// 20 | /// Splits strings on spaces, but preserves strings which are between double quotes. 21 | /// 22 | /// 23 | /// 24 | public static string[] SplitWords(string inputString) 25 | { 26 | return inputString.Split('"') 27 | .Select((element, index) => index % 2 == 0 // If even index 28 | ? element.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) // Split the item 29 | : new string[] { element }) // Keep the entire item 30 | .SelectMany(element => element).ToArray(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/ValidationUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace Digimezzo.Foundation.Core.Utils 4 | { 5 | public static class ValidationUtils 6 | { 7 | /// 8 | /// Validates a source URL 9 | /// 10 | /// The source URL 11 | /// True if the URL is valid 12 | public static bool IsUrl(string source) 13 | { 14 | 15 | bool retVal = false; 16 | 17 | // As found at http://www.dotnetfunda.com/codes/show/1519/regex-pattern-to-validate-url 18 | Match m = Regex.Match(source, @"^(file|http|https):/{2}[a-zA-Z./&\d_-]+", RegexOptions.IgnoreCase); 19 | 20 | if ((m.Success)) 21 | { 22 | retVal = true; 23 | } 24 | 25 | return retVal; 26 | } 27 | 28 | /// 29 | /// Validates a source e-mail address 30 | /// 31 | /// The source e-mail address 32 | /// True if the e-mail address is valid 33 | public static bool IsEmail(string source) 34 | { 35 | 36 | bool retVal = false; 37 | 38 | // As found at http://www.regular-expressions.info/email.html 39 | Match m = Regex.Match(source, @"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", RegexOptions.IgnoreCase); 40 | 41 | if ((m.Success)) 42 | { 43 | retVal = true; 44 | } 45 | 46 | return retVal; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Utils/VisualTreeUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace Digimezzo.Foundation.Core.Utils 6 | { 7 | public static class VisualTreeUtils 8 | { 9 | /// 10 | /// Finds the first ancestor of type T in the Visual Tree of a given DependencyObject 11 | /// 12 | /// The type of the ancestor to find in the Visual Tree 13 | /// The given DependencyObject 14 | /// 15 | public static T FindAncestor(DependencyObject current) where T : DependencyObject 16 | { 17 | do 18 | { 19 | if (current is T) 20 | { 21 | return (T)current; 22 | } 23 | 24 | current = VisualTreeHelper.GetParent(current); 25 | 26 | } while (current != null); 27 | 28 | return null; 29 | } 30 | 31 | /// 32 | /// Finds the first Visual ancestor of the given type in the Visual Tree of a given Visual 33 | /// 34 | /// The given Visual 35 | /// The type of the Visual to find in the Visual Tree 36 | /// 37 | public static Visual GetDescendantByType(Visual element, Type type) 38 | { 39 | if (element == null) 40 | { 41 | return null; 42 | } 43 | if (element.GetType() == type) 44 | { 45 | return element; 46 | } 47 | 48 | Visual foundElement = null; 49 | 50 | if (element is FrameworkElement) 51 | { 52 | (element as FrameworkElement).ApplyTemplate(); 53 | } 54 | 55 | for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(element) - 1; i++) 56 | { 57 | Visual visual = VisualTreeHelper.GetChild(element, i) as Visual; 58 | foundElement = GetDescendantByType(visual, type); 59 | 60 | if (foundElement != null) 61 | { 62 | break; 63 | } 64 | } 65 | 66 | return foundElement; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/ABE.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum ABE : uint 4 | { 5 | Left = 0, 6 | Top = 1, 7 | Right = 2, 8 | Bottom = 3 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/ABM.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum ABM : uint 4 | { 5 | New = 0x00000000, 6 | Remove = 0x00000001, 7 | QueryPos = 0x00000002, 8 | SetPos = 0x00000003, 9 | GetState = 0x00000004, 10 | GetTaskbarPos = 0x00000005, 11 | Activate = 0x00000006, 12 | GetAutoHideBar = 0x00000007, 13 | SetAutoHideBar = 0x00000008, 14 | WindowPosChanged = 0x00000009, 15 | SetState = 0x0000000A, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/ABS.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal static class ABS 4 | { 5 | public const int Autohide = 0x0000001; 6 | public const int AlwaysOnTop = 0x0000002; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/APPBARDATA.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Digimezzo.Foundation.Core.Win32 5 | { 6 | [StructLayout(LayoutKind.Sequential)] 7 | internal struct APPBARDATA 8 | { 9 | public uint cbSize; 10 | public IntPtr hWnd; 11 | public uint uCallbackMessage; 12 | public ABE uEdge; 13 | public RECT rc; 14 | public int lParam; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/AccentPolicy.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Digimezzo.Foundation.Core.Win32 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | internal struct AccentPolicy 7 | { 8 | public AccentState AccentState; 9 | public int AccentFlags; 10 | public int GradientColor; 11 | public int AnimationId; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/AccentState.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum AccentState 4 | { 5 | ACCENT_DISABLED = 0, 6 | ACCENT_ENABLE_GRADIENT = 1, 7 | ACCENT_ENABLE_TRANSPARENTGRADIENT = 2, 8 | ACCENT_ENABLE_BLURBEHIND = 3, 9 | ACCENT_INVALID_STATE = 4 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/FileOperationFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Digimezzo.Foundation.Core.Win32 4 | { 5 | /// 6 | /// Possible flags for the SHFileOperation method. 7 | /// 8 | [Flags] 9 | internal enum FileOperationFlags : ushort 10 | { 11 | /// 12 | /// Do not show a dialog during the process 13 | /// 14 | FOF_SILENT = 0x0004, 15 | /// 16 | /// Do not ask the user to confirm selection 17 | /// 18 | FOF_NOCONFIRMATION = 0x0010, 19 | /// 20 | /// Delete the file to the recycle bin. (Required flag to send a file to the bin 21 | /// 22 | FOF_ALLOWUNDO = 0x0040, 23 | /// 24 | /// Do not show the names of the files or folders that are being recycled. 25 | /// 26 | FOF_SIMPLEPROGRESS = 0x0100, 27 | /// 28 | /// Surpress errors, if any occur during the process. 29 | /// 30 | FOF_NOERRORUI = 0x0400, 31 | /// 32 | /// Warn if files are too big to fit in the recycle bin and will need 33 | /// to be deleted completely. 34 | /// 35 | FOF_WANTNUKEWARNING = 0x4000, 36 | } 37 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/FileOperationType.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | /// 4 | /// File Operation Function Type for SHFileOperation 5 | /// 6 | internal enum FileOperationType : uint 7 | { 8 | /// 9 | /// Move the objects 10 | /// 11 | FO_MOVE = 0x0001, 12 | /// 13 | /// Copy the objects 14 | /// 15 | FO_COPY = 0x0002, 16 | /// 17 | /// Delete (or recycle) the objects 18 | /// 19 | FO_DELETE = 0x0003, 20 | /// 21 | /// Rename the object(s) 22 | /// 23 | FO_RENAME = 0x0004, 24 | } 25 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/GWL.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum GWL : int 4 | { 5 | STYLE = -16, 6 | EXSTYLE = -20 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace Digimezzo.Foundation.Core.Win32 6 | { 7 | internal static class NativeMethods 8 | { 9 | [DllImport("user32.dll")] 10 | public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); 11 | 12 | [DllImport("user32.dll", SetLastError = true)] 13 | public static extern Int32 GetWindowLong(IntPtr hWnd, int nIndex); 14 | 15 | [DllImport("kernel32.dll", EntryPoint = "SetLastError")] 16 | public static extern void SetLastError(int dwErrorCode); 17 | 18 | [DllImport("user32.dll")] 19 | static internal extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); 20 | 21 | [DllImport("shell32.dll", SetLastError = true)] 22 | public static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData); 23 | 24 | [DllImport("user32.dll", SetLastError = true)] 25 | public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 26 | 27 | /// 28 | /// Due to a bug in User32.dll, calling SetWindowLongPtr fails on 32 bit systems. 29 | /// This exception occurs: Unable to find an entry point named 'SetWindowLongPtr' in DLL 'user32.dll' 30 | /// See: https://www.medo64.com/2013/07/setwindowlongptr/ 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLong")] 37 | [SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "return", Justification = "This declaration is not used on 64-bit Windows.")] 38 | [SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "2", Justification = "This declaration is not used on 64-bit Windows.")] 39 | public static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, Int32 nIndex, IntPtr dwNewLong); 40 | 41 | /// 42 | /// Due to a bug in User32.dll, calling SetWindowLongPtr fails on 32 bit systems. 43 | /// This exception occurs: Unable to find an entry point named 'SetWindowLongPtr' in DLL 'user32.dll' 44 | /// See: https://www.medo64.com/2013/07/setwindowlongptr/ 45 | /// 46 | /// 47 | /// 48 | /// 49 | /// 50 | [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLongPtr")] 51 | [SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist", Justification = "Entry point does exist on 64-bit Windows.")] 52 | public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, Int32 nIndex, IntPtr dwNewLong); 53 | 54 | public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong) 55 | { 56 | if (IntPtr.Size == 4) 57 | { 58 | return SetWindowLongPtr32(hWnd, nIndex, dwNewLong); 59 | } 60 | else 61 | { 62 | return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); 63 | } 64 | } 65 | 66 | [DllImport("shell32.dll", CharSet = CharSet.Auto)] 67 | public static extern int SHFileOperation(ref SHFILEOPSTRUCT FileOp); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/RECT.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Digimezzo.Foundation.Core.Win32 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | internal struct RECT 7 | { 8 | public int left; 9 | public int top; 10 | public int right; 11 | public int bottom; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/SHFILEOPSTRUCT.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Digimezzo.Foundation.Core.Win32 5 | { 6 | /// 7 | /// SHFILEOPSTRUCT for SHFileOperation from COM 8 | /// 9 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] 10 | internal struct SHFILEOPSTRUCT 11 | { 12 | public IntPtr hwnd; 13 | [MarshalAs(UnmanagedType.U4)] 14 | public FileOperationType wFunc; 15 | public string pFrom; 16 | public string pTo; 17 | public FileOperationFlags fFlags; 18 | [MarshalAs(UnmanagedType.Bool)] 19 | public bool fAnyOperationsAborted; 20 | public IntPtr hNameMappings; 21 | public string lpszProgressTitle; 22 | } 23 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/SHFileOperationReturnCode.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum SHFileOperationReturnCode : ulong 4 | { 5 | /// 6 | /// Operation completed successfully. 7 | /// 8 | SUCCESSFUL = 0L, 9 | 10 | /// 11 | /// The process cannot access the file because it is being used by another process. 12 | /// 13 | ERROR_SHARING_VIOLATION = 32L, 14 | 15 | /// 16 | /// MAX_PATH was exceeded during the operation. 17 | /// 18 | DE_ERROR_MAX = 0xB7, 19 | 20 | /// 21 | /// An unspecified error occurred on the destination. 22 | /// 23 | ERRORONDEST = 0x10000 24 | } 25 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/WS.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 Digimezzo.Foundation.Core.Win32 8 | { 9 | internal enum WS : int 10 | { 11 | SYSMENU = 0x80000 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/WSEX.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum WSEX : int 4 | { 5 | TOOLWINDOW = 0x00000080 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/WindowCompositionAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.Core.Win32 2 | { 3 | internal enum WindowCompositionAttribute 4 | { 5 | WCA_ACCENT_POLICY = 19 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.Core/Win32/WindowCompositionAttributeData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Digimezzo.Foundation.Core.Win32 5 | { 6 | [StructLayout(LayoutKind.Sequential)] 7 | internal struct WindowCompositionAttributeData 8 | { 9 | public WindowCompositionAttribute Attribute; 10 | public IntPtr Data; 11 | public int SizeOfData; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace Digimezzo.Foundation.WPF.Demo 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/Digimezzo.Foundation.WPF.Demo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1FA66114-32D5-475F-86F9-9C90236F1232} 8 | WinExe 9 | Digimezzo.Foundation.WPF.Demo 10 | Digimezzo.Foundation.WPF.Demo 11 | v4.7.2 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 4.0 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | MSBuild:Compile 56 | Designer 57 | 58 | 59 | MSBuild:Compile 60 | Designer 61 | 62 | 63 | SharedAssemblyInfo.cs 64 | 65 | 66 | App.xaml 67 | Code 68 | 69 | 70 | MainWindow.xaml 71 | Code 72 | 73 | 74 | 75 | 76 | Code 77 | 78 | 79 | True 80 | True 81 | Resources.resx 82 | 83 | 84 | True 85 | Settings.settings 86 | True 87 | 88 | 89 | ResXFileCodeGenerator 90 | Resources.Designer.cs 91 | 92 | 93 | SettingsSingleFileGenerator 94 | Settings.Designer.cs 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | {f376ccca-325f-4533-934d-a9c4a7cfc69b} 103 | Digimezzo.Foundation.Core 104 | 105 | 106 | {db02d05f-5fd8-4d14-b446-354de8b4791e} 107 | Digimezzo.Foundation.WPF 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Controls; 2 | 3 | namespace Digimezzo.Foundation.WPF.Demo 4 | { 5 | public partial class MainWindow : Windows10BorderlessWindow 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void HamburgerButton_Click(object sender, System.Windows.RoutedEventArgs e) 13 | { 14 | this.MySplitView.IsPaneOpen = !this.MySplitView.IsPaneOpen; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("Digimezzo.Foundation.WPF.Demo")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | //[assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Digimezzo.Foundation.WPF.Demo")] 15 | //[assembly: AssemblyCopyright("Copyright © 2018")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | //[assembly: AssemblyVersion("1.0.0.0")] 55 | //[assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/Properties/Resources.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 Digimezzo.Foundation.WPF.Demo.Properties { 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 Resources { 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 Resources() { 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("Digimezzo.Foundation.WPF.Demo.Properties.Resources", typeof(Resources).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 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/Properties/Settings.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 Digimezzo.Foundation.WPF.Demo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF.Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Base/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Base 5 | { 6 | internal static class Constants 7 | { 8 | //Common 9 | public static readonly Duration MouseEnterDuration = new Duration(TimeSpan.FromMilliseconds(250)); 10 | public static readonly Duration MouseLeaveDuration = MouseEnterDuration; 11 | 12 | //ToggleSwitch 13 | public static readonly Duration ToggleSwitchDuration = MouseEnterDuration; 14 | 15 | //VirtualizingWrapPanel 16 | public static readonly Duration SmoothScrollingDuration = MouseEnterDuration; 17 | 18 | // UWPSlider 19 | public const int UWPSliderBaseUnit = 8; 20 | public const int UWPSliderCanvasLengthOffset = -2 * UWPSliderBaseUnit; 21 | public const double UWPSliderButtonSize = 2 * UWPSliderBaseUnit; 22 | public static readonly Thickness HorizontalUWPSliderMargin = new Thickness(-UWPSliderBaseUnit, 0, 0, 0); 23 | public static readonly Thickness VerticalUWPSliderMargin = new Thickness(0, 0, 0, -UWPSliderBaseUnit); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Base/FontIconBase.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Digimezzo.Foundation.WPF.Base 5 | { 6 | public class FontIconBase : Control 7 | { 8 | public string Text 9 | { 10 | get { return (string)GetValue(TextProperty); } 11 | set { SetValue(TextProperty, value); } 12 | } 13 | 14 | public static readonly DependencyProperty TextProperty = 15 | DependencyProperty.Register(nameof(Text), typeof(string), typeof(FontIconBase), new PropertyMetadata(null)); 16 | 17 | static FontIconBase() 18 | { 19 | DefaultStyleKeyProperty.OverrideMetadata(typeof(FontIconBase), new FrameworkPropertyMetadata(typeof(FontIconBase))); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Base/MaterialButtonBase.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Media; 4 | 5 | namespace Digimezzo.Foundation.WPF.Base 6 | { 7 | public class MaterialButtonBase : Button 8 | { 9 | public Brush Accent 10 | { 11 | get { return (Brush)GetValue(AccentProperty); } 12 | set { SetValue(AccentProperty, value); } 13 | } 14 | 15 | public static readonly DependencyProperty AccentProperty = 16 | DependencyProperty.Register(nameof(Accent), typeof(Brush), typeof(MaterialButtonBase), new PropertyMetadata(Brushes.Red)); 17 | 18 | static MaterialButtonBase() 19 | { 20 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialButtonBase), new FrameworkPropertyMetadata(typeof(MaterialButtonBase))); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Base/PropertyChangedBase.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace Digimezzo.Foundation.WPF.Base 4 | { 5 | public class PropertyChangedBase : INotifyPropertyChanged 6 | { 7 | public event PropertyChangedEventHandler PropertyChanged; 8 | 9 | protected virtual void OnPropertyChanged(string propertyName) 10 | { 11 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/FontIcons.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class AwesomeIcon : FontIconBase 7 | { 8 | static AwesomeIcon() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(AwesomeIcon), new FrameworkPropertyMetadata(typeof(AwesomeIcon))); 11 | } 12 | } 13 | 14 | public class SegoeIcon : FontIconBase 15 | { 16 | static SegoeIcon() 17 | { 18 | DefaultStyleKeyProperty.OverrideMetadata(typeof(SegoeIcon), new FrameworkPropertyMetadata(typeof(SegoeIcon))); 19 | } 20 | } 21 | 22 | public class MaterialIcon : FontIconBase 23 | { 24 | static MaterialIcon() 25 | { 26 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialIcon), new FrameworkPropertyMetadata(typeof(MaterialIcon))); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/LabelToLower.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class LabelToLower : Label 7 | { 8 | static LabelToLower() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(LabelToLower), new FrameworkPropertyMetadata(typeof(LabelToLower))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/LabelToUpper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class LabelToUpper : Label 7 | { 8 | static LabelToUpper() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(LabelToUpper), new FrameworkPropertyMetadata(typeof(LabelToUpper))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MaterialCircularProgressBar.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Media; 4 | 5 | namespace Digimezzo.Foundation.WPF.Controls 6 | { 7 | public class MaterialCircularProgressBar : ProgressBar 8 | { 9 | public Brush Accent 10 | { 11 | get { return (Brush)GetValue(AccentProperty); } 12 | set { SetValue(AccentProperty, value); } 13 | } 14 | 15 | public static readonly DependencyProperty AccentProperty = 16 | DependencyProperty.Register(nameof(Accent), typeof(Brush), typeof(MaterialCircularProgressBar), new PropertyMetadata(Brushes.Red)); 17 | 18 | public double StrokeThickness 19 | { 20 | get { return (double)GetValue(StrokeThicknessProperty); } 21 | set { SetValue(StrokeThicknessProperty, value); } 22 | } 23 | 24 | public static readonly DependencyProperty StrokeThicknessProperty = 25 | DependencyProperty.Register(nameof(StrokeThickness), typeof(double), typeof(MaterialCircularProgressBar), new PropertyMetadata(3.0)); 26 | 27 | 28 | 29 | static MaterialCircularProgressBar() 30 | { 31 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialCircularProgressBar), new FrameworkPropertyMetadata(typeof(MaterialCircularProgressBar))); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MaterialFlatButton.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class MaterialFlatButton : MaterialButtonBase 7 | { 8 | static MaterialFlatButton() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialFlatButton), new FrameworkPropertyMetadata(typeof(MaterialFlatButton))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MaterialFloatingActionButton.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class MaterialFloatingActionButton : MaterialButtonBase 7 | { 8 | static MaterialFloatingActionButton() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialFloatingActionButton), new FrameworkPropertyMetadata(typeof(MaterialFloatingActionButton))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MaterialMiniFloatingActionButton.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class MaterialMiniFloatingActionButton : MaterialButtonBase 7 | { 8 | static MaterialMiniFloatingActionButton() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialMiniFloatingActionButton), new FrameworkPropertyMetadata(typeof(MaterialMiniFloatingActionButton))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MaterialRaisedButton.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class MaterialRaisedButton : MaterialButtonBase 7 | { 8 | static MaterialRaisedButton() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialRaisedButton), new FrameworkPropertyMetadata(typeof(MaterialRaisedButton))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MaterialToggleSwitch.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Input; 4 | using System.Windows.Media; 5 | 6 | namespace Digimezzo.Foundation.WPF.Controls 7 | { 8 | public class MaterialToggleSwitch : CheckBox 9 | { 10 | private Ripple ripple; 11 | 12 | public Brush Accent 13 | { 14 | get { return (Brush)GetValue(AccentProperty); } 15 | set { SetValue(AccentProperty, value); } 16 | } 17 | 18 | public static readonly DependencyProperty AccentProperty = 19 | DependencyProperty.Register(nameof(Accent), typeof(Brush), typeof(MaterialToggleSwitch), new PropertyMetadata(new SolidColorBrush(Colors.Blue))); 20 | 21 | static MaterialToggleSwitch() 22 | { 23 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialToggleSwitch), new FrameworkPropertyMetadata(typeof(MaterialToggleSwitch))); 24 | } 25 | 26 | public override void OnApplyTemplate() 27 | { 28 | base.OnApplyTemplate(); 29 | 30 | this.ripple = (Ripple)GetTemplateChild("PART_Ripple"); 31 | 32 | if(this.Background == null) 33 | { 34 | this.Background = new SolidColorBrush(Colors.Black); 35 | } 36 | } 37 | 38 | protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) 39 | { 40 | base.OnPreviewMouseLeftButtonDown(e); 41 | this.ripple.DoRippple(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/MultiSelectListBox.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Input; 4 | 5 | namespace Digimezzo.Foundation.WPF.Controls 6 | { 7 | /// 8 | /// The default WPF ListBox deselects items on MouseDown instead of MouseUp, which causes deselection 9 | /// of selected items when starting a Drag operation. This ListBox enables Windows Explorer like drag/drop 10 | /// behaviour by deferring deselection to MouseUp. This code is based on code from David Schmitt in this 11 | /// stackoverflow article http://stackoverflow.com/questions/1553622/wpf-drag-drop-from-listbox-with-selectionmode-multiple 12 | /// 13 | /// 14 | public class MultiSelectListBox : ListBox 15 | { 16 | protected override DependencyObject GetContainerForItemOverride() 17 | { 18 | return new MultiSelectListBoxItem(); 19 | } 20 | 21 | public class MultiSelectListBoxItem : ListBoxItem 22 | { 23 | private bool deferSelection = false; 24 | 25 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) 26 | { 27 | 28 | if ((e.ClickCount == 1 && IsSelected)) 29 | { 30 | // The user may start a drag by clicking on the selected items 31 | // Delay destroying the selection to the Up event 32 | this.deferSelection = true; 33 | } 34 | else 35 | { 36 | base.OnMouseLeftButtonDown(e); 37 | } 38 | } 39 | 40 | protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) 41 | { 42 | if (this.deferSelection) 43 | { 44 | try 45 | { 46 | base.OnMouseLeftButtonDown(e); 47 | } 48 | finally 49 | { 50 | this.deferSelection = false; 51 | } 52 | 53 | base.OnMouseLeftButtonUp(e); 54 | } 55 | } 56 | 57 | protected override void OnMouseLeave(MouseEventArgs e) 58 | { 59 | // Abort deferred Down 60 | this.deferSelection = false; 61 | base.OnMouseLeave(e); 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/UWPSliderHorizontal.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System; 3 | using System.Windows; 4 | using System.Windows.Media; 5 | 6 | namespace Digimezzo.Foundation.WPF.Controls 7 | { 8 | public class UWPSliderHorizontal : Windows8SliderHorizontal 9 | { 10 | public double BarFillPosition 11 | { 12 | get { return Convert.ToDouble(BarFillPositionProperty); } 13 | set { SetValue(BarFillPositionProperty, value); } 14 | } 15 | 16 | public static readonly DependencyProperty BarFillPositionProperty = 17 | DependencyProperty.Register(nameof(BarFillPosition), typeof(double), typeof(UWPSliderHorizontal), new PropertyMetadata(0.0)); 18 | 19 | public Brush ButtonInnerBackground 20 | { 21 | get { return (Brush)GetValue(ButtonInnerBackgroundProperty); } 22 | set { SetValue(ButtonInnerBackgroundProperty, value); } 23 | } 24 | 25 | public static readonly DependencyProperty ButtonInnerBackgroundProperty = 26 | DependencyProperty.Register(nameof(ButtonInnerBackground), typeof(Brush), typeof(UWPSliderHorizontal), new PropertyMetadata(null)); 27 | 28 | static UWPSliderHorizontal() 29 | { 30 | DefaultStyleKeyProperty.OverrideMetadata(typeof(UWPSliderHorizontal), new FrameworkPropertyMetadata(typeof(UWPSliderHorizontal))); 31 | } 32 | 33 | protected override void UpdatePosition() 34 | { 35 | base.UpdatePosition(); 36 | this.CalculateVisibleLengths(); 37 | } 38 | 39 | protected override void CalculatePosition() 40 | { 41 | base.CalculatePosition(); 42 | this.CalculateVisibleLengths(); 43 | } 44 | 45 | protected virtual void CalculateVisibleLengths() 46 | { 47 | if (this.sliderCanvas != null && this.sliderCanvas.ActualWidth != 0 && this.sliderButton != null) 48 | { 49 | this.BarFillPosition = this.Position * (this.sliderCanvas.ActualWidth - Constants.UWPSliderCanvasLengthOffset) / 50 | this.sliderCanvas.ActualWidth; 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/UWPSliderHorizontalBottom.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System; 3 | using System.Windows; 4 | using System.Windows.Media; 5 | 6 | 7 | namespace Digimezzo.Foundation.WPF.Controls 8 | { 9 | public class UWPSliderHorizontalBottom : UWPSliderHorizontal 10 | { 11 | private static readonly CornerRadius rightCornerRadius = new CornerRadius(Constants.UWPSliderBaseUnit, Constants.UWPSliderBaseUnit, 0, Constants.UWPSliderBaseUnit); 12 | private static readonly CornerRadius leftCornerRadius = new CornerRadius(Constants.UWPSliderBaseUnit, Constants.UWPSliderBaseUnit, Constants.UWPSliderBaseUnit, 0); 13 | private static readonly Thickness rightButtonMargin = new Thickness(-24, 0, 0, 0); 14 | private static readonly Thickness leftButtonMargin = new Thickness(-8, 0, 0, 0); 15 | private static readonly double leftButtonBorderLeft = 20; 16 | private static readonly double rightButtonBorderLeft = 4; 17 | private CornerRadius SliderButtonCornerRadius 18 | { 19 | get { return (CornerRadius)GetValue(SliderButtonCornerRadiusProperty); } 20 | set { SetValue(SliderButtonCornerRadiusProperty, value); } 21 | } 22 | 23 | private static readonly DependencyProperty SliderButtonCornerRadiusProperty = 24 | DependencyProperty.Register(nameof(SliderButtonCornerRadius), typeof(CornerRadius), typeof(UWPSliderHorizontalBottom), new PropertyMetadata(null)); 25 | 26 | private Thickness SliderButtonMargin 27 | { 28 | get { return (Thickness)GetValue(SliderButtonMarginProperty); } 29 | set { SetValue(SliderButtonMarginProperty, value); } 30 | } 31 | 32 | private static readonly DependencyProperty SliderButtonMarginProperty = 33 | DependencyProperty.Register(nameof(SliderButtonMargin), typeof(Thickness), typeof(UWPSliderHorizontalBottom), new PropertyMetadata(null)); 34 | 35 | private double SliderButtonBorderLeft 36 | { 37 | get { return (double)GetValue(SliderButtonBorderLeftProperty); } 38 | set { SetValue(SliderButtonBorderLeftProperty, value); } 39 | } 40 | 41 | private static readonly DependencyProperty SliderButtonBorderLeftProperty = 42 | DependencyProperty.Register(nameof(SliderButtonBorderLeft), typeof(double), typeof(UWPSliderHorizontalBottom), new PropertyMetadata(null)); 43 | 44 | static UWPSliderHorizontalBottom() 45 | { 46 | DefaultStyleKeyProperty.OverrideMetadata(typeof(UWPSliderHorizontalBottom), new FrameworkPropertyMetadata(typeof(UWPSliderHorizontalBottom))); 47 | } 48 | 49 | protected override void CalculateVisibleLengths() 50 | { 51 | if (this.sliderCanvas == null) return; 52 | 53 | if (this.Position > this.sliderCanvas.ActualWidth / 2) 54 | { 55 | this.SliderButtonCornerRadius = rightCornerRadius; 56 | this.SliderButtonMargin = rightButtonMargin; 57 | this.SliderButtonBorderLeft = rightButtonBorderLeft; 58 | this.BarFillPosition = this.Position; 59 | } 60 | else 61 | { 62 | this.SliderButtonCornerRadius = leftCornerRadius; 63 | this.SliderButtonMargin = leftButtonMargin; 64 | this.SliderButtonBorderLeft = leftButtonBorderLeft; 65 | this.BarFillPosition = this.Position; 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/UWPSliderVertical.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System; 3 | using System.Windows; 4 | using System.Windows.Media; 5 | 6 | namespace Digimezzo.Foundation.WPF.Controls 7 | { 8 | public class UWPSliderVertical : Windows8SliderVertical 9 | { 10 | public double BarFillPosition 11 | { 12 | get { return Convert.ToDouble(BarFillPositionProperty); } 13 | set { SetValue(BarFillPositionProperty, value); } 14 | } 15 | public Brush ButtonInnerBackground 16 | { 17 | get { return (Brush)GetValue(ButtonInnerBackgroundProperty); } 18 | set { SetValue(ButtonInnerBackgroundProperty, value); } 19 | } 20 | 21 | public static readonly DependencyProperty BarFillPositionProperty = DependencyProperty.Register("BarFillPosition", typeof(double), typeof(UWPSliderVertical), new PropertyMetadata(0.0)); 22 | public static readonly DependencyProperty ButtonInnerBackgroundProperty = DependencyProperty.Register("ButtonInnerBackground", typeof(Brush), typeof(UWPSliderVertical), new PropertyMetadata(null)); 23 | 24 | static UWPSliderVertical() 25 | { 26 | DefaultStyleKeyProperty.OverrideMetadata(typeof(UWPSliderVertical), new FrameworkPropertyMetadata(typeof(UWPSliderVertical))); 27 | } 28 | 29 | protected override void UpdatePosition() 30 | { 31 | base.UpdatePosition(); 32 | this.CalculateVisibleLengths(); 33 | } 34 | 35 | protected override void CalculatePosition() 36 | { 37 | base.CalculatePosition(); 38 | this.CalculateVisibleLengths(); 39 | } 40 | 41 | private void CalculateVisibleLengths() 42 | { 43 | if (this.sliderCanvas != null && this.sliderCanvas.ActualWidth != 0 && this.sliderButton != null) 44 | { 45 | this.BarFillPosition = this.Position * (this.sliderCanvas.ActualHeight - Constants.UWPSliderCanvasLengthOffset) / 46 | this.sliderCanvas.ActualHeight; 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows10BorderlessWindow.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace Digimezzo.Foundation.WPF.Controls 6 | { 7 | public class Windows10BorderlessWindow : BorderlessWindowBase 8 | { 9 | public bool ApplyDefaultButtonColors 10 | { 11 | get { return (bool)GetValue(ApplyDefaultButtonColorsProperty); } 12 | set { SetValue(ApplyDefaultButtonColorsProperty, value); } 13 | } 14 | 15 | public static readonly DependencyProperty ApplyDefaultButtonColorsProperty = 16 | DependencyProperty.Register(nameof(ApplyDefaultButtonColors), typeof(bool), typeof(BorderlessWindowBase), new PropertyMetadata(true)); 17 | 18 | static Windows10BorderlessWindow() 19 | { 20 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows10BorderlessWindow), new FrameworkPropertyMetadata(typeof(Windows10BorderlessWindow))); 21 | } 22 | 23 | public override void OnApplyTemplate() 24 | { 25 | base.OnApplyTemplate(); 26 | 27 | if (this.ApplyDefaultButtonColors) 28 | { 29 | this.TitleBarHeight = 29; 30 | this.MinMaxBackground = Brushes.Transparent; 31 | this.MinMaxHoveredBackground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E5E5E5")); 32 | this.MinMaxPressedBackground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#CACACB")); 33 | this.MinMaxForeground = Brushes.Black; 34 | this.MinMaxHoveredForeground = Brushes.Black; 35 | this.MinMaxPressedForeground = Brushes.Black; 36 | this.CloseBackground = Brushes.Transparent; 37 | this.CloseHoveredBackground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E81123")); 38 | this.ClosePressedBackground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#F1707A")); 39 | this.CloseForeground = Brushes.Black; 40 | this.CloseHoveredForeground = Brushes.White; 41 | this.ClosePressedForeground = Brushes.White; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows10SliderHorizontal.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Digimezzo.Foundation.WPF.Controls 4 | { 5 | public class Windows10SliderHorizontal : Windows8SliderHorizontal 6 | { 7 | static Windows10SliderHorizontal() 8 | { 9 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows10SliderHorizontal), new FrameworkPropertyMetadata(typeof(Windows10SliderHorizontal))); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows10SliderVertical.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Digimezzo.Foundation.WPF.Controls 4 | { 5 | public class Windows10SliderVertical : Windows8SliderVertical 6 | { 7 | static Windows10SliderVertical() 8 | { 9 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows10SliderVertical), new FrameworkPropertyMetadata(typeof(Windows10SliderVertical))); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows10ToggleSwitch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Media; 5 | 6 | namespace Digimezzo.Foundation.WPF.Controls 7 | { 8 | public class Windows10ToggleSwitch : CheckBox 9 | { 10 | public Brush Accent 11 | { 12 | get { return (Brush)GetValue(AccentProperty); } 13 | set { SetValue(AccentProperty, value); } 14 | } 15 | 16 | public static readonly DependencyProperty AccentProperty = 17 | DependencyProperty.Register(nameof(Accent), typeof(Brush), typeof(Windows10ToggleSwitch), new PropertyMetadata(new SolidColorBrush(Colors.Blue))); 18 | 19 | public string OnLabel 20 | { 21 | get { return Convert.ToString(GetValue(OnLabelProperty)); } 22 | set { SetValue(OnLabelProperty, value); } 23 | } 24 | 25 | public static readonly DependencyProperty OnLabelProperty = 26 | DependencyProperty.Register(nameof(OnLabel), typeof(string), typeof(Windows10ToggleSwitch), new PropertyMetadata("On")); 27 | 28 | public string OffLabel 29 | { 30 | get { return Convert.ToString(GetValue(OffLabelProperty)); } 31 | set { SetValue(OffLabelProperty, value); } 32 | } 33 | 34 | public static readonly DependencyProperty OffLabelProperty = 35 | DependencyProperty.Register(nameof(OffLabel), typeof(string), typeof(Windows10ToggleSwitch), new PropertyMetadata("Off")); 36 | 37 | static Windows10ToggleSwitch() 38 | { 39 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows10ToggleSwitch), new FrameworkPropertyMetadata(typeof(Windows10ToggleSwitch))); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows8BorderlessWindow.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | 4 | namespace Digimezzo.Foundation.WPF.Controls 5 | { 6 | public class BorderlessWindows8Window : BorderlessWindowBase 7 | { 8 | static BorderlessWindows8Window() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(BorderlessWindows8Window), new FrameworkPropertyMetadata(typeof(BorderlessWindows8Window))); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows8SliderHorizontal.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | 5 | namespace Digimezzo.Foundation.WPF.Controls 6 | { 7 | public class Windows8SliderHorizontal : SliderBase 8 | { 9 | static Windows8SliderHorizontal() 10 | { 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows8SliderHorizontal), new FrameworkPropertyMetadata(typeof(Windows8SliderHorizontal))); 12 | } 13 | 14 | protected override void UpdatePosition() 15 | { 16 | if (this.sliderCanvas == null) return; 17 | 18 | this.Position = Mouse.GetPosition(this.sliderCanvas).X; 19 | 20 | if (this.Position > this.sliderCanvas.ActualWidth) 21 | { 22 | this.Position = this.sliderCanvas.ActualWidth; 23 | } 24 | 25 | if (this.Position < 0.0) 26 | { 27 | this.Position = 0.0; 28 | } 29 | } 30 | 31 | protected override void CalculatePosition() 32 | { 33 | if (this.sliderCanvas == null) return; 34 | 35 | if (!this.isCalculating) 36 | { 37 | this.isCalculating = true; 38 | 39 | if ((this.Maximum - this.Minimum) > 0 && this.sliderCanvas.ActualWidth > 0) 40 | { 41 | this.Position = ((this.Value -this.Minimum) / (this.Maximum - this.Minimum)) * this.sliderCanvas.ActualWidth; 42 | } 43 | else 44 | { 45 | this.Position = 0; 46 | } 47 | 48 | this.isCalculating = false; 49 | } 50 | } 51 | 52 | protected override void CalculateValue() 53 | { 54 | if (this.sliderCanvas == null) return; 55 | 56 | if (!this.isCalculating) 57 | { 58 | this.isCalculating = true; 59 | 60 | if ( this.sliderCanvas.ActualWidth > 0) 61 | { 62 | this.Value = ((this.Position * (this.Maximum - this.Minimum)) / this.sliderCanvas.ActualWidth) + this.Minimum; 63 | } 64 | else 65 | { 66 | this.Value = 0; 67 | } 68 | 69 | this.isCalculating = false; 70 | } 71 | 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows8SliderVertical.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Base; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | 5 | namespace Digimezzo.Foundation.WPF.Controls 6 | { 7 | public class Windows8SliderVertical : SliderBase 8 | { 9 | 10 | static Windows8SliderVertical() 11 | { 12 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows8SliderVertical), new FrameworkPropertyMetadata(typeof(Windows8SliderVertical))); 13 | } 14 | 15 | protected override void UpdatePosition() 16 | { 17 | if (this.sliderCanvas == null) return; 18 | 19 | this.Position = this.sliderCanvas.ActualHeight - Mouse.GetPosition(this.sliderCanvas).Y; 20 | 21 | if (this.Position > this.sliderCanvas.ActualHeight) 22 | { 23 | this.Position = this.sliderCanvas.ActualHeight; 24 | } 25 | 26 | if (this.Position < 0.0) 27 | { 28 | this.Position = 0.0; 29 | } 30 | 31 | } 32 | 33 | protected override void CalculatePosition() 34 | { 35 | if (this.sliderCanvas == null) return; 36 | 37 | if (!this.isCalculating) 38 | { 39 | this.isCalculating = true; 40 | 41 | if ((this.Maximum - this.Minimum) > 0 && this.sliderCanvas.ActualHeight > 0) 42 | { 43 | this.Position = ((this.Value - this.Minimum) / (this.Maximum - this.Minimum)) * this.sliderCanvas.ActualHeight; 44 | } 45 | else 46 | { 47 | this.Position = 0; 48 | } 49 | 50 | this.isCalculating = false; 51 | } 52 | } 53 | 54 | protected override void CalculateValue() 55 | { 56 | if (this.sliderCanvas == null) return; 57 | 58 | if (!this.isCalculating) 59 | { 60 | this.isCalculating = true; 61 | 62 | if (this.sliderCanvas.ActualHeight > 0) 63 | { 64 | this.Value = ((this.Position * (this.Maximum - this.Minimum)) / this.sliderCanvas.ActualHeight) + this.Minimum; 65 | } 66 | else 67 | { 68 | this.Value = 0; 69 | } 70 | 71 | this.isCalculating = false; 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Controls/Windows8ToggleSwitch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Input; 5 | using System.Windows.Media; 6 | 7 | namespace Digimezzo.Foundation.WPF.Controls 8 | { 9 | public class Windows8ToggleSwitch : CheckBox 10 | { 11 | private Label onLabel; 12 | private Label offLabel; 13 | 14 | public Brush SwitchBackground 15 | { 16 | get { return (Brush)GetValue(SwitchBackgroundProperty); } 17 | set { SetValue(SwitchBackgroundProperty, value); } 18 | } 19 | 20 | public static readonly DependencyProperty SwitchBackgroundProperty = 21 | DependencyProperty.Register(nameof(SwitchBackground), typeof(Brush), typeof(Windows8ToggleSwitch), new PropertyMetadata(new SolidColorBrush(Colors.Blue))); 22 | 23 | public Brush ThumbBackground 24 | { 25 | get { return (Brush)GetValue(ThumbBackgroundProperty); } 26 | set { SetValue(ThumbBackgroundProperty, value); } 27 | } 28 | 29 | public static readonly DependencyProperty ThumbBackgroundProperty = 30 | DependencyProperty.Register(nameof(ThumbBackground), typeof(Brush), typeof(Windows8ToggleSwitch), new PropertyMetadata(new SolidColorBrush(Colors.Black))); 31 | 32 | public string OnLabel 33 | { 34 | get { return Convert.ToString(GetValue(OnLabelProperty)); } 35 | set { SetValue(OnLabelProperty, value); } 36 | } 37 | 38 | public static readonly DependencyProperty OnLabelProperty = 39 | DependencyProperty.Register(nameof(OnLabel), typeof(string), typeof(Windows8ToggleSwitch), new PropertyMetadata("On")); 40 | 41 | public string OffLabel 42 | { 43 | get { return Convert.ToString(GetValue(OffLabelProperty)); } 44 | set { SetValue(OffLabelProperty, value); } 45 | } 46 | 47 | public static readonly DependencyProperty OffLabelProperty = 48 | DependencyProperty.Register(nameof(OffLabel), typeof(string), typeof(Windows8ToggleSwitch), new PropertyMetadata("Off")); 49 | 50 | static Windows8ToggleSwitch() 51 | { 52 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Windows8ToggleSwitch), new FrameworkPropertyMetadata(typeof(Windows8ToggleSwitch))); 53 | } 54 | 55 | public override void OnApplyTemplate() 56 | { 57 | base.OnApplyTemplate(); 58 | 59 | this.onLabel = (Label)GetTemplateChild("PART_OnLabel"); 60 | this.offLabel = (Label)GetTemplateChild("PART_OffLabel"); 61 | 62 | if (this.onLabel != null) 63 | { 64 | this.onLabel.MouseDown += ToggleSwitch_MouseDown; 65 | } 66 | 67 | if (this.offLabel != null) 68 | { 69 | this.offLabel.MouseDown += ToggleSwitch_MouseDown; 70 | } 71 | } 72 | 73 | private void ToggleSwitch_MouseDown(object sender, MouseButtonEventArgs e) 74 | { 75 | e.Handled = true; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/AddValueConverter.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Extensions; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class AddValueConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | 13 | if (value == null || parameter == null || !parameter.ToString().IsNumeric()) 14 | { 15 | return Binding.DoNothing; 16 | } 17 | 18 | return double.Parse(value.ToString()) + double.Parse(parameter.ToString()); 19 | } 20 | 21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 22 | { 23 | return Binding.DoNothing; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/BooleanToCollapsedConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class BooleanToCollapsedConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | 13 | bool vis = System.Convert.ToBoolean(value); 14 | return vis ? Visibility.Visible : Visibility.Collapsed; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | Visibility vis = (Visibility)value; 20 | return (vis == Visibility.Visible); 21 | } 22 | } 23 | 24 | public class InvertingBooleanToCollapsedConverter : IValueConverter 25 | { 26 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | 29 | bool vis = System.Convert.ToBoolean(value); 30 | return vis ? Visibility.Collapsed : Visibility.Visible; 31 | } 32 | 33 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 34 | { 35 | Visibility vis = (Visibility)value; 36 | return (vis == Visibility.Collapsed); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/BooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class BooleanToVisibilityConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | 13 | bool vis = System.Convert.ToBoolean(value); 14 | return vis ? Visibility.Visible : Visibility.Hidden; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | Visibility vis = (Visibility)value; 20 | return (vis == Visibility.Visible); 21 | } 22 | } 23 | 24 | public class InvertingBooleanToVisibilityConverter : IValueConverter 25 | { 26 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | 29 | bool vis = System.Convert.ToBoolean(value); 30 | return vis ? Visibility.Hidden : Visibility.Visible; 31 | } 32 | 33 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 34 | { 35 | Visibility vis = (Visibility)value; 36 | return (vis == Visibility.Hidden); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/EnumConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class EnumConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | int returnValue = 0; 13 | 14 | if (parameter is Type) 15 | { 16 | returnValue = (int)Enum.Parse((Type)parameter, value.ToString()); 17 | } 18 | 19 | return returnValue; 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | Enum enumValue = default(Enum); 25 | if (parameter is Type) 26 | { 27 | enumValue = (Enum)Enum.Parse((Type)parameter, value.ToString()); 28 | } 29 | return enumValue; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/InvertingBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters 6 | { 7 | public class InvertingBooleanConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (targetType != typeof(bool)) 12 | { 13 | throw new InvalidOperationException("The target must be a boolean"); 14 | } 15 | 16 | return !bool.Parse(value.ToString()); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotSupportedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/ArcEndPointConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 7 | { 8 | /// 9 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 10 | /// Their license is included in the "Licenses" folder. 11 | /// 12 | public class ArcEndPointConverter : IMultiValueConverter 13 | { 14 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | var actualWidth = values[0].ExtractDouble(); 17 | var value = values[1].ExtractDouble(); 18 | var minimum = values[2].ExtractDouble(); 19 | var maximum = values[3].ExtractDouble(); 20 | 21 | if (new[] { actualWidth, value, minimum, maximum }.AnyNan()) 22 | return Binding.DoNothing; 23 | 24 | if (values.Length == 5) 25 | { 26 | var fullIndeterminateScaling = values[4].ExtractDouble(); 27 | if (!double.IsNaN(fullIndeterminateScaling) && fullIndeterminateScaling > 0.0) 28 | { 29 | value = (maximum - minimum) * fullIndeterminateScaling; 30 | } 31 | } 32 | 33 | var percent = maximum <= minimum ? 1.0 : (value - minimum) / (maximum - minimum); 34 | var degrees = 360 * percent; 35 | var radians = degrees * (Math.PI / 180); 36 | 37 | var centre = new Point(actualWidth / 2, actualWidth / 2); 38 | var hypotenuseRadius = (actualWidth / 2); 39 | 40 | var adjacent = Math.Cos(radians) * hypotenuseRadius; 41 | var opposite = Math.Sin(radians) * hypotenuseRadius; 42 | 43 | return new Point(centre.X + opposite, centre.Y - adjacent); 44 | } 45 | 46 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 47 | { 48 | throw new NotImplementedException(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/ArcSizeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 7 | { 8 | /// 9 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 10 | /// Their license is included in the "Licenses" folder. 11 | /// 12 | public class ArcSizeConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (value is double && ((double)value > 0.0)) 17 | { 18 | return new Size((double)value / 2, (double)value / 2); 19 | } 20 | 21 | return new Point(); 22 | } 23 | 24 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 25 | { 26 | return Binding.DoNothing; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/LargeArcConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 6 | { 7 | /// 8 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 9 | /// Their license is included in the "Licenses" folder. 10 | /// 11 | public class LargeArcConverter : IMultiValueConverter 12 | { 13 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | var value = values[0].ExtractDouble(); 16 | var minimum = values[1].ExtractDouble(); 17 | var maximum = values[2].ExtractDouble(); 18 | 19 | if (new[] { value, minimum, maximum }.AnyNan()) 20 | return Binding.DoNothing; 21 | 22 | if (values.Length == 4) 23 | { 24 | var fullIndeterminateScaling = values[3].ExtractDouble(); 25 | if (!double.IsNaN(fullIndeterminateScaling) && fullIndeterminateScaling > 0.0) 26 | { 27 | value = (maximum - minimum) * fullIndeterminateScaling; 28 | } 29 | } 30 | 31 | var percent = maximum <= minimum ? 1.0 : (value - minimum) / (maximum - minimum); 32 | 33 | return percent > 0.5; 34 | } 35 | 36 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/LocalEx.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 5 | { 6 | /// 7 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 8 | /// Their license is included in the "Licenses" folder. 9 | /// 10 | internal static class LocalEx 11 | { 12 | public static double ExtractDouble(this object val) 13 | { 14 | var d = val as double? ?? double.NaN; 15 | return double.IsInfinity(d) ? double.NaN : d; 16 | } 17 | 18 | 19 | public static bool AnyNan(this IEnumerable vals) 20 | { 21 | return vals.Any(double.IsNaN); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/NotZeroConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 6 | { 7 | /// 8 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 9 | /// Their license is included in the "Licenses" folder. 10 | /// 11 | public class NotZeroConverter : IValueConverter 12 | { 13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | if (double.TryParse((value ?? "").ToString(), out double val)) 16 | { 17 | return Math.Abs(val) > 0.0; 18 | } 19 | return null; 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | return Binding.DoNothing; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/RotateTransformCentreConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 6 | { 7 | /// 8 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 9 | /// Their license is included in the "Licenses" folder. 10 | /// 11 | public class RotateTransformCentreConverter : IValueConverter 12 | { 13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | // value == actual width 16 | return (double)value / 2; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | return Binding.DoNothing; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/RotateTransformConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 6 | { 7 | /// 8 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 9 | /// Their license is included in the "Licenses" folder. 10 | /// 11 | public class RotateTransformConverter : IMultiValueConverter 12 | { 13 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | var value = values[0].ExtractDouble(); 16 | var minimum = values[1].ExtractDouble(); 17 | var maximum = values[2].ExtractDouble(); 18 | 19 | if (new[] { value, minimum, maximum }.AnyNan()) 20 | return Binding.DoNothing; 21 | 22 | var percent = maximum <= minimum ? 1.0 : (value - minimum) / (maximum - minimum); 23 | 24 | return 360 * percent; 25 | } 26 | 27 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/MaterialCircularProgressBar/StartPointConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters.MaterialCircularProgressBar 7 | { 8 | /// 9 | /// This code is based on code from MaterialDesignInXamlToolkit: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit 10 | /// Their license is included in the "Licenses" folder. 11 | /// 12 | public class StartPointConverter : IValueConverter 13 | { 14 | [Obsolete] 15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | if (value is double && ((double)value > 0.0)) 18 | { 19 | return new Point((double)value / 2, 0); 20 | } 21 | 22 | return new Point(); 23 | } 24 | 25 | [Obsolete] 26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | return Binding.DoNothing; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/NullToCollapsedConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class NullToCollapsedConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (value == null) 13 | { 14 | return Visibility.Collapsed; 15 | } 16 | 17 | return Visibility.Visible; 18 | } 19 | 20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 21 | { 22 | return Binding.DoNothing; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/NullToVisibleConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class NullToVisibleConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (value == null) 13 | { 14 | return Visibility.Visible; 15 | } 16 | 17 | return Visibility.Collapsed; 18 | } 19 | 20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 21 | { 22 | return Binding.DoNothing; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/ResizeModeMinMaxButtonVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | /// 9 | /// ResizeModeMinMaxButtonVisibilityConverter is based on code from MahApps.Metro: https://github.com/MahApps/MahApps.Metro 10 | /// Their license is included in the "Licenses" folder. 11 | /// 12 | public class ResizeModeMinMaxButtonVisibilityConverter : IMultiValueConverter 13 | { 14 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (values != null && values.Length == 2 && parameter is string) 17 | { 18 | bool windowPropValue = System.Convert.ToBoolean(values[0]); 19 | ResizeMode windowResizeMode = (ResizeMode)values[1]; 20 | string whichButton = System.Convert.ToString(parameter); 21 | 22 | switch (windowResizeMode) 23 | { 24 | case ResizeMode.NoResize: 25 | return Visibility.Collapsed; 26 | case ResizeMode.CanMinimize: 27 | if (whichButton == "MIN") 28 | { 29 | return (windowPropValue ? Visibility.Visible : Visibility.Collapsed); 30 | } 31 | return Visibility.Collapsed; 32 | case ResizeMode.CanResize: 33 | return (windowPropValue ? Visibility.Visible : Visibility.Collapsed); 34 | case ResizeMode.CanResizeWithGrip: 35 | return (windowPropValue ? Visibility.Visible : Visibility.Collapsed); 36 | default: 37 | return (windowPropValue ? Visibility.Visible : Visibility.Collapsed); 38 | } 39 | } 40 | return Visibility.Visible; 41 | } 42 | 43 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 44 | { 45 | throw new NotImplementedException(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/SolidColorBrushToColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace Digimezzo.Foundation.WPF.Converters 7 | { 8 | public class SolidColorBrushToColorConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (value == null) 13 | { 14 | return null; 15 | } 16 | 17 | if (!(value is SolidColorBrush)) 18 | { 19 | throw new InvalidOperationException("Unsupported type [" + value.GetType().Name + "], SolidColorBrushToColorConverter.Convert()"); 20 | } 21 | 22 | return ((SolidColorBrush)value).Color; 23 | } 24 | 25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 26 | { 27 | throw new NotSupportedException(); 28 | } 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/StringToLowerConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters 6 | { 7 | public class StringToLowerConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value != null) 12 | { 13 | return System.Convert.ToString(value).ToLower(); 14 | } 15 | return value; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotSupportedException(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Converters/StringToUpperConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Digimezzo.Foundation.WPF.Converters 6 | { 7 | public class StringToUpperConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value != null) 12 | { 13 | return System.Convert.ToString(value).ToUpper(); 14 | } 15 | return value; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotSupportedException(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Effects/FeatheringEffect.cs: -------------------------------------------------------------------------------- 1 | using Digimezzo.Foundation.WPF.Utils; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Effects; 5 | 6 | namespace Digimezzo.Foundation.WPF.Effects 7 | { 8 | public class FeatheringEffect : ShaderEffect 9 | { 10 | private static PixelShader shader = new PixelShader() 11 | { 12 | UriSource = UriUtils.MakePackUri("Effects/FeatheringEffect.ps") 13 | }; 14 | 15 | public Brush InputBackground 16 | { 17 | get => (Brush)GetValue(InputBackgroundProperty); 18 | set => SetValue(InputBackgroundProperty, value); 19 | } 20 | 21 | public double FeatheringRadius 22 | { 23 | get => (double) GetValue(FeatheringRadiusProperty); 24 | set => SetValue(FeatheringRadiusProperty, value); 25 | } 26 | 27 | public double TexWidth 28 | { 29 | get => (double)GetValue(TexWidthProperty); 30 | set => SetValue(TexWidthProperty, value); 31 | } 32 | 33 | public static DependencyProperty InputBackgroundProperty = 34 | RegisterPixelShaderSamplerProperty("InputBackground", typeof(FeatheringEffect), 0); 35 | 36 | public static DependencyProperty FeatheringRadiusProperty = DependencyProperty.Register("FeatheringRadius", 37 | typeof(double), typeof(FeatheringEffect), new UIPropertyMetadata(default(double), PixelShaderConstantCallback(0))); 38 | 39 | public static DependencyProperty TexWidthProperty = DependencyProperty.Register("TexWidth", typeof(double), 40 | typeof(FeatheringEffect), new UIPropertyMetadata(default(double), PixelShaderConstantCallback(1))); 41 | 42 | public FeatheringEffect() 43 | { 44 | PixelShader = shader; 45 | UpdateShaderValue(InputBackgroundProperty); 46 | UpdateShaderValue(FeatheringRadiusProperty); 47 | UpdateShaderValue(TexWidthProperty); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Effects/FeatheringEffect.fx: -------------------------------------------------------------------------------- 1 | //ps_3_0 2 | 3 | sampler2D implicitInputBackground : register(s0); 4 | float implicitfeather : register(c0); 5 | float implicitwidth : register(c1); 6 | float implicitheight : register(c2); 7 | 8 | float4 main(float2 uv : TEXCOORD) : COLOR 9 | { 10 | float4 colorSample = tex2D(implicitInputBackground, uv); 11 | float width = uv[0] * implicitwidth; 12 | float feather = implicitfeather; 13 | if (width < feather) 14 | { 15 | colorSample *= width / feather; 16 | } 17 | if (width > implicitwidth - feather) 18 | { 19 | colorSample *= (implicitwidth - width) / feather; 20 | } 21 | 22 | return colorSample; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Effects/FeatheringEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Digimezzo.Foundation.WPF/Effects/FeatheringEffect.ps -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.WPF.Extensions 2 | { 3 | public static class StringExtensions 4 | { 5 | public static bool IsNumeric(this string str) 6 | { 7 | float output; 8 | return float.TryParse(str, out output); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Fonts/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Digimezzo.Foundation.WPF/Fonts/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Fonts/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Digimezzo.Foundation.WPF/Fonts/Roboto-Thin.ttf -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Digimezzo.Foundation.WPF/Fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Fonts/segmdl2.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Digimezzo.Foundation.WPF/Fonts/segmdl2.ttf -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Licenses/MahApps.Metro.txt: -------------------------------------------------------------------------------- 1 | Microsoft Public License (Ms-PL) 2 | 3 | This license governs use of the accompanying software. If you use the software, you 4 | accept this license. If you do not accept the license, do not use the software. 5 | 6 | 1. Definitions 7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the 8 | same meaning here as under U.S. copyright law. 9 | A "contribution" is the original software, or any additions or changes to the software. 10 | A "contributor" is any person that distributes its contribution under this license. 11 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 12 | 13 | 2. Grant of Rights 14 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 15 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 16 | 17 | 3. Conditions and Limitations 18 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 19 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 20 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 21 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 22 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Licenses/MaterialDesignInXamlToolkit.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) James Willock, Mulholland Software and Contributors 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. -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Native/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.WPF.Native 2 | { 3 | public static class Constants 4 | { 5 | public const uint MONITOR_DEFAULTTONEAREST = 0x2; 6 | public const int WM_NCLBUTTONDOWN = 0xa1; 7 | public const int HT_CAPTION = 0x2; 8 | public const uint SWP_SHOWWINDOW = 0x40; 9 | public const int HWND_NOTOPMOST = -2; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Native/Enums.cs: -------------------------------------------------------------------------------- 1 | namespace Digimezzo.Foundation.WPF.Native 2 | { 3 | internal enum ABEdge 4 | { 5 | ABE_LEFT = 0, 6 | ABE_TOP = 1, 7 | ABE_RIGHT = 2, 8 | ABE_BOTTOM = 3 9 | } 10 | 11 | internal enum ABMsg 12 | { 13 | ABM_NEW = 0, 14 | ABM_REMOVE = 1, 15 | ABM_QUERYPOS = 2, 16 | ABM_SETPOS = 3, 17 | ABM_GETSTATE = 4, 18 | ABM_GETTASKBARPOS = 5, 19 | ABM_ACTIVATE = 6, 20 | ABM_GETAUTOHIDEBAR = 7, 21 | ABM_SETAUTOHIDEBAR = 8, 22 | ABM_WINDOWPOSCHANGED = 9, 23 | ABM_SETSTATE = 10 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Native/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Digimezzo.Foundation.WPF.Native 5 | { 6 | public static class NativeMethods 7 | { 8 | [DllImport("shell32.dll")] 9 | internal static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData); 10 | 11 | [DllImport("user32.dll", EntryPoint = "GetMonitorInfoW", ExactSpelling = true, CharSet = CharSet.Unicode)] 12 | [return: MarshalAs(UnmanagedType.Bool)] 13 | internal static extern bool GetMonitorInfo(IntPtr hMonitor, [Out] MONITORINFO lpmi); 14 | 15 | [DllImport("user32.dll")] 16 | internal static extern IntPtr MonitorFromWindow(IntPtr handle, uint flags); 17 | 18 | [DllImport("user32.dll")] 19 | public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); 20 | 21 | [DllImport("user32.dll")] 22 | [return: MarshalAs(UnmanagedType.Bool)] 23 | internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Native/Structs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Digimezzo.Foundation.WPF.Native 5 | { 6 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] 7 | public class MONITORINFO 8 | { 9 | public int cbSize = Marshal.SizeOf(typeof(MONITORINFO)); 10 | public RECT rcMonitor = new RECT(); 11 | public RECT rcWork = new RECT(); 12 | public int dwFlags = 0; 13 | } 14 | 15 | [StructLayout(LayoutKind.Sequential, Pack = 0)] 16 | public struct RECT 17 | { 18 | public int left; 19 | public int top; 20 | public int right; 21 | public int bottom; 22 | } 23 | 24 | [StructLayout(LayoutKind.Sequential)] 25 | internal struct APPBARDATA 26 | { 27 | public int cbSize; 28 | public IntPtr hWnd; 29 | public int uCallbackMessage; 30 | public int uEdge; 31 | public RECT rc; 32 | public bool lParam; 33 | } 34 | 35 | [StructLayout(LayoutKind.Sequential)] 36 | internal struct MINMAXINFO 37 | { 38 | public POINT ptReserved; 39 | public POINT ptMaxSize; 40 | public POINT ptMaxPosition; 41 | public POINT ptMinTrackSize; 42 | public POINT ptMaxTrackSize; 43 | } 44 | 45 | [StructLayout(LayoutKind.Sequential)] 46 | internal struct POINT 47 | { 48 | public int x; 49 | public int y; 50 | 51 | public POINT(int x, int y) 52 | { 53 | this.x = x; 54 | this.y = y; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("Digimezzo.Foundation.WPF")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | //[assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Digimezzo.Foundation.WPF")] 15 | //[assembly: AssemblyCopyright("Copyright © 2018")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | //[assembly: AssemblyVersion("1.0.0.0")] 55 | //[assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Properties/Resources.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 Digimezzo.Foundation.WPF.Properties { 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 Resources { 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 Resources() { 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("Digimezzo.Foundation.WPF.Properties.Resources", typeof(Resources).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 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Properties/Settings.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 Digimezzo.Foundation.WPF.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/FontIcons.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | /Digimezzo.Foundation.WPF;component/Fonts/#FontAwesome 6 | /Digimezzo.Foundation.WPF;component/Fonts/#Material Icons 7 | /Digimezzo.Foundation.WPF;component/Fonts/#Segoe MDL2 Assets 8 | 9 | 19 | 20 | 30 | 31 | 41 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/LabelToLower.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 31 | 32 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/LabelToUpper.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 31 | 32 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MaterialDateBox.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 38 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MaterialFlatButton.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 36 | 37 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MaterialFloatingActionButton.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 56 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MaterialMiniFloatingActionButton.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 56 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MaterialRaisedButton.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 49 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MaterialTextBox.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 28 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/MultiPanePanel.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 69 | 70 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/PageIndicator.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 37 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/Ripple.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 19 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/SlidingContentControl.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 17 | 18 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/SplitView.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 45 | 46 | 47 | 52 | 56 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/Windows10SliderHorizontal.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/Windows10SliderVertical.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/Windows8SliderHorizontal.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Themes/Windows8SliderVertical.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Utils/AnimationUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | using System.Windows.Media.Animation; 5 | using System.Windows.Media.Imaging; 6 | 7 | namespace Digimezzo.Foundation.WPF.Utils 8 | { 9 | public sealed class AnimationUtils 10 | { 11 | public static AnimationTimeline CreateSlideAnimation(double from, double to, double easingAmplitude, double slideDuration, EventHandler whenDone = null) 12 | { 13 | IEasingFunction ease = new BackEase 14 | { 15 | Amplitude = easingAmplitude, 16 | EasingMode = EasingMode.EaseOut 17 | }; 18 | 19 | var duration = new Duration(TimeSpan.FromSeconds(slideDuration)); 20 | var anim = new DoubleAnimation(from, to, duration) { EasingFunction = ease }; 21 | 22 | if (whenDone != null) anim.Completed += whenDone; 23 | 24 | anim.Freeze(); 25 | 26 | return anim; 27 | } 28 | 29 | public static AnimationTimeline CreateFadeAnimation(double from, double to, double durationSeconds, EventHandler whenDone = null) 30 | { 31 | var duration = new Duration(TimeSpan.FromSeconds(durationSeconds)); 32 | var anim = new DoubleAnimation(from, to, duration); 33 | 34 | if (whenDone != null) 35 | { 36 | anim.Completed += whenDone; 37 | } 38 | 39 | anim.Freeze(); 40 | 41 | return anim; 42 | } 43 | 44 | public static Brush CreateBrushFromVisual(Visual visual, double desiredWidth, double desiredHeight) 45 | { 46 | if (visual == null) 47 | { 48 | throw new ArgumentNullException("visual"); 49 | } 50 | 51 | var target = new RenderTargetBitmap(Convert.ToInt32(desiredWidth), Convert.ToInt32(desiredHeight), 96, 96, PixelFormats.Pbgra32); 52 | target.Render(visual); 53 | var brush = new ImageBrush(target); 54 | brush.Freeze(); 55 | return brush; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Utils/UriUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Digimezzo.Foundation.WPF.Utils 4 | { 5 | public class UriUtils 6 | { 7 | public static Uri MakePackUri(string relativeFile) 8 | { 9 | var a = typeof(T).Assembly; 10 | var assemblyShortName = a.ToString().Split(',')[0]; 11 | var uriString = $"pack://application:,,,/{assemblyShortName};component/{relativeFile}"; 12 | 13 | return new Uri(uriString); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Digimezzo.Foundation.WPF/Utils/VisualTreeUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Media; 3 | using System.Windows.Media.Media3D; 4 | 5 | namespace Digimezzo.Foundation.WPF.Utils 6 | { 7 | public sealed class VisualTreeUtils 8 | { 9 | public static T FindAncestor(DependencyObject d) where T : class 10 | { 11 | if (d is Visual || d is Visual3D) 12 | { 13 | DependencyObject item = VisualTreeHelper.GetParent(d); 14 | 15 | while (item != null) 16 | { 17 | T itemAsT = item as T; 18 | if (itemAsT != null) 19 | { 20 | return itemAsT; 21 | } 22 | item = VisualTreeHelper.GetParent(item); 23 | } 24 | } 25 | 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Foundation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Foundation.png -------------------------------------------------------------------------------- /Foundation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digimezzo.Foundation.Core", "Digimezzo.Foundation.Core\Digimezzo.Foundation.Core.csproj", "{F376CCCA-325F-4533-934D-A9C4A7CFC69B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digimezzo.Foundation.WPF", "Digimezzo.Foundation.WPF\Digimezzo.Foundation.WPF.csproj", "{DB02D05F-5FD8-4D14-B446-354DE8B4791E}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digimezzo.Foundation.WPF.Demo", "Digimezzo.Foundation.WPF.Demo\Digimezzo.Foundation.WPF.Demo.csproj", "{1FA66114-32D5-475F-86F9-9C90236F1232}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {F376CCCA-325F-4533-934D-A9C4A7CFC69B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {F376CCCA-325F-4533-934D-A9C4A7CFC69B}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {F376CCCA-325F-4533-934D-A9C4A7CFC69B}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {F376CCCA-325F-4533-934D-A9C4A7CFC69B}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {DB02D05F-5FD8-4D14-B446-354DE8B4791E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {DB02D05F-5FD8-4D14-B446-354DE8B4791E}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {DB02D05F-5FD8-4D14-B446-354DE8B4791E}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {DB02D05F-5FD8-4D14-B446-354DE8B4791E}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {1FA66114-32D5-475F-86F9-9C90236F1232}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {1FA66114-32D5-475F-86F9-9C90236F1232}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {1FA66114-32D5-475F-86F9-9C90236F1232}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {1FA66114-32D5-475F-86F9-9C90236F1232}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {A23F94C4-C77E-426A-A903-48FBD015FC5D} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Foundation.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 43 | 45 | 46 | 48 | image/svg+xml 49 | 51 | 52 | 53 | 54 | 55 | 60 | 66 | 69 | 78 | 87 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Foundation_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digimezzo/Foundation/1310b7362e7eacebf7720a68f60d025378d35178/Foundation_small.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Digimezzo 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 | ![Foundation](Foundation_small.png) 2 | 3 | # Foundation 4 | A set of libraries which can be used as a foundation for Windows Desktop applications. 5 | 6 | Once ready, it will replace Digimezzo.Utilities and Digimezzo.WPFControls. 7 | 8 | [![Release](https://img.shields.io/github/release/digimezzo/Foundation.svg?style=flat-square)](https://github.com/digimezzo/Foundation/releases/latest) 9 | [![Issues](https://img.shields.io/github/issues/digimezzo/Foundation.svg?style=flat-square)](https://github.com/digimezzo/Foundation/issues) 10 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MQALEWTEZ7HX8) 11 | --------------------------------------------------------------------------------