public MainViewModel() { IsLoading = Visibility.Collapsed; NoDeletedItemsVisibility = Visibility.Collapsed; //初始化 NewToDo = new ToDo(); CurrentUser = new MyerListUser(); MyToDos = new ObservableCollection <ToDo>(); DeletedToDos = new ObservableCollection <ToDo>(); CurrentDisplayToDos = MyToDos; IsInSortMode = false; SelectedCate = 0; CateColor = App.Current.Resources["DefaultColor"] as SolidColorBrush; CateColorLight = App.Current.Resources["DefaultColorLight"] as SolidColorBrush; CateColorDark = App.Current.Resources["DefaultColorDark"] as SolidColorBrush; //设置当前页面为 To-Do SelectedIndex = 0; TodoIconAlpha = 1; DeleteIconAlpha = 0.3; Title = ResourcesHelper.GetString("ToDoPivotItem"); //按下Enter后 Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.EnterToAdd, act => { if (!string.IsNullOrEmpty(NewToDo.Content)) { OkCommand.Execute(null); } }); //完成ToDo Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.CheckToDo, act => { var id = act.Content; CheckCommand.Execute(id); }); //删除To-Do Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.DeleteToDo, act => { var id = act.Content; DeleteCommand.Execute(id); }); Messenger.Default.Register <GenericMessage <ToDo> >(this, MessengerTokens.ReaddToDo, act => { this.NewToDo = act.Content; OkCommand.Execute(false); }); Messenger.Default.Register <GenericMessage <string> >(this, MessengerTokens.CompleteSort, async act => { await UpdateOrder(); }); }
public void TestGetResourceLoader(string key) { ResourceLoader resources = new ResourcesHelper().GetResourceLoader(ResourceMapIds.Strings); Assert.IsFalse( resources.GetString(key).IsNullOrEmpty(), $"Could not retrieve the string with key '{key}'"); }
private void RegisterOrRemovePlugin(object sender, PluginRegisterEventArgs e) { if (e.Register) { Console.WriteLine(ResourcesHelper.GetString("RegisterHelpPlugin"), e.Child, e.Parent); } else { Console.WriteLine(ResourcesHelper.GetString("RemoveHelpPlugin"), e.Child, e.Parent); } }
private void RegisterOrRemoveFilter(object sender, CommonRegisterEventArgs e) { if (e.Register) { Console.WriteLine(ResourcesHelper.GetString("RegisterHelpFilter"), e.Name); } else { Console.WriteLine(ResourcesHelper.GetString("RemoveHelpFilter"), e.Name); } }
private bool UpdateFilesSize(long newFileSize) { long newSumSize = _filesSize + newFileSize; if (newSumSize >= MaxNewFilesSize) { ErrorMessage = ResourcesHelper.GetString("MmsLimit"); return(false); } _filesSize = newSumSize; return(true); }
private static async void ServiceAuthorizationFailed(object sender, EventArgs e) { if (CurrentKeyPosition + 1 == _staticSettings.Count) { var messageDialog = new MessageDialog(ResourcesHelper.GetString("KeysExpired")); await messageDialog.ShowAsync(); } else { CurrentKeyPosition++; } }
/// <summary> /// 进入 MainPage 会调用 /// </summary> /// <param name="param"></param> public async void Activate(object param) { TitleBarHelper.SetUpCateTitleBar(Enum.GetName(typeof(CateColors), SelectedCate)); if (param is LoginMode) { if (LOAD_ONCE) { return; } LOAD_ONCE = true; var mode = (LoginMode)param; switch (mode) { //已经登陆过的了 case LoginMode.Login: { CurrentUser.Email = LocalSettingHelper.GetValue("email"); ShowLoginBtnVisibility = Visibility.Collapsed; ShowAccountInfoVisibility = Visibility.Visible; //没有网络 if (App.IsNoNetwork) { await RestoreData(true); await Task.Delay(500); Messenger.Default.Send(new GenericMessage <string>(ResourcesHelper.GetString("NoNetworkHint")), MessengerTokens.ToastToken); } //有网络 else { Messenger.Default.Send(new GenericMessage <string>(ResourcesHelper.GetString("WelcomeBackHint")), MessengerTokens.ToastToken); await SyncAllToDos(); CurrentDisplayToDos = MyToDos; var resotreTask = RestoreData(false); } }; break; //处于离线模式 case LoginMode.OfflineMode: { ShowLoginBtnVisibility = Visibility.Visible; ShowAccountInfoVisibility = Visibility.Collapsed; var restoreTask = RestoreData(true); }; break; } } }
/// <summary> /// 从云端同步所有待办事项 /// </summary> /// <returns></returns> private async Task SyncAllToDos() { try { //没网络 if (App.IsNoNetwork) { //通知没有网络 Messenger.Default.Send(new GenericMessage <string>(ResourcesHelper.GetString("NoNetworkHint")), MessengerTokens.ToastToken); return; } //加载滚动条 IsLoading = Visibility.Visible; DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(3.2); timer.Tick += ((sendert, et) => { IsLoading = Visibility.Collapsed; }); timer.Start(); var result = await PostHelper.GetMySchedules(LocalSettingHelper.GetValue("sid")); if (!string.IsNullOrEmpty(result)) { //获得无序的待办事项 var scheduleWithoutOrder = ToDo.ParseJsonToObs(result); //获得顺序列表 var orders = await PostHelper.GetMyOrder(LocalSettingHelper.GetValue("sid")); //排序 MyToDos = ToDo.SetOrderByString(scheduleWithoutOrder, orders); ChangeDisplayCateList(SelectedCate); Messenger.Default.Send(new GenericMessage <string>(ResourcesHelper.GetString("SyncSuccessfully")), MessengerTokens.ToastToken); await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(MyToDos, SerializerFileNames.ToDoFileName, true); } //最后更新动态磁贴 Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile); } catch (Exception e) { var task = ExceptionHelper.WriteRecord(e); } }
/// <summary> /// 得到多语言版本中字符描述 /// </summary> /// <param name="pKeyName"></param> /// <param name="pDefaultValue"></param> /// <returns></returns> public static string GetString(string textLandid, params string[] paramValues) { string id = textLandid; if (id.IndexOf(LEFT_NAME) < 0) { return(id); } else { id = id.Replace(LEFT_NAME, string.Empty); } return(ResourcesHelper.GetString(DEFAULT_XML_NAME, DEFAULT_PATH, id, id, paramValues)); }
/// <summary> /// 改变要显示的列表 /// </summary> /// <param name="id"></param> private void ChangeDisplayCateList(int id) { Messenger.Default.Send(new GenericMessage <string>(""), MessengerTokens.CloseHam); var cateid = id; CateColor = App.Current.Resources[Enum.GetName(typeof(CateColors), cateid)] as SolidColorBrush; CateColorLight = App.Current.Resources[Enum.GetName(typeof(CateColors), cateid) + "Light"] as SolidColorBrush; CateColorDark = App.Current.Resources[Enum.GetName(typeof(CateColors), cateid) + "Dark"] as SolidColorBrush; TitleBarHelper.SetUpCateTitleBar(Enum.GetName(typeof(CateColors), cateid)); UpdateDisplayList(id); IsInSortMode = false; switch (cateid) { case 0: { Title = ResourcesHelper.GetString("CateDefault"); }; break; case 1: { Title = ResourcesHelper.GetString("CateWork"); }; break; case 2: { Title = ResourcesHelper.GetString("CateLife"); }; break; case 3: { Title = ResourcesHelper.GetString("CateFamily"); }; break; case 4: { Title = ResourcesHelper.GetString("CateEnter"); }; break; } }
private async void FileOpenCommandAction(object parameter) { ErrorMessage = ""; var openPicker = new FileOpenPicker { ViewMode = PickerViewMode.Thumbnail }; switch (FileType) { case FileType.Audio: openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary; foreach (string extension in _audioExtensions) { openPicker.FileTypeFilter.Add(extension); } break; case FileType.Video: openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary; foreach (string extension in _videoExtensions) { openPicker.FileTypeFilter.Add(extension); } break; case FileType.Picture: openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; foreach (string extension in _pictureExtensions) { openPicker.FileTypeFilter.Add(extension); } break; default: openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; foreach (string extension in _allExtensions) { openPicker.FileTypeFilter.Add(extension); } break; } if (SelectMultipleFiles) { IEnumerable <StorageFile> files = await openPicker.PickMultipleFilesAsync(); if (await CheckSize(null, files)) { foreach (StorageFile file in files) { Files.Add(file); FilesExt.Add(new FilePreview(file, RemoveCommand)); } if (Files.Count > 0) { CurrentFile = FilesExt[FilesExt.Count - 1]; } } else { ErrorMessage = ResourcesHelper.GetString("MmsLimit"); } } else { StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { if (await CheckSize(file, null)) { Files.Clear(); FilesExt.Clear(); Files.Add(file); FilesExt.Add(new FilePreview(file, RemoveCommand)); CurrentFile = FilesExt[FilesExt.Count - 1]; File = file; } else { ErrorMessage = ResourcesHelper.GetString("MmsLimit"); } } } }
public int Run(string[] args) { this.ParseCommandLine(args); if (this.showLogo) { Assembly me = Assembly.GetExecutingAssembly(); Console.WriteLine("Help 2.0 Registration Utility v{0}", me.GetName().Version.ToString()); Console.WriteLine("Copyright (c) 2005 Mathias Simmack. All rights reserved."); Console.WriteLine(); } if (this.showHelp || args.Length == 0) { Assembly me = Assembly.GetExecutingAssembly(); Console.WriteLine(ResourcesHelper.GetString("RegisterToolCommandLineOptions"), me.GetName().Name); return((this.errorCodes)?1:0); } // Error code 2 is obsolete. It was set in my Delphi version if XML was not installed if (!ApplicationHelpers.IsClassRegistered("{31411198-A502-11D2-BBCA-00C04F8EC294}")) { if (!this.beQuiet) { Console.WriteLine(ResourcesHelper.GetString("ErrorNoHelp2Environment")); } return((this.errorCodes)?3:0); } if (!ApplicationHelpers.IsThisUserPrivileged()) { if (!this.beQuiet) { Console.WriteLine(ResourcesHelper.GetString("ErrorInvalidPrivileges")); } return((this.errorCodes)?4:0); } if (this.actionParam != "/r" && this.actionParam != "/u" && this.actionParam != "+r" && this.actionParam != "-r" && this.actionParam != "+p" && this.actionParam != "-p") { if (!this.beQuiet) { Console.WriteLine(ResourcesHelper.GetString("ErrorInvalidCommandLine"), this.actionParam); } return((this.errorCodes)?5:0); } if (string.IsNullOrEmpty(this.xmlFilename) || !File.Exists(this.xmlFilename)) { if (!this.beQuiet) { Console.WriteLine(ResourcesHelper.GetString("ErrorInvalidXmlFile"), this.xmlFilename); } return((this.errorCodes)?6:0); } if (!XmlValidator.XsdFileDoesExist) { if (!this.beQuiet) { Console.WriteLine(ResourcesHelper.GetString("ErrorCannotValidateXmlFile"), this.xmlFilename); } return((this.errorCodes)?7:0); } if (!XmlValidator.Validate(this.xmlFilename, this.beQuiet)) { // get a message from the validator class return((this.errorCodes)?7:0); } ApplicationHelpers.KillIllegalProcesses(this.invalidProcesses); if (this.actionParam == "/r" || this.actionParam == "+r") { this.DoHelpStuff(true); } if (this.actionParam == "/r" || this.actionParam == "+p") { this.DoPluginStuff(true); } if (this.actionParam == "/u" || this.actionParam == "-p") { this.DoPluginStuff(false); } if (this.actionParam == "/u" || this.actionParam == "-r") { this.DoHelpStuff(false); } return(0); }
private void NamespaceMerge(object sender, MergeNamespaceEventArgs e) { Console.WriteLine(ResourcesHelper.GetString("MergeHelpNamespace"), e.Name); }