示例#1
0
        public async Task SetOptions(LiveWallpaperOptions setting)
        {
            var ipc = await GetIPCHelper();

            await ipc.Send(new InvokeILiveWallpaperAPI()
            {
                InvokeMethod = nameof(ILiveWallpaperAPI.SetOptions),
                Parameters   = new object[] { setting }
            });
        }
        public async Task SetOptions(LiveWallpaperOptions setting)
        {
            try
            {
                using var cts = new CancellationTokenSource();
                cts.CancelAfter(TimeSpan.FromSeconds(10));

                var reply = await _client.SetOptionsAsync(setting);
            }
            catch (Exception)
            {
            }
        }
示例#3
0
        public static async Task ApplySetting(SettingObject setting)
        {
            LocalWallpaperDir = Setting.General.WallpaperSaveDir;
            string cultureName = setting.General.CurrentLan;

            if (cultureName == null)
            {
                cultureName = Thread.CurrentThread.CurrentUICulture.Name;
            }

            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cultureName);
            await LanService.UpdateLanguage();

            try
            {
                await _startupManager.Set(setting.General.StartWithWindows);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
            setting.General.StartWithWindows = await _startupManager.Check();

            var screenSetting = WallpaperManager.Instance.ScreenIndexs.Select((m) => new ScreenOption()
            {
                ScreenIndex      = m,
                WhenAppMaximized = setting.Wallpaper.ActionWhenMaximized,
            }).ToList();

            var liveWallpaperOptions = new LiveWallpaperOptions
            {
                AppMaximizedEffectAllScreen = true,
                AudioScreenIndex            = setting.Wallpaper.AudioSource,
                ScreenOptions = screenSetting
            };

            await WallpaperManager.Instance.SetOptions(liveWallpaperOptions);
        }
示例#4
0
        public Task SetOptions(LiveWallpaperOptions options)
        {
            Options = options;

            ExplorerMonitor.ExpolrerCreated -= ExplorerMonitor_ExpolrerCreated;
            MaximizedMonitor.AppMaximized   -= MaximizedMonitor_AppMaximized;

            if (options.AutoRestartWhenExplorerCrash == true)
            {
                ExplorerMonitor.ExpolrerCreated += ExplorerMonitor_ExpolrerCreated;
            }

            bool enableMaximized = options.ScreenOptions.Exists(m => m.WhenAppMaximized != ActionWhenMaximized.Play);

            if (enableMaximized)
            {
                MaximizedMonitor.AppMaximized += MaximizedMonitor_AppMaximized;
            }

            StartTimer(options.AutoRestartWhenExplorerCrash != null && options.AutoRestartWhenExplorerCrash.Value || enableMaximized);

            return(Task.CompletedTask);
        }
示例#5
0
        public MainWindow()
        {
            WallpaperManager.InitUIDispatcher(Dispatcher);
            InitializeComponent();
            //用node+electron+http api渲染,待c#有更好的库时,再考虑c#渲染
            RenderFactory.Renders.Add(typeof(ElectronWebRender), ElectronWebRender.StaticSupportTypes);

            monitors.ItemsSource = monitorsVM = Screen.AllScreens.Select(m => new Monitor()
            {
                DeviceName = m.DeviceName,
                Checked    = true
            }).ToList();

            var audioOption = Screen.AllScreens.Select(m => new DescriptorInfo()
            {
                Text         = m.DeviceName,
                DefaultValue = Screen.AllScreens.ToList().IndexOf(m)
            }).ToList();

            audioOption.Insert(0, new DescriptorInfo()
            {
                Text = "禁用", DefaultValue = -1
            });

            var screenSetting = Screen.AllScreens.Select(m => new ScreenOption()
            {
                ScreenIndex      = (uint)Screen.AllScreens.ToList().IndexOf(m),
                WhenAppMaximized = ActionWhenMaximized.Pause,
            }).ToList();

            var screenSettingOptions = new List <DescriptorInfo>()
            {
                new DescriptorInfo()
                {
                    Text = "播放", DefaultValue = ActionWhenMaximized.Play
                },
                new DescriptorInfo()
                {
                    Text = "暂停", DefaultValue = ActionWhenMaximized.Pause
                },
                new DescriptorInfo()
                {
                    Text = "停止", DefaultValue = ActionWhenMaximized.Stop
                },
            };

            var descInfo = new DescriptorInfoDict()
            {
                { nameof(LiveWallpaperOptions),
                  new DescriptorInfo()
                  {
                      Text = "壁纸设置",
                      PropertyDescriptors = new DescriptorInfoDict()
                      {
                          {
                              nameof(LiveWallpaperOptions.AudioScreenIndex),
                              new DescriptorInfo()
                              {
                                  Text         = "音源",
                                  Type         = PropertyType.Combobox, Options = new ObservableCollection <DescriptorInfo>(audioOption),
                                  DefaultValue = -1,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.AutoRestartWhenExplorerCrash),
                              new DescriptorInfo()
                              {
                                  Text         = "崩溃后自动恢复",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.AppMaximizedEffectAllScreen),
                              new DescriptorInfo()
                              {
                                  Text         = "全屏检测影响所有屏幕",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.ScreenOptions),
                              new DescriptorInfo()
                              {
                                  Text                = "显示器设置",
                                  Type                = PropertyType.List,
                                  CanAddItem          = false,
                                  CanRemoveItem       = false,
                                  DefaultValue        = screenSetting,
                                  PropertyDescriptors = new DescriptorInfoDict()
                                  {
                                      { nameof(ScreenOption.ScreenIndex), new DescriptorInfo()
                                        {
                                            Text = "屏幕", Type = PropertyType.Label
                                        } },
                                      { nameof(ScreenOption.WhenAppMaximized), new DescriptorInfo()
                                        {
                                            Text = "桌面被挡住时", Options = new ObservableCollection <DescriptorInfo>(screenSettingOptions)
                                        } }
                                  }
                              }
                          },
                      }
                  } }
            };
            var setting = new LiveWallpaperOptions()
            {
                ScreenOptions = screenSetting
            };
            var vm = ConfigerService.GetVM(setting, descInfo);

            configer.DataContext = vm;
        }
示例#6
0
        public MainWindow()
        {
            Activated   += MainWindow_Activated;
            Deactivated += MainWindow_Deactivated;
            WallpaperApi.Initlize(Dispatcher);
            InitializeComponent();
            monitors.ItemsSource = monitorsVM = Screen.AllScreens.Select(m => new Monitor()
            {
                DeviceName = m.DeviceName,
                Checked    = true
            }).ToList();

            var audioOption = Screen.AllScreens.Select(m => new DescriptorInfo()
            {
                Text         = m.DeviceName,
                DefaultValue = m.DeviceName
            }).ToList();

            audioOption.Insert(0, new DescriptorInfo()
            {
                Text = "Disabled", DefaultValue = null
            });

            var screenSetting = Screen.AllScreens.Select(m => new ScreenOption()
            {
                Screen           = m.DeviceName,
                WhenAppMaximized = ActionWhenMaximized.Pause,
            }).ToList();

            var screenSettingOptions = new List <DescriptorInfo>()
            {
                new DescriptorInfo()
                {
                    Text = "Play", DefaultValue = ActionWhenMaximized.Play
                },
                new DescriptorInfo()
                {
                    Text = "Pause", DefaultValue = ActionWhenMaximized.Pause
                },
                new DescriptorInfo()
                {
                    Text = "Stop", DefaultValue = ActionWhenMaximized.Stop
                },
            };

            var descInfo = new DescriptorInfoDict()
            {
                { nameof(LiveWallpaperOptions),
                  new DescriptorInfo()
                  {
                      Text = "Wallpaper Settings",
                      PropertyDescriptors = new DescriptorInfoDict()
                      {
                          {
                              nameof(LiveWallpaperOptions.AudioScreen),
                              new DescriptorInfo()
                              {
                                  Text         = "Audio Source",
                                  Type         = PropertyType.Combobox, Options = new ObservableCollection <DescriptorInfo>(audioOption),
                                  DefaultValue = null,
                              }
                          },
                          //{
                          //    nameof(LiveWallpaperOptions.AutoRestartWhenExplorerCrash),
                          //    new DescriptorInfo(){
                          //        Text="崩溃后自动恢复",
                          //        DefaultValue=true,
                          //}},
                          {
                              nameof(LiveWallpaperOptions.AppMaximizedEffectAllScreen),
                              new DescriptorInfo()
                              {
                                  Text         = "Full screen detection affects all screens",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.ForwardMouseEvent),
                              new DescriptorInfo()
                              {
                                  Text         = "Forward mouse event",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.ScreenOptions),
                              new DescriptorInfo()
                              {
                                  Text                = "Display Settings",
                                  Type                = PropertyType.List,
                                  CanAddItem          = false,
                                  CanRemoveItem       = false,
                                  DefaultValue        = screenSetting,
                                  PropertyDescriptors = new DescriptorInfoDict()
                                  {
                                      { nameof(ScreenOption.Screen), new DescriptorInfo()
                                        {
                                            Text = "Screen", Type = PropertyType.Label
                                        } },
                                      { nameof(ScreenOption.WhenAppMaximized), new DescriptorInfo()
                                        {
                                            Text = "When other programs are maximized", Options = new ObservableCollection <DescriptorInfo>(screenSettingOptions)
                                        } }
                                  }
                              }
                          },
                      }
                  } }
            };
            var setting = new LiveWallpaperOptions()
            {
                ScreenOptions = screenSetting
            };
            var vm = ConfigerService.GetVM(setting, descInfo);

            configer.DataContext = vm;
        }
        public MainWindow()
        {
            Activated   += MainWindow_Activated;
            Deactivated += MainWindow_Deactivated;
            WallpaperApi.Initlize(Dispatcher);
            InitializeComponent();
            monitors.ItemsSource = monitorsVM = Screen.AllScreens.Select(m => new Monitor()
            {
                DeviceName = m.DeviceName,
                Checked    = true
            }).ToList();

            var audioOption = Screen.AllScreens.Select(m => new DescriptorInfo()
            {
                Text         = m.DeviceName,
                DefaultValue = m.DeviceName
            }).ToList();

            audioOption.Insert(0, new DescriptorInfo()
            {
                Text = "禁用", DefaultValue = null
            });

            var screenSetting = Screen.AllScreens.Select(m => new ScreenOption()
            {
                Screen           = m.DeviceName,
                WhenAppMaximized = ActionWhenMaximized.Pause,
            }).ToList();

            var screenSettingOptions = new List <DescriptorInfo>()
            {
                new DescriptorInfo()
                {
                    Text = "播放", DefaultValue = ActionWhenMaximized.Play
                },
                new DescriptorInfo()
                {
                    Text = "暂停", DefaultValue = ActionWhenMaximized.Pause
                },
                new DescriptorInfo()
                {
                    Text = "停止", DefaultValue = ActionWhenMaximized.Stop
                },
            };

            var descInfo = new DescriptorInfoDict()
            {
                { nameof(LiveWallpaperOptions),
                  new DescriptorInfo()
                  {
                      Text = "壁纸设置",
                      PropertyDescriptors = new DescriptorInfoDict()
                      {
                          {
                              nameof(LiveWallpaperOptions.AudioScreen),
                              new DescriptorInfo()
                              {
                                  Text         = "音源",
                                  Type         = PropertyType.Combobox, Options = new ObservableCollection <DescriptorInfo>(audioOption),
                                  DefaultValue = null,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.AutoRestartWhenExplorerCrash),
                              new DescriptorInfo()
                              {
                                  Text         = "崩溃后自动恢复",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.AppMaximizedEffectAllScreen),
                              new DescriptorInfo()
                              {
                                  Text         = "全屏检测影响所有屏幕",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.ForwardMouseEvent),
                              new DescriptorInfo()
                              {
                                  Text         = "转发鼠标事件",
                                  DefaultValue = true,
                              }
                          },
                          {
                              nameof(LiveWallpaperOptions.ScreenOptions),
                              new DescriptorInfo()
                              {
                                  Text                = "显示器设置",
                                  Type                = PropertyType.List,
                                  CanAddItem          = false,
                                  CanRemoveItem       = false,
                                  DefaultValue        = screenSetting,
                                  PropertyDescriptors = new DescriptorInfoDict()
                                  {
                                      { nameof(ScreenOption.Screen), new DescriptorInfo()
                                        {
                                            Text = "屏幕", Type = PropertyType.Label
                                        } },
                                      { nameof(ScreenOption.WhenAppMaximized), new DescriptorInfo()
                                        {
                                            Text = "桌面被挡住时", Options = new ObservableCollection <DescriptorInfo>(screenSettingOptions)
                                        } }
                                  }
                              }
                          },
                      }
                  } }
            };
            var setting = new LiveWallpaperOptions()
            {
                ScreenOptions = screenSetting
            };
            var vm = ConfigerService.GetVM(setting, descInfo);

            configer.DataContext = vm;
        }
        public override async Task <Empty> SetOptions(LiveWallpaperOptions request, ServerCallContext context)
        {
            await WallpaperManager.Instance.SetOptions(request);

            return(new Empty());
        }