├── .gitignore ├── LICENSE ├── README.md ├── Spectrum.Demo ├── Spectrum.Demo.Shared │ ├── App.xaml │ ├── App.xaml.cs │ ├── Controls │ │ └── UniformGrid.cs │ ├── Converters │ │ ├── ColorHexConveter.cs │ │ ├── ColorToBrushConverter.cs │ │ └── StringFormatConverter.cs │ ├── Extensions │ │ ├── ComparableExtensions.cs │ │ ├── EnumerableExtensions.cs │ │ └── StoryboardExtensions.cs │ ├── Resources │ │ ├── Fonts │ │ │ └── Lobster-Regular.ttf │ │ └── Styles.Shared.xaml │ ├── Services │ │ ├── AppSettingsService.cs │ │ ├── BitmapService.cs │ │ ├── ColorConverter.cs │ │ ├── IAppSettingsService.cs │ │ ├── IBitmapService.cs │ │ ├── ISchemeStorageService.cs │ │ ├── ITileService.cs │ │ ├── IWindowManager.cs │ │ ├── Scheme.cs │ │ ├── SchemeStorageService.cs │ │ ├── SchemeType.cs │ │ ├── TileService.cs │ │ └── TileSize.cs │ ├── Spectrum.Demo.Shared.projitems │ ├── Spectrum.Demo.Shared.shproj │ ├── ViewModels │ │ ├── EditSchemeViewModel.cs │ │ ├── Editors │ │ │ ├── AnalogousSchemeEditorViewModel.cs │ │ │ ├── ColourViewModel.cs │ │ │ ├── ComplimentarySchemeEditorViewModel.cs │ │ │ ├── CustomSchemeEditorViewModel.cs │ │ │ ├── EditColourViewModel.cs │ │ │ ├── MonochromeSchemeEditorViewModel.cs │ │ │ ├── SchemeEditorViewModelBase.cs │ │ │ ├── SingleColorSchemeEditorViewModelBase.cs │ │ │ └── TriadSchemeEditorViewModel.cs │ │ ├── SaveSchemeViewModel.cs │ │ ├── SchemeListViewModel.cs │ │ ├── SchemeTypeViewModel.cs │ │ └── SchemeViewModel.cs │ └── Views │ │ ├── Editors │ │ ├── EditColourView.xaml │ │ ├── EditColourView.xaml.cs │ │ └── IColourView.cs │ │ ├── SaveSchemeView.xaml │ │ ├── SaveSchemeView.xaml.cs │ │ ├── SchemeView.xaml │ │ └── SchemeView.xaml.cs ├── Spectrum.Demo.Windows │ ├── BundleArtifacts │ │ └── neutral.txt │ ├── Controls │ │ ├── DialogAction.cs │ │ ├── DialogContentControl.cs │ │ └── DialogDismissedEventArgs.cs │ ├── FodyWeavers.xml │ ├── Package.StoreAssociation.xml │ ├── Package.appxmanifest │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Images │ │ │ ├── Splash.scale-100.png │ │ │ ├── Splash.scale-140.png │ │ │ ├── Splash.scale-180.png │ │ │ ├── Square150.scale-100.png │ │ │ ├── Square150.scale-140.png │ │ │ ├── Square150.scale-180.png │ │ │ ├── Square30.scale-100.png │ │ │ ├── Square30.scale-140.png │ │ │ ├── Square30.scale-180.png │ │ │ ├── Square50.scale-100.png │ │ │ ├── Square50.scale-140.png │ │ │ ├── Square50.scale-180.png │ │ │ ├── Square70.scale-100.png │ │ │ ├── Square70.scale-140.png │ │ │ ├── Square70.scale-180.png │ │ │ ├── Wide.scale-100.png │ │ │ ├── Wide.scale-140.png │ │ │ └── Wide.scale-180.png │ │ └── Styles.xaml │ ├── Services │ │ └── WindowManager.cs │ ├── Spectrum.Demo.Windows.csproj │ ├── Themes │ │ └── Generic.xaml │ ├── Views │ │ ├── EditSchemeView.xaml │ │ ├── EditSchemeView.xaml.cs │ │ ├── Editors │ │ │ ├── AnalogousSchemeEditorView.xaml │ │ │ ├── AnalogousSchemeEditorView.xaml.cs │ │ │ ├── ColourView.xaml │ │ │ ├── ColourView.xaml.cs │ │ │ ├── ComplimentarySchemeEditorView.xaml │ │ │ ├── ComplimentarySchemeEditorView.xaml.cs │ │ │ ├── CustomSchemeEditorView.xaml │ │ │ ├── CustomSchemeEditorView.xaml.cs │ │ │ ├── DerivedColourView.xaml │ │ │ ├── DerivedColourView.xaml.cs │ │ │ ├── MonochromeSchemeEditorView.xaml │ │ │ ├── MonochromeSchemeEditorView.xaml.cs │ │ │ ├── SingleColorSchemeEditorViewBase.cs │ │ │ ├── TriadSchemeEditorView.xaml │ │ │ └── TriadSchemeEditorView.xaml.cs │ │ ├── SchemeListView.xaml │ │ └── SchemeListView.xaml.cs │ └── packages.config └── Spectrum.Demo.WindowsPhone │ ├── BundleArtifacts │ └── neutral.txt │ ├── FodyWeavers.xml │ ├── Package.StoreAssociation.xml │ ├── Package.appxmanifest │ ├── Properties │ └── AssemblyInfo.cs │ ├── Resources │ ├── Images │ │ ├── Splash.scale-100.png │ │ ├── Splash.scale-140.png │ │ ├── Splash.scale-240.png │ │ ├── Square150.scale-100.png │ │ ├── Square150.scale-140.png │ │ ├── Square150.scale-240.png │ │ ├── Square44.scale-100.png │ │ ├── Square44.scale-140.png │ │ ├── Square44.scale-240.png │ │ ├── Square50.scale-100.png │ │ ├── Square50.scale-140.png │ │ ├── Square50.scale-240.png │ │ ├── Square71.scale-100.png │ │ ├── Square71.scale-140.png │ │ ├── Square71.scale-240.png │ │ ├── Wide.scale-100.png │ │ ├── Wide.scale-140.png │ │ └── Wide.scale-240.png │ └── Styles.xaml │ ├── Services │ └── WindowManager.cs │ ├── Spectrum.Demo.WindowsPhone.csproj │ ├── Views │ ├── EditSchemeView.xaml │ ├── EditSchemeView.xaml.cs │ ├── Editors │ │ ├── AnalogousSchemeEditorView.xaml │ │ ├── AnalogousSchemeEditorView.xaml.cs │ │ ├── ColourView.xaml │ │ ├── ColourView.xaml.cs │ │ ├── ComplimentarySchemeEditorView.xaml │ │ ├── ComplimentarySchemeEditorView.xaml.cs │ │ ├── CustomSchemeEditorView.xaml │ │ ├── CustomSchemeEditorView.xaml.cs │ │ ├── DerivedColourView.xaml │ │ ├── DerivedColourView.xaml.cs │ │ ├── MonochromeSchemeEditorView.xaml │ │ ├── MonochromeSchemeEditorView.xaml.cs │ │ ├── SingleColorSchemeEditorViewBase.cs │ │ ├── TriadSchemeEditorView.xaml │ │ └── TriadSchemeEditorView.xaml.cs │ ├── SchemeListView.xaml │ └── SchemeListView.xaml.cs │ └── packages.config ├── Spectrum.Tests ├── ColorTests.HSL.cs ├── ColorTests.HSV.cs ├── ColorTests.RGB.cs ├── Properties │ └── AssemblyInfo.cs └── Spectrum.Tests.csproj ├── Spectrum.Universal ├── Color.RGB.Extensions.cs ├── Converters │ ├── ComplimentConverter.cs │ ├── ForegroundTextConverter.cs │ ├── ShiftHueConverter.cs │ ├── ShiftLightnessConverter.cs │ └── ShiftSaturationConverter.cs ├── Properties │ └── AssemblyInfo.cs └── Spectrum.Universal.csproj ├── Spectrum.sln ├── Spectrum ├── Color.HSL.cs ├── Color.HSV.cs ├── Color.RGB.cs ├── DoubleExtensions.cs ├── Properties │ └── AssemblyInfo.cs └── Spectrum.csproj ├── design ├── Splash.Windows.design ├── Splash.design ├── Square.design └── Wide.design └── tools └── nuget ├── NuGet.exe ├── Spectrum.Universal.nuspec ├── Spectrum.nuspec └── build-packages.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | x86/ 16 | build/ 17 | bld/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | 21 | # Roslyn cache directories 22 | *.ide/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | #NUNIT 29 | *.VisualState.xml 30 | TestResult.xml 31 | 32 | # Build Results of an ATL Project 33 | [Dd]ebugPS/ 34 | [Rr]eleasePS/ 35 | dlldata.c 36 | 37 | *_i.c 38 | *_p.c 39 | *_i.h 40 | *.ilk 41 | *.meta 42 | *.obj 43 | *.pch 44 | *.pdb 45 | *.pgc 46 | *.pgd 47 | *.rsp 48 | *.sbr 49 | *.tlb 50 | *.tli 51 | *.tlh 52 | *.tmp 53 | *.tmp_proj 54 | *.log 55 | *.vspscc 56 | *.vssscc 57 | .builds 58 | *.pidb 59 | *.svclog 60 | *.scc 61 | 62 | # Chutzpah Test files 63 | _Chutzpah* 64 | 65 | # Visual C++ cache files 66 | ipch/ 67 | *.aps 68 | *.ncb 69 | *.opensdf 70 | *.sdf 71 | *.cachefile 72 | 73 | # Visual Studio profiler 74 | *.psess 75 | *.vsp 76 | *.vspx 77 | 78 | # TFS 2012 Local Workspace 79 | $tf/ 80 | 81 | # Guidance Automation Toolkit 82 | *.gpState 83 | 84 | # ReSharper is a .NET coding add-in 85 | _ReSharper*/ 86 | *.[Rr]e[Ss]harper 87 | *.DotSettings.user 88 | 89 | # JustCode is a .NET coding addin-in 90 | .JustCode 91 | 92 | # TeamCity is a build add-in 93 | _TeamCity* 94 | 95 | # DotCover is a Code Coverage Tool 96 | *.dotCover 97 | 98 | # NCrunch 99 | _NCrunch_* 100 | .*crunch*.local.xml 101 | 102 | # MightyMoose 103 | *.mm.* 104 | AutoTest.Net/ 105 | 106 | # Web workbench (sass) 107 | .sass-cache/ 108 | 109 | # Installshield output folder 110 | [Ee]xpress/ 111 | 112 | # DocProject is a documentation generator add-in 113 | DocProject/buildhelp/ 114 | DocProject/Help/*.HxT 115 | DocProject/Help/*.HxC 116 | DocProject/Help/*.hhc 117 | DocProject/Help/*.hhk 118 | DocProject/Help/*.hhp 119 | DocProject/Help/Html2 120 | DocProject/Help/html 121 | 122 | # Click-Once directory 123 | publish/ 124 | 125 | # Publish Web Output 126 | *.[Pp]ublish.xml 127 | *.azurePubxml 128 | # TODO: Comment the next line if you want to checkin your web deploy settings 129 | # but database connection strings (with potential passwords) will be unencrypted 130 | *.pubxml 131 | *.publishproj 132 | 133 | # NuGet Packages 134 | *.nupkg 135 | # The packages folder can be ignored because of Package Restore 136 | **/packages/* 137 | # except build/, which is used as an MSBuild target. 138 | !**/packages/build/ 139 | # If using the old MSBuild-Integrated Package Restore, uncomment this: 140 | #!**/packages/repositories.config 141 | 142 | # Windows Azure Build Output 143 | csx/ 144 | *.build.csdef 145 | 146 | # Windows Store app package directory 147 | AppPackages/ 148 | 149 | # Others 150 | sql/ 151 | *.Cache 152 | ClientBin/ 153 | [Ss]tyle[Cc]op.* 154 | ~$* 155 | *~ 156 | *.dbmdl 157 | *.dbproj.schemaview 158 | *.pfx 159 | *.publishsettings 160 | node_modules/ 161 | 162 | # RIA/Silverlight projects 163 | Generated_Code/ 164 | 165 | # Backup & report files from converting an old project file 166 | # to a newer Visual Studio version. Backup files are not needed, 167 | # because we have git ;-) 168 | _UpgradeReport_Files/ 169 | Backup*/ 170 | UpgradeLog*.XML 171 | UpgradeLog*.htm 172 | 173 | # SQL Server files 174 | *.mdf 175 | *.ldf 176 | 177 | # Business Intelligence projects 178 | *.rdl.data 179 | *.bim.layout 180 | *.bim_*.settings 181 | 182 | # Microsoft Fakes 183 | FakesAssemblies/ 184 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spectrum 2 | 3 | ## What is it? 4 | 5 | Spectrum is a library to manipulate colours in the .NET framework, specifically in the RGB, HSL and HSV colour spaces. 6 | 7 | It's currently not designed to the be all and end all in terms of colour but more to assist developers in building harmonious colour schemes for their applications. 8 | 9 | It exists as two parts: 10 | 11 | 1. **Spectrum** is the core library that contains the classes you'd expect in a library such as this. It's a portable class library covering all the major platforms (math is very portable). 12 | 2. **Spectrum.Universal** is the interesting part and is where I hope to extend most of all, it's a playground for how we can use colour space calculations in our apps. It's portable across Windows 8 and Windows Phone 8.1. 13 | 14 | ## How does it work? 15 | 16 | The core Spectrum library has only three classes `Color.RGB`, `Color.HSL` and `Color.HSV`, these naturally have methods to convert between themselves. 17 | 18 | ``` csharp 19 | var accent = new Color.RGB(240, 150, 9); 20 | 21 | var hsl = accent.ToHSL(); 22 | 23 | Assert.AreEqual(new Color.HSL(36.6, 0.928, 0.488), hsl); 24 | ``` 25 | 26 | The `Color.HSL` class has number of helper methods to create other related colours. 27 | 28 | ``` csharp 29 | var hsl = new Color.HSL(90, 0.5, 0.5); 30 | 31 | var compliment = hsl.ShiftHue(180.0d); 32 | 33 | var analogous = hsl.GetAnalogous(); 34 | ``` 35 | 36 | It gets more interesting when we start to use **Spectrum.Universal**. This contains a few Xaml Value Converters that can shift between `Windows.UI.Color` instances for us. 37 | 38 | Given resource declarations like the following: 39 | 40 | ``` xml 41 | 42 | 43 | 44 | ``` 45 | 46 | and our base accent colour: 47 | 48 | ``` xml 49 | #FF0088D1 50 | 51 | ``` 52 | 53 | We can create lighter and darker versions of that same colour using 54 | 55 | ``` xml 56 | 61 | 62 | 67 | ``` 68 | 69 | as well as create a minor accent colour 70 | 71 | ``` xml 72 | 77 | ``` 78 | 79 | We can now manage an app's full palatte of colour resources by tweaking a few base colours. 80 | 81 | ## Where I can get this? 82 | 83 | Source is obviously here, and is also on [nuget](http://www.nuget.org/packages/Spectrum.Universal/). 84 | 85 | 86 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/App.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Windows.ApplicationModel.Activation; 4 | using Windows.UI.ViewManagement; 5 | using Windows.UI.Xaml.Controls; 6 | using Caliburn.Micro; 7 | using Spectrum.Demo.Services; 8 | using Spectrum.Demo.ViewModels; 9 | using Spectrum.Demo.Views; 10 | 11 | namespace Spectrum.Demo 12 | { 13 | public sealed partial class App 14 | { 15 | private WinRTContainer container; 16 | 17 | public App() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | protected override void Configure() 23 | { 24 | var baseGetLog = LogManager.GetLog; 25 | 26 | LogManager.GetLog = t => t == typeof (ViewModelBinder) ? new DebugLog(t) : baseGetLog(t); 27 | 28 | ConfigureSpecialValues(); 29 | 30 | container = new WinRTContainer(); 31 | 32 | container.RegisterWinRTServices(); 33 | 34 | container 35 | .Singleton() 36 | .Singleton() 37 | .Singleton() 38 | .Singleton() 39 | .Singleton(); 40 | 41 | container 42 | .PerRequest() 43 | .PerRequest(); 44 | 45 | container.RegisterSharingService(); 46 | 47 | #if WINDOWS_PHONE_APP 48 | var statusBar = StatusBar.GetForCurrentView(); 49 | 50 | statusBar.HideAsync(); 51 | #endif 52 | 53 | var tileService = container.GetInstance(); 54 | 55 | tileService.Initialise(); 56 | } 57 | 58 | private static void ConfigureSpecialValues() 59 | { 60 | MessageBinder.SpecialValues.Add("$clickeditem", c => ((ItemClickEventArgs)c.EventArgs).ClickedItem); 61 | } 62 | 63 | protected override void PrepareViewFirst(Frame rootFrame) 64 | { 65 | container.RegisterNavigationService(rootFrame); 66 | } 67 | 68 | protected override void OnLaunched(LaunchActivatedEventArgs args) 69 | { 70 | DisplayRootView(); 71 | } 72 | 73 | protected override void BuildUp(object instance) 74 | { 75 | container.BuildUp(instance); 76 | } 77 | 78 | protected override IEnumerable GetAllInstances(Type service) 79 | { 80 | return container.GetAllInstances(service); 81 | } 82 | 83 | protected override object GetInstance(Type service, string key) 84 | { 85 | return container.GetInstance(service, key); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Converters/ColorHexConveter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml.Data; 3 | 4 | namespace Spectrum.Demo.Converters 5 | { 6 | public class ColorHexConveter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, string language) 9 | { 10 | var color = (Windows.UI.Color)value; 11 | 12 | return String.Format("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B); 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, string language) 16 | { 17 | throw new NotSupportedException(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Converters/ColorToBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI; 3 | using Windows.UI.Xaml.Data; 4 | using Windows.UI.Xaml.Media; 5 | using Spectrum.Universal; 6 | using WinColor = Windows.UI.Color; 7 | 8 | namespace Spectrum.Demo.Converters 9 | { 10 | public class ColorToBrushConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, string language) 13 | { 14 | var color = Colors.Transparent; 15 | 16 | var rgb = value as Color.RGB; 17 | 18 | if (rgb != null) 19 | { 20 | color = rgb.ToSystemColor(255); 21 | } 22 | else if (value is WinColor) 23 | { 24 | color = (WinColor) value; 25 | } 26 | 27 | 28 | return new SolidColorBrush(color); 29 | } 30 | 31 | public object ConvertBack(object value, Type targetType, object parameter, string language) 32 | { 33 | throw new NotSupportedException(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Converters/StringFormatConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using Windows.UI.Xaml.Data; 6 | 7 | namespace Spectrum.Demo.Converters 8 | { 9 | public class StringFormatConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, string language) 12 | { 13 | parameter = parameter ?? "{0}"; 14 | 15 | return String.Format(CultureInfo.CurrentUICulture, parameter.ToString(), value); 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, string language) 19 | { 20 | throw new NotSupportedException(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Extensions/ComparableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Extensions 4 | { 5 | public static class ComparableExtensions 6 | { 7 | public static T Clamp(this T value, T minimum, T maximum) 8 | where T : IComparable 9 | { 10 | if (value.CompareTo(minimum) < 0) 11 | return minimum; 12 | 13 | if (value.CompareTo(maximum) > 0) 14 | return maximum; 15 | 16 | return value; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Extensions/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace Spectrum.Demo.Extensions 7 | { 8 | public static class EnumerableExtensions 9 | { 10 | public static bool None(this IEnumerable values) 11 | { 12 | return !values.Any(); 13 | } 14 | 15 | public static bool None(this IEnumerable values, Func predicate) 16 | { 17 | return !values.Any(predicate); 18 | } 19 | 20 | public static async Task> SelectAsync(this IEnumerable values, Func> asyncSelector) 21 | { 22 | return await Task.WhenAll(values.Select(asyncSelector)); 23 | } 24 | 25 | public static async Task WhenAllAsync(this IEnumerable values, Func asyncMethod) 26 | { 27 | await Task.WhenAll(values.Select(asyncMethod)); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Extensions/StoryboardExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Windows.UI.Xaml.Media.Animation; 4 | 5 | namespace Spectrum.Demo.Extensions 6 | { 7 | public static class StoryboardExtensions 8 | { 9 | public static Task BeginAsync(this Storyboard storyboard) 10 | { 11 | var taskSource = new TaskCompletionSource(); 12 | 13 | EventHandler completed = null; 14 | 15 | completed += (s, e) => 16 | { 17 | storyboard.Completed -= completed; 18 | 19 | taskSource.SetResult(null); 20 | }; 21 | 22 | storyboard.Completed += completed; 23 | 24 | storyboard.Begin(); 25 | 26 | return taskSource.Task; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Resources/Fonts/Lobster-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Shared/Resources/Fonts/Lobster-Regular.ttf -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Resources/Styles.Shared.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | /Resources/Fonts/Lobster-Regular.ttf#Lobster 6 | 7 | 8 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/AppSettingsService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Windows.Storage; 5 | 6 | namespace Spectrum.Demo.Services 7 | { 8 | public class AppSettingsService : IAppSettingsService 9 | { 10 | private readonly ApplicationDataContainer roamingSettings; 11 | private ApplicationDataContainer localSettings; 12 | 13 | public AppSettingsService() 14 | { 15 | roamingSettings = ApplicationData.Current.RoamingSettings; 16 | localSettings = ApplicationData.Current.LocalSettings; 17 | } 18 | 19 | public bool StorageInitialised 20 | { 21 | get 22 | { 23 | if (!roamingSettings.Values.ContainsKey("StorageInitialised")) 24 | return false; 25 | 26 | return (bool) roamingSettings.Values["StorageInitialised"]; 27 | } 28 | set { roamingSettings.Values["StorageInitialised"] = value; } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/BitmapService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Windows.Graphics.Imaging; 4 | using Windows.Storage; 5 | using Windows.UI.Xaml.Media.Imaging; 6 | using Spectrum.Universal; 7 | using WinRTXamlToolkit.Imaging; 8 | 9 | namespace Spectrum.Demo.Services 10 | { 11 | public class BitmapService : IBitmapService 12 | { 13 | public async Task CreateSchemeBitmapAsync(Scheme scheme, TileSize size) 14 | { 15 | var width = size == TileSize.Square ? 150 : 310; 16 | 17 | var bitmap = new WriteableBitmap(width, 150); 18 | 19 | var columnWidth = width / scheme.Colours.Count; 20 | 21 | var x = 0; 22 | 23 | for (int i = 0; i < scheme.Colours.Count; i++) 24 | { 25 | var colour = scheme.Colours[i]; 26 | 27 | if (i == scheme.Colours.Count - 1) // last column 28 | columnWidth = width - ((scheme.Colours.Count - 1) * columnWidth); 29 | 30 | bitmap.FillRectangle(x, 0, x + columnWidth, 150, colour.ToSystemColor(255)); 31 | 32 | x += columnWidth; 33 | } 34 | 35 | var file = await CreateImageFileAsync(scheme, size); 36 | 37 | await bitmap.SaveToFile(file, BitmapEncoder.PngEncoderId); 38 | 39 | return String.Format("ms-appdata:///local/{0}", file.Name); 40 | } 41 | 42 | private Task CreateImageFileAsync(Scheme scheme, TileSize size) 43 | { 44 | var filename = String.Format("{0:N}-{1}.png", scheme.Id, size); 45 | 46 | return ApplicationData.Current.LocalFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting).AsTask(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/ColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using Newtonsoft.Json; 5 | 6 | namespace Spectrum.Demo.Services 7 | { 8 | public class ColorConverter : JsonConverter 9 | { 10 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 11 | { 12 | if (value == null) 13 | return; 14 | 15 | var colours = (IList) value; 16 | 17 | writer.WriteStartArray(); 18 | 19 | foreach (var colour in colours) 20 | { 21 | writer.WriteValue(colour.ToHexString()); 22 | } 23 | 24 | writer.WriteEndArray(); 25 | } 26 | 27 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 28 | { 29 | var colours = new List(); 30 | 31 | if (reader.TokenType != JsonToken.StartArray) 32 | return colours; 33 | 34 | reader.Read(); 35 | 36 | while (reader.TokenType != JsonToken.EndArray) 37 | { 38 | colours.Add(new Color.RGB(reader.Value.ToString())); 39 | 40 | reader.Read(); 41 | } 42 | 43 | return colours; 44 | } 45 | 46 | public override bool CanConvert(Type objectType) 47 | { 48 | var colorTypeInfo = typeof (IList).GetTypeInfo(); 49 | var objectTypeInfo = objectType.GetTypeInfo(); 50 | 51 | return colorTypeInfo.IsAssignableFrom(objectTypeInfo); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/IAppSettingsService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Services 4 | { 5 | public interface IAppSettingsService 6 | { 7 | bool StorageInitialised { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/IBitmapService.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Spectrum.Demo.Services 4 | { 5 | public interface IBitmapService 6 | { 7 | Task CreateSchemeBitmapAsync(Scheme scheme, TileSize size); 8 | } 9 | } -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/ISchemeStorageService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace Spectrum.Demo.Services 5 | { 6 | public interface ISchemeStorageService 7 | { 8 | Task> GetSchemesAsync(); 9 | Task SaveSchemeAsync(Scheme scheme, bool enqueueTile = true); 10 | Task DeleteSchemeAsync(Scheme scheme); 11 | } 12 | } -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/ITileService.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Spectrum.Demo.Services 4 | { 5 | public interface ITileService 6 | { 7 | void Initialise(); 8 | Task EnqueueSchemeTileAsync(Scheme scheme); 9 | } 10 | } -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/IWindowManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace Spectrum.Demo.Services 5 | { 6 | public interface IWindowManager 7 | { 8 | Task ShowDialogAsync(object rootModel, object context = null, IDictionary settings = null); 9 | } 10 | } -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/Scheme.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Spectrum.Demo.Services 6 | { 7 | public class Scheme 8 | { 9 | public Scheme() 10 | { 11 | Id = Guid.NewGuid(); 12 | Colours = new List(); 13 | } 14 | 15 | public Guid Id 16 | { 17 | get; set; 18 | } 19 | 20 | public string Name 21 | { 22 | get; set; 23 | } 24 | 25 | public SchemeType Type 26 | { 27 | get; set; 28 | } 29 | 30 | public DateTimeOffset CreatedOn 31 | { 32 | get; set; 33 | } 34 | 35 | [JsonConverter(typeof(ColorConverter))] 36 | public IList Colours 37 | { 38 | get; set; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/SchemeStorageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Windows.Storage; 7 | using Newtonsoft.Json; 8 | using Spectrum.Demo.Extensions; 9 | 10 | namespace Spectrum.Demo.Services 11 | { 12 | public class SchemeStorageService : ISchemeStorageService 13 | { 14 | private readonly ITileService tileService; 15 | private readonly IAppSettingsService appSettingsService; 16 | private IList cachedSchemes; 17 | 18 | public SchemeStorageService(ITileService tileService, IAppSettingsService appSettingsService) 19 | { 20 | this.tileService = tileService; 21 | this.appSettingsService = appSettingsService; 22 | } 23 | 24 | public async Task> GetSchemesAsync() 25 | { 26 | if (cachedSchemes != null) 27 | return new ReadOnlyCollection(cachedSchemes); 28 | 29 | cachedSchemes = new List(); 30 | 31 | if (!appSettingsService.StorageInitialised) 32 | { 33 | await CreateDemoDataAsync(); 34 | 35 | appSettingsService.StorageInitialised = true; 36 | } 37 | 38 | var roamingFiles = await ApplicationData.Current.RoamingFolder.GetFilesAsync(); 39 | 40 | cachedSchemes = (await roamingFiles 41 | .Where(f => f.FileType == ".scheme") 42 | .SelectAsync(DeserializeFileAsync)) 43 | .OrderBy(s => s.Name) 44 | .ToList(); 45 | 46 | return new ReadOnlyCollection(cachedSchemes); 47 | } 48 | 49 | private async Task CreateDemoDataAsync() 50 | { 51 | await SaveSchemeAsync(new Scheme 52 | { 53 | Name = "Aspirin C", 54 | CreatedOn = DateTimeOffset.Now, 55 | Type = SchemeType.Custom, 56 | Colours = new List 57 | { 58 | new Color.RGB("225378"), 59 | new Color.RGB("1695A3"), 60 | new Color.RGB("ACF0F2"), 61 | new Color.RGB("F3FFE2"), 62 | new Color.RGB("EB7F00") 63 | } 64 | }, enqueueTile: false); 65 | 66 | await SaveSchemeAsync(new Scheme 67 | { 68 | Name = "Cherry Cheesecake", 69 | CreatedOn = DateTimeOffset.Now, 70 | Type = SchemeType.Custom, 71 | Colours = new List 72 | { 73 | new Color.RGB("B9121B"), 74 | new Color.RGB("4C1B1B"), 75 | new Color.RGB("F6E497"), 76 | new Color.RGB("FCFAE1"), 77 | new Color.RGB("BD8D46") 78 | } 79 | }, enqueueTile: false); 80 | 81 | await SaveSchemeAsync(new Scheme 82 | { 83 | Name = "Quiet Cry", 84 | CreatedOn = DateTimeOffset.Now, 85 | Type = SchemeType.Custom, 86 | Colours = new List 87 | { 88 | new Color.RGB("1C1D21"), 89 | new Color.RGB("31353D"), 90 | new Color.RGB("445878"), 91 | new Color.RGB("92CDCF"), 92 | new Color.RGB("EEEFF7") 93 | } 94 | }, enqueueTile: false); 95 | 96 | await SaveSchemeAsync(new Scheme 97 | { 98 | Name = "Sandy Stone", 99 | CreatedOn = DateTimeOffset.Now, 100 | Type = SchemeType.Custom, 101 | Colours = new List 102 | { 103 | new Color.RGB("E6E2AF"), 104 | new Color.RGB("A7A37E"), 105 | new Color.RGB("EFECCA"), 106 | new Color.RGB("046380"), 107 | new Color.RGB("002F2F") 108 | } 109 | }, enqueueTile: false); 110 | } 111 | 112 | public async Task SaveSchemeAsync(Scheme scheme, bool enqueueTile = true) 113 | { 114 | if (!cachedSchemes.Contains(scheme)) 115 | cachedSchemes.Add(scheme); 116 | 117 | var file = await ApplicationData.Current.RoamingFolder.CreateFileAsync(String.Format("{0:N}.scheme", scheme.Id), CreationCollisionOption.ReplaceExisting); 118 | 119 | var json = JsonConvert.SerializeObject(scheme); 120 | 121 | await FileIO.WriteTextAsync(file, json); 122 | 123 | if (enqueueTile) 124 | await tileService.EnqueueSchemeTileAsync(scheme); 125 | } 126 | 127 | public async Task DeleteSchemeAsync(Scheme scheme) 128 | { 129 | if (cachedSchemes.Contains(scheme)) 130 | cachedSchemes.Remove(scheme); 131 | 132 | var file = await ApplicationData.Current.RoamingFolder.CreateFileAsync(String.Format("{0:N}.scheme", scheme.Id), CreationCollisionOption.OpenIfExists); 133 | 134 | await file.DeleteAsync(); 135 | } 136 | 137 | private async Task DeserializeFileAsync(StorageFile file) 138 | { 139 | var json = await FileIO.ReadTextAsync(file); 140 | 141 | return JsonConvert.DeserializeObject(json); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/SchemeType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Services 4 | { 5 | public enum SchemeType 6 | { 7 | Custom, 8 | Monochromatic, 9 | Analogous, 10 | Triad, 11 | Complimentary 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/TileService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Windows.UI.Notifications; 4 | using NotificationsExtensions.TileContent; 5 | 6 | namespace Spectrum.Demo.Services 7 | { 8 | public class TileService : ITileService 9 | { 10 | private readonly IBitmapService bitmapService; 11 | 12 | public TileService(IBitmapService bitmapService) 13 | { 14 | this.bitmapService = bitmapService; 15 | } 16 | 17 | public void Initialise() 18 | { 19 | var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); 20 | 21 | tileUpdater.EnableNotificationQueue(true); 22 | } 23 | 24 | private void EnsureDefaultTile() 25 | { 26 | var wideTile = TileContentFactory.CreateTileWide310x150Image(); 27 | var squareTile = TileContentFactory.CreateTileSquare150x150Image(); 28 | 29 | wideTile.Square150x150Content = squareTile; 30 | 31 | squareTile.Branding = TileBranding.Name; 32 | squareTile.Image.Src = "ms-appx:///resources/images/square150.png"; 33 | 34 | wideTile.Branding = TileBranding.Name; 35 | wideTile.Image.Src = "ms-appx:///resources/images/wide.png"; 36 | 37 | var notification = wideTile.CreateNotification(); 38 | 39 | notification.Tag = "default"; 40 | 41 | var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); 42 | 43 | tileUpdater.Update(notification); 44 | } 45 | 46 | public async Task EnqueueSchemeTileAsync(Scheme scheme) 47 | { 48 | var wideImage = await bitmapService.CreateSchemeBitmapAsync(scheme, TileSize.Wide); 49 | var squareImage = await bitmapService.CreateSchemeBitmapAsync(scheme, TileSize.Square); 50 | 51 | var wideTile = TileContentFactory.CreateTileWide310x150ImageAndText01(); 52 | var squareTile = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); 53 | 54 | wideTile.Square150x150Content = squareTile; 55 | 56 | squareTile.Branding = TileBranding.None; 57 | squareTile.Image.Src = squareImage; 58 | squareTile.TextHeading.Text = scheme.Name; 59 | 60 | wideTile.Branding = TileBranding.None; 61 | wideTile.Image.Src = wideImage; 62 | wideTile.TextCaptionWrap.Text = scheme.Name; 63 | 64 | var notification = wideTile.CreateNotification(); 65 | 66 | notification.Tag = scheme.Id.GetHashCode().ToString(); 67 | 68 | var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); 69 | 70 | tileUpdater.Update(notification); 71 | 72 | EnsureDefaultTile(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Services/TileSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Services 4 | { 5 | public enum TileSize 6 | { 7 | Square, 8 | Wide 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Spectrum.Demo.Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 6f62bcce-2510-459f-b15a-4ea0fe5f73eb 7 | 8 | 9 | Spectrum.Demo 10 | 11 | 12 | 13 | Designer 14 | 15 | 16 | App.xaml 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | EditColourView.xaml 54 | 55 | 56 | 57 | SaveSchemeView.xaml 58 | 59 | 60 | SchemeView.xaml 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Designer 69 | MSBuild:Compile 70 | 71 | 72 | Designer 73 | MSBuild:Compile 74 | 75 | 76 | Designer 77 | MSBuild:Compile 78 | 79 | 80 | Designer 81 | MSBuild:Compile 82 | 83 | 84 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Spectrum.Demo.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6f62bcce-2510-459f-b15a-4ea0fe5f73eb 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/AnalogousSchemeEditorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Spectrum.Demo.Services; 5 | using Spectrum.Universal; 6 | 7 | namespace Spectrum.Demo.ViewModels.Editors 8 | { 9 | public class AnalogousSchemeEditorViewModel : SingleColorSchemeEditorViewModelBase 10 | { 11 | public AnalogousSchemeEditorViewModel(IWindowManager windowManager) 12 | : base(windowManager) 13 | { 14 | 15 | } 16 | 17 | public override IEnumerable GetColours() 18 | { 19 | var rgb = CurrentColor.Color.FromSystemColor(); 20 | var hsl = rgb.ToHSL(); 21 | 22 | return new[] 23 | { 24 | hsl.ShiftHue(-30).ToRGB(), 25 | hsl.ShiftHue(15).ToRGB(), 26 | rgb, 27 | hsl.ShiftHue(15).ToRGB(), 28 | hsl.ShiftHue(30).ToRGB(), 29 | }; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/ColourViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | using PropertyChanged; 4 | using Spectrum.Universal; 5 | using WinColor = Windows.UI.Color; 6 | 7 | namespace Spectrum.Demo.ViewModels.Editors 8 | { 9 | public class ColourViewModel : PropertyChangedBase 10 | { 11 | public WinColor Color 12 | { 13 | get; set; 14 | } 15 | 16 | [DependsOn("Color")] 17 | public string Description 18 | { 19 | get { return Color.FromSystemColor().ToHexString(); } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/ComplimentarySchemeEditorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Spectrum.Demo.Services; 4 | using Spectrum.Universal; 5 | 6 | namespace Spectrum.Demo.ViewModels.Editors 7 | { 8 | public class ComplimentarySchemeEditorViewModel : SingleColorSchemeEditorViewModelBase 9 | { 10 | public ComplimentarySchemeEditorViewModel(IWindowManager windowManager) 11 | : base(windowManager) 12 | { 13 | 14 | } 15 | 16 | public override IEnumerable GetColours() 17 | { 18 | var rgb = CurrentColor.Color.FromSystemColor(); 19 | var hsl = rgb.ToHSL(); 20 | 21 | return new[] 22 | { 23 | hsl.ShiftHue(180).ToRGB(), 24 | hsl.ShiftHue(180).ShiftLightness(0.05).ToRGB(), 25 | rgb, 26 | hsl.ShiftLightness(0.05).ToRGB(), 27 | hsl.ShiftLightness(0.1).ToRGB(), 28 | }; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/CustomSchemeEditorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Windows.UI; 5 | using Caliburn.Micro; 6 | using Spectrum.Demo.Services; 7 | using Spectrum.Universal; 8 | using WinColor = Windows.UI.Color; 9 | 10 | namespace Spectrum.Demo.ViewModels.Editors 11 | { 12 | public class CustomSchemeEditorViewModel : SchemeEditorViewModelBase 13 | { 14 | public CustomSchemeEditorViewModel(IWindowManager windowManager) 15 | : base(windowManager) 16 | 17 | { 18 | Colors = new BindableCollection(); 19 | Colors.CollectionChanged += (s, e) => NotifyOfPropertyChange(() => CanSave); 20 | } 21 | 22 | public BindableCollection Colors 23 | { 24 | get; private set; 25 | } 26 | 27 | public void Add(WinColor color) 28 | { 29 | Colors.Add(new ColourViewModel { Color = color }); 30 | } 31 | 32 | public void Remove(ColourViewModel color) 33 | { 34 | Colors.Remove(color); 35 | } 36 | 37 | public override IEnumerable GetColours() 38 | { 39 | return Colors.Select(c => c.Color.FromSystemColor()); 40 | } 41 | 42 | public override void SetColors(IEnumerable colours) 43 | { 44 | Colors.AddRange(colours.Select(c => new ColourViewModel { Color = c.ToSystemColor(255) })); 45 | } 46 | 47 | public override bool CanSave 48 | { 49 | get { return Colors.Any(); } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/EditColourViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | using PropertyChanged; 4 | 5 | namespace Spectrum.Demo.ViewModels.Editors 6 | { 7 | public class EditColourViewModel : Screen 8 | { 9 | public EditColourViewModel(Color.RGB colour) 10 | { 11 | var hsl = colour.ToHSL(); 12 | 13 | Hue = hsl.H; 14 | Saturation = hsl.S; 15 | Lightness = hsl.L; 16 | } 17 | 18 | [DependsOn("Hue", "Saturation", "Lightness")] 19 | public Color.RGB Colour 20 | { 21 | get 22 | { 23 | return new Color.HSL(Hue, Saturation, Lightness).ToRGB(); 24 | } 25 | } 26 | 27 | public double Hue 28 | { 29 | get; set; 30 | } 31 | 32 | public double Saturation 33 | { 34 | get; set; 35 | } 36 | 37 | public double Lightness 38 | { 39 | get; set; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/MonochromeSchemeEditorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Spectrum.Demo.Services; 5 | using Spectrum.Universal; 6 | using WinColor = Windows.UI.Color; 7 | 8 | namespace Spectrum.Demo.ViewModels.Editors 9 | { 10 | public class MonochromeSchemeEditorViewModel : SingleColorSchemeEditorViewModelBase 11 | { 12 | public MonochromeSchemeEditorViewModel(IWindowManager windowManager) 13 | : base(windowManager) 14 | { 15 | 16 | } 17 | 18 | public override IEnumerable GetColours() 19 | { 20 | var rgb = CurrentColor.Color.FromSystemColor(); 21 | var hsl = rgb.ToHSL(); 22 | 23 | return new[] 24 | { 25 | hsl.ShiftLightness(-0.2).ToRGB(), 26 | hsl.ShiftLightness(-0.1).ToRGB(), 27 | rgb, 28 | hsl.ShiftLightness(0.1).ToRGB(), 29 | hsl.ShiftLightness(0.2).ToRGB(), 30 | }; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/SchemeEditorViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Caliburn.Micro; 4 | using Spectrum.Demo.Services; 5 | using Spectrum.Universal; 6 | using WinColor = Windows.UI.Color; 7 | 8 | namespace Spectrum.Demo.ViewModels.Editors 9 | { 10 | public abstract class SchemeEditorViewModelBase : Screen 11 | { 12 | private readonly IWindowManager windowManager; 13 | 14 | protected SchemeEditorViewModelBase(IWindowManager windowManager) 15 | { 16 | this.windowManager = windowManager; 17 | } 18 | 19 | public abstract IEnumerable GetColours(); 20 | 21 | public async void Edit(ColourViewModel color) 22 | { 23 | var editColourViewModel = new EditColourViewModel(color.Color.FromSystemColor()); 24 | 25 | var confirmed = await windowManager.ShowDialogAsync(editColourViewModel, settings: new Dictionary 26 | { 27 | { "Title", "Edit Color"}, 28 | { "IsPrimaryButtonEnabled", true }, 29 | { "PrimaryButtonText", "save" }, 30 | { "IsSecondaryButtonEnabled", true }, 31 | { "SecondaryButtonText", "cancel" }, 32 | { "FullSizeDesired", false } 33 | }); 34 | 35 | if (!confirmed) 36 | return; 37 | 38 | color.Color = editColourViewModel.Colour.ToSystemColor(255); 39 | } 40 | 41 | public abstract void SetColors(IEnumerable colours); 42 | 43 | public abstract bool CanSave { get; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/SingleColorSchemeEditorViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Spectrum.Demo.Services; 5 | using Spectrum.Universal; 6 | 7 | namespace Spectrum.Demo.ViewModels.Editors 8 | { 9 | public abstract class SingleColorSchemeEditorViewModelBase : SchemeEditorViewModelBase 10 | { 11 | protected SingleColorSchemeEditorViewModelBase(IWindowManager windowManager) 12 | : base(windowManager) 13 | { 14 | var random = new Random(); 15 | 16 | var hue = random.Next(0, 360); 17 | 18 | var hsl = new Color.HSL(hue, 0.5d, 0.5d); 19 | 20 | CurrentColor = new ColourViewModel { Color =hsl.ToRGB().ToSystemColor(255) }; 21 | 22 | CurrentHue = hsl.H; 23 | CurrentSaturation = hsl.S; 24 | CurrentLuminosity = hsl.L; 25 | } 26 | 27 | public double CurrentHue 28 | { 29 | get; 30 | set; 31 | } 32 | 33 | public double CurrentSaturation 34 | { 35 | get; 36 | set; 37 | } 38 | 39 | public double CurrentLuminosity 40 | { 41 | get; 42 | set; 43 | } 44 | 45 | public ColourViewModel CurrentColor 46 | { 47 | get; 48 | set; 49 | } 50 | 51 | public void UpdateColor() 52 | { 53 | CurrentColor.Color = new Color.HSL(CurrentHue, CurrentSaturation, CurrentLuminosity) 54 | .ToRGB() 55 | .ToSystemColor(255); 56 | } 57 | 58 | public override void SetColors(IEnumerable colours) 59 | { 60 | CurrentColor = new ColourViewModel { Color = colours.ElementAt(2).ToSystemColor(255) }; 61 | } 62 | 63 | public override bool CanSave 64 | { 65 | get { return true; } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/Editors/TriadSchemeEditorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Spectrum.Demo.Services; 5 | using Spectrum.Universal; 6 | 7 | namespace Spectrum.Demo.ViewModels.Editors 8 | { 9 | public class TriadSchemeEditorViewModel : SingleColorSchemeEditorViewModelBase 10 | { 11 | public TriadSchemeEditorViewModel(IWindowManager windowManager) 12 | : base(windowManager) 13 | { 14 | 15 | } 16 | 17 | public override IEnumerable GetColours() 18 | { 19 | var rgb = CurrentColor.Color.FromSystemColor(); 20 | var hsl = rgb.ToHSL(); 21 | 22 | return new[] 23 | { 24 | hsl.ShiftHue(-120).ToRGB(), 25 | hsl.ShiftHue(120).ToRGB(), 26 | rgb, 27 | hsl.ShiftLightness(0.05).ToRGB(), 28 | hsl.ShiftLightness(0.1).ToRGB(), 29 | }; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/SaveSchemeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | 4 | namespace Spectrum.Demo.ViewModels 5 | { 6 | public class SaveSchemeViewModel : Screen 7 | { 8 | public string Name 9 | { 10 | get; set; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/SchemeListViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Caliburn.Micro; 5 | using Spectrum.Demo.Services; 6 | 7 | namespace Spectrum.Demo.ViewModels 8 | { 9 | public class SchemeListViewModel : Screen 10 | { 11 | private readonly INavigationService navigation; 12 | private readonly ISchemeStorageService schemeStorage; 13 | 14 | public SchemeListViewModel(INavigationService navigation, ISchemeStorageService schemeStorage) 15 | { 16 | this.navigation = navigation; 17 | this.schemeStorage = schemeStorage; 18 | 19 | Schemes = new BindableCollection(); 20 | } 21 | 22 | protected override async void OnInitialize() 23 | { 24 | var schemes = await schemeStorage.GetSchemesAsync(); 25 | 26 | Schemes.AddRange(schemes.Select(s => new SchemeViewModel(s))); 27 | } 28 | 29 | public void Create() 30 | { 31 | navigation.UriFor() 32 | .Navigate(); 33 | } 34 | 35 | public void View(SchemeViewModel schemeViewModel) 36 | { 37 | navigation.UriFor() 38 | .WithParam(v => v.Id, schemeViewModel.Scheme.Id) 39 | .Navigate(); 40 | } 41 | 42 | public BindableCollection Schemes 43 | { 44 | get; private set; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/SchemeTypeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Caliburn.Micro; 4 | using Spectrum.Demo.Services; 5 | using Spectrum.Demo.ViewModels.Editors; 6 | 7 | namespace Spectrum.Demo.ViewModels 8 | { 9 | public class SchemeTypeViewModel : PropertyChangedBase 10 | { 11 | private readonly SchemeType _type; 12 | private readonly SchemeEditorViewModelBase _editor; 13 | 14 | public SchemeTypeViewModel(SchemeType type, SchemeEditorViewModelBase editor) 15 | { 16 | _type = type; 17 | _editor = editor; 18 | } 19 | 20 | public SchemeType Type 21 | { 22 | get { return _type; } 23 | } 24 | 25 | public SchemeEditorViewModelBase Editor 26 | { 27 | get { return _editor; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/ViewModels/SchemeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | using Spectrum.Demo.Services; 4 | 5 | namespace Spectrum.Demo.ViewModels 6 | { 7 | public class SchemeViewModel : PropertyChangedBase 8 | { 9 | private readonly Scheme scheme; 10 | 11 | public SchemeViewModel(Scheme scheme) 12 | { 13 | this.scheme = scheme; 14 | } 15 | 16 | public Scheme Scheme 17 | { 18 | get { return scheme; } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/Editors/EditColourView.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/Editors/EditColourView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 17 | 18 | namespace Spectrum.Demo.Views.Editors 19 | { 20 | public sealed partial class EditColourView : UserControl 21 | { 22 | public EditColourView() 23 | { 24 | this.InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/Editors/IColourView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Views.Editors 4 | { 5 | public interface IColourView 6 | { 7 | bool DisplayOverlay { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/SaveSchemeView.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/SaveSchemeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 17 | 18 | namespace Spectrum.Demo.Views 19 | { 20 | public sealed partial class SaveSchemeView : UserControl 21 | { 22 | public SaveSchemeView() 23 | { 24 | this.InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/SchemeView.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Shared/Views/SchemeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Views 4 | { 5 | public sealed partial class SchemeView 6 | { 7 | public SchemeView() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/BundleArtifacts/neutral.txt: -------------------------------------------------------------------------------- 1 | MainPackage=D:\Dev\GitHub\Spectrum\Spectrum.Demo\Spectrum.Demo.Windows\bin\Release\Spectrum.Demo.Windows_1.1.0.2_Bundle\Spectrum.Demo.Windows_1.1.0.2_AnyCPU.appx 2 | SymbolPackage=D:\Software\Packages\Spectrum.Demo.Windows_1.1.0.2_Test\Spectrum.Demo.Windows_1.1.0.2_AnyCPU.appxsym 3 | ResourcePack=D:\Dev\GitHub\Spectrum\Spectrum.Demo\Spectrum.Demo.Windows\bin\Release\Spectrum.Demo.Windows_1.1.0.2_Bundle\Spectrum.Demo.Windows_1.1.0.2_scale-140.appx 4 | ResourcePack=D:\Dev\GitHub\Spectrum\Spectrum.Demo\Spectrum.Demo.Windows\bin\Release\Spectrum.Demo.Windows_1.1.0.2_Bundle\Spectrum.Demo.Windows_1.1.0.2_scale-180.appx 5 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Controls/DialogAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Controls 4 | { 5 | public enum DialogAction 6 | { 7 | Primary, 8 | Secondary, 9 | Other 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Controls/DialogContentControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml; 3 | using Windows.UI.Xaml.Controls; 4 | using Windows.UI.Xaml.Controls.Primitives; 5 | 6 | namespace Spectrum.Demo.Controls 7 | { 8 | [TemplatePart(Type = typeof(FrameworkElement), Name = BackgroundElementName)] 9 | [TemplatePart(Type = typeof(ButtonBase), Name = PrimaryButtonName)] 10 | [TemplatePart(Type = typeof(ButtonBase), Name = SecondaryButtonName)] 11 | public class DialogContentControl : ContentControl 12 | { 13 | private const string BackgroundElementName = "BackgroundElement"; 14 | private const string PrimaryButtonName = "PrimaryButton"; 15 | private const string SecondaryButtonName = "SecondaryButton"; 16 | 17 | public static readonly DependencyProperty TitleProperty = 18 | DependencyProperty.Register("Title", typeof (string), typeof (DialogContentControl), new PropertyMetadata(default(string))); 19 | 20 | public static readonly DependencyProperty PrimaryButtonTextProperty = 21 | DependencyProperty.Register("PrimaryButtonText", typeof (string), typeof (DialogContentControl), new PropertyMetadata(default(string))); 22 | 23 | public static readonly DependencyProperty SecondaryButtonTextProperty = 24 | DependencyProperty.Register("SecondaryButtonText", typeof (string), typeof (DialogContentControl), new PropertyMetadata(default(string))); 25 | 26 | public DialogContentControl() 27 | { 28 | DefaultStyleKey = typeof(DialogContentControl); 29 | } 30 | 31 | public string Title 32 | { 33 | get { return (string)GetValue(TitleProperty); } 34 | set { SetValue(TitleProperty, value); } 35 | } 36 | 37 | public string SecondaryButtonText 38 | { 39 | get { return (string)GetValue(SecondaryButtonTextProperty); } 40 | set { SetValue(SecondaryButtonTextProperty, value); } 41 | } 42 | 43 | public string PrimaryButtonText 44 | { 45 | get { return (string)GetValue(PrimaryButtonTextProperty); } 46 | set { SetValue(PrimaryButtonTextProperty, value); } 47 | } 48 | 49 | public event EventHandler Dismissed; 50 | 51 | protected virtual void OnDismissed(DialogDismissedEventArgs e) 52 | { 53 | var dismissed = Dismissed; 54 | 55 | if (dismissed != null) 56 | dismissed(this, e); 57 | } 58 | 59 | protected override void OnApplyTemplate() 60 | { 61 | base.OnApplyTemplate(); 62 | 63 | var backgroundElement = GetTemplateChild(BackgroundElementName) as FrameworkElement; 64 | 65 | if (backgroundElement != null) 66 | { 67 | backgroundElement.Tapped += (s, e) => OnDismissed(new DialogDismissedEventArgs(DialogAction.Other)); 68 | } 69 | 70 | var primaryButton = GetTemplateChild(PrimaryButtonName) as ButtonBase; 71 | 72 | if (primaryButton != null) 73 | { 74 | primaryButton.Click += (s, e) => OnDismissed(new DialogDismissedEventArgs(DialogAction.Primary)); 75 | } 76 | 77 | var secondaryButton = GetTemplateChild(SecondaryButtonName) as ButtonBase; 78 | 79 | if (secondaryButton != null) 80 | { 81 | secondaryButton.Click += (s, e) => OnDismissed(new DialogDismissedEventArgs(DialogAction.Secondary)); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Controls/DialogDismissedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Spectrum.Demo.Controls 4 | { 5 | public class DialogDismissedEventArgs : EventArgs 6 | { 7 | private readonly DialogAction action; 8 | 9 | public DialogDismissedEventArgs(DialogAction action) 10 | { 11 | this.action = action; 12 | } 13 | 14 | public DialogAction Action 15 | { 16 | get { return action; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Spectrum Scheme 6 | Compiled Experience 7 | Resources\Images\Square50.png 8 | 9 | 10 | 6.3.0 11 | 6.3.0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/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("Spectrum.Demo.Windows")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Spectrum.Demo.Windows")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Splash.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Splash.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Splash.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Splash.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Splash.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Splash.scale-180.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square150.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square150.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square150.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square150.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square150.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square150.scale-180.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square30.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square30.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square30.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square30.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square30.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square30.scale-180.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square50.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square50.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square50.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square50.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square50.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square50.scale-180.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square70.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square70.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square70.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square70.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square70.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Square70.scale-180.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Wide.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Wide.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Wide.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Wide.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Wide.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.Windows/Resources/Images/Wide.scale-180.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Services/WindowManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Threading.Tasks; 5 | using Windows.UI.Xaml; 6 | using Windows.UI.Xaml.Controls; 7 | using Windows.UI.Xaml.Controls.Primitives; 8 | using Caliburn.Micro; 9 | using Spectrum.Demo.Controls; 10 | 11 | namespace Spectrum.Demo.Services 12 | { 13 | public class WindowManager : IWindowManager 14 | { 15 | public virtual Task ShowDialogAsync(object rootModel, object context = null, IDictionary settings = null) 16 | { 17 | var taskSource = new TaskCompletionSource(); 18 | 19 | var view = LocateAndBindView(rootModel, context); 20 | 21 | var popup = CreatePopup(view, settings); 22 | var dialog = (DialogContentControl) popup.Child; 23 | 24 | var page = GetCurrentPage(); 25 | 26 | ManageHostPage(page, popup, opening: true); 27 | 28 | EventHandler closed = null; 29 | 30 | closed = (s, o) => 31 | { 32 | DeactivateViewModel(rootModel); 33 | 34 | ManageHostPage(page, popup, opening: false); 35 | 36 | taskSource.SetResult(o.Action == DialogAction.Primary); 37 | 38 | dialog.Dismissed -= closed; 39 | }; 40 | 41 | dialog.Dismissed += closed; 42 | 43 | ActivateViewModel(rootModel); 44 | 45 | return taskSource.Task; 46 | } 47 | 48 | private static void ManageHostPage(Page page, Popup popup, bool opening) 49 | { 50 | if (page == null) 51 | return; 52 | 53 | var panel = page.Content as Panel; 54 | 55 | if (panel != null) 56 | { 57 | if (opening) 58 | panel.Children.Add(popup); 59 | else 60 | { 61 | panel.Children.Remove(popup); 62 | } 63 | } 64 | 65 | } 66 | 67 | private static void DeactivateViewModel(object rootModel) 68 | { 69 | var deactivateViewModel = rootModel as IDeactivate; 70 | 71 | if (deactivateViewModel != null) 72 | deactivateViewModel.Deactivate(true); 73 | } 74 | 75 | private static void ActivateViewModel(object rootModel) 76 | { 77 | var activateViewModel = rootModel as IActivate; 78 | 79 | if (activateViewModel != null) 80 | activateViewModel.Activate(); 81 | } 82 | 83 | private Popup CreatePopup(UIElement view, IEnumerable> settings) 84 | { 85 | var dialogContent = new DialogContentControl 86 | { 87 | Content = view, 88 | Width = Window.Current.Bounds.Width, 89 | Height = Window.Current.Bounds.Height, 90 | }; 91 | 92 | ApplySettings(dialogContent, settings); 93 | 94 | var popup = new Popup 95 | { 96 | Child = dialogContent, 97 | IsLightDismissEnabled = false, 98 | IsOpen = true, 99 | HorizontalOffset = 0.0d, 100 | VerticalOffset = 0.0d 101 | }; 102 | 103 | dialogContent.Dismissed += (s, e) => popup.IsOpen = false; 104 | 105 | return popup; 106 | } 107 | 108 | private static UIElement LocateAndBindView(object rootModel, object context) 109 | { 110 | var view = ViewLocator.LocateForModel(rootModel, null, context); 111 | 112 | ViewModelBinder.Bind(rootModel, view, context); 113 | 114 | return view; 115 | } 116 | 117 | protected virtual bool ApplySettings(object target, IEnumerable> settings) 118 | { 119 | if (settings != null) 120 | { 121 | var type = target.GetType(); 122 | 123 | foreach (var pair in settings) 124 | { 125 | var propertyInfo = type.GetRuntimeProperty(pair.Key); 126 | 127 | if (propertyInfo != null) 128 | { 129 | propertyInfo.SetValue(target, pair.Value, null); 130 | } 131 | } 132 | 133 | return true; 134 | } 135 | 136 | return false; 137 | } 138 | 139 | protected virtual Page GetCurrentPage() 140 | { 141 | var frame = Window.Current.Content as Frame; 142 | 143 | if (frame == null) 144 | return null; 145 | 146 | return frame.Content as Page; 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Views/EditSchemeView.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 43 | 44 | 50 | 51 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Views/EditSchemeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml; 3 | 4 | namespace Spectrum.Demo.Views 5 | { 6 | public sealed partial class EditSchemeView 7 | { 8 | public EditSchemeView() 9 | { 10 | InitializeComponent(); 11 | } 12 | 13 | private void OnGoBack(object sender, RoutedEventArgs e) 14 | { 15 | Frame.GoBack(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Views/Editors/AnalogousSchemeEditorView.xaml: -------------------------------------------------------------------------------- 1 |  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 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Views/Editors/AnalogousSchemeEditorView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Windows.UI.Xaml.Controls; 4 | 5 | namespace Spectrum.Demo.Views.Editors 6 | { 7 | public sealed partial class AnalogousSchemeEditorView 8 | { 9 | public AnalogousSchemeEditorView() 10 | { 11 | InitializeComponent(); 12 | } 13 | 14 | protected override Panel GetInputPanel() 15 | { 16 | return InputPanel; 17 | } 18 | 19 | protected override Slider GetSaturationSlider() 20 | { 21 | return SaturationSlider; 22 | } 23 | 24 | protected override IEnumerable GetColourViews() 25 | { 26 | return new IColourView[] 27 | { 28 | MainColor, 29 | Color1, 30 | Color2, 31 | Color3, 32 | Color4 33 | }; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Views/Editors/ColourView.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 18 | 19 | 20 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/Views/SchemeListView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 17 | 18 | namespace Spectrum.Demo.Views 19 | { 20 | /// 21 | /// An empty page that can be used on its own or navigated to within a Frame. 22 | /// 23 | public sealed partial class SchemeListView : Page 24 | { 25 | public SchemeListView() 26 | { 27 | this.InitializeComponent(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.Windows/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/BundleArtifacts/neutral.txt: -------------------------------------------------------------------------------- 1 | MainPackage=D:\Dev\GitHub\Spectrum\Spectrum.Demo\Spectrum.Demo.WindowsPhone\bin\Release\Spectrum.Demo.WindowsPhone_1.1.0.2_Bundle\Spectrum.Demo.WindowsPhone_1.1.0.2_AnyCPU.appx 2 | SymbolPackage=D:\Software\Packages\Spectrum.Demo.WindowsPhone_1.1.0.2_Test\Spectrum.Demo.WindowsPhone_1.1.0.2_AnyCPU.appxsym 3 | ResourcePack=D:\Dev\GitHub\Spectrum\Spectrum.Demo\Spectrum.Demo.WindowsPhone\bin\Release\Spectrum.Demo.WindowsPhone_1.1.0.2_Bundle\Spectrum.Demo.WindowsPhone_1.1.0.2_scale-100.appx 4 | ResourcePack=D:\Dev\GitHub\Spectrum\Spectrum.Demo\Spectrum.Demo.WindowsPhone\bin\Release\Spectrum.Demo.WindowsPhone_1.1.0.2_Bundle\Spectrum.Demo.WindowsPhone_1.1.0.2_scale-140.appx 5 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Spectrum Scheme 7 | Compiled Experience 8 | Resources\Images\Square50.png 9 | 10 | 11 | 6.3.1 12 | 6.3.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/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("Spectrum.Demo.WindowsPhone")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Spectrum.Demo.WindowsPhone")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Splash.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Splash.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Splash.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Splash.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Splash.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Splash.scale-240.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square150.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square150.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square150.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square150.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square150.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square150.scale-240.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square44.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square44.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square44.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square44.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square44.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square44.scale-240.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square50.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square50.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square50.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square50.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square50.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square50.scale-240.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square71.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square71.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square71.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square71.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square71.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Square71.scale-240.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Wide.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Wide.scale-100.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Wide.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Wide.scale-140.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Wide.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nigel-sampson/spectrum/a19e7ba65dc84672026e4720575f6c40d4f7a62e/Spectrum.Demo/Spectrum.Demo.WindowsPhone/Resources/Images/Wide.scale-240.png -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Services/WindowManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Threading.Tasks; 5 | using Windows.UI.Xaml; 6 | using Windows.UI.Xaml.Controls; 7 | using Caliburn.Micro; 8 | 9 | namespace Spectrum.Demo.Services 10 | { 11 | public class WindowManager : IWindowManager 12 | { 13 | public virtual async Task ShowDialogAsync(object rootModel, object context = null, IDictionary settings = null) 14 | { 15 | var view = LocateAndBindView(rootModel, context); 16 | 17 | var contentDialog = CreateDialog(view); 18 | 19 | ApplySettings(contentDialog, settings); 20 | 21 | ActivateViewModel(rootModel); 22 | 23 | var result = await contentDialog.ShowAsync(); 24 | 25 | DeactivateViewModel(rootModel); 26 | 27 | return result == ContentDialogResult.Primary; 28 | } 29 | 30 | private static void DeactivateViewModel(object rootModel) 31 | { 32 | var deactivateViewModel = rootModel as IDeactivate; 33 | 34 | if (deactivateViewModel != null) 35 | deactivateViewModel.Deactivate(true); 36 | } 37 | 38 | private static void ActivateViewModel(object rootModel) 39 | { 40 | var activateViewModel = rootModel as IActivate; 41 | 42 | if (activateViewModel != null) 43 | activateViewModel.Activate(); 44 | } 45 | 46 | private static ContentDialog CreateDialog(UIElement view) 47 | { 48 | var dialog = new ContentDialog 49 | { 50 | Content = view, 51 | }; 52 | 53 | return dialog; 54 | } 55 | 56 | private static UIElement LocateAndBindView(object rootModel, object context) 57 | { 58 | var view = ViewLocator.LocateForModel(rootModel, null, context); 59 | 60 | ViewModelBinder.Bind(rootModel, view, context); 61 | 62 | return view; 63 | } 64 | 65 | protected virtual bool ApplySettings(object target, IEnumerable> settings) 66 | { 67 | if (settings != null) 68 | { 69 | var type = target.GetType(); 70 | 71 | foreach (var pair in settings) 72 | { 73 | var propertyInfo = type.GetRuntimeProperty(pair.Key); 74 | 75 | if (propertyInfo != null) 76 | { 77 | propertyInfo.SetValue(target, pair.Value, null); 78 | } 79 | } 80 | 81 | return true; 82 | } 83 | 84 | return false; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Views/EditSchemeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml; 3 | 4 | namespace Spectrum.Demo.Views 5 | { 6 | public sealed partial class EditSchemeView 7 | { 8 | private static bool helpShownOnLoad; 9 | private bool helpVisible; 10 | 11 | public EditSchemeView() 12 | { 13 | InitializeComponent(); 14 | 15 | Loaded += OnLoaded; 16 | } 17 | 18 | private void OnLoaded(object sender, RoutedEventArgs e) 19 | { 20 | if (helpShownOnLoad) 21 | { 22 | HideHelp(false); 23 | } 24 | else 25 | { 26 | ShowHelp(false); 27 | helpShownOnLoad = true; 28 | } 29 | } 30 | 31 | private void ShowHelp(bool useTransitions = true) 32 | { 33 | helpVisible = true; 34 | 35 | VisualStateManager.GoToState(this, HelpVisible.Name, useTransitions); 36 | } 37 | 38 | private void HideHelp(bool useTransitions = true) 39 | { 40 | helpVisible = false; 41 | 42 | VisualStateManager.GoToState(this, HelpCollapsed.Name, useTransitions); 43 | } 44 | 45 | private void OnHideHelp(object sender, RoutedEventArgs e) 46 | { 47 | HideHelp(); 48 | } 49 | 50 | private void OnToggleHelp(object sender, RoutedEventArgs e) 51 | { 52 | if (helpVisible) 53 | HideHelp(); 54 | else 55 | ShowHelp(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Views/Editors/AnalogousSchemeEditorView.xaml: -------------------------------------------------------------------------------- 1 |  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 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Views/Editors/AnalogousSchemeEditorView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Windows.UI.Xaml.Controls; 4 | 5 | namespace Spectrum.Demo.Views.Editors 6 | { 7 | public sealed partial class AnalogousSchemeEditorView 8 | { 9 | public AnalogousSchemeEditorView() 10 | { 11 | InitializeComponent(); 12 | } 13 | 14 | protected override Panel GetInputPanel() 15 | { 16 | return InputPanel; 17 | } 18 | 19 | protected override Slider GetSaturationSlider() 20 | { 21 | return SaturationSlider; 22 | } 23 | 24 | protected override IEnumerable GetColourViews() 25 | { 26 | return new IColourView[] 27 | { 28 | MainColor, 29 | Color1, 30 | Color2, 31 | Color3, 32 | Color4 33 | }; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Spectrum.Demo/Spectrum.Demo.WindowsPhone/Views/Editors/ColourView.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 17 | 18 | 19 |