private void GetReport(List <NodeItem> nodes) { int entityFound = GetEntityCount(nodes); int realPropTotal = 0; int idealPropTotal = 0; decimal percentage; foreach (var node in nodes) { realPropTotal += GetRealPropCount(node); idealPropTotal += GetIdealPropCount(node); } if (realPropTotal != 0 && idealPropTotal != 0) { percentage = Math.Round(((decimal)realPropTotal / idealPropTotal) * 100, 2); } else { percentage = 0; } Keyword = $"{percentage}%"; KeywordDescription = $"{ResourceExtensions.GetLocalized("ReportInfo_Presence")}"; OriginalInfo = $"{entityFound} {ResourceExtensions.GetLocalized("ReportInfo_EntityFound")}"; TraitedInfo = $"{realPropTotal} {ResourceExtensions.GetLocalized("ReportInfo_PropertyFound")}"; }
public void UpdateDefaultLanguage() { if (!string.IsNullOrEmpty(SelectedDomain)) { string languangeCode = DomainDic[SelectedDomain].Domain.DefaultLanguageCode; DefaultLanguage = $"{ResourceExtensions.GetLocalized("ClassificationPage_DefaultLanguage")}: {LanguageDic[languangeCode]}"; } }
private void OnFileDragOver(object sender, Windows.UI.Xaml.DragEventArgs e) { e.AcceptedOperation = DataPackageOperation.Copy; e.DragUIOverride.Caption = ResourceExtensions.GetLocalized("Tool_OnFileDragOver"); e.DragUIOverride.IsGlyphVisible = true; e.DragUIOverride.IsContentVisible = true; e.DragUIOverride.IsCaptionVisible = true; this.DragDropPanel.Opacity = 0.5; }
// Preperation Methods /// <summary> /// Sets up a new document for use in this ViewModel /// </summary> private void PrepareNewDocument() { TextDataModel emptyData = new TextDataModel(); emptyData.DocumentTitle = ResourceExtensions.GetLocalized("UnititledLabel"); Data = emptyData; File = null; SetEditedFalse(); RefreshTitlebarTitle(); }
public static List <Step> GenerateIfcValidatorSteps() { List <Step> steps = new List <Step>(); steps.Add(new Step(1, ResourceExtensions.GetLocalized("ValidatorPage_Step1"), true)); steps.Add(new Step(2, ResourceExtensions.GetLocalized("ValidatorPage_Step2"))); steps.Add(new Step(3, ResourceExtensions.GetLocalized("ValidatorPage_Step3"))); steps.Add(new Step(4, ResourceExtensions.GetLocalized("ValidatorPage_Step4"))); return(steps); }
private void MainViewModel_ShareDataRequested(DataTransferManager sender, DataRequestedEventArgs args) { // Show the Share UI DataRequest request = args.Request; // Set the metadata request.Data.Properties.Title = Windows.ApplicationModel.Package.Current.DisplayName; request.Data.Properties.Description = (ResourceExtensions.GetLocalized("ShareDescription") + " " + FilesToShare[0].Name); // Set the StorageItem request.Data.SetStorageItems(FilesToShare); }
private void UpdateSelecedClassesNotice() { if (_selectedClasses.Count > 0) { SelectedNotice = $"{ResourceExtensions.GetLocalized("ClassificationPage_Selected")}: {_selectedClasses.Count}"; HasSelection = true; } else { SelectedNotice = null; HasSelection = false; } }
private void LoadLanguages() { var response = new LanguageApi(LocalData.baseHttp).ApiLanguageV1Get(); List <string> languages = new List <string>(); languages.Add(ResourceExtensions.GetLocalized("ClassificationPage_AllLanguage")); foreach (var item in response) { LanguageDic.Add(item.IsoCode, item.Name); languages.Add($"{item.Name} ({item.IsoCode})"); } _languages = new BindableCollection <string>(languages); }
private void NextBtn_Click(object sender, RoutedEventArgs e) { int step = StepServices.GetCompletedStepCount(ViewModel.Steps); switch (step) { case 1: if (classificationPage.ViewModel.HasSelection) { propertyPage.ViewModel.GetAllProperties(classificationPage.ViewModel.SelectedClasses); propertyPage.UpdateSelection(); Workspace1.Content = propertyPage; StepControl.Content = new StepUserControl(ViewModel.MoveSteps()); } else { NoticeShow(ResourceExtensions.GetLocalized("ValidatorPage_Notice_NoClasses")); } break; case 2: if (propertyPage.ViewModel.HasSelection) { LocalConfig.SaveConfigFile(propertyPage.ViewModel.SelectedClasses); Workspace1.Content = inputFilePage; StepControl.Content = new StepUserControl(ViewModel.MoveSteps()); } else { NoticeShow(ResourceExtensions.GetLocalized("ValidatorPage_Notice_NoProps")); } break; case 3: if (inputFilePage.ViewModel.InputFiles.Count > 0) { reportPage.ViewModel.LoadReport(inputFilePage.ViewModel.InputFiles, propertyPage.ViewModel.SelectedClasses); StepControl.Content = new StepUserControl(ViewModel.MoveSteps()); Workspace1.Content = reportPage; } else { NoticeShow(ResourceExtensions.GetLocalized("ValidatorPage_Notice_NoFile")); } break; default: break; } }
// Main Toastbuilder /// <summary> /// Show a Toast Notification /// </summary> /// <param name="message">Insert messages like this --> "nameOfTheResourceString"</param> /// <param name="title">Insert a title like this --> "nameOfTheResourceString"</param> /// <param name="exportPath">Insert the export path to be displayed when this is for notifying the user of an successful export</param> private static void ShowToast(string message, string title, string exportPath = null) { var toast = new ToastContent(); toast.Visual = new ToastVisual(); if (exportPath != null) { toast.Visual.BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = ResourceExtensions.GetLocalized(title), HintStyle = AdaptiveTextStyle.Title }, new AdaptiveText() { Text = (ResourceExtensions.GetLocalized(message) + " " + exportPath) } } }; } else { toast.Visual.BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = ResourceExtensions.GetLocalized(title), HintStyle = AdaptiveTextStyle.Title }, new AdaptiveText() { Text = (ResourceExtensions.GetLocalized(message)) } } }; } var toastNotification = new ToastNotification(toast.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toastNotification); }
public string GetSelectLanguageCode() { if (_selectedLanguage == null) { return(null); } else if (_selectedLanguage.Equals(ResourceExtensions.GetLocalized("ClassificationPage_AllLanguage"))) { return(null); } else { Regex regex = new Regex(@"(?is)(?<=\()(.*)(?=\))"); return(regex.Match(_selectedLanguage).Value); } }
private void UpdatePropNotice(BindableCollection <NodeItem> newNodes) { if (newNodes.Count > 0) { int classCount = 0; string classText; int propCount = 0; string propText; foreach (var item in newNodes) { if (item.Type == NodeItem.NodeItemType.Classification) { classCount++; foreach (var propSet in item.Children) { foreach (var prop in propSet.Children) { propCount++; } } } } if (classCount > 1) { classText = $"{classCount} {ResourceExtensions.GetLocalized("PropertyNotice_ClassN")}"; } else { classText = $"{classCount} {ResourceExtensions.GetLocalized("PropertyNotice_Class1")}"; } if (propCount > 1) { propText = $"{propCount} {ResourceExtensions.GetLocalized("PropertyNotice_PropN")}"; } else { propText = $"{propCount} {ResourceExtensions.GetLocalized("PropertyNotice_Prop1")}"; } PropertyNotice = $"{ResourceExtensions.GetLocalized("PropertyNotice_Selected")} {propText} " + $"{ResourceExtensions.GetLocalized("PropertyNotice_In")} {classText}"; HasSelection = propCount > 0 ? true : false; } else { PropertyNotice = null; HasSelection = false; } }
private void UpdateClassificationNotice(int?number) { if (number != null) { if (number >= 200) { ClassificationNotice = ResourceExtensions.GetLocalized("ClassificationPage_MoreThan200"); } else if (number == 0) { ClassificationNotice = ResourceExtensions.GetLocalized("ClassificationPage_NoResult"); } else { ClassificationNotice = $"{ResourceExtensions.GetLocalized("ClassificationPage_Total")}: {number}"; } } }
private async Task <bool> PreparePlayback() { IsPreparing = true; // Create an audio stream of the text SpeechSynthesisStream synthStream; // Check if any text has been entered, otherwise play a secret message if (Text == "") { // Randomize Text SetSecretText(); synthStream = await _speechSynthesizer.SynthesizeTextToStreamAsync(SecretText); } else { synthStream = await _speechSynthesizer.SynthesizeTextToStreamAsync(Text); } MediaSource mediaSource = MediaSource.CreateFromStream(synthStream, "audio"); // Now make a PlaybackItem from this stream MediaPlaybackItem playbackItem = new MediaPlaybackItem(mediaSource); // Now set the properties of this PlaybackItem MediaItemDisplayProperties mediaProperties = playbackItem.GetDisplayProperties(); mediaProperties.Type = MediaPlaybackType.Music; mediaProperties.MusicProperties.Artist = ("Talkinator " + ResourceExtensions.GetLocalized("VoicedBy") + " " + SelectedVoice.VoiceName); mediaProperties.MusicProperties.Title = ResourceExtensions.GetLocalized("SpokenText"); playbackItem.ApplyDisplayProperties(mediaProperties); // Set this to enabled to make sure the info entered above will be shown in the System UI _mediaPlayer.SystemMediaTransportControls.IsEnabled = true; // Set the created item as a Source into the MediaPlayer _mediaPlayer.Source = playbackItem; // #TODO: Implement AutoPlay as well? Need to test their importance first _mediaPlayer.MediaEnded += _mediaPlayer_MediaEnded; // #TODO: Reimplement easter eggs IsPreparing = false; return(true); }
/* * OnePomodoro是一个用于番茄工作法的计时器,这个计时器让你专注工作25分钟。 * * 在专注工作25分钟以后(一个Pomodoro),别忘记休息5分钟,在工作4个Pomodoro以后休息一段长时间(15分钟)。 * * 可以通过设置改变工作和休息时间,并且可以更改通知设置。 * * OnePomodoro提供了多种Pomodoro,让工作不那么无聊。 * * 大部分番茄钟提供Pinable模式,这意味着它们可以Always on top. * * About页面里提供了番茄钟做法的更多提示。 * * * OnePomodoro is a timer for Pomodoro Technique that lets you focus on work for 25 minutes. * * After 25 minutes of focusing (a Pomodoro), don't forget to take a 5-minute break and take a long break (15 minutes) after working 4 Pomodoros. * * You can change work and rest times through settings, and you can change notification settings. * * OnePomodoro offers a variety of pomodoros to make your job less boring. * * Most pomodoros offer Pinable mode, which means they can always on top. * * More tips on the Pomodoro Technique are available on the About page. */ public TeachSource() { Items = new List <TeachItem>(); Items.Add(new TeachItem { Screenshot = "/Assets/Teach/teach1.png", Description = ResourceExtensions.GetLocalized("Teach1Description"), Title = ResourceExtensions.GetLocalized("Teach1Title"), }); Items.Add(new TeachItem { Screenshot = "/Assets/Teach/teach2.png", Description = ResourceExtensions.GetLocalized("Teach2Description"), Title = ResourceExtensions.GetLocalized("Teach2Title"), }); Items.Add(new TeachItem { Screenshot = "/Assets/Teach/teach3.png", Description = ResourceExtensions.GetLocalized("Teach3Description"), Title = ResourceExtensions.GetLocalized("Teach3Title"), }); Items.Add(new TeachItem { Screenshot = "/Assets/Teach/teach4.png", Description = ResourceExtensions.GetLocalized("Teach4Description"), Title = ResourceExtensions.GetLocalized("Teach4Title"), }); Items.Add(new TeachItem { Screenshot = "/Assets/Teach/teach5.png", Description = ResourceExtensions.GetLocalized("Teach5Description"), Title = ResourceExtensions.GetLocalized("Teach5Title"), }); Items.Add(new TeachItem { Screenshot = "/Assets/Teach/teach6.png", Description = ResourceExtensions.GetLocalized("Teach6Description"), Title = ResourceExtensions.GetLocalized("Teach6Title"), }); }
/// <summary> /// Prepare the temp files to be shared in a ReadOnlyList /// </summary> private async Task <bool> GetShareStorageFiles() { // Save the current document to a temp folder ApplicationData appData = ApplicationData.Current; StorageFile tempFile; // If the file being shared already has been saved use that name instead // #TODO: Instead, save the current file as well? if (File != null) { tempFile = await appData.TemporaryFolder.CreateFileAsync(File.Name, CreationCollisionOption.ReplaceExisting); } else { tempFile = await appData.TemporaryFolder.CreateFileAsync((ResourceExtensions.GetLocalized("UnititledLabel") + ".txt"), CreationCollisionOption.ReplaceExisting); } // Write the data to the temp file // Prevent remote access to file until saving is done CachedFileManager.DeferUpdates(tempFile); //We need to make sure Data.Text isn't null. Data.Text = Data.Text ?? ""; //coalescing operator '??' returns left-hand operand's value if it isn't null, else right-hand's // Write the stuff to the file await FileIO.WriteTextAsync(tempFile, Data.Text); // Let Windows know stuff is done FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(tempFile); // Create a List and set add the files to it List <StorageFile> filesToShare = new List <StorageFile>(); filesToShare.Add(tempFile); // Set the ReadOnlyList with the new data FilesToShare = filesToShare; // Preperation is done, continue with the other stuff return(true); }
/// <summary> /// Exports the entered text to a soundfile /// </summary> /// <param name="input">The text that's going to be converted into a soundfile</param> /// <param name="voice">The VoiceInformation containing the voice that's going to be used. If null system will use the default system voice</param> /// <returns></returns> public static async Task <bool> ExportTextToSpeechFile(string input, VoiceInformation voice = null) { bool success = false; // Add the spoken text var synth = new SpeechSynthesizer(); if (voice != null) { synth.Voice = voice; } SpeechSynthesisStream synthStream = await synth.SynthesizeTextToStreamAsync(input); // Check devicefamily var device = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues; bool isDesktop = (device.ContainsKey("DeviceFamily") && device["DeviceFamily"] == "Desktop"); bool isXbox = (device.ContainsKey("DeviceFamily") && device["DeviceFamily"] == "Xbox"); // Now get the export-file picker var exportPicker = new FileSavePicker(); exportPicker.SuggestedStartLocation = PickerLocationId.Desktop; // Check whether the using is using Windows 10 Mobile, if true, only add .wav-export, because the codecs in Mobile are f*****g retarded if (isDesktop == true) { exportPicker.FileTypeChoices.Add(".MP3", new List <string>() { ".mp3" }); exportPicker.FileTypeChoices.Add(".WMA", new List <string>() { ".wma" }); } else if (isXbox == true) { exportPicker.FileTypeChoices.Add(".WMA", new List <string>() { ".wma" }); } exportPicker.FileTypeChoices.Add(".WAV", new List <string>() { ".wav" }); exportPicker.SuggestedFileName = ResourceExtensions.GetLocalized("SpokenText"); // Fill data of the fileTarget with selection from the Save-picker var fileTarget = await exportPicker.PickSaveFileAsync(); if (fileTarget != null) { if (fileTarget.FileType == ".wma" || fileTarget.FileType == ".mp3" || fileTarget.FileType == ".m4a") { success = await SaveAndEncodeFile(fileTarget, synthStream, synth.Voice); } else if (fileTarget.FileType == ".wav") { try { using (var reader = new DataReader(synthStream)) { await reader.LoadAsync((uint)synthStream.Size); IBuffer buffer = reader.ReadBuffer((uint)synthStream.Size); await FileIO.WriteBufferAsync(fileTarget, buffer); } success = true; } catch (Exception ex) { Debug.WriteLine("Couldn't export to wav"); Debug.WriteLine(ex); } } } return(success); }
/// <summary> /// /// </summary> /// <param name="fileTarget">File to write to</param> /// <param name="synthStream">The SpeechSynthesisStream with the actual sound</param> /// <param name="voice">The VoiceInformation for setting the correct voice in the artist</param> /// <returns></returns> private static async Task <bool> SaveAndEncodeFile(StorageFile fileTarget, SpeechSynthesisStream synthStream, VoiceInformation voice) { bool success = false; // Initialise some stuff MediaEncodingProfile _profile; MediaTranscoder _transcoder = new MediaTranscoder(); CoreDispatcher _dispatcher = Window.Current.Dispatcher; CancellationTokenSource _cts = new CancellationTokenSource(); Debug.WriteLine(fileTarget.FileType + " selected"); // Set encoding profiles _profile = null; AudioEncodingQuality audioEncodingProfile = AudioEncodingQuality.High; if (fileTarget.FileType == ".wma") { _profile = MediaEncodingProfile.CreateWma(audioEncodingProfile); } else if (fileTarget.FileType == ".mp3") { _profile = MediaEncodingProfile.CreateMp3(audioEncodingProfile); } else if (fileTarget.FileType == ".m4a") { _profile = MediaEncodingProfile.CreateM4a(audioEncodingProfile); } else { Debug.WriteLine("Can't select a media encoding profile"); return(success); } // Write temporary Wav to Temp-storage ApplicationData appData = ApplicationData.Current; StorageFile source = await appData.TemporaryFolder.CreateFileAsync("temporary.wav", CreationCollisionOption.ReplaceExisting); try { using (var reader = new DataReader(synthStream)) { await reader.LoadAsync((uint)synthStream.Size); IBuffer buffer = reader.ReadBuffer((uint)synthStream.Size); await FileIO.WriteBufferAsync(source, buffer); } } catch (Exception ex) { Debug.WriteLine("Couldn't prepare wav for transcoding"); Debug.WriteLine(ex); } // Prepare transcoding files var preparedTranscoderResult = await _transcoder.PrepareFileTranscodeAsync(source, fileTarget, _profile); if (preparedTranscoderResult.CanTranscode) { // Set task for transcoding await preparedTranscoderResult.TranscodeAsync().AsTask(_cts.Token); // Set Music-properties MusicProperties fileProperties = await fileTarget.Properties.GetMusicPropertiesAsync(); fileProperties.Title = fileTarget.DisplayName; fileProperties.Artist = ("Talkinator " + ResourceExtensions.GetLocalized("VoicedBy") + " " + voice.DisplayName); await fileProperties.SavePropertiesAsync(); // #TODO: Add the newly created file to the systems MRU? // Add the file to app MRU and possibly system MRU //RecentStorageItemVisibility visibility = SystemMRUCheckBox.IsChecked.Value ? RecentStorageItemVisibility.AppAndSystem : RecentStorageItemVisibility.AppOnly; //rootPage.mruToken = StorageApplicationPermissions.MostRecentlyUsedList.Add(file, file.Name, visibility); //RecentStorageItemVisibility visibility = RecentStorageItemVisibility.AppOnly; //StorageApplicationPermissions.FutureAccessList.Add(fileTarget, fileTarget.DisplayName); // Report completed success = true; Debug.WriteLine(fileTarget.FileType + " export completed"); } else { Debug.WriteLine(preparedTranscoderResult.FailureReason); } return(success); }