public Project1UIWindow() { this.DefaultStyleKey = typeof(Project1UIWindow); //添加当前窗体到窗体集合 WindowsCollection.Add(this); NavigationViewAnimation = new DoubleAnimation(); NavigationViewStoryboard = new Storyboard(); theme = new Theme(); theme.ApplyTheme(); //命令绑定 this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.MinimizeWindowCommand, OnMinimizeWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.MaximizeWindowCommand, OnMaximizeWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.RestoreWindowCommand, OnRestoreWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.CloseWindowCommand, OnCloseWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.LogoButtonClickCommand, OnLogoButtonClickCommand)); //HandleAnimationSetting(); Loaded += new RoutedEventHandler(window_Loaded); //动画 var transformGroup = new TransformGroup(); RenderTransform = transformGroup; //获取屏幕尺寸 var intPtr = new WindowInteropHelper(this).Handle; //获取当前窗口的句柄 var screen = System.Windows.Forms.Screen.FromHandle(intPtr); //获取当前屏幕 ScreenArea = screen.Bounds; }
public App() { Theme theme = new Theme(); UIDefaultSetting.DefaultThemeName = "blue"; UIDefaultSetting.DefaultThemePath = "/ProjectEye;component/Resources/Themes/"; theme.ApplyTheme(); }
/// <summary> /// 设置主题 /// </summary> /// <param name="themeName"></param> public void SetTheme(string themeName) { if (Project1.UI.Cores.UIDefaultSetting.DefaultThemeName != themeName) { Project1.UI.Cores.UIDefaultSetting.DefaultThemeName = themeName; Project1.UI.Cores.UIDefaultSetting.DefaultThemePath = "/ProjectEye;component/Resources/Themes/"; theme.ApplyTheme(); } }
public void HtmlColorTest() { var form = new TestForm { BackColor = Color.Black }; const string htmlColor = "#2060ff"; var theme = new Theme(new[] { new SelectorBlock("Form", new[] { new Property("BackColor", htmlColor) }) }); theme.ApplyTheme(form); Assert.Equal(ColorTranslator.FromHtml(htmlColor), form.BackColor); }
public void SelectWithVariables() { IWinformThemeElement variables = new VariableBlock(new[] { new Property("colorOfSky", "Blue") }); IWinformThemeElement selector = new SelectorBlock("Form", new[] { new Property("BackColor", "@colorOfSky") }); var theme = new Theme(new[] { variables, selector }); var form = new TestForm { BackColor = Color.Black }; theme.ApplyTheme(form); Assert.Equal(Color.Blue, form.BackColor); }
private void _twainVM_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "State") { if (_twainVM.State == 5) { Theme.ApplyTheme(ThemeColor.Light, Accent.Orange); } else if (_twainVM.State == 4) { Theme.ApplyTheme(ThemeColor.Light, Accent.Green); } } }
/// <summary> /// 设置主题 /// </summary> /// <param name="themeName"></param> public void SetTheme(string themeName) { if (Project1.UI.Cores.UIDefaultSetting.DefaultThemeName != themeName) { string oldName = Project1.UI.Cores.UIDefaultSetting.DefaultThemeName; Project1.UI.Cores.UIDefaultSetting.DefaultThemeName = themeName; Project1.UI.Cores.UIDefaultSetting.DefaultThemePath = "/ProjectEye;component/Resources/Themes/"; theme.ApplyTheme(); OnChangedTheme?.Invoke(oldName, themeName); } }
private void themeListView_SelectedIndexChanged(object sender, EventArgs e) { if (themeListView.FocusedItem == null) { return; } Theme theme = (Theme)themeListView.FocusedItem.Tag; theme.ApplyTheme(PreviewPanel, new Type[] { typeof(Label), typeof(Button), typeof(CircularProgressBar.CircularProgressBar), typeof(ComboBox), typeof(CheckBox) }); Global_Hour.ForeColor = theme.OtherForeground; Global_HourColon.ForeColor = theme.OtherForeground; Task_Hour.ForeColor = theme.OtherForeground; Task_HourColon.ForeColor = theme.OtherForeground; Task_Minute.ForeColor = theme.OtherForeground; Task_MinuteColon.ForeColor = theme.OtherForeground; }
public void NestedSelectors() { var form = new TestForm(); form.button1.Tag = form.button2.Tag = "yellow"; form.BackColor = form.button1.BackColor = form.button2.BackColor = Color.Black; IWinformThemeElement yellowClassSelector = new SelectorBlock(".yellow", new[] { new Property("BackColor", "Yellow") }); IWinformThemeElement panel1Selector = new SelectorBlock("#panel1", new[] { new Property("BackColor", "Blue"), yellowClassSelector }); var theme = new Theme(new[] { panel1Selector }); theme.ApplyTheme(form); Assert.Equal(Color.Black, form.BackColor); Assert.Equal(Color.Black, form.button1.BackColor); Assert.Equal(Color.Yellow, form.button2.BackColor); Assert.Equal(Color.Blue, form.panel1.BackColor); }
public Project1UIWindow() { this.DefaultStyleKey = typeof(Project1UIWindow); //添加当前窗体到窗体集合 WindowsCollection.Add(this); NavigationViewAnimation = new DoubleAnimation(); NavigationViewStoryboard = new Storyboard(); theme = new Theme(); theme.ApplyTheme(); //命令绑定 this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.MinimizeWindowCommand, OnMinimizeWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.MaximizeWindowCommand, OnMaximizeWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.RestoreWindowCommand, OnRestoreWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.CloseWindowCommand, OnCloseWindowCommand)); this.CommandBindings.Add(new CommandBinding(Project1UIWindowCommands.LogoButtonClickCommand, OnLogoButtonClickCommand)); Loaded += new RoutedEventHandler(window_Loaded); }
public void SetFieldColors(IGameCustomizationHandler handler) { lock (this) { foreach (var iteraterow in FieldContents) { foreach (var iteratecell in iteraterow) { if (iteratecell != null && iteratecell.Owner != null) { Theme.ApplyTheme(iteratecell.Owner, handler, this, NominoTheme.ThemeApplicationReason.Normal); } } } HasChanged = true; } }
private static void ApplyAndAssertBackColorRed(Form form, string identifier, params Control[] assertOnControls) { foreach (var control in assertOnControls) { control.BackColor = Color.Black; } form.BackColor = Color.Black; var theme = new Theme(new[] { new SelectorBlock(identifier, new[] { new Property("BackColor", "Red") }) }); theme.ApplyTheme(form); if (assertOnControls.Length == 0) { assertOnControls = new[] { form } } ; Assert.All(assertOnControls, control => Assert.Equal(Color.Red, control.BackColor)); }
public void Execute() { var currentTheme = Theme.GetCurrentThemeName(); switch (currentTheme) { case "": Theme.ApplyTheme("Themes/Light/LightTheme.xaml"); break; case "LightTheme.xaml": // Theme.ApplyTheme("Themes/Dark/DarkTheme.xaml"); Theme.ClearApplicationThemeToDefault(); break; // default: // Theme.ApplyTheme("Themes/Light/LightTheme.xaml"); break; } }
public void ThemeWithInlude() { IWinformThemeElement variables = new VariableBlock(new[] { new Property("colorOfSky", "Blue") }); IWinformThemeElement selector = new SelectorBlock("Form", new[] { new Property("BackColor", "@colorOfSky") }); var theme = new Theme(new[] { variables, selector }); var theme2 = new Theme(new[] { new SelectorBlock("Button", new[] { new Property("BackColor", "Yellow") }) }); theme.IncludeThemes.Add(theme2); var form = new TestForm { BackColor = Color.Black }; form.button1.BackColor = Color.Black; form.button2.BackColor = Color.Black; theme.ApplyTheme(form); Assert.Equal(Color.Blue, form.BackColor); Assert.Equal(Color.Yellow, form.button1.BackColor); Assert.Equal(Color.Yellow, form.button2.BackColor); }
private void TwainVM_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "State") { if (twainVM.State == 5) { Theme.ApplyTheme(ThemeColor.Light, Accent.Orange); } else if (twainVM.State == 4) { Theme.ApplyTheme(ThemeColor.Light, Accent.Gold); } } if (e.PropertyName == "SelectedImage") { if (twainVM.CapturedImages.Count > 0) { ImageControls.Visibility = Visibility.Visible; SendButton.Visibility = Visibility.Visible; ScansListBox.ScrollIntoView(twainVM.SelectedImage); } else { ImageControls.Visibility = Visibility.Hidden; SendButton.Visibility = Visibility.Hidden; } } if (e.PropertyName == "StartUpload") { UploadingPDF.Visibility = Visibility.Visible; } if (e.PropertyName == "Uploaded") { UploadingPDF.Visibility = Visibility.Hidden; } }
private void radioAccent_Checked(object sender, RoutedEventArgs e) { var accent = (Accent)((RadioButton)sender).DataContext; Theme.ApplyTheme(Theme.CurrentTheme.GetValueOrDefault(), accent, this.Resources); }
private void cbxThemes_SelectedIndexChanged(object sender, EventArgs e) { switch (cbxThemes.SelectedIndex) { case 0: Theme.ApplyTheme(Theme.Themes.DarkGreen); break; case 1: Theme.ApplyTheme(Theme.Themes.DarkBlue); break; case 2: Theme.ApplyTheme(Theme.Themes.DarkCyan); break; case 3: Theme.ApplyTheme(Theme.Themes.DarkGray); break; case 4: Theme.ApplyTheme(Theme.Themes.DarkPurple); break; case 5: Theme.ApplyTheme(Theme.Themes.DarkRed); break; case 6: Theme.ApplyTheme(Theme.Themes.LightBlue); break; case 7: Theme.ApplyTheme(Theme.Themes.LightCyan); break; case 8: Theme.ApplyTheme(Theme.Themes.LightGray); break; case 9: Theme.ApplyTheme(Theme.Themes.LightPurple); break; case 10: Theme.ApplyTheme(Theme.Themes.LightRed); break; default: break; } }
protected override void OnStartup(StartupEventArgs e) { Theme.ApplyTheme(ThemeColor.Light, Accent.Green); base.OnStartup(e); }