public virtual string BaseStringShort(double durationMs) { return(String.Format(Localizer.Message("phrase_short_to_string"), TODO ? Localizer.Message("phrase_short_TODO") : "", mRole == Role.Custom ? String.Format(Localizer.Message("phrase_short_custom"), mCustomRole) : mRole == Role.Page ? String.Format(Localizer.Message("phrase_short_page"), mPageNumber != null ? mPageNumber.ToString() : "") : mRole == Role.Anchor && this.AssociatedNode == null ? Localizer.Message("phrase_short_" + mRole.ToString()) + "= ?" : Localizer.Message("phrase_short_" + mRole.ToString()), durationMs == 0.0 ? Localizer.Message("empty") : Program.FormatDuration_Smart(durationMs))); }
/// <summary> /// Stop recording or monitoring. /// </summary> public void Stop() { bool wasRecording = mRecorder.CurrentState == AudioLib.AudioRecorder.State.Recording; if (wasRecording) { ApplyPhraseDetectionOnTheFly(null); //@onTheFly: before stopping last chunk of memory stream is passed into phrase detection } if (mRecorder.CurrentState == AudioLib.AudioRecorder.State.Monitoring || wasRecording) { if (wasRecording && mPhraseMarks.Count > 0) { FinishedPhrase(); } mRecorder.StopRecording(); if (wasRecording) { for (int i = m_PhraseMarksOnTheFly.Count - 2; i >= 0; --i) { if (i != 0 && i < m_PhraseMarksOnTheFly.Count && (m_PhraseMarksOnTheFly[i] - m_PhraseMarksOnTheFly[i - 1]) <= 250) { m_PhraseMarksOnTheFly.Remove(m_PhraseMarksOnTheFly[i]); i++; } else if (i == 0 && i < m_PhraseMarksOnTheFly.Count && m_PhraseMarksOnTheFly[i] <= 250) { m_PhraseMarksOnTheFly.Remove(m_PhraseMarksOnTheFly[i]); i++; } } for (int i = mPhraseMarks.Count - 2; i >= 0; --i) { if (mPhraseMarks[i] < mSessionMedia.Duration.AsMilliseconds && mSessionMedia.Duration.AsMilliseconds > 200) { ManagedAudioMedia split = mSessionMedia.Split(new Time(Convert.ToInt64(mPhraseMarks[i] * Time.TIME_UNIT))); mAudioList.Insert(mSessionOffset, split); } else { MessageBox.Show(Localizer.Message("RecordingSession_SplitError"), Localizer.Message("Caption_Warning")); } } // The first asset is what remains of the session asset mAudioList.Insert(mSessionOffset, mSessionMedia); } mRecordingUpdateTimer.Enabled = false; } }
public virtual string BaseString(double durationMs) { return(String.Format(Localizer.Message("phrase_to_string"), TODO ? Localizer.Message("phrase_short_TODO") : "", Used ? "" : Localizer.Message("unused"), IsRooted ? Index + 1 : 0, IsRooted ? ParentAs <ObiNode>().PhraseChildCount : 0, durationMs == 0.0 ? Localizer.Message("empty") : Program.FormatDuration_Long(durationMs), mRole == Role.Custom ? String.Format(Localizer.Message("phrase_extra_custom"), mCustomRole) : mRole == Role.Page ? String.Format(Localizer.Message("phrase_extra_page"), mPageNumber != null ? mPageNumber.ToString() : "") : mRole == Role.Anchor && this.AssociatedNode == null? Localizer.Message("phrase_extra_" + mRole.ToString()) + "= ?": Localizer.Message("phrase_extra_" + mRole.ToString()))); }
/// <summary> /// String output to help with debugging. /// </summary> public override string ToString() { string tempLabel = Label.Replace("\n", string.Empty); return(string.Format(Localizer.Message("section_to_string"), Used ? "" : Localizer.Message("unused"), tempLabel, Duration == 0.0 ? Localizer.Message("empty") : string.Format(Localizer.Message("duration_s_ms"), Duration / 1000.0), string.Format(Localizer.Message("section_level_to_string"), IsRooted ? Level : 0), PhraseChildCount == 0 ? "" : PhraseChildCount == 1 ? Localizer.Message("section_one_phrase_to_string") : string.Format(Localizer.Message("section_phrases_to_string"), PhraseChildCount))); }
/// <summary> /// Create a section node belonging to this presentation. /// </summary> public SectionNode CreateSectionNode() { SectionNode node = (SectionNode)m_ObiNodeFactory.createNode(XukAble.GetXukName(typeof(SectionNode)).z(PrettyFormat), DataModelFactory.NS); //sdk2 :local ObiNode factory used urakawa.property.channel.ChannelsProperty channelsProperty = PropertyFactory.CreateChannelsProperty(); node.AddProperty(channelsProperty); // Create the text media object for the label with a default label TextMedia labelMedia = MediaFactory.CreateTextMedia(); labelMedia.Text = Localizer.Message("default_section_label"); channelsProperty.SetMedia(ChannelsManager.GetOrCreateTextChannel(), labelMedia); return(node); }
/// <summary> /// Open a project from a XUK file. /// </summary> public void Open(string path) { m_ErrorsInOpeningProject = false; m_ListOfErrorMessages.Clear(); mProject = new urakawa.Project(); //sdk2 //mProject.setDataModelFactory ( mDataModelFactory ); mProject.dataIsMissing += new EventHandler <urakawa.events.media.data.DataIsMissingEventArgs>(OnDataIsMissing); //long memoryBefore = System.GC.GetTotalMemory(true); //sdk2 //mProject.openXUK ( new Uri ( path ) ); //System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); //stopWatch.Start(); OpenXukAction action = new OpenXukAction(mProject, new Uri(path)); action.ShortDescription = "DUMMY"; action.LongDescription = "DUMMY"; action.DoWork(); //stopWatch.Stop(); //Console.WriteLine("Time taken for xuk-in in milliseconds " + stopWatch.ElapsedMilliseconds); //Presentation = mProject.Presentations.Get(0); //long memoryAfter = System.GC.GetTotalMemory(true); //long memoryDiff = memoryBefore - memoryAfter; //Console.WriteLine("opening project memory differenc is " + (memoryDiff / 1024)); mPath = path; GetLock(mPath); Presentation.Initialize(this); // Hack to ignore the empty commands saved by the default undo/redo manager Presentation.UndoRedoManager.FlushCommands(); ((ObiRootNode)mProject.Presentations.Get(0).RootNode).LocateBookMarkAndAssociatedNode(); SetupBackupFilesForNewSession(path); if (ProjectOpened != null) { ProjectOpened(this, null); } if (m_ListOfErrorMessages.Count > 0) { m_ErrorsInOpeningProject = true; Dialogs.ReportDialog reportDialog = new Obi.Dialogs.ReportDialog(Localizer.Message("Warning"), Localizer.Message("Error_Message"), m_ListOfErrorMessages); reportDialog.ShowDialog(); } ShouldDisableDiskSpaceCheck(); }
// Create a new phrase node with the audio from the clipboard // and merge the selected node with this one. protected virtual urakawa.command.Command PasteCommandAudio(ProjectView.ProjectView view) { AudioClipboard c = (AudioClipboard)view.Clipboard; //urakawa.media.data.audio.ManagedAudioMedia media = ((PhraseNode)view.Clipboard.Node).Audio.copy( urakawa.media.data.audio.ManagedAudioMedia media = view.Presentation.MediaFactory.CreateManagedAudioMedia(); WavAudioMediaData wavData = ((WavAudioMediaData)((PhraseNode)view.Clipboard.Node).Audio.AudioMediaData).Copy( new Time(Convert.ToInt64(c.AudioRange.SelectionBeginTime * Time.TIME_UNIT)), new Time(Convert.ToInt64(c.AudioRange.SelectionEndTime * Time.TIME_UNIT)));//sdk2 media.AudioMediaData = wavData; CompositeCommand p = view.Presentation.CreateCompositeCommand(Localizer.Message("paste_audio")); if (Node is EmptyNode) { if (view.TransportBar.CurrentState == Obi.ProjectView.TransportBar.State.Paused) { Command pasteCommand = new Commands.Audio.Paste(view, view.TransportBar.SplitBeginTime); p.ChildCommands.Insert(p.ChildCommands.Count, pasteCommand); } else { PhraseNode phrase = view.Presentation.CreatePhraseNode(media); p.ChildCommands.Insert(p.ChildCommands.Count, new Commands.Node.AddNode(view, phrase, ParentForNewNode(phrase), IndexForNewNode(phrase))); p.ChildCommands.Insert(p.ChildCommands.Count, Commands.Node.MergeAudio.GetMergeCommand(view, (EmptyNode)Node, phrase)); if (Node is PhraseNode) { p.ChildCommands.Insert(p.ChildCommands.Count, new Commands.UpdateSelection(view, new AudioSelection((PhraseNode)Node, Control, new AudioRange(Node.Duration, Node.Duration + phrase.Duration)))); } else if (Node is EmptyNode) { p.ChildCommands.Insert(p.ChildCommands.Count, new Commands.UpdateSelection(view, new NodeSelection(phrase, Control))); } } } else { PhraseNode phrase = view.Presentation.CreatePhraseNode(media); p.ChildCommands.Insert(p.ChildCommands.Count, new Commands.Node.AddNode(view, phrase, ParentForNewNode(phrase), IndexForNewNode(phrase))); } return(p); }
// Get a lock file, and throw an exception if there is already one. private void GetLock(string path) { mCanDeleteLock = false; string path_lock = path + ".lock"; if (System.IO.File.Exists(path_lock)) { throw new Exception(string.Format(Localizer.Message("project_locked"), path_lock)); } try { System.IO.File.Create(path_lock).Close(); mCanDeleteLock = true; } catch (Exception e) { throw new Exception(string.Format(Localizer.Message("project_lock_error"), path_lock, e.Message), e); } }
/// <summary> /// Renumber this node and all following pages of the same kind starting from this number. /// </summary> public override CompositeCommand RenumberCommand(ProjectView.ProjectView view, PageNumber from) { if (mRole == Role.Page && mPageNumber.Kind == from.Kind) { CompositeCommand k = base.RenumberCommand(view, from.NextPageNumber()); if (k == null) { k = Presentation.CommandFactory.CreateCompositeCommand(); k.ShortDescription = string.Format(Localizer.Message("renumber_pages"), Localizer.Message(string.Format("{0}_pages", from.Kind.ToString()))); } k.ChildCommands.Insert(k.ChildCommands.Count, new Commands.Node.SetPageNumber(view, this, from)); return(k); } else { return(base.RenumberCommand(view, from)); } }
/// <summary> /// Always save, regardless of change count (which gets reset.) /// </summary> public void ForceSave() { if (CheckDiskSpace() <= 10) { DialogResult result = MessageBox.Show(string.Format(Localizer.Message("LimitedDiskSpaceWarning"), 10), Localizer.Message("Memory_Warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.No) { return; } } if (Save(mPath)) { m_ErrorsInOpeningProject = false; mChangesCount = 0; if (ProjectSaved != null) { ProjectSaved(this, null); } } }
protected override urakawa.command.Command PasteCommandAudio(Obi.ProjectView.ProjectView view) { AudioClipboard c = (AudioClipboard)view.Clipboard; urakawa.media.data.audio.ManagedAudioMedia media = view.Presentation.MediaFactory.CreateManagedAudioMedia(); WavAudioMediaData wavData = ((WavAudioMediaData)((PhraseNode)view.Clipboard.Node).Audio.AudioMediaData).Copy( new Time(Convert.ToInt64(c.AudioRange.SelectionBeginTime * Time.TIME_UNIT)), new Time(Convert.ToInt64(c.AudioRange.SelectionEndTime * Time.TIME_UNIT)));//sdk2 media.AudioMediaData = wavData; PhraseNode phrase = view.Presentation.CreatePhraseNode(media); CompositeCommand p = view.Presentation.CreateCompositeCommand(Localizer.Message("paste_audio")); p.ChildCommands.Insert(p.ChildCommands.Count, new Commands.Node.AddNode(view, phrase, ParentForNewNode(phrase), IndexForNewNode(phrase))); if (!Node.Used) { view.AppendMakeUnused(p, phrase); } return(p); }
public void CheckAndCreateDefaultMetadataItems(UserProfile userProfile) { if (GetFirstMetadataItem(Metadata.DC_PUBLISHER) == null) { SetSingleMetadataItem(Obi.Metadata.DC_PUBLISHER, userProfile.Organization); } if (GetFirstMetadataItem(Metadata.DC_LANGUAGE) == null) { SetSingleMetadataItem(Obi.Metadata.DC_LANGUAGE, userProfile.Culture.ToString()); } if (GetFirstMetadataItem(Metadata.DC_CREATOR) == null) { SetSingleMetadataItem(Obi.Metadata.DC_CREATOR, Localizer.Message("Metadata_CreatorNameForInitializing")); //it is important for DAISY 2.02 } if (GetFirstMetadataItem(Metadata.DTB_NARRATOR) == null) { SetSingleMetadataItem(Obi.Metadata.DTB_NARRATOR, userProfile.Name); } urakawa.metadata.Metadata mdGenerator = GetFirstMetadataItem(Metadata.GENERATOR); if (mdGenerator == null) { SetSingleMetadataItem(Obi.Metadata.GENERATOR, DataModelFactory.Generator); } else { mdGenerator.NameContentAttribute.Value = DataModelFactory.Generator; } urakawa.metadata.Metadata mdXukVersion = GetFirstMetadataItem(Metadata.OBI_XUK_VERSION); if (mdXukVersion == null) { SetSingleMetadataItem(Obi.Metadata.OBI_XUK_VERSION, DataModelFactory.XUK_VERSION); } else { mdXukVersion.NameContentAttribute.Value = DataModelFactory.XUK_VERSION; } }
/// <summary> /// Format a duration in milliseconds in a smart way. /// </summary> public static string FormatDuration_Smart(double durationMs) { double seconds = durationMs / 1000.0; if (seconds < 60.0) { return(string.Format(Localizer.Message("duration_s_ms"), seconds)); } else { int minutes = (int)Math.Floor(seconds / 60.0); int seconds_ = (int)Math.Round(seconds - minutes * 60.0); if (minutes < 60) { return(string.Format(Localizer.Message("duration_mm_ss"), minutes, seconds_)); } else { return(string.Format(Localizer.Message("duration_h_mm_ss"), minutes / 60, minutes % 60, seconds_)); } } }
public void MergeProject() { m_SectionsToMerge.Clear(); try { //1 Uri uri = new Uri(m_SourceProjectPath, UriKind.Absolute); bool pretty = m_session.Presentation.Project.PrettyFormat; Project subproject = new Project(); OpenXukAction action = new OpenXukAction(subproject, uri); action.ShortDescription = "..."; action.LongDescription = "..."; action.Execute(); subproject.PrettyFormat = pretty; Presentation subpresentation = subproject.Presentations.Get(0); // compare audio formats if (m_session.Presentation.MediaDataManager.DefaultPCMFormat.Data.BitDepth != subpresentation.MediaDataManager.DefaultPCMFormat.Data.BitDepth || m_session.Presentation.MediaDataManager.DefaultPCMFormat.Data.BlockAlign != subpresentation.MediaDataManager.DefaultPCMFormat.Data.BlockAlign || m_session.Presentation.MediaDataManager.DefaultPCMFormat.Data.SampleRate != subpresentation.MediaDataManager.DefaultPCMFormat.Data.SampleRate) { throw new System.Exception("Audio format of project does not match"); } TreeNode subroot = subpresentation.RootNode; int sectionCount = ((ObiRootNode)subroot).SectionChildCount; if (sectionCount == 0) { return; } int progressValue = 0; reportProgress(progressValue, ""); SectionNode section = ((ObiRootNode)subroot).SectionChild(0); while (section != null) { //2 if (RequestCancellation) { return; } TreeNode importedLevel = section.Export(m_session.Presentation); ObiRootNode parent = (ObiRootNode)m_session.Presentation.RootNode; //parent.AppendChild((SectionNode) importedLevel); m_SectionsToMerge.Add((SectionNode)importedLevel); progressValue += 90 / sectionCount; reportProgress(progressValue, string.Format(Localizer.Message("MergeProject_SectionProgress"), section.Label)); //System.Windows.Forms.MessageBox.Show(section.GetText().ToString()); section = section.NextSibling; } //-2 } //-1 //catch (Exception ex) //{//1 //messageBoxAlert("PROBLEM:\n " + xukPath, null); //m_session.messageBoxText("MERGE PROBLEM", xukPath, ex.Message); //throw ex; //System.Windows.Forms.MessageBox.Show(ex.ToString()); //}//-1 finally { } reportProgress(100, ""); }
/* * private void PopulateMenuShortcutsDictionary() * { * if (MenuKeyboardShortCutsList != null) * { * for (int i = 0; i < MenuKeyboardShortCutsList.Length; i++) * { * if (string.IsNullOrEmpty(MenuKeyboardShortCutsList[i].Description)) continue; * KeyboardShortcutsDescription.Add(MenuKeyboardShortCutsList[i].Description, MenuKeyboardShortCutsList[i]); * MenuKeyboardShortCutsList[i].IsMenuShortcut = true; * } * } * } */ private void PopulateKeyboardShortcutsDictionary() { KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectCompleteWaveform.Description), ContentView_SelectCompleteWaveform); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_PlaySelectedWaveform.Description), ContentView_PlaySelectedWaveform); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarNextSection.Description), ContentView_TransportBarNextSection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviousSection.Description), ContentView_TransportBarPreviousSection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviousPhrase.Description), ContentView_TransportBarPreviousPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarNextPhrase.Description), ContentView_TransportBarNextPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarNudgeForward.Description), ContentView_TransportBarNudgeForward); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarNudgeBackward.Description), ContentView_TransportBarNudgeBackward); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarFineNavigationOn.Description), ContentView_TransportBarFineNavigationOn); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarFineNavigationOff.Description), ContentView_TransportBarFineNavigationOff); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_MarkSelectionBeginTime.Description), ContentView_MarkSelectionBeginTime); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_MarkSelectionEndTime.Description), ContentView_MarkSelectionEndTime); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ExpandAudioSelectionAtLeft.Description), ContentView_ExpandAudioSelectionAtLeft); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ContractAudioSelectionAtLeft.Description), ContentView_ContractAudioSelectionAtLeft); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarNextPage.Description), ContentView_TransportBarNextPage); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviousPage.Description), ContentView_TransportBarPreviousPage); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviewFromAudioCursor.Description), ContentView_TransportBarPreviewFromAudioCursor); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviewFromSelection.Description), ContentView_TransportBarPreviewFromSelection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviewUptoAudioCursor.Description), ContentView_TransportBarPreviewUptoAudioCursor); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarPreviewUptoSelection.Description), ContentView_TransportBarPreviewUptoSelection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarExpandPlayOptions.Description), ContentView_TransportBarExpandPlayOptions); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarExpandRecordOptions.Description), ContentView_TransportBarExpandRecordOptions); if (ContentView_TransportBarExpandSwitchProfile == null) { ContentView_TransportBarExpandSwitchProfile = new KeyboardShortcut(Keys.Control | Keys.F5, "KeysS_TransportBarExpandSwitchProfile"); } KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarExpandSwitchProfile.Description), ContentView_TransportBarExpandSwitchProfile); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ZoomWaveformPanel.Description), ContentView_ZoomWaveformPanel); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarRecordSingleKey.Description), ContentView_TransportBarRecordSingleKey); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_TransportBarStopSingleKey.Description), ContentView_TransportBarStopSingleKey); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_FastPlayStepDown.Description), ContentView_FastPlayStepDown); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_FastPlayStepUp.Description), ContentView_FastPlayStepUp); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_FastPlayRateNormilize.Description), ContentView_FastPlayRateNormilize); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_FastPlayNormalizeWithElapseBack.Description), ContentView_FastPlayNormalizeWithElapseBack); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_FastPlayWithElapseForward.Description), ContentView_FastPlayWithElapseForward); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_MarkSelectionFromBeginningToTheCursor.Description), ContentView_MarkSelectionFromBeginningToTheCursor); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_MarkSelectionFromCursorToTheEnd.Description), ContentView_MarkSelectionFromCursorToTheEnd); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectPrecedingPhrase.Description), ContentView_SelectPrecedingPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectFollowingPhrase.Description), ContentView_SelectFollowingPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectLastPhraseInStrip.Description), ContentView_SelectLastPhraseInStrip); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectFirstPhraseInStrip.Description), ContentView_SelectFirstPhraseInStrip); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectNextPagePhrase.Description), ContentView_SelectNextPagePhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectPrecedingPagePhrase.Description), ContentView_SelectPrecedingPagePhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectNextSpecialRolePhrase.Description), ContentView_SelectNextSpecialRolePhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectPrecedingSpecialRolePhrase.Description), ContentView_SelectPrecedingSpecialRolePhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectNextEmptyPhrase.Description), ContentView_SelectNextEmptyPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectFirstSkippableNode.Description), ContentView_SelectFirstSkippableNode); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectLastSkippableNode.Description), ContentView_SelectLastSkippableNode); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectPrecedingStrip.Description), ContentView_SelectPrecedingStrip); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectFollowingStrip.Description), ContentView_SelectFollowingStrip); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectFirstStrip.Description), ContentView_SelectFirstStrip); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectLastStrip.Description), ContentView_SelectLastStrip); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectUp.Description), ContentView_SelectUp); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectPrecedingStripCursor.Description), ContentView_SelectPrecedingStripCursor); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectFollowingStripCursor.Description), ContentView_SelectFollowingStripCursor); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ScrollDown_LargeIncrementWithSelection.Description), ContentView_ScrollDown_LargeIncrementWithSelection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ScrollUp_LargeIncrementWithSelection.Description), ContentView_ScrollUp_LargeIncrementWithSelection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ScrollUp_SmallIncrementWithSelection.Description), ContentView_ScrollUp_SmallIncrementWithSelection); KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_ScrollDown_SmallIncrementWithSelection.Description), ContentView_ScrollDown_SmallIncrementWithSelection); if (ContentView_SelectStartOfThePhrase == null) { ContentView_SelectStartOfThePhrase = new KeyboardShortcut(Keys.Home | Keys.Alt | Keys.Control, "KeyS_SelectStartOfThePhrase"); } KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectStartOfThePhrase.Description), ContentView_SelectStartOfThePhrase); if (ContentView_SelectEndOfPhrase == null) { ContentView_SelectEndOfPhrase = new KeyboardShortcut(Keys.End | Keys.Alt | Keys.Control, "KeyS_SelectEndOfPhrase"); } KeyboardShortcutsDescription.Add(Localizer.Message(ContentView_SelectEndOfPhrase.Description), ContentView_SelectEndOfPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_MoveToNextViewClockwise.Description), ProjectView_MoveToNextViewClockwise); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_MoveToPreviousViewAnticlockwise.Description), ProjectView_MoveToPreviousViewAnticlockwise); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_ToggleBetweenContentViewAndTOCView.Description), ProjectView_ToggleBetweenContentViewAndTOCView); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_PlayPauseUsingSelection.Description), ProjectView_PlayPauseUsingSelection); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_PlayPauseUsingAudioCursor_Default.Description), ProjectView_PlayPauseUsingAudioCursor_Default); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_ShowPropertiesOfSelectedNode.Description), ProjectView_ShowPropertiesOfSelectedNode); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_FocusOnTransportBarTimeDisplay.Description), ProjectView_FocusOnTransportBarTimeDisplay); KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_HardResetAllSettings.Description), ProjectView_HardResetAllSettings); if (ProjectView_PlayOnNavigate == null) { ProjectView_PlayOnNavigate = new KeyboardShortcut(Keys.Control | Keys.U, "KeyS_PlayOnNavigate"); } KeyboardShortcutsDescription.Add(Localizer.Message(ProjectView_PlayOnNavigate.Description), ProjectView_PlayOnNavigate); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_Close.Description), ZoomPanel_Close); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_NextPhrase.Description), ZoomPanel_NextPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_PreviousPhrase.Description), ZoomPanel_PreviousPhrase); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_Reset.Description), ZoomPanel_Reset); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_ZoomIn.Description), ZoomPanel_ZoomIn); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_ZoomOut.Description), ZoomPanel_ZoomOut); KeyboardShortcutsDescription.Add(Localizer.Message(ZoomPanel_ZoomSelection.Description), ZoomPanel_ZoomSelection); }
/// <summary> /// Stringify the selection for showing in the status bar. /// </summary> public override string ToString() { return(String.Format(Localizer.Message("node_selection_to_string"), Node != null? Node.ToString(): "", Control.ToString())); }
public override string ToString() { return(String.Format(Localizer.Message("strip_cursor_selection_to_string"), mIndex, Node.ToString(), Control.ToString())); }
public override string ToString() { string audioRangeString = AudioRange != null?AudioRange.ToString() : " "; // for precaution return(String.Format(Localizer.Message("audio_selection_to_string"), audioRangeString, Node.ToString(), Control.ToString())); }
public override string ToString() { return(String.Format(Localizer.Message("text_selection_to_string"), Node.ToString(), Control.ToString(), mText)); }
public CultureInfo Culture; // user language /// <summary> /// Create a new user profile from the OS settings. /// </summary> public UserProfile() { Name = Environment.UserName; Organization = Localizer.Message("default_organization"); Culture = Thread.CurrentThread.CurrentCulture; }
/// <summary> /// save project to backup file for recovery purpose /// </summary> public string SaveToBackup() { if (m_BackupDirPath != null && Directory.Exists(m_BackupDirPath)) { try { if (!File.Exists(m_BackupProjectFilePath_temp)) { File.Create(m_BackupProjectFilePath_temp).Close(); } //sdk2 //Uri prevUri = Presentation.getRootUri (); //Presentation.setRootUri ( new Uri ( m_BackupProjectFilePath_temp ) ); Uri oldUri = Presentation.RootUri; string oldDataDir = Presentation.DataProviderManager.DataFileDirectory; string dirPath = System.IO.Path.GetDirectoryName(m_BackupProjectFilePath_temp); string prefix = System.IO.Path.GetFileName(m_BackupProjectFilePath_temp); //TODO: it would be good for Obi to separate Data folder based on project file name, //TODO: otherwise collision of Data folder may happen if several project files are in same directory. //Presentation.DataProviderManager.SetDataFileDirectoryWithPrefix(prefix); Presentation.RootUri = new Uri(dirPath + System.IO.Path.DirectorySeparatorChar, UriKind.Absolute); Save(m_BackupProjectFilePath_temp); //sdk2 //Presentation.setRootUri ( prevUri ); Presentation.RootUri = oldUri; Presentation.DataProviderManager.DataFileDirectory = oldDataDir; if (!Directory.Exists(m_BackupDirPath)) { Directory.CreateDirectory(m_BackupDirPath); } string backupPath = System.IO.Path.Combine(m_BackupDirPath, System.IO.Path.GetFileName(m_BackupProjectFilePath_temp)); // move backup file to backupfolder if (File.Exists(backupPath)) { File.Delete(backupPath); } File.Move(m_BackupProjectFilePath_temp, backupPath); return(backupPath); } catch (System.Exception ex) { MessageBox.Show(Localizer.Message("AutoSave_Error") + "\n\n" + ex.ToString()); } } // backup dir check ends return(null); }
/// <summary> /// Format a duration in milliseconds in a verbose way. /// </summary> public static string FormatDuration_Long(double durationMs) { double seconds = durationMs / 1000.0; if (seconds < 60.0) { return(string.Format(Localizer.Message("long_s_ms"), seconds, Localizer.Message(seconds > 1 ? "seconds" : "second"))); } else { int minutes = (int)Math.Floor(seconds / 60.0); int seconds_ = (int)Math.Round(seconds - minutes * 60.0); if (minutes < 60) { return(string.Format(Localizer.Message("long_mm_ss"), minutes, Localizer.Message(minutes > 1 ? "minutes" : "minute"), string.Format(seconds_ == 0 ? "" : string.Format(Localizer.Message("long_addl_time"), seconds_, Localizer.Message(seconds_ > 1 ? "seconds" : "second"))))); } else { int hours = minutes / 60; int minutes_ = minutes % 60; return(string.Format(Localizer.Message("long_h_mm_ss"), hours, Localizer.Message(hours > 1 ? "hours" : "hour"), string.Format(minutes_ == 0 ? "" : string.Format(Localizer.Message("long_addl_time"), minutes_, Localizer.Message(minutes_ > 1 ? "minutes" : "minute"))), string.Format(seconds_ == 0 ? "" : string.Format(Localizer.Message("long_addl_time"), seconds_, Localizer.Message(seconds_ > 1 ? "seconds" : "second"))))); } } }
public override string ToString() { return(Localizer.Message("role_" + mRole.ToString())); }
/// <summary> /// Create the default DAISY entries. /// </summary> private static void CreateDAISYEntries() { DAISY_ENTRIES[Metadata.DC_TITLE] = new MetadataEntryDescription( Metadata.DC_TITLE, MetadataOccurrence.Required, Localizer.Message("dc_title_description"), true, false); DAISY_ENTRIES[Metadata.DC_CREATOR] = new MetadataEntryDescription( Metadata.DC_CREATOR, MetadataOccurrence.Recommended, Localizer.Message("dc_creator_description"), true, false); DAISY_ENTRIES[Metadata.DC_SUBJECT] = new MetadataEntryDescription( Metadata.DC_SUBJECT, MetadataOccurrence.Recommended, Localizer.Message("dc_subject_description"), true, false); DAISY_ENTRIES[Metadata.DC_DESCRIPTION] = new MetadataEntryDescription( Metadata.DC_DESCRIPTION, MetadataOccurrence.Optional, Localizer.Message("dc_description_description"), true, false); DAISY_ENTRIES[Metadata.DC_PUBLISHER] = new MetadataEntryDescription( Metadata.DC_PUBLISHER, MetadataOccurrence.Required, Localizer.Message("dc_publisher_description"), true, false); DAISY_ENTRIES[Metadata.DC_CONTRIBUTOR] = new MetadataEntryDescription( Metadata.DC_CONTRIBUTOR, MetadataOccurrence.Optional, Localizer.Message("dc_contributor_description"), true, false); DAISY_ENTRIES[Metadata.DC_DATE] = new MetadataEntryDescription( Metadata.DC_DATE, MetadataOccurrence.Required, Localizer.Message("dc_date_description"), true, false); DAISY_ENTRIES[Metadata.DC_TYPE] = new MetadataEntryDescription( Metadata.DC_TYPE, MetadataOccurrence.Optional, Localizer.Message("dc_type_description"), true, false); DAISY_ENTRIES[Metadata.DC_FORMAT] = new MetadataEntryDescription( Metadata.DC_FORMAT, MetadataOccurrence.Required, Localizer.Message("dc_format_description"), true, true); DAISY_ENTRIES[Metadata.DC_IDENTIFIER] = new MetadataEntryDescription( Metadata.DC_IDENTIFIER, MetadataOccurrence.Required, Localizer.Message("dc_identifier_description"), true, false); DAISY_ENTRIES[Metadata.DC_SOURCE] = new MetadataEntryDescription( Metadata.DC_SOURCE, MetadataOccurrence.Recommended, Localizer.Message("dc_source"), true, false); DAISY_ENTRIES[Metadata.DC_LANGUAGE] = new MetadataEntryDescription( Metadata.DC_LANGUAGE, MetadataOccurrence.Required, Localizer.Message("dc_language_description"), true, false); DAISY_ENTRIES[Metadata.DC_RELATION] = new MetadataEntryDescription( Metadata.DC_RELATION, MetadataOccurrence.Optional, Localizer.Message("dc_relation_description"), true, false); DAISY_ENTRIES[Metadata.DC_COVERAGE] = new MetadataEntryDescription( Metadata.DC_COVERAGE, MetadataOccurrence.Optional, Localizer.Message("dc_coverage_description"), true, false); DAISY_ENTRIES[Metadata.DC_RIGHTS] = new MetadataEntryDescription( Metadata.DC_RIGHTS, MetadataOccurrence.Optional, Localizer.Message("dc_rights_description"), true, false); DAISY_ENTRIES[Metadata.DTB_SOURCE_DATE] = new MetadataEntryDescription( Metadata.DTB_SOURCE_DATE, MetadataOccurrence.Recommended, Localizer.Message("dtb_source_date_description"), false, false); DAISY_ENTRIES[Metadata.DTB_SOURCE_EDITION] = new MetadataEntryDescription( Metadata.DTB_SOURCE_EDITION, MetadataOccurrence.Recommended, Localizer.Message("dtb_source_edition_description"), false, false); DAISY_ENTRIES[Metadata.DTB_SOURCE_PUBLISHER] = new MetadataEntryDescription( Metadata.DTB_SOURCE_PUBLISHER, MetadataOccurrence.Recommended, Localizer.Message("dtb_source_publisher_description"), false, false); DAISY_ENTRIES[Metadata.DTB_SOURCE_RIGHTS] = new MetadataEntryDescription( Metadata.DTB_SOURCE_RIGHTS, MetadataOccurrence.Recommended, Localizer.Message("dtb_source_rights_description"), false, false); DAISY_ENTRIES[Metadata.DTB_SOURCE_TITLE] = new MetadataEntryDescription( Metadata.DTB_SOURCE_TITLE, MetadataOccurrence.Optional, Localizer.Message("dtb_source_title_description"), false, false); DAISY_ENTRIES[Metadata.DTB_MULTIMEDIA_TYPE] = new MetadataEntryDescription( Metadata.DTB_MULTIMEDIA_TYPE, MetadataOccurrence.Required, Localizer.Message("dtb_multimedia_type_description"), false, true); DAISY_ENTRIES[Metadata.DTB_MULTIMEDIA_CONTENT] = new MetadataEntryDescription( Metadata.DTB_MULTIMEDIA_CONTENT, MetadataOccurrence.Required, Localizer.Message("dtb_multimedia_content_description"), false, true); DAISY_ENTRIES[Metadata.DTB_NARRATOR] = new MetadataEntryDescription( Metadata.DTB_NARRATOR, MetadataOccurrence.Recommended, Localizer.Message("dtb_narrator_description"), true, false); DAISY_ENTRIES[Metadata.DTB_PRODUCER] = new MetadataEntryDescription( Metadata.DTB_PRODUCER, MetadataOccurrence.Optional, Localizer.Message("dtb_producer_description"), true, false); DAISY_ENTRIES[Metadata.DTB_PRODUCED_DATE] = new MetadataEntryDescription( Metadata.DTB_PRODUCED_DATE, MetadataOccurrence.Optional, Localizer.Message("dtb_produced_date_description"), false, false); DAISY_ENTRIES[Metadata.DTB_REVISION] = new MetadataEntryDescription( Metadata.DTB_REVISION, MetadataOccurrence.Optional, Localizer.Message("dtb_revision_description"), false, false); DAISY_ENTRIES[Metadata.DTB_REVISION_DATE] = new MetadataEntryDescription( Metadata.DTB_REVISION_DATE, MetadataOccurrence.Optional, Localizer.Message("dtb_revision_date_description"), false, false); DAISY_ENTRIES[Metadata.DTB_REVISION_DESCRIPTION] = new MetadataEntryDescription( Metadata.DTB_REVISION_DESCRIPTION, MetadataOccurrence.Optional, Localizer.Message("dtb_description_description"), false, false); DAISY_ENTRIES[Metadata.DTB_TOTAL_TIME] = new MetadataEntryDescription( Metadata.DTB_TOTAL_TIME, MetadataOccurrence.Required, Localizer.Message("dtb_total_time_description"), false, true); DAISY_ENTRIES[Metadata.DTB_AUDIO_FORMAT] = new MetadataEntryDescription( Metadata.DTB_AUDIO_FORMAT, MetadataOccurrence.Recommended, Localizer.Message("dtb_audio_format_description"), true, true); DAISY_ENTRIES[Metadata.GENERATOR] = new MetadataEntryDescription( Metadata.GENERATOR, MetadataOccurrence.Required, Localizer.Message("generator_description"), false, true); DAISY_ENTRIES[Metadata.OBI_XUK_VERSION] = new MetadataEntryDescription( Metadata.OBI_XUK_VERSION, MetadataOccurrence.Required, Localizer.Message("obi_xuk_version_description"), false, true); DAISY_ENTRIES[Metadata.OBI_DAISY3ExportPath] = new MetadataEntryDescription( Metadata.OBI_DAISY3ExportPath, MetadataOccurrence.Optional, Localizer.Message("obi_DAISY3ExportPath_Description"), false, true); DAISY_ENTRIES[Metadata.OBI_DAISY2ExportPath] = new MetadataEntryDescription( Metadata.OBI_DAISY2ExportPath, MetadataOccurrence.Optional, Localizer.Message("obi_DAISY2ExportPath_Description"), false, true); DAISY_ENTRIES[Metadata.OBI_EPUB3ExportPath] = new MetadataEntryDescription( Metadata.OBI_EPUB3ExportPath, MetadataOccurrence.Optional, Localizer.Message("obi_EPUB3ExportPath_Description"), false, true); }