public static Uri Validate(IAvaloniaObject obj, Uri src) { var style = new StyleInclude(new Uri("avares://Markdown.AvaloniaFluentDemo/Styles")) { Source = src }; var app = Application.Current; if (app.Styles.Count == 0) { app.Styles.Add(style); return(src); } var oldStyle = app.Styles[0]; if (!(oldStyle is StyleInclude oldStyleInc && oldStyleInc.Source == style.Source)) { app.Styles[0] = style; } return(src); }
public void SetThemeNotChangeValue(AppTheme value) { string?the; //FluentThemeMode mode; switch (value) { case AppTheme.Light: the = "Light"; //mode = FluentThemeMode.Light; break; case AppTheme.Dark: default: the = "Dark"; //mode = FluentThemeMode.Dark; break; } //var uri_0 = new Uri($"avares://Avalonia.Themes.Fluent/Fluent{the}.xaml"); var uri_1 = new Uri($"avares://System.Application.SteamTools.Client.Avalonia/Application/UI/Styles/Theme{the}.xaml"); //Styles[0] = new FluentTheme(uri_0) //{ // Mode = mode, //}; Styles[1] = new StyleInclude(uri_1) { Source = uri_1, }; AvaloniaLocator.Current.GetService <FluentAvaloniaTheme>() !.RequestedTheme = the; }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); mainPanel = this.FindControl <Panel>("mainPanel"); lblStatus = this.FindControl <TextBlock>("lblStatus"); cbIsGloballyActive = this.FindControl <CheckBox>("cbIsGlobalActive"); menuRecentFiles = this.FindControl <MenuItem>("menuRecentFiles"); Groups = new List <Group>(); IsGloballyActive = true; // create global input hook once GlobalInput = new GlobalInputWindows(); this.Closed += MainWindow_Closed; // load recent files to menu UpdateRecentFilesMenu(); // use dark theme var dark = new StyleInclude(new Uri("resm:Styles?assembly=KeySequenceSimulator")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") //Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/FluentDark.xaml") }; Application.Current.Styles.Add(dark); }
public SettingsPageViewModel(IScreen screen) : base(screen) { Title = "Settings"; NextCommand = ReactiveCommand.Create(() => screen.Router.Navigate.Execute(new SettingsPageViewModel(screen))); OpenDialogCommand = ReactiveCommand.CreateFromTask(async() => await ConfirmSetting.Handle("Please confirm the setting:").ToTask()); ConfirmSetting = new Interaction <string, bool>(); ConfirmSetting.RegisterHandler( async interaction => { var x = new TestDialogViewModel(screen, interaction.Input); var result = await x.ShowDialogAsync(); interaction.SetOutput(result); }); ChangeThemeCommand = ReactiveCommand.Create(() => { var currentTheme = Application.Current.Styles.Select(x => (StyleInclude)x).FirstOrDefault(x => x.Source is { } && x.Source.AbsolutePath.Contains("Themes")); if (currentTheme?.Source is { } src) { var themeIndex = Application.Current.Styles.IndexOf(currentTheme); var newTheme = new StyleInclude(new Uri("avares://WalletWasabi.Fluent/App.xaml")) { Source = new Uri($"avares://WalletWasabi.Fluent/Styles/Themes/{(src.AbsolutePath.Contains("Light") ? "BaseDark" : "BaseLight")}.xaml") }; Application.Current.Styles[themeIndex] = newTheme; } });
public void ChangeLanguage(string language) { IStyle lang; switch (GeneralSettings.Settings.Language) { case "ru": lang = new StyleInclude(new Uri("resm:Styles?assembly=Regul")) { Source = new Uri($"avares://Regul.SaveCleaner/Localization/{language}.axaml") }; break; default: lang = new StyleInclude(new Uri("resm:Styles?assembly=Regul")) { Source = new Uri("avares://Regul.SaveCleaner/Localization/en.axaml") }; break; } if (_indexLanguage == -1) { App.ModulesLanguage.Add(lang); } else { App.ModulesLanguage[_indexLanguage] = lang; return; } _indexLanguage = App.ModulesLanguage.IndexOf(lang); }
public MainView() { this.InitializeComponent(); var _themeSelector = this.Find <ComboBox>("themeSelector"); _themeSelector.SelectionChanged += (sender, e) => { switch (_themeSelector.SelectedIndex) { case 0: Styles[0] = _lightTheme; break; case 1: Styles[0] = _darkTheme; break; } }; _lightTheme = new StyleInclude(new Uri("resm:Styles?assembly=ThemeEditor")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") }; _darkTheme = new StyleInclude(new Uri("resm:Styles?assembly=ThemeEditor")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") }; Styles.Add(_darkTheme); }
private StyleInclude IncludeStyle(string uri) { var u = new Uri(uri); var style = new StyleInclude(u); style.Source = u; return(style); }
/// <summary> /// fills the theme through the generation file /// </summary> private void EnsureThemes() { if (themes.Count > 0) { return; } try { var assembly = typeof(ThemeManager).Assembly; string resourceName = assembly.GetManifestResourceNames().FirstOrDefault(x => x.Contains(GeneratedParameterFile)); GeneratorParameters generatorParameters = null; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { using (StreamReader sr = new StreamReader(stream)) { generatorParameters = JsonConvert.DeserializeObject <GeneratorParameters>(sr.ReadToEnd()); } } string nameSpace = typeof(ThemeManager).Namespace; string basePath = resourceName.Replace(GeneratedParameterFile, string.Empty) .Replace(nameSpace, string.Empty) .Replace(".", "/"); basePath = nameSpace + basePath; List <string> availableXamlThemes = new List <string>(); foreach (var colorScheme in generatorParameters.ColorSchemes.Select(x => x.Name)) { foreach (var baseColorScheme in generatorParameters.BaseColorSchemes.Select(x => x.Name)) { string themeName = $"{baseColorScheme}.{colorScheme}"; string xamlPathName = basePath + $"{themeName}.xaml"; availableXamlThemes.Add(xamlPathName); } } availableXamlThemes = availableXamlThemes.OrderBy(x => x).ToList(); foreach (string xamlFile in availableXamlThemes) { string tempXamlPath = xamlFile.Replace("/", "."); var theme = new StyleInclude(new Uri("resm:Styles?assembly=Avalonia.ExtendedToolkit")) { //resm:Avalonia.Controls.DataGrid.Themes.Default.xaml?assembly=Avalonia.Controls.DataGrid Source = new Uri($"avares://{xamlFile}") //Source = new Uri($"resm:{tempXamlPath}?assembly=Avalonia.ExtendedToolkit") }; themesInternal.Add(new Theme(theme)); } } catch (Exception e) { throw new InvalidOperationException(e.Message); } }
/// <summary> /// Loads a theme from the given XAML path within the QuestPatcher project. /// </summary> /// <param name="xamlPath">Path to the XAML for the theme</param> /// <param name="name">Name of the theme</param> /// <returns>Loaded theme</returns> public static Theme LoadEmbeddedTheme(string xamlPath, string name) { IStyle styling = new StyleInclude(new Uri("resm:Styles?assembly=QuestPatcher")) { Source = new Uri($"avares://QuestPatcher/{xamlPath}") }; return(new Theme(styling, name)); }
public MainView() { AvaloniaXamlLoader.Load(this); if (AvaloniaLocator.Current.GetService <IRuntimePlatform>().GetRuntimeInfo().IsDesktop) { IList tabItems = ((IList)this.FindControl <TabControl>("Sidebar").Items); tabItems.Add(new TabItem() { Header = "Dialogs", Content = new DialogsPage() }); tabItems.Add(new TabItem() { Header = "Screens", Content = new ScreenPage() }); } var light = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") }; var dark = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") }; var themes = this.Find <ComboBox>("Themes"); themes.SelectionChanged += (sender, e) => { switch (themes.SelectedIndex) { case 0: Styles[0] = light; break; case 1: Styles[0] = dark; break; } }; Styles.Add(light); var decorations = this.Find <ComboBox>("Decorations"); decorations.SelectionChanged += (sender, e) => { if (VisualRoot is Window window) { window.SystemDecorations = (SystemDecorations)decorations.SelectedIndex; } }; }
/// <summary> /// gets the correct visual from the xaml /// </summary> public MessageBoxImageToImageSourceConverter() { var icons = new StyleInclude(new Uri($"resm:Styles?assembly={this.GetType().Namespace}")) { Source = new Uri(HandStopErrorResource) }; object icon = null; if (icons.TryGetResource("appbar_noentry", out icon)) { hand_stop_error = icon as IVisual; } }
public ThemeModel(string name, params Uri[] themeStyleUris) { Name = name; var styles = new List <IStyle>(); foreach (var styleUri in themeStyleUris) { var style = new StyleInclude(styleUri) { Source = styleUri }; styles.Add(style); } Styles = styles; }
/// <summary> /// loads the skins and sets the selected skin to the first item. /// </summary> private void EnsureSkins() { if (skins.Count > 0) { return; } foreach (SkinType item in Enum.GetValues(typeof(SkinType))) { string xamlFile = string.Empty; switch (item) { case SkinType.OfficeBlack: xamlFile = string.Format(FormatedStyleResource, OfficeBlackStylePrefix); break; case SkinType.OfficeBlue: xamlFile = string.Format(FormatedStyleResource, OfficeBlueStylePrefix); break; case SkinType.OfficeSilver: xamlFile = string.Format(FormatedStyleResource, OfficeSilverStylePrefix); break; case SkinType.Windows7: xamlFile = string.Format(FormatedStyleResource, Windows7StylePrefix); break; case SkinType.MahApps: xamlFile = string.Format(FormatedStyleResource, MahAppsStylePrefix); break; } var skinStyle = new StyleInclude(new Uri($"resm:Styles?assembly={this.GetType().Namespace}")) { Source = new Uri(xamlFile) }; skinsInternal.Add(new Skin(item, skinStyle)); } SelectedSkin = skinsInternal.FirstOrDefault(x => x.SkinType == SkinType.MahApps); }
public static void SetStyle(this Window window, string styleUri) { if (string.IsNullOrEmpty(styleUri)) { return; } try { StyleInclude style = new StyleInclude(new Uri(styleUri)) { Source = new Uri(styleUri) }; window.Styles.Add(style); } catch { // ignored } }
public static Uri Validate(IAvaloniaObject obj, Uri src) { var ctrl = obj as Control; var style = new StyleInclude(new Uri("avares://Markdown.AvaloniaDemo/Styles")) { Source = src }; if (ctrl.Styles.Count == 0) { ctrl.Styles.Add(style); } else { ctrl.Styles[0] = style; } return(src); }
public MainWindow() { InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif var light = new StyleInclude(new Uri("resm:Styles?assembly=UdpServer")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") }; var dark = new StyleInclude(new Uri("resm:Styles?assembly=UdpServer")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") }; _light = light; _dark = dark; Styles.Add(light); }
public MainWindow() { InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif notificationManager = new WindowNotificationManager(this) { Position = NotificationPosition.TopRight, MaxItems = 3 }; var _themeSelector = this.Find <CheckBox>("themeSelector"); _themeSelector.Checked += (sender, e) => { Styles[0] = _darkTheme; }; _themeSelector.Unchecked += (sender, e) => { Styles[0] = _lightTheme; }; _lightTheme = new StyleInclude(new Uri("resm:Styles?assembly=Solria.SAFT.Desktop")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") }; _darkTheme = new StyleInclude(new Uri("resm:Styles?assembly=Solria.SAFT.Desktop")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") }; Styles.Add(_darkTheme); txtMessage = this.Find <TextBlock>("messages"); this.WhenActivated(disposables => { Disposable.Create(() => { }) .DisposeWith(disposables); }); }
private void SetLightTheme() { var theme = new Avalonia.Themes.Fluent.FluentTheme(new System.Uri("avares://Avalonia.Themes.Fluent/FluentTheme.xaml")); var oxyPlotUri = new System.Uri("resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia"); var lightUri = new System.Uri("avares://PingLogger/Themes/Light.axaml"); var lightXAML = new StyleInclude(lightUri) { Source = lightUri }; var oxyPlotTheme = new StyleInclude(oxyPlotUri) { Source = oxyPlotUri }; Styles.Clear(); theme.Mode = Avalonia.Themes.Fluent.FluentThemeMode.Light; Styles.Add(oxyPlotTheme); Styles.Add(theme); Styles.Add(lightXAML); DarkMode = false; }
private void SetDarkTheme() { var theme = new Avalonia.Themes.Fluent.FluentTheme(new System.Uri("avares://Avalonia.Themes.Fluent/FluentTheme.xaml")); var oxyPlotUri = new System.Uri("resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia"); var darkUri = new System.Uri("avares://PingLogger/Themes/Dark.axaml"); var darkXAML = new StyleInclude(darkUri) { Source = darkUri }; var oxyPlotTheme = new StyleInclude(oxyPlotUri) { Source = oxyPlotUri }; Styles.Clear(); theme.Mode = Avalonia.Themes.Fluent.FluentThemeMode.Dark; Styles.Add(oxyPlotTheme); Styles.Add(theme); Styles.Add(darkXAML); DarkMode = true; }
public override void Initialize() { AvaloniaXamlLoader.Load(this); switch (ReplayLoader.ColorScheme.SchemeType) { case Core.ColorScheme.Type.Dark: var dark = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") }; Styles.Add(dark); break; case Core.ColorScheme.Type.Light: var light = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") }; Styles.Add(light); break; } }
public static void SetTheme(Window window, string theme) { var light = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default") }; var dark = new StyleInclude(new Uri("resm:Styles?assembly=ControlCatalog")) { Source = new Uri("resm:Avalonia.Themes.Default.Accents.BaseDark.xaml?assembly=Avalonia.Themes.Default") }; switch (theme) { case "Dark": window.Styles[0] = dark; break; default: window.Styles[0] = light; break; } }
public override void Execute(object?parameter) { var useLight = parameter is true; // This is slated to change in future release of Avalonia var styles = new StyleInclude(new Uri("resm:Styles")) { Source = useLight ? new Uri("avares://Avalonia.Themes.Default/Accents/BaseLight.xaml") : new Uri("avares://Avalonia.Themes.Default/Accents/BaseDark.xaml") }; Application.Current !.Styles[1] = styles; var overrides = new StyleInclude(new Uri("resm:Styles")) { Source = useLight ? new Uri("avares://Loon/Assets/LightThemeOverrides.xaml") : new Uri("avares://Loon/Assets/DarkThemeOverrides.xaml") }; Application.Current !.Styles[2] = overrides; }
public static void SetTheme(StyleInclude style) { App.Current.Styles[1] = style; }
public SettingsPageViewModel(NavigationStateViewModel navigationState) : base(navigationState) { Title = "Settings"; Global = Locator.Current.GetService <Global>(); this.ValidateProperty(x => x.DustThreshold, ValidateDustThreshold); this.ValidateProperty(x => x.TorSocks5EndPoint, ValidateTorSocks5EndPoint); this.ValidateProperty(x => x.BitcoinP2PEndPoint, ValidateBitcoinP2PEndPoint); _darkModeEnabled = true; _selectedTab = 0; Autocopy = Global.UiConfig.Autocopy; CustomFee = Global.UiConfig.IsCustomFee; CustomChangeAddress = Global.UiConfig.IsCustomChangeAddress; var config = new Config(Global.Config.FilePath); config.LoadOrCreateDefaultFile(); _network = config.Network; _torSocks5EndPoint = config.TorSocks5EndPoint.ToString(-1); UseTor = config.UseTor; TerminateTorOnExit = config.TerminateTorOnExit; StartLocalBitcoinCoreOnStartup = config.StartLocalBitcoinCoreOnStartup; StopLocalBitcoinCoreOnShutdown = config.StopLocalBitcoinCoreOnShutdown; _minimalPrivacyLevel = config.PrivacyLevelSome; _mediumPrivacyLevel = config.PrivacyLevelFine; _strongPrivacyLevel = config.PrivacyLevelStrong; _dustThreshold = config.DustThreshold.ToString(); _bitcoinP2PEndPoint = config.GetP2PEndpoint().ToString(defaultPort: -1); _localBitcoinCoreDataDir = config.LocalBitcoinCoreDataDir; IsModified = !Global.Config.AreDeepEqual(config); this.WhenAnyValue( x => x.Network, x => x.UseTor, x => x.TerminateTorOnExit, x => x.StartLocalBitcoinCoreOnStartup, x => x.StopLocalBitcoinCoreOnShutdown) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(_ => Save()); this.WhenAnyValue(x => x.Autocopy) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(x => Global.UiConfig.Autocopy = x); this.WhenAnyValue(x => x.CustomFee) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(x => Global.UiConfig.IsCustomFee = x); this.WhenAnyValue(x => x.CustomChangeAddress) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(x => Global.UiConfig.IsCustomChangeAddress = x); OpenConfigFileCommand = ReactiveCommand.CreateFromTask(OpenConfigFileAsync); TextBoxLostFocusCommand = ReactiveCommand.Create(Save); Observable .Merge(OpenConfigFileCommand.ThrownExceptions) .Merge(TextBoxLostFocusCommand.ThrownExceptions) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(ex => Logger.LogError(ex)); SelectedFeeDisplayFormat = Enum.IsDefined(typeof(FeeDisplayFormat), Global.UiConfig.FeeDisplayFormat) ? (FeeDisplayFormat)Global.UiConfig.FeeDisplayFormat : FeeDisplayFormat.SatoshiPerByte; this.WhenAnyValue(x => x.SelectedFeeDisplayFormat) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => Global.UiConfig.FeeDisplayFormat = (int)x); this.WhenAnyValue(x => x.DarkModeEnabled) .Skip(1) .Subscribe( _ => { var currentTheme = Application.Current.Styles.Select(x => (StyleInclude)x).FirstOrDefault(x => x.Source is { } && x.Source.AbsolutePath.Contains("Themes")); if (currentTheme?.Source is { } src) { var themeIndex = Application.Current.Styles.IndexOf(currentTheme); var newTheme = new StyleInclude(new Uri("avares://WalletWasabi.Fluent/App.xaml")) { Source = new Uri($"avares://WalletWasabi.Fluent/Styles/Themes/{(src.AbsolutePath.Contains("Light") ? "BaseDark" : "BaseLight")}.xaml") }; Application.Current.Styles[themeIndex] = newTheme; } });
public void SetTheme(StyleInclude style) { Styles[1] = style; }
public ThemeService(Theme theme) { _lightTheme = CreateStyle("avares://InDepthSearch.UI/Themes/Light.xaml"); _darkTheme = CreateStyle("avares://InDepthSearch.UI/Themes/Dark.xaml"); currentTheme = theme; }
private static void UpdateTheme(StyleInclude theme) { var app = Application.Current; app.Styles[1] = theme; }