public ClassWindow() { InitializeComponent(); _vm = ConfigerService.GetVM(new object[] { tmp }, null); configer.DataContext = _vm; }
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { var data = await JsonHelper.JsonDeserializeFromFileAsync <Setting>(path); var dataDesc = await JsonHelper.JsonDeserializeFromFileAsync <DescriptorInfoDict>(descPath); List <dynamic> extraDescObjs = new List <dynamic>(); extraDescObjs.Add(new { lan = string.Format($"禁用"), value = -1 }); for (int i = 0; i < System.Windows.Forms.Screen.AllScreens.Length; i++) { extraDescObjs.Add(new { lan = string.Format($"屏幕{i}"), value = i }); } configer.DataContext = ConfigerService.GetVM(new object[] { data }, dataDesc); }
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; }
public void TestGetVM() { TestSetting setting = new TestSetting() { P1 = 1, P2 = null, P3 = true }; var descriptor = new DescriptorInfoDict() { { "TestSetting", new DescriptorInfo() { Text = "node 0", PropertyDescriptors = new DescriptorInfoDict() { { "P1", new DescriptorInfo() { Text = "int property" } }, { "P2", new DescriptorInfo() { Text = "string property", DefaultValue = "xxx" } }, { "SubSetting", new DescriptorInfo() { Text = "string property", DefaultValue = new SubSetting(), PropertyDescriptors = new DescriptorInfoDict() { { "SP1", new DescriptorInfo() { Text = "sub int property" } }, { "SP2", new DescriptorInfo() { Text = "sub string property", DefaultValue = "ooo" } } } } }, } } } }; var vm = ConfigerService.GetVM(setting, descriptor); Assert.IsTrue(vm.Nodes.Count == 1); Assert.IsTrue(vm.Nodes[0].Selected); Assert.IsTrue(vm.Nodes[0].Properties.Count == 4); Assert.IsTrue(vm.Nodes[0].Properties[1].Value.ToString() == "xxx"); Assert.IsTrue(vm.Nodes[0].Descriptor.Text == "node 0"); var p1 = vm.Nodes[0].Properties[0]; Assert.IsTrue(p1.Descriptor.Text == "int property"); Assert.IsTrue((int)p1.Value == 1); Assert.IsTrue(vm.Nodes[0].SubNodes[0].Properties[0].Descriptor.Text == "sub int property"); Assert.IsTrue(vm.Nodes[0].SubNodes[0].Properties[1].Descriptor.Text == "sub string property"); var tmpList = ConfigerService.GetAllData <TestSetting>(vm.Nodes); Assert.IsTrue(tmpList[0].P1 == 1); Assert.IsTrue(tmpList[0].P2 == "xxx"); Assert.IsTrue(tmpList[0].P3); Assert.IsTrue(tmpList[0].SubSetting.SP2 == "ooo"); }
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; }