private async void CheckVIP() { var purchaseVM = AppManager.GetPurchaseViewModel(); var ok = await purchaseVM.CheckVIP(); if (!ok) { return; } if (!purchaseVM.IsVIP) { AppHelper AppHelper = new AppHelper(); //0.0069444444444444, 0.0138888888888889 10/20分钟 //bool canPrpmpt = AppHelper.ShouldPrompt(new WPFPurchasedDataManager(AppManager.PurchaseDataPath), 0.0069444444444444, 0.0138888888888889); bool canPrpmpt = AppHelper.ShouldPrompt(new WPFPurchasedDataManager(AppManager.PurchaseDataPath), 15, 30); if (canPrpmpt) { //var windowManager = IoC.Get<IWindowManager>(); var view = new PurchaseTipsView(); var vm = new PurchaseTipsViewModel() { BGM = new Uri("Res//Sounds//PurchaseTipsBg.mp3", UriKind.RelativeOrAbsolute), Content = new DefaultPurchaseTipsContent(), PurchaseContent = await LanService.Get("donate_text"), RatingContent = await LanService.Get("rating_text"), }; vm.Initlize(purchaseVM); view.DataContext = vm; view.Show(); } } }
private void BtnReadInCode_Click(object sender, RoutedEventArgs e) { var l = LanService.Get("btn_readInCode"); MessageBox.Show(l); Button btn = sender as Button; stcPanel.Children.Remove(btn); }
public async void Save() { if (CurrentWallpaper == null) { MessageBox.Show(await LanService.Get("wallpaperEditor_warning_invalidWallpaper")); return; } if (string.IsNullOrEmpty(CurrentWallpaper.ProjectInfo.Title)) { MessageBox.Show(await LanService.Get("wallpaperEditor_warning_titleEmpty")); return; } CanSave = false; try { if (_editMode) { if (_OldWallpaper == null) { //只修改了title,desc等信息 _OldWallpaper = CurrentWallpaper; } await Wallpaper.EditLocakPack(CurrentWallpaper, _OldWallpaper.Dir); } else { string destDir; destDir = Path.Combine(AppManager.LocalWallpaperDir, Guid.NewGuid().ToString()); await Wallpaper.CreateLocalPack(CurrentWallpaper, destDir); } //if (_editMode) //{ // //删除旧包 // var temp = CurrentWallpaper; // CurrentWallpaper = null; // bool ok = await Wallpaper.Delete(temp); // if (!ok) // { // MessageBox.Show("删除失败请手动删除"); // } //} } catch (Exception ex) { CanSave = true; logger.Error(ex); MessageBox.Show(ex.Message); return; } Result = true; TryClose(); }
protected override async void OnInitialize() { if (firstLaunch) { firstLaunch = false; //读取json按对象重新保存一次。防止json格式不全 var Setting = await JsonHelper.JsonDeserializeFromFileAsync <SettingObject>(AppManager.SettingPath); await JsonHelper.JsonSerializeAsync(Setting, AppManager.SettingPath); } var config = await JsonHelper.JsonDeserializeFromFileAsync <dynamic>(AppManager.SettingPath); //string descPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Res\\setting.desc.json"); var descConfig = await JsonHelper.JsonDeserializeFromFileAsync <dynamic>(AppManager.SettingDescFile); List <dynamic> audioSource = new List <dynamic>(); List <dynamic> displayMonitor = new List <dynamic>(); displayMonitor.Add(new { lanKey = "setting_displayMonitor_default", value = -1 }); audioSource.Add(new { lanKey = "setting_audioSource_mute", value = -1 }); string screenStr = await LanService.Get("setting_screen"); for (int i = 0; i < System.Windows.Forms.Screen.AllScreens.Length; i++) { displayMonitor.Add(new { lan = string.Format($"{screenStr} {i + 1}"), value = i }); audioSource.Add(new { lan = string.Format($"{screenStr} {i + 1}"), value = i }); } _jcrService.InjectDescObjs("$AudioSource", audioSource); _jcrService.InjectDescObjs("$DisplayMonitor", displayMonitor); JsonConfierViewModel = _jcrService.GetVM(config, descConfig); base.OnInitialize(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { DescriptorInfo d = null; if (value is ConfigItemNode node) { d = node.Descriptor; } else if (value is ConfigItemProperty property) { d = property.Descriptor; } else if (value is DescriptorInfo) { d = value as DescriptorInfo; } if (d != null) { if (ReadDesc) { if (!string.IsNullOrEmpty(d.Desc)) { return(d.Desc); } if (!string.IsNullOrEmpty(d.DescKey)) { string lan = LanService.Get(d.DescKey).Result; return(lan); } return(null); } else { if (!string.IsNullOrEmpty(d.Text)) { return(d.Text); } if (!string.IsNullOrEmpty(d.TextKey)) { string lan = LanService.Get(d.TextKey).Result; return(lan); } } //return d.Name; } return(value); }
private async void btnReadInCode_Click(object sender, RoutedEventArgs e) { var l = await LanService.Get("btn_readInCode"); ContentDialog d = new ContentDialog(); d.PrimaryButtonText = l; d.Content = l; await d.ShowAsync(); Button btn = sender as Button; stcPanel.Children.Remove(btn); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) #endif { #pragma warning disable CS0436 // Type conflicts with imported type if (value is CBaseObj) { CBaseObj cp = value as CBaseObj; #pragma warning restore CS0436 // Type conflicts with imported type if (ReadDesc) { if (!string.IsNullOrEmpty(cp.Desc)) { return(cp.Desc); } if (!string.IsNullOrEmpty(cp.DescLanKey)) { string lan = LanService.Get(cp.DescLanKey).Result; return(lan); } return(null); } else { if (!string.IsNullOrEmpty(cp.Lan)) { return(cp.Lan); } if (!string.IsNullOrEmpty(cp.LanKey)) { string lan = LanService.Get(cp.LanKey).Result; return(lan); } } #if WINDOWS_UWP if (!string.IsNullOrEmpty(cp.UID)) { string lan = GetString(cp.UID); return(lan); } #endif return(cp.Name); } return(value); }
public async Task OnLoaded() { if (_firstLaunch) { AppManager.Run(); //第一次时打开检查更新 var handle = (new WindowInteropHelper(Application.Current.MainWindow)).Handle; await Task.Run(() => { AppManager.MainHandle = handle; AppManager.CheckUpates(handle); }); DZY.Util.Common.Helpers.AppHelper AppHelper = new DZY.Util.Common.Helpers.AppHelper(); //0.0069444444444444, 0.0138888888888889 10/20分钟 bool canPrpmpt = AppHelper.ShouldPrompt(new WPFPurchasedDataManager(AppManager.PurchaseDataPath), 30, 60); if (canPrpmpt) { var windowManager = IoC.Get <IWindowManager>(); var view = new PurchaseTipsView(); var vm = new PurchaseTipsViewModel() { BGM = new Uri("Res//Sounds//PurchaseTipsBg.mp3", UriKind.RelativeOrAbsolute), Content = new DefaultPurchaseTipsContent(), PurchaseContent = await LanService.Get("donate_text"), RatingContent = await LanService.Get("rating_text"), }; vm.Initlize(AppManager.GetPurchaseViewModel()); view.DataContext = vm; view.Show(); } _firstLaunch = false; if (AppManager.Setting.General.MinimizeUI) { TryClose(); } } Wallpapers = new ObservableCollection <Wallpaper>(AppManager.Wallpapers); if (AppManager.Setting.General.RecordWindowSize) { Width = AppManager.Setting.General.Width; Height = AppManager.Setting.General.Height; } }
public async void Save() { if (CurrentWallpaper == null) { MessageBox.Show(await LanService.Get("wallpaperEditor_warning_invalidWallpaper")); return; } if (string.IsNullOrEmpty(CurrentWallpaper.ProjectInfo.Title)) { MessageBox.Show(await LanService.Get("wallpaperEditor_warning_titleEmpty")); return; } CanSave = false; string destDir = Path.Combine(AppManager.LocalWallpaperDir, Guid.NewGuid().ToString()); try { //await Task.Run(() => //{ var result = await Task.Run(() => { return(WallpaperManager.CreateLocalPack(CurrentWallpaper, destDir)); }); if (_editMode) { //删除旧包 var temp = CurrentWallpaper; CurrentWallpaper = null; bool ok = await WallpaperManager.Delete(temp); if (!ok) { MessageBox.Show("删除失败请手动删除"); } } //}); } catch (Exception ex) { CanSave = true; logger.Error(ex); MessageBox.Show(ex.Message); return; } Result = true; TryClose(); }
public object Convert(object value, Type targetType, object parameter, string language) { if (value is CBaseObj) { CBaseObj cp = value as CBaseObj; if (ReadDesc) { if (!string.IsNullOrEmpty(cp.Desc)) { return(cp.Desc); } if (!string.IsNullOrEmpty(cp.DescLanKey)) { string lan = LanService.Get(cp.DescLanKey).Result; return(lan); } return(null); } else { if (!string.IsNullOrEmpty(cp.Lan)) { return(cp.Lan); } if (!string.IsNullOrEmpty(cp.LanKey)) { string lan = LanService.Get(cp.LanKey).Result; return(lan); } } if (!string.IsNullOrEmpty(cp.UID)) { string lan = GetString(cp.UID); return(lan); } return(cp.Name); } return(value); }
public async void SelectFile() { StringBuilder sb = new StringBuilder(); sb.Append(await LanService.Get("wallpaperEditor_fileDialogType")); foreach (var item in Wallpaper.VideoExtensions) { sb.Append($"{item};"); } var openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = sb.ToString() }; var result = openFileDialog.ShowDialog(); if (result == true) { FilePath = openFileDialog.FileName; } }
public CreateWallpaperViewModel() { DisplayName = LanService.Get("common_create").Result; PreviewWallpaper = _preview; }
internal void SetPaper(Wallpaper w) { DisplayName = LanService.Get("common_edit").Result; CurrentWallpaper = w; _editMode = true; }
protected override async void OnInitialize() { if (firstLaunch) { firstLaunch = false; //读取json按对象重新保存一次。防止json格式不全 var Setting = await JsonHelper.JsonDeserializeFromFileAsync <SettingObject>(AppManager.SettingPath); await JsonHelper.JsonSerializeAsync(Setting, AppManager.SettingPath); } var config = await JsonHelper.JsonDeserializeFromFileAsync <dynamic>(AppManager.SettingPath); //string descPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Res\\setting.desc.json"); var descConfig = await JsonHelper.JsonDeserializeFromFileAsync <dynamic>(AppManager.SettingDescFile); List <dynamic> audioSource = new List <dynamic>(); List <dynamic> displayMonitor = new List <dynamic>(); displayMonitor.Add(new { lanKey = "setting_displayMonitor_default", value = -1 }); audioSource.Add(new { lanKey = "setting_audioSource_mute", value = -1 }); string screenStr = await LanService.Get("setting_screen"); for (int i = 0; i < System.Windows.Forms.Screen.AllScreens.Length; i++) { displayMonitor.Add(new { lan = string.Format($"{screenStr} {i + 1}"), value = i }); audioSource.Add(new { lan = string.Format($"{screenStr} {i + 1}"), value = i }); } _jcrService.InjectDescObjs("$AudioSource", audioSource); _jcrService.InjectDescObjs("$DisplayMonitor", displayMonitor); //多语言 DirectoryInfo languageFilesDir = new DirectoryInfo(AppManager.GetLangaugesFilePath()); var files = languageFilesDir.GetFiles("*.json"); if (files != null) { List <dynamic> languages = new List <dynamic>(); foreach (var file in files) { string cultureName = file.Name.Replace(file.Extension, ""); string text = await LanService.Get("language", cultureName); languages.Add(new { lan = text, value = cultureName }); } _jcrService.InjectDescObjs("$languages", languages); } JsonConfierViewModel = _jcrService.GetVM(config, descConfig); base.OnInitialize(); }