Пример #1
0
 protected override void StartApplicationInternal(Operation <Window> operation)
 {
     app_builder
     .AfterSetup(delegate(AppBuilder builder) {
         ((IClassicDesktopStyleApplicationLifetime)builder.Instance.ApplicationLifetime).MainWindow = operation();
     })
     .StartWithClassicDesktopLifetime(Empty.Array <string>());
 }
        public static AppBuilder HandleOSThemeChange(this AppBuilder appBuilder)
        {
            return(appBuilder.AfterSetup(_ =>
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    MessageCommunicatorGlobalProperties.Current.CurrentTheme = WindowsThemeToMessageCommunicator(
                        WindowsThemeDetector.GetWindowsTheme());

                    var syncContext = SynchronizationContext.Current;
                    if (syncContext is AvaloniaSynchronizationContext)
                    {
                        WindowsThemeDetector.ListenForThemeChangeEvent(newTheme =>
                        {
                            syncContext.Post(args =>
                            {
                                MessageBus.Current.SendMessage(
                                    new MessageThemeChangeRequest(WindowsThemeToMessageCommunicator(newTheme)));
                            }, null);
                        });
                    }
                }
            }));
        }