public SpecialPhraseList(Obi.ProjectView.ProjectView projectView) { mView = projectView; mBar = projectView.TransportBar; InitializeComponent(); m_btnOK.Enabled = false; AddCustomRoles(); Assembly myAssembly = Assembly.GetExecutingAssembly(); Stream pauseStr = null; Stream playStr = null; Stream stopStr = null; pauseStr = myAssembly.GetManifestResourceStream("Obi.UserControls.media-playback-pause.png"); playStr = myAssembly.GetManifestResourceStream("Obi.UserControls.media-playback-start.png"); stopStr = myAssembly.GetManifestResourceStream("Obi.UserControls.media-playback-stop.png"); m_PauseImg = Image.FromStream(pauseStr); m_PlayImg = Image.FromStream(playStr); m_StopImg = Image.FromStream(stopStr); m_BtnPause.Image = m_PauseImg; m_BtnPlay.Image = m_PlayImg; m_BtnStop.Image = m_StopImg; mBar.StateChanged += new AudioLib.AudioPlayer.StateChangedHandler(State_Changed_Player); helpProvider1.HelpNamespace = Localizer.Message("CHMhelp_file_name"); helpProvider1.SetHelpNavigator(this, HelpNavigator.Topic); helpProvider1.SetHelpKeyword(this, "HTML Files/Exploring the GUI/Obi Views and Transport Bar/Collect special phrases and navigate.htm"); if (mView.ObiForm.Settings.ObiFont != this.Font.Name) { this.Font = new Font(mView.ObiForm.Settings.ObiFont, this.Font.Size, FontStyle.Regular);//@fontconfig } }
/// <summary> /// Get a delete command handling the delete all audio case gracefully. /// </summary> public static urakawa.command.Command GetCommand(Obi.ProjectView.ProjectView view) { Delete command = new Delete(view); if (!command.mHasAudioAfterDeleted && command.mSplitTimeBegin.AsMilliseconds == 0.0) { // Delete the whole audio urakawa.command.CompositeCommand composite = view.Presentation.CreateCompositeCommand(command.ShortDescription); EmptyNode empty = view.Presentation.TreeNodeFactory.Create <EmptyNode>(); composite.ChildCommands.Insert(composite.ChildCommands.Count, new Commands.Node.AddEmptyNode(view, empty, command.mNode.ParentAs <ObiNode>(), command.mNode.Index) ); Commands.Node.MergeAudio.AppendCopyNodeAttributes(composite, view, command.mNode, empty); Commands.Node.Delete delete = new Commands.Node.Delete(view, command.mNode); delete.UpdateSelection = false; composite.ChildCommands.Insert(composite.ChildCommands.Count, delete); return(composite); } else { return(command); } }
public SelectMergeSectionRange(Obi.ProjectView.ProjectView projectView, Obi.ProjectView.ContentView contentview) : this() { m_ProjectView = projectView; m_ContentView = contentview; InitializeList(); populateListboxForSectionsToMerge(); m_tb_SectionsSelected.Text = m_StatusLabelForMergeSection.Text = String.Format(Localizer.Message("StatusForMergeSection"), m_SectionList[0].Label, m_SectionList[m_SectionList.Count - 1].Label); m_ProjectView.TransportBar.StateChanged += new AudioLib.AudioPlayer.StateChangedHandler(State_Changed_Player); toolTip.SetToolTip(m_btn_IncreaseSectionLevel, Localizer.Message("MergeOptions_IncreaseLevel")); toolTip.SetToolTip(m_btn_DecreaseSectionLevel, Localizer.Message("MergeOptions_DecreaseLevel")); toolTip.SetToolTip(m_btn_Merge, Localizer.Message("MergeOptions_Merge")); if (projectView.ObiForm.Settings.ObiFont != this.Font.Name) { this.Font = new Font(projectView.ObiForm.Settings.ObiFont, this.Font.Size, FontStyle.Regular); //@fontconfig m_btn_Close.Font = m_btn_SelectAll.Font = new Font(projectView.ObiForm.Settings.ObiFont, this.Font.Size, FontStyle.Regular); //@fontconfig } }
/// <summary> /// Create a command to crop the current selection. /// </summary> public static urakawa.command.Command GetCropCommand(Obi.ProjectView.ProjectView view) { PhraseNode phrase = view.SelectedNodeAs <PhraseNode>(); if (phrase != null) { double begin = view.TransportBar.SplitBeginTime; double end = view.TransportBar.SplitEndTime; if (end >= phrase.Duration) { end = 0.0; } CompositeCommand command = view.Presentation.CreateCompositeCommand(Localizer.Message("crop_audio")); if (begin > 0.0 || end > 0.0) { SplitAudio split; // actual split command PhraseNode after = null; // node to select after splitting if (end > 0.0) { split = AppendSplitCommandWithProperties(view, command, phrase, end, false); after = split.Node; command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.UpdateSelection(view, new NodeSelection(after, view.Selection.Control)));//@singleSection:moved from last of function command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.DeleteWithOffset(view, phrase, 1)); } if (begin > 0.0) { split = AppendSplitCommandWithProperties(view, command, phrase, begin, view.Selection is AudioSelection && ((AudioSelection)view.Selection).AudioRange != null && !((AudioSelection)view.Selection).AudioRange.HasCursor); after = split.NodeAfter; command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.UpdateSelection(view, new NodeSelection(after, view.Selection.Control)));//@singleSection:moved from last of function command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.Delete(view, phrase, false)); } //command.append(new Commands.UpdateSelection(view, new NodeSelection(after, view.Selection.Control))); return(command); } } return(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); }
/// <summary> /// Create a paste command for this selection and the clipboard selection. /// </summary> public override urakawa.command.Command PasteCommand(Obi.ProjectView.ProjectView view, bool allowAutoSpecialRole) //@AssociateNode { return(new Commands.Audio.Paste(view)); }
protected override void SetParentAndIndex(Obi.ProjectView.ProjectView view) { mParent = view.Selection.Node; mIndex = mParent.SectionChildCount; }
private bool ReadListsFromCSVFile(List <string> nameList, List <string> content, string CSVFullPath, ObiPresentation presentation, Obi.ProjectView.ProjectView projectView) { string[] linesInFiles; try { linesInFiles = File.ReadAllLines(CSVFullPath, Encoding.Default); } catch (IOException e) { MessageBox.Show(Localizer.Message("FileInUse"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } catch (Exception e) { return(false); } CompositeCommand command = presentation.CreateCompositeCommand(Localizer.Message("modify_metadata_entry")); List <string> entryHavingWrongDateFormat = new List <string>(); foreach (string line in linesInFiles) { string[] cellsInLineArray = null; if (Path.GetExtension(CSVFullPath).ToLower() == ".csv") { cellsInLineArray = line.Split(','); } else { cellsInLineArray = line.Split('\t'); } if (cellsInLineArray.Length >= 2 && !string.IsNullOrWhiteSpace(cellsInLineArray[0]) && !string.IsNullOrWhiteSpace(cellsInLineArray[1])) { if (projectView == null) { if (Metadata.DAISY3MetadataNames.Contains(cellsInLineArray[0], StringComparer.OrdinalIgnoreCase)) { foreach (string metadataName in Metadata.DAISY3MetadataNames) { if (metadataName.IndexOf(cellsInLineArray[0], StringComparison.OrdinalIgnoreCase) >= 0) { cellsInLineArray[0] = metadataName; } } cellsInLineArray[0] = Metadata.DAISY3MetadataNames.ElementAt(Metadata.DAISY3MetadataNames.IndexOf(cellsInLineArray[0])); } if (cellsInLineArray[0].ToLower() == "dtb:produceddate" || cellsInLineArray[0].ToLower() == "dtb:revisiondate" || cellsInLineArray[0].ToLower() == "dc:date" || cellsInLineArray[0].ToLower() == "dtb:sourcedate") { string dateFormat = GetDate(cellsInLineArray[0], cellsInLineArray[1], entryHavingWrongDateFormat); cellsInLineArray[1] = dateFormat; } if (cellsInLineArray[0].ToLower() == "custom") { if (!entryHavingWrongDateFormat.Contains(cellsInLineArray[0], StringComparer.OrdinalIgnoreCase)) { m_metadataFieldsNotImported += "\n\n" + "-> " + cellsInLineArray[0] + " " + Localizer.Message("Metadata_NameCannotBeCustom"); entryHavingWrongDateFormat.Add(cellsInLineArray[0]); } } else { presentation.SetSingleMetadataItem(cellsInLineArray[0], cellsInLineArray[1]); } } else if (projectView != null) { if (projectView.CanAddMetadataEntry()) { bool entryModified = false; foreach (urakawa.metadata.Metadata entry in presentation.GetMetadata(cellsInLineArray[0])) { if (cellsInLineArray[0].ToLower() == "dtb:produceddate" || cellsInLineArray[0].ToLower() == "dtb:revisiondate" || cellsInLineArray[0].ToLower() == "dc:date" || cellsInLineArray[0].ToLower() == "dtb:sourcedate") { string dateFormat = GetDate(cellsInLineArray[0], cellsInLineArray[1], entryHavingWrongDateFormat); cellsInLineArray[1] = dateFormat; } if (cellsInLineArray[0].ToLower() == "custom") { if (!entryHavingWrongDateFormat.Contains(cellsInLineArray[0], StringComparer.OrdinalIgnoreCase)) { m_metadataFieldsNotImported += "\n\n" + "-> " + cellsInLineArray[0] + " " + Localizer.Message("Metadata_NameCannotBeCustom"); entryHavingWrongDateFormat.Add(cellsInLineArray[0]); } } else { command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Metadata.ModifyContent(projectView, entry, cellsInLineArray[1])); } entryModified = true; } if (!entryModified) { if (Metadata.DAISY3MetadataNames.Contains(cellsInLineArray[0], StringComparer.OrdinalIgnoreCase)) { foreach (string metadataName in Metadata.DAISY3MetadataNames) { if (metadataName.IndexOf(cellsInLineArray[0], StringComparison.OrdinalIgnoreCase) >= 0) { cellsInLineArray[0] = metadataName; } } cellsInLineArray[0] = Metadata.DAISY3MetadataNames.ElementAt(Metadata.DAISY3MetadataNames.IndexOf(cellsInLineArray[0])); } if (cellsInLineArray[0].ToLower() == "custom") { if (!entryHavingWrongDateFormat.Contains(cellsInLineArray[0], StringComparer.OrdinalIgnoreCase)) { m_metadataFieldsNotImported += "\n\n" + "-> " + cellsInLineArray[0] + " " + Localizer.Message("Metadata_NameCannotBeCustom"); entryHavingWrongDateFormat.Add(cellsInLineArray[0]); } } else { Commands.Metadata.AddEntry cmd = new Commands.Metadata.AddEntry(projectView, cellsInLineArray[0]); command.ChildCommands.Insert(command.ChildCommands.Count, cmd); if (cellsInLineArray[0] == "dtb:producedDate" || cellsInLineArray[0] == "dtb:revisionDate" || cellsInLineArray[0] == "dc:Date" || cellsInLineArray[0] == "dtb:sourceDate") { cellsInLineArray[1] = GetDate(cellsInLineArray[0], cellsInLineArray[1], entryHavingWrongDateFormat); } command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Metadata.ModifyContent(projectView, cmd.Entry, cellsInLineArray[1])); } } } } } } if (command.ChildCommands.Count > 0) { presentation.UndoRedoManager.Execute(command); } if (m_metadataFieldsNotImported != string.Empty) { MessageBox.Show(String.Format(Localizer.Message("Metadata_NotImported"), m_metadataFieldsNotImported), Localizer.Message("Metadata_Imported"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(String.Format(Localizer.Message("Metadata_ImportedSuccessfully"), m_metadataFieldsNotImported), Localizer.Message("Metadata_Imported"), MessageBoxButtons.OK, MessageBoxIcon.Information); } return(true); }
public bool ImportFromCSVFile(string CSVFullPath, ObiPresentation presentation, Obi.ProjectView.ProjectView projectView = null) { List <string> nameList = new List <string>(); List <string> content = new List <string>(); bool result = ReadListsFromCSVFile(nameList, content, CSVFullPath, presentation, projectView); return(result); }