Esempio n. 1
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                desktop.MainWindow = new MainWindow
                {
                    DataContext = new MainWindowViewModel(),
                };
            }
            else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime)
            {
                singleViewLifetime.MainView = new MainView
                {
                    DataContext = new MainWindowViewModel(),
                };
            }

            var theme = new Avalonia.Themes.Default.DefaultTheme();

            theme.TryGetResource("Button", out _);

            var theme1 = new Avalonia.Themes.Fluent.FluentTheme();

            theme1.TryGetResource("Button", out _);

            base.OnFrameworkInitializationCompleted();
        }
Esempio n. 2
0
 private void InitializeComponent()
 {
     // TODO: iOS does not support dynamically loading assemblies
     // so we must refer to this resource DLL statically. For
     // now I am doing that here. But we need a better solution!!
     // Note, theme swiching probably will not work in runtime for iOS.
     if (Application.Current.Styles.Contains(App.FluentDark) ||
         Application.Current.Styles.Contains(App.FluentLight))
     {
         var theme = new Avalonia.Themes.Fluent.FluentTheme();
         theme.TryGetResource("Button", out _);
     }
     else
     {
         var theme = new Avalonia.Themes.Default.DefaultTheme();
         theme.TryGetResource("Button", out _);
     }
     AvaloniaXamlLoader.Load(this);
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                desktop.MainWindow = new MainWindow
                {
                    DataContext = new MainWindowViewModel()
                };

                desktop.Exit += OnExit;
            }

            var theme = new Themes.Default.DefaultTheme();

            theme.TryGetResource("Button", out _);

            var theme1 = new Themes.Fluent.FluentTheme();

            theme1.TryGetResource("Button", out _);

            base.OnFrameworkInitializationCompleted();
        }