Example #1
0
        private void InitializeAppContextComponent()
        {
            _components  = new System.ComponentModel.Container();
            _contextMenu = new ContextMenuStrip();

            _btnMainUI = new ToolStripMenuItem()
            {
                Text = "打开Web控制台"
            };
            _btnMainUI.Click += BtnMainUI_Click;
            _contextMenu.Items.Add(_btnMainUI);

            _btnExit = new ToolStripMenuItem
            {
                Text = "退出",
            };
            _btnExit.Click += BtnExit_Click;
            _contextMenu.Items.Add(_btnExit);

            _notifyIcon = new NotifyIcon(_components)
            {
                Icon             = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location),
                ContextMenuStrip = _contextMenu,
                Text             = "巨应壁纸",
                Visible          = true
            };

            _notifyIcon.MouseClick += new MouseEventHandler(NotifyIcon_MouseClick);
            WallpaperApi.Initlize(Dispatcher.CurrentDispatcher);
            Task.Run(() =>
            {
                int port = GetPort();
                ServerWrapper.Start(port);
            });
        }
Example #2
0
        public AppContext()
        {
            _uiDispatcher = Dispatcher.CurrentDispatcher;
            InitializeUI();

            WallpaperApi.Initlize(_uiDispatcher);
            AppManager.CultureChanged += LanService_CultureChanged;
            SetMenuText();
            _ = Task.Run(() =>
            {
                int port = GetPort();
                ServerWrapper.Start(port);
            });
            CheckMutex();
        }
Example #3
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;
        }