private void Rectangle_Tapped(object sender, TappedRoutedEventArgs e) { phoneAccentToggleSwitch.IsOn = false; Rectangle rect = sender as Rectangle; Windows.UI.Color color = ((SolidColorBrush)rect.Fill).Color; ((SolidColorBrush)App.Current.Resources["UserAccentBrush"]).Color = color; ApplicationSettingsHelper.SaveSettingsValue(AppConstants.AppAccent, color.ToString()); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.IsPhoneAccentSet, false); Helpers.StyleHelper.ChangeMainPageButtonsBackground(); }
void UpdateTemplate() { var fillColorProperty = (Xamarin.Forms.Color)Element.GetType().GetProperty("FillColor" + (Element.Checked ? "" : "Un") + "Check").GetValue(Element); var color = new Windows.UI.Color { A = Convert.ToByte(fillColorProperty.A * 255), R = Convert.ToByte(fillColorProperty.R * 255), G = Convert.ToByte(fillColorProperty.G * 255), B = Convert.ToByte(fillColorProperty.B * 255) }; SetControlTemplate(color.ToString(), Element.Icon); }
private string GetPosRGB(double posX, double posY) { int pixelX = ConvertPosToPixel((int)posX); int pixelY = ConvertPosToPixel((int)posY); var k = (pixelY * decoder.PixelWidth + pixelX) * 4; Windows.UI.Color color = new Windows.UI.Color(); if (k >= 0 && k + 3 < colorData.Length) { color = Windows.UI.Color.FromArgb(colorData[k + 3], colorData[k + 2], colorData[k + 1], colorData[k + 0]); } return(ARGB2RGB(color.ToString())); }
public string GenerateExportData(IControlPaletteModel model, ControlPaletteViewModel viewModel, bool showAllColors = false) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<!-- Free Public License 1.0.0 Permission to use, copy, modify, and/or distribute this code for any purpose with or without fee is hereby granted. -->"); sb.AppendLine("<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\""); sb.AppendLine(" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\""); sb.AppendLine(" xmlns:Windows10version1809=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)\""); sb.AppendLine(" xmlns:BelowWindows10version1809=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract, 7)\">"); sb.AppendLine(" <ResourceDictionary.ThemeDictionaries>"); sb.AppendLine(" <ResourceDictionary x:Key=\"Default\">"); sb.AppendLine(" <ResourceDictionary.MergedDictionaries>"); sb.Append(" <Windows10version1809:ColorPaletteResources"); if (model.DarkColorMapping != null) { foreach (var m in model.DarkColorMapping) { sb.Append(" "); sb.Append(m.Target.ToString()); sb.Append("=\""); sb.Append(m.Source.ActiveColor.ToString()); sb.Append("\""); } } sb.AppendLine(" />"); sb.AppendLine(" <ResourceDictionary>"); if (model.DarkColorMapping != null) { foreach (var m in model.DarkColorMapping) { sb.AppendLine($" <BelowWindows10version1809:Color x:Key=\"System{m.Target.ToString()}Color\">{m.Source.ActiveColor.ToString()}</BelowWindows10version1809:Color>"); } } Windows.UI.Color ChromeAltMediumHigh = model.DarkRegion.ActiveColor; ChromeAltMediumHigh.A = 204; sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltMediumHighColor\">{0}</Color>", ChromeAltMediumHigh.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltHighColor\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListLowColor\">{0}</Color>", model.DarkBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListMediumColor\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(" <AcrylicBrush x:Key=\"SystemControlAcrylicWindowBrush\" BackgroundSource=\"HostBackdrop\" TintColor=\"{ThemeResource SystemChromeAltHighColor}\" TintOpacity=\"0.8\" FallbackColor=\"{ThemeResource SystemChromeMediumColor}\" />"); sb.AppendLine(" <!-- Override system shape defaults -->"); sb.AppendLine(string.Format(" <CornerRadius x:Key=\"ControlCornerRadius\">{0},{1},{2},{3}</CornerRadius>", viewModel.ControlCornerRadiusValue.TopLeft, viewModel.ControlCornerRadiusValue.TopRight, viewModel.ControlCornerRadiusValue.BottomLeft, viewModel.ControlCornerRadiusValue.BottomRight)); sb.AppendLine(string.Format(" <CornerRadius x:Key=\"OverlayCornerRadius\">{0},{1},{2},{3}</CornerRadius>", viewModel.OverlayCornerRadiusValue.TopLeft, viewModel.OverlayCornerRadiusValue.TopRight, viewModel.OverlayCornerRadiusValue.BottomLeft, viewModel.OverlayCornerRadiusValue.BottomRight)); sb.AppendLine(" <!-- Override system borders -->"); sb.AppendLine(string.Format(" <Thickness x:Key=\"MenuBarItemBorderThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"GridViewItemMultiselectBorderThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"CheckBoxBorderThemeThickness\">{0}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <x:Double x:Key=\"GridViewItemSelectedBorderThemeThickness\">{0}</x:Double>", Math.Max(Math.Max(Math.Max(viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top), viewModel.ControlBorderThicknessValue.Right), viewModel.ControlBorderThicknessValue.Bottom))); sb.AppendLine(string.Format(" <x:Double x:Key=\"RadioButtonBorderThemeThickness\">{0}</x:Double>", Math.Max(Math.Max(Math.Max(viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top), viewModel.ControlBorderThicknessValue.Right), viewModel.ControlBorderThicknessValue.Bottom))); sb.AppendLine(string.Format(" <Thickness x:Key=\"ButtonBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"CalendarDatePickerBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"TimePickerBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"DatePickerBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ToggleSwitchOuterBorderStrokeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"RepeatButtonBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"SearchBoxBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ToggleButtonBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"TextControlBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"RepeatButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ToggleButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"AppBarEllipsisButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"AppBarButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"AppBarToggleButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ListViewItemRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"GridViewItemRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ComboBoxItemRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <x:Double x:Key=\"PersonPictureEllipseBadgeStrokeThickness\">{0}</x:Double>", Math.Max(Math.Max(Math.Max(viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top), viewModel.ControlBorderThicknessValue.Right), viewModel.ControlBorderThicknessValue.Bottom))); sb.AppendLine(" <!-- Override system generated accent colors -->"); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark1\">{0}</Color>", model.DarkPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark2\">{0}</Color>", model.DarkPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark3\">{0}</Color>", model.DarkPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight1\">{0}</Color>", model.DarkPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight2\">{0}</Color>", model.DarkPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight3\">{0}</Color>", model.DarkPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"RegionColor\">{0}</Color>", model.DarkRegion.ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); if (showAllColors) { sb.AppendLine(string.Format(" <Color x:Key=\"BaseColor\">{0}</Color>", model.DarkBase.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette000Color\">{0}</Color>", model.DarkBase.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette100Color\">{0}</Color>", model.DarkBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette200Color\">{0}</Color>", model.DarkBase.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette300Color\">{0}</Color>", model.DarkBase.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette400Color\">{0}</Color>", model.DarkBase.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette500Color\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette600Color\">{0}</Color>", model.DarkBase.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette700Color\">{0}</Color>", model.DarkBase.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette800Color\">{0}</Color>", model.DarkBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette900Color\">{0}</Color>", model.DarkBase.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette1000Color\">{0}</Color>", model.DarkBase.Palette[10].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryColor\">{0}</Color>", model.DarkPrimary.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette000Color\">{0}</Color>", model.DarkPrimary.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette100Color\">{0}</Color>", model.DarkPrimary.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette200Color\">{0}</Color>", model.DarkPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette300Color\">{0}</Color>", model.DarkPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette400Color\">{0}</Color>", model.DarkPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette500Color\">{0}</Color>", model.DarkPrimary.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette600Color\">{0}</Color>", model.DarkPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette700Color\">{0}</Color>", model.DarkPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette800Color\">{0}</Color>", model.DarkPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette900Color\">{0}</Color>", model.DarkPrimary.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette1000Color\">{0}</Color>", model.DarkPrimary.Palette[10].ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"BaseBrush\" Color=\"{StaticResource BaseColor}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette000Brush\" Color=\"{StaticResource BasePalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette100Brush\" Color=\"{StaticResource BasePalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette200Brush\" Color=\"{StaticResource BasePalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette300Brush\" Color=\"{StaticResource BasePalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette400Brush\" Color=\"{StaticResource BasePalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette500Brush\" Color=\"{StaticResource BasePalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette600Brush\" Color=\"{StaticResource BasePalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette700Brush\" Color=\"{StaticResource BasePalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette800Brush\" Color=\"{StaticResource BasePalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette900Brush\" Color=\"{StaticResource BasePalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette1000Brush\" Color=\"{StaticResource BasePalette1000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette000Brush\" Color=\"{StaticResource PrimaryPalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette100Brush\" Color=\"{StaticResource PrimaryPalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette200Brush\" Color=\"{StaticResource PrimaryPalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette300Brush\" Color=\"{StaticResource PrimaryPalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette400Brush\" Color=\"{StaticResource PrimaryPalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette500Brush\" Color=\"{StaticResource PrimaryPalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette600Brush\" Color=\"{StaticResource PrimaryPalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette700Brush\" Color=\"{StaticResource PrimaryPalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette800Brush\" Color=\"{StaticResource PrimaryPalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette900Brush\" Color=\"{StaticResource PrimaryPalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette1000Brush\" Color=\"{StaticResource PrimaryPalette1000Color}\" />"); } sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.MergedDictionaries>"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" <ResourceDictionary x:Key=\"Light\">"); sb.AppendLine(" <ResourceDictionary.MergedDictionaries>"); sb.Append(" <Windows10version1809:ColorPaletteResources"); if (model.LightColorMapping != null) { foreach (var m in model.LightColorMapping) { sb.Append(" "); sb.Append(m.Target.ToString()); sb.Append("=\""); sb.Append(m.Source.ActiveColor.ToString()); sb.Append("\""); } } sb.AppendLine(" />"); sb.AppendLine(" <ResourceDictionary>"); if (model.DarkColorMapping != null) { foreach (var m in model.LightColorMapping) { sb.AppendLine($" <BelowWindows10version1809:Color x:Key=\"System{m.Target.ToString()}Color\">{m.Source.ActiveColor.ToString()}</BelowWindows10version1809:Color>"); } } ChromeAltMediumHigh = model.LightRegion.ActiveColor; ChromeAltMediumHigh.A = 204; sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltMediumHighColor\">{0}</Color>", ChromeAltMediumHigh.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltHighColor\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListLowColor\">{0}</Color>", model.LightBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListMediumColor\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(" <AcrylicBrush x:Key=\"SystemControlAcrylicWindowBrush\" BackgroundSource=\"HostBackdrop\" TintColor=\"{ThemeResource SystemChromeAltHighColor}\" TintOpacity=\"0.8\" FallbackColor=\"{ThemeResource SystemChromeMediumColor}\" />"); sb.AppendLine(" <!-- Override system shape defaults -->"); sb.AppendLine(string.Format(" <CornerRadius x:Key=\"ControlCornerRadius\">{0},{1},{2},{3}</CornerRadius>", viewModel.ControlCornerRadiusValue.TopLeft, viewModel.ControlCornerRadiusValue.TopRight, viewModel.ControlCornerRadiusValue.BottomLeft, viewModel.ControlCornerRadiusValue.BottomRight)); sb.AppendLine(string.Format(" <CornerRadius x:Key=\"OverlayCornerRadius\">{0},{1},{2},{3}</CornerRadius>", viewModel.OverlayCornerRadiusValue.TopLeft, viewModel.OverlayCornerRadiusValue.TopRight, viewModel.OverlayCornerRadiusValue.BottomLeft, viewModel.OverlayCornerRadiusValue.BottomRight)); sb.AppendLine(" <!-- Override system borders -->"); sb.AppendLine(string.Format(" <Thickness x:Key=\"MenuBarItemBorderThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"GridViewItemMultiselectBorderThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"CheckBoxBorderThemeThickness\">{0}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <x:Double x:Key=\"GridViewItemSelectedBorderThemeThickness\">{0}</x:Double>", Math.Max(Math.Max(Math.Max(viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top), viewModel.ControlBorderThicknessValue.Right), viewModel.ControlBorderThicknessValue.Bottom))); sb.AppendLine(string.Format(" <x:Double x:Key=\"RadioButtonBorderThemeThickness\">{0}</x:Double>", Math.Max(Math.Max(Math.Max(viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top), viewModel.ControlBorderThicknessValue.Right), viewModel.ControlBorderThicknessValue.Bottom))); sb.AppendLine(string.Format(" <Thickness x:Key=\"ButtonBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"CalendarDatePickerBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"TimePickerBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"DatePickerBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ToggleSwitchOuterBorderStrokeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"RepeatButtonBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"SearchBoxBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ToggleButtonBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"TextControlBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"RepeatButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ToggleButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"AppBarEllipsisButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"AppBarButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"AppBarToggleButtonRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ListViewItemRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"GridViewItemRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <Thickness x:Key=\"ComboBoxItemRevealBorderThemeThickness\">{0},{1},{2},{3}</Thickness>", viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top, viewModel.ControlBorderThicknessValue.Right, viewModel.ControlBorderThicknessValue.Bottom)); sb.AppendLine(string.Format(" <x:Double x:Key=\"PersonPictureEllipseBadgeStrokeThickness\">{0}</x:Double>", Math.Max(Math.Max(Math.Max(viewModel.ControlBorderThicknessValue.Left, viewModel.ControlBorderThicknessValue.Top), viewModel.ControlBorderThicknessValue.Right), viewModel.ControlBorderThicknessValue.Bottom))); sb.AppendLine(" <!-- Override system generated accent colors -->"); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight1\">{0}</Color>", model.LightPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight2\">{0}</Color>", model.LightPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight3\">{0}</Color>", model.LightPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark1\">{0}</Color>", model.LightPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark2\">{0}</Color>", model.LightPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark3\">{0}</Color>", model.LightPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(" <RevealBackgroundBrush x:Key=\"SystemControlHighlightListLowRevealBackgroundBrush\" TargetTheme=\"Light\" Color=\"{ThemeResource SystemRevealListMediumColor}\" FallbackColor=\"{ StaticResource SystemListMediumColor}\" />"); sb.AppendLine(string.Format(" <Color x:Key=\"RegionColor\">{0}</Color>", model.LightRegion.ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); if (showAllColors) { sb.AppendLine(string.Format(" <Color x:Key=\"BaseColor\">{0}</Color>", model.LightBase.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette000Color\">{0}</Color>", model.LightBase.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette100Color\">{0}</Color>", model.LightBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette200Color\">{0}</Color>", model.LightBase.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette300Color\">{0}</Color>", model.LightBase.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette400Color\">{0}</Color>", model.LightBase.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette500Color\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette600Color\">{0}</Color>", model.LightBase.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette700Color\">{0}</Color>", model.LightBase.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette800Color\">{0}</Color>", model.LightBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette900Color\">{0}</Color>", model.LightBase.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette1000Color\">{0}</Color>", model.LightBase.Palette[10].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryColor\">{0}</Color>", model.LightPrimary.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette000Color\">{0}</Color>", model.LightPrimary.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette100Color\">{0}</Color>", model.LightPrimary.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette200Color\">{0}</Color>", model.LightPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette300Color\">{0}</Color>", model.LightPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette400Color\">{0}</Color>", model.LightPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette500Color\">{0}</Color>", model.LightPrimary.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette600Color\">{0}</Color>", model.LightPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette700Color\">{0}</Color>", model.LightPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette800Color\">{0}</Color>", model.LightPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette900Color\">{0}</Color>", model.LightPrimary.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette1000Color\">{0}</Color>", model.LightPrimary.Palette[10].ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"BaseBrush\" Color=\"{StaticResource BaseColor}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette000Brush\" Color=\"{StaticResource BasePalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette100Brush\" Color=\"{StaticResource BasePalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette200Brush\" Color=\"{StaticResource BasePalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette300Brush\" Color=\"{StaticResource BasePalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette400Brush\" Color=\"{StaticResource BasePalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette500Brush\" Color=\"{StaticResource BasePalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette600Brush\" Color=\"{StaticResource BasePalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette700Brush\" Color=\"{StaticResource BasePalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette800Brush\" Color=\"{StaticResource BasePalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette900Brush\" Color=\"{StaticResource BasePalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette1000Brush\" Color=\"{StaticResource BasePalette1000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette000Brush\" Color=\"{StaticResource PrimaryPalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette100Brush\" Color=\"{StaticResource PrimaryPalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette200Brush\" Color=\"{StaticResource PrimaryPalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette300Brush\" Color=\"{StaticResource PrimaryPalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette400Brush\" Color=\"{StaticResource PrimaryPalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette500Brush\" Color=\"{StaticResource PrimaryPalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette600Brush\" Color=\"{StaticResource PrimaryPalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette700Brush\" Color=\"{StaticResource PrimaryPalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette800Brush\" Color=\"{StaticResource PrimaryPalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette900Brush\" Color=\"{StaticResource PrimaryPalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette1000Brush\" Color=\"{StaticResource PrimaryPalette1000Color}\" />"); } sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.MergedDictionaries>"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" <ResourceDictionary x:Key=\"HighContrast\">"); sb.AppendLine(" <StaticResource x:Key=\"RegionColor\" ResourceKey=\"SystemColorWindowColor\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.ThemeDictionaries>"); sb.AppendLine("</ResourceDictionary>"); var retVal = sb.ToString(); return(retVal); }
public string GenerateExportData(IControlPaletteModel model, bool showAllColors = false) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<!-- Free Public License 1.0.0 Permission to use, copy, modify, and/or distribute this code for any purpose with or without fee is hereby granted. -->"); sb.AppendLine("<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\""); sb.AppendLine(" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\""); sb.AppendLine(" xmlns:Windows10version1809=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)\""); sb.AppendLine(" xmlns:BelowWindows10version1809=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract, 7)\">"); sb.AppendLine(" <ResourceDictionary.ThemeDictionaries>"); sb.AppendLine(" <ResourceDictionary x:Key=\"Default\">"); sb.AppendLine(" <ResourceDictionary.MergedDictionaries>"); sb.Append(" <Windows10version1809:ColorPaletteResources"); if (model.DarkColorMapping != null) { foreach (var m in model.DarkColorMapping) { sb.Append(" "); sb.Append(m.Target.ToString()); sb.Append("=\""); sb.Append(m.Source.ActiveColor.ToString()); sb.Append("\""); } } sb.AppendLine(" />"); sb.AppendLine(" <ResourceDictionary>"); if (model.DarkColorMapping != null) { foreach (var m in model.DarkColorMapping) { sb.AppendLine($" <BelowWindows10version1809:Color x:Key=\"System{m.Target.ToString()}Color\">{m.Source.ActiveColor.ToString()}</BelowWindows10version1809:Color>"); } } Windows.UI.Color ChromeAltMediumHigh = model.DarkRegion.ActiveColor; ChromeAltMediumHigh.A = 204; sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltMediumHighColor\">{0}</Color>", ChromeAltMediumHigh.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltHighColor\">{0}</Color>", model.DarkRegion.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListLowColor\">{0}</Color>", model.DarkBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListMediumColor\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(" <!-- Override system generated accent colors -->"); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark1\">{0}</Color>", model.DarkPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark2\">{0}</Color>", model.DarkPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark3\">{0}</Color>", model.DarkPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight1\">{0}</Color>", model.DarkPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight2\">{0}</Color>", model.DarkPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight3\">{0}</Color>", model.DarkPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"RegionColor\">{0}</Color>", model.DarkRegion.ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); if (showAllColors) { sb.AppendLine(string.Format(" <Color x:Key=\"BaseColor\">{0}</Color>", model.DarkBase.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette000Color\">{0}</Color>", model.DarkBase.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette100Color\">{0}</Color>", model.DarkBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette200Color\">{0}</Color>", model.DarkBase.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette300Color\">{0}</Color>", model.DarkBase.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette400Color\">{0}</Color>", model.DarkBase.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette500Color\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette600Color\">{0}</Color>", model.DarkBase.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette700Color\">{0}</Color>", model.DarkBase.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette800Color\">{0}</Color>", model.DarkBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette900Color\">{0}</Color>", model.DarkBase.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette1000Color\">{0}</Color>", model.DarkBase.Palette[10].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryColor\">{0}</Color>", model.DarkPrimary.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette000Color\">{0}</Color>", model.DarkPrimary.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette100Color\">{0}</Color>", model.DarkPrimary.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette200Color\">{0}</Color>", model.DarkPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette300Color\">{0}</Color>", model.DarkPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette400Color\">{0}</Color>", model.DarkPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette500Color\">{0}</Color>", model.DarkPrimary.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette600Color\">{0}</Color>", model.DarkPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette700Color\">{0}</Color>", model.DarkPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette800Color\">{0}</Color>", model.DarkPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette900Color\">{0}</Color>", model.DarkPrimary.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette1000Color\">{0}</Color>", model.DarkPrimary.Palette[10].ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"BaseBrush\" Color=\"{StaticResource BaseColor}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette000Brush\" Color=\"{StaticResource BasePalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette100Brush\" Color=\"{StaticResource BasePalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette200Brush\" Color=\"{StaticResource BasePalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette300Brush\" Color=\"{StaticResource BasePalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette400Brush\" Color=\"{StaticResource BasePalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette500Brush\" Color=\"{StaticResource BasePalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette600Brush\" Color=\"{StaticResource BasePalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette700Brush\" Color=\"{StaticResource BasePalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette800Brush\" Color=\"{StaticResource BasePalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette900Brush\" Color=\"{StaticResource BasePalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette1000Brush\" Color=\"{StaticResource BasePalette1000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette000Brush\" Color=\"{StaticResource PrimaryPalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette100Brush\" Color=\"{StaticResource PrimaryPalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette200Brush\" Color=\"{StaticResource PrimaryPalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette300Brush\" Color=\"{StaticResource PrimaryPalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette400Brush\" Color=\"{StaticResource PrimaryPalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette500Brush\" Color=\"{StaticResource PrimaryPalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette600Brush\" Color=\"{StaticResource PrimaryPalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette700Brush\" Color=\"{StaticResource PrimaryPalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette800Brush\" Color=\"{StaticResource PrimaryPalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette900Brush\" Color=\"{StaticResource PrimaryPalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette1000Brush\" Color=\"{StaticResource PrimaryPalette1000Color}\" />"); } sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.MergedDictionaries>"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" <ResourceDictionary x:Key=\"Light\">"); sb.AppendLine(" <ResourceDictionary.MergedDictionaries>"); sb.Append(" <Windows10version1809:ColorPaletteResources"); if (model.LightColorMapping != null) { foreach (var m in model.LightColorMapping) { sb.Append(" "); sb.Append(m.Target.ToString()); sb.Append("=\""); sb.Append(m.Source.ActiveColor.ToString()); sb.Append("\""); } } sb.AppendLine(" />"); sb.AppendLine(" <ResourceDictionary>"); if (model.DarkColorMapping != null) { foreach (var m in model.LightColorMapping) { sb.AppendLine($" <BelowWindows10version1809:Color x:Key=\"System{m.Target.ToString()}Color\">{m.Source.ActiveColor.ToString()}</BelowWindows10version1809:Color>"); } } ChromeAltMediumHigh = model.LightRegion.ActiveColor; ChromeAltMediumHigh.A = 204; sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltMediumHighColor\">{0}</Color>", ChromeAltMediumHigh.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltHighColor\">{0}</Color>", model.LightRegion.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListLowColor\">{0}</Color>", model.LightBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListMediumColor\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(" <!-- Override system generated accent colors -->"); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight1\">{0}</Color>", model.LightPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight2\">{0}</Color>", model.LightPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorLight3\">{0}</Color>", model.LightPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark1\">{0}</Color>", model.LightPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark2\">{0}</Color>", model.LightPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemAccentColorDark3\">{0}</Color>", model.LightPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(" <RevealBackgroundBrush x:Key=\"SystemControlHighlightListLowRevealBackgroundBrush\" TargetTheme=\"Light\" Color=\"{ThemeResource SystemRevealListMediumColor}\" FallbackColor=\"{ StaticResource SystemListMediumColor}\" />"); sb.AppendLine(string.Format(" <Color x:Key=\"RegionColor\">{0}</Color>", model.LightRegion.ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); if (showAllColors) { sb.AppendLine(string.Format(" <Color x:Key=\"BaseColor\">{0}</Color>", model.LightBase.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette000Color\">{0}</Color>", model.LightBase.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette100Color\">{0}</Color>", model.LightBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette200Color\">{0}</Color>", model.LightBase.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette300Color\">{0}</Color>", model.LightBase.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette400Color\">{0}</Color>", model.LightBase.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette500Color\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette600Color\">{0}</Color>", model.LightBase.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette700Color\">{0}</Color>", model.LightBase.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette800Color\">{0}</Color>", model.LightBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette900Color\">{0}</Color>", model.LightBase.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette1000Color\">{0}</Color>", model.LightBase.Palette[10].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryColor\">{0}</Color>", model.LightPrimary.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette000Color\">{0}</Color>", model.LightPrimary.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette100Color\">{0}</Color>", model.LightPrimary.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette200Color\">{0}</Color>", model.LightPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette300Color\">{0}</Color>", model.LightPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette400Color\">{0}</Color>", model.LightPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette500Color\">{0}</Color>", model.LightPrimary.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette600Color\">{0}</Color>", model.LightPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette700Color\">{0}</Color>", model.LightPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette800Color\">{0}</Color>", model.LightPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette900Color\">{0}</Color>", model.LightPrimary.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette1000Color\">{0}</Color>", model.LightPrimary.Palette[10].ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"BaseBrush\" Color=\"{StaticResource BaseColor}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette000Brush\" Color=\"{StaticResource BasePalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette100Brush\" Color=\"{StaticResource BasePalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette200Brush\" Color=\"{StaticResource BasePalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette300Brush\" Color=\"{StaticResource BasePalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette400Brush\" Color=\"{StaticResource BasePalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette500Brush\" Color=\"{StaticResource BasePalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette600Brush\" Color=\"{StaticResource BasePalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette700Brush\" Color=\"{StaticResource BasePalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette800Brush\" Color=\"{StaticResource BasePalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette900Brush\" Color=\"{StaticResource BasePalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette1000Brush\" Color=\"{StaticResource BasePalette1000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette000Brush\" Color=\"{StaticResource PrimaryPalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette100Brush\" Color=\"{StaticResource PrimaryPalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette200Brush\" Color=\"{StaticResource PrimaryPalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette300Brush\" Color=\"{StaticResource PrimaryPalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette400Brush\" Color=\"{StaticResource PrimaryPalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette500Brush\" Color=\"{StaticResource PrimaryPalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette600Brush\" Color=\"{StaticResource PrimaryPalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette700Brush\" Color=\"{StaticResource PrimaryPalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette800Brush\" Color=\"{StaticResource PrimaryPalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette900Brush\" Color=\"{StaticResource PrimaryPalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette1000Brush\" Color=\"{StaticResource PrimaryPalette1000Color}\" />"); } sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.MergedDictionaries>"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" <ResourceDictionary x:Key=\"HighContrast\">"); sb.AppendLine(" <StaticResource x:Key=\"RegionColor\" ResourceKey=\"SystemColorWindowColor\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.ThemeDictionaries>"); sb.AppendLine("</ResourceDictionary>"); var retVal = sb.ToString(); return(retVal); }
// This is owned by the UI thread for the _exportWindow //private ExportViewModel _exportViewModel; public string GenerateExportData(IControlPaletteModel model, bool showAllColors = false) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<!-- Free Public License 1.0.0 Permission to use, copy, modify, and/or distribute this code for any purpose with or without fee is hereby granted. -->"); sb.AppendLine("<ResourceDictionary.ThemeDictionaries>"); sb.AppendLine(" <ResourceDictionary x:Key=\"Default\">"); sb.AppendLine(" <ResourceDictionary.MergedDictionaries>"); sb.Append(" <ColorPaletteResources"); if (model.DarkColorMapping != null) { foreach (var m in model.DarkColorMapping) { sb.Append(" "); sb.Append(m.Target.ToString()); sb.Append("=\""); sb.Append(m.Source.ActiveColor.ToString()); sb.Append("\""); } } sb.AppendLine(" />"); sb.AppendLine(" <ResourceDictionary>"); Windows.UI.Color ChromeAltMediumHigh = model.DarkRegion.ActiveColor; ChromeAltMediumHigh.A = 204; sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltMediumHighColor\">{0}</Color>", ChromeAltMediumHigh.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltHighColor\">{0}</Color>", model.DarkRegion.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListLowColor\">{0}</Color>", model.DarkBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListMediumColor\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"RegionColor\">{0}</Color>", model.DarkRegion.ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); if (showAllColors) { sb.AppendLine(string.Format(" <Color x:Key=\"BaseColor\">{0}</Color>", model.DarkBase.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette000Color\">{0}</Color>", model.DarkBase.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette100Color\">{0}</Color>", model.DarkBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette200Color\">{0}</Color>", model.DarkBase.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette300Color\">{0}</Color>", model.DarkBase.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette400Color\">{0}</Color>", model.DarkBase.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette500Color\">{0}</Color>", model.DarkBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette600Color\">{0}</Color>", model.DarkBase.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette700Color\">{0}</Color>", model.DarkBase.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette800Color\">{0}</Color>", model.DarkBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette900Color\">{0}</Color>", model.DarkBase.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette1000Color\">{0}</Color>", model.DarkBase.Palette[10].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryColor\">{0}</Color>", model.DarkPrimary.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette000Color\">{0}</Color>", model.DarkPrimary.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette100Color\">{0}</Color>", model.DarkPrimary.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette200Color\">{0}</Color>", model.DarkPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette300Color\">{0}</Color>", model.DarkPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette400Color\">{0}</Color>", model.DarkPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette500Color\">{0}</Color>", model.DarkPrimary.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette600Color\">{0}</Color>", model.DarkPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette700Color\">{0}</Color>", model.DarkPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette800Color\">{0}</Color>", model.DarkPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette900Color\">{0}</Color>", model.DarkPrimary.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette1000Color\">{0}</Color>", model.DarkPrimary.Palette[10].ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"BaseBrush\" Color=\"{StaticResource BaseColor}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette000Brush\" Color=\"{StaticResource BasePalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette100Brush\" Color=\"{StaticResource BasePalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette200Brush\" Color=\"{StaticResource BasePalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette300Brush\" Color=\"{StaticResource BasePalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette400Brush\" Color=\"{StaticResource BasePalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette500Brush\" Color=\"{StaticResource BasePalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette600Brush\" Color=\"{StaticResource BasePalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette700Brush\" Color=\"{StaticResource BasePalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette800Brush\" Color=\"{StaticResource BasePalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette900Brush\" Color=\"{StaticResource BasePalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette1000Brush\" Color=\"{StaticResource BasePalette1000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette000Brush\" Color=\"{StaticResource PrimaryPalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette100Brush\" Color=\"{StaticResource PrimaryPalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette200Brush\" Color=\"{StaticResource PrimaryPalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette300Brush\" Color=\"{StaticResource PrimaryPalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette400Brush\" Color=\"{StaticResource PrimaryPalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette500Brush\" Color=\"{StaticResource PrimaryPalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette600Brush\" Color=\"{StaticResource PrimaryPalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette700Brush\" Color=\"{StaticResource PrimaryPalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette800Brush\" Color=\"{StaticResource PrimaryPalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette900Brush\" Color=\"{StaticResource PrimaryPalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette1000Brush\" Color=\"{StaticResource PrimaryPalette1000Color}\" />"); } sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.MergedDictionaries>"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" <ResourceDictionary x:Key=\"Light\">"); sb.AppendLine(" <ResourceDictionary.MergedDictionaries>"); sb.Append(" <ColorPaletteResources"); if (model.LightColorMapping != null) { foreach (var m in model.LightColorMapping) { sb.Append(" "); sb.Append(m.Target.ToString()); sb.Append("=\""); sb.Append(m.Source.ActiveColor.ToString()); sb.Append("\""); } } sb.AppendLine(" />"); sb.AppendLine(" <ResourceDictionary>"); ChromeAltMediumHigh = model.LightRegion.ActiveColor; ChromeAltMediumHigh.A = 204; sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltMediumHighColor\">{0}</Color>", ChromeAltMediumHigh.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemChromeAltHighColor\">{0}</Color>", model.LightRegion.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListLowColor\">{0}</Color>", model.LightBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"SystemRevealListMediumColor\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(" <RevealBackgroundBrush x:Key=\"SystemControlHighlightListLowRevealBackgroundBrush\" TargetTheme=\"Light\" Color=\"{ThemeResource SystemRevealListMediumColor}\" FallbackColor=\"{ StaticResource SystemListMediumColor}\" />"); sb.AppendLine(string.Format(" <Color x:Key=\"RegionColor\">{0}</Color>", model.LightRegion.ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); if (showAllColors) { sb.AppendLine(string.Format(" <Color x:Key=\"BaseColor\">{0}</Color>", model.LightBase.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette000Color\">{0}</Color>", model.LightBase.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette100Color\">{0}</Color>", model.LightBase.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette200Color\">{0}</Color>", model.LightBase.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette300Color\">{0}</Color>", model.LightBase.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette400Color\">{0}</Color>", model.LightBase.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette500Color\">{0}</Color>", model.LightBase.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette600Color\">{0}</Color>", model.LightBase.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette700Color\">{0}</Color>", model.LightBase.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette800Color\">{0}</Color>", model.LightBase.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette900Color\">{0}</Color>", model.LightBase.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"BasePalette1000Color\">{0}</Color>", model.LightBase.Palette[10].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryColor\">{0}</Color>", model.LightPrimary.BaseColor.ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette000Color\">{0}</Color>", model.LightPrimary.Palette[0].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette100Color\">{0}</Color>", model.LightPrimary.Palette[1].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette200Color\">{0}</Color>", model.LightPrimary.Palette[2].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette300Color\">{0}</Color>", model.LightPrimary.Palette[3].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette400Color\">{0}</Color>", model.LightPrimary.Palette[4].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette500Color\">{0}</Color>", model.LightPrimary.Palette[5].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette600Color\">{0}</Color>", model.LightPrimary.Palette[6].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette700Color\">{0}</Color>", model.LightPrimary.Palette[7].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette800Color\">{0}</Color>", model.LightPrimary.Palette[8].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette900Color\">{0}</Color>", model.LightPrimary.Palette[9].ActiveColor.ToString())); sb.AppendLine(string.Format(" <Color x:Key=\"PrimaryPalette1000Color\">{0}</Color>", model.LightPrimary.Palette[10].ActiveColor.ToString())); sb.AppendLine(" <SolidColorBrush x:Key=\"BaseBrush\" Color=\"{StaticResource BaseColor}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette000Brush\" Color=\"{StaticResource BasePalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette100Brush\" Color=\"{StaticResource BasePalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette200Brush\" Color=\"{StaticResource BasePalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette300Brush\" Color=\"{StaticResource BasePalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette400Brush\" Color=\"{StaticResource BasePalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette500Brush\" Color=\"{StaticResource BasePalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette600Brush\" Color=\"{StaticResource BasePalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette700Brush\" Color=\"{StaticResource BasePalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette800Brush\" Color=\"{StaticResource BasePalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette900Brush\" Color=\"{StaticResource BasePalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"BasePalette1000Brush\" Color=\"{StaticResource BasePalette1000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette000Brush\" Color=\"{StaticResource PrimaryPalette000Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette100Brush\" Color=\"{StaticResource PrimaryPalette100Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette200Brush\" Color=\"{StaticResource PrimaryPalette200Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette300Brush\" Color=\"{StaticResource PrimaryPalette300Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette400Brush\" Color=\"{StaticResource PrimaryPalette400Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette500Brush\" Color=\"{StaticResource PrimaryPalette500Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette600Brush\" Color=\"{StaticResource PrimaryPalette600Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette700Brush\" Color=\"{StaticResource PrimaryPalette700Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette800Brush\" Color=\"{StaticResource PrimaryPalette800Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette900Brush\" Color=\"{StaticResource PrimaryPalette900Color}\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"PrimaryPalette1000Brush\" Color=\"{StaticResource PrimaryPalette1000Color}\" />"); } sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" </ResourceDictionary.MergedDictionaries>"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine(" <ResourceDictionary x:Key=\"HighContrast\">"); sb.AppendLine(" <StaticResource x:Key=\"RegionColor\" ResourceKey=\"SystemColorWindowColor\" />"); sb.AppendLine(" <SolidColorBrush x:Key=\"RegionBrush\" Color=\"{StaticResource RegionColor}\" />"); sb.AppendLine(" </ResourceDictionary>"); sb.AppendLine("</ResourceDictionary.ThemeDictionaries>"); var retVal = sb.ToString(); return(retVal); }
string ParseToRtf(string text, string contentDate) { string prefix = "<html><body style='font-family:Segoe UI'><table><tr><td rowspan = '2'><svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><g><circle x='0' y='0' cx='20' cy='20' r='20' fill='{0}' /><text x='19' y='26' text-anchor='middle' font-family='Segoe UI' font-size='18' fill='white'>{1}</text></g></svg></td><td style='font-family:Segoe UI;font-size:18px;text-indent:10px'>{2}</td></tr><tr><td style='font-family:Segoe UI;font-size:14px;text-indent:10px;color:#737373'>{3}</td></tr></table><p><b>{4}</b></p>"; return(string.Format(prefix, "#" + Color.ToString().Substring(3), Initials, From, contentDate, Subject) + text + "</body></html>"); }
private async void Shezhi_zhu_Loaded(object sender, RoutedEventArgs e) { //更新UI toggle1.IsOn = daima.huancun.shezhi_Quanju.shifou_fenxiang_baocun; if (toggle1.IsOn == false) { textbox1.IsEnabled = false; button1.IsEnabled = false; } textbox1.Text = daima.huancun.shezhi_Quanju.baocun_wenjianjia_lujing; textblock9.Text = daima.Gongju.zhanyongkongjian(daima.huancun.shezhi_Quanju.zuida_huancun * 1024 * 1024); combobox1.SelectedIndex = daima.huancun.shezhi_Quanju.huancun_qingli_fangshi; slider1.Value = daima.huancun.shezhi_Quanju.zuida_huancun; image4.Source = await daima.huancun.shezhi_Quanju.huoqu_beijing_tupianAsync(); Windows.UI.Color linshi1 = Windows.UI.Color.FromArgb(daima.huancun.shezhi_Quanju.A, daima.huancun.shezhi_Quanju.R, daima.huancun.shezhi_Quanju.G, daima.huancun.shezhi_Quanju.B); color1.Color = linshi1; danqian_yanse = textbox2.Text = linshi1.ToString(); if (daima.huancun.shezhi_Quanju.zhuti_xuanzhe != 2) { textblock15.Visibility = Visibility.Collapsed; textblock16.Visibility = Visibility.Collapsed; button4.Visibility = Visibility.Collapsed; image4.Visibility = Visibility.Collapsed; textbox2.Visibility = Visibility.Collapsed; textblock19.Visibility = Visibility.Collapsed; textblock20.Visibility = Visibility.Collapsed; textblock21.Visibility = Visibility.Collapsed; textblock22.Visibility = Visibility.Collapsed; textblock23.Visibility = Visibility.Collapsed; button5.Visibility = Visibility.Collapsed; radio2.Visibility = Visibility.Collapsed; radio3.Visibility = Visibility.Collapsed; slider2.Visibility = Visibility.Collapsed; } else { textblock15.Visibility = Visibility.Visible; textblock16.Visibility = Visibility.Visible; button4.Visibility = Visibility.Visible; image4.Visibility = Visibility.Visible; textbox2.Visibility = Visibility.Visible; textblock19.Visibility = Visibility.Visible; textblock20.Visibility = Visibility.Visible; textblock21.Visibility = Visibility.Visible; textblock22.Visibility = Visibility.Visible; textblock23.Visibility = Visibility.Visible; button5.Visibility = Visibility.Visible; radio2.Visibility = Visibility.Visible; radio3.Visibility = Visibility.Visible; slider2.Visibility = Visibility.Visible; } if (daima.huancun.shezhi_Quanju.tupian_chuli == 0 || daima.huancun.shezhi_Quanju.tupian_chuli == 1) { textblock21.Visibility = Visibility.Collapsed; textblock22.Visibility = Visibility.Collapsed; slider2.Visibility = Visibility.Collapsed; } slider2.Value = daima.huancun.shezhi_Quanju.toumingdu * 100; textblock22.Text = slider2.Value + "%"; radio1.SelectedIndex = daima.huancun.shezhi_Quanju.zhuti_xuanzhe; radio2.SelectedIndex = daima.huancun.shezhi_Quanju.tupian_chuli; radio3.SelectedIndex = daima.huancun.shezhi_Quanju.wenzi_zhuti; toggle2.IsOn = daima.huancun.shezhi_Quanju.shifou_liulanqi_touming; //计算缓存大小 IAsyncAction asyncAction = Windows.System.Threading.ThreadPool.RunAsync( (workItem) => { jisuan_huancun(); }); shifou_jiazai = true; }