Ejemplo n.º 1
0
        // Create a split command preserving used/TODO status, and optionally transferring the role to the next node
        public static SplitAudio AppendSplitCommandWithProperties(ProjectView.ProjectView view, CompositeCommand command,
                                                                  PhraseNode phrase, double time, bool transferRole)
        {
            SplitAudio split = new SplitAudio(view, phrase, time);

            if (split.Node.TODO)
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.ToggleNodeTODO(view, split.NodeAfter));
            }
            if (!split.Node.Used)
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.ToggleNodeUsed(view, split.NodeAfter));
            }
            if (split.Node.Role_ == EmptyNode.Role.Silence || phrase.Role_ == EmptyNode.Role.Custom)
            {
                Commands.Node.AssignRole copyRoleCmd =
                    new Commands.Node.AssignRole(view, split.NodeAfter, phrase.Role_, phrase.CustomRole);
                copyRoleCmd.UpdateSelection = false;
                command.ChildCommands.Insert(command.ChildCommands.Count, copyRoleCmd);
            }
            command.ChildCommands.Insert(command.ChildCommands.Count, split);
            if (transferRole && phrase.Role_ != EmptyNode.Role.Plain)
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AssignRole(view, phrase, EmptyNode.Role.Plain));
                if (phrase.Role_ == EmptyNode.Role.Page)
                {
                    command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.SetPageNumber(view, split.NodeAfter, phrase.PageNumber.Clone()));
                }
                else
                {
                    command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AssignRole(view, split.NodeAfter, phrase.Role_, phrase.CustomRole));
                }
            }
            return(split);
        }
Ejemplo n.º 2
0
        private Time mSplitTime;        // split point (begin/cursor)


        // Create a split command to split the selected node at the given position.
        // Use only through GetSplitCommand.
        private SplitAudio(ProjectView.ProjectView view, PhraseNode node, double time) : base(view)
        {
            mNode      = node;
            mNodeAfter = view.Presentation.CreatePhraseNode();
            mSplitTime = new Time((long)(time * Time.TIME_UNIT));
            SetDescriptions(Localizer.Message("split_phrase"));
        }
Ejemplo n.º 3
0
        private bool mOriginalStatus;  // original used status of the node

        /// <summary>
        /// Change the used status of a single node.
        /// </summary>
        public ToggleNodeTODO(ProjectView.ProjectView view, EmptyNode node)
            : base(view)
        {
            mNode           = node;
            mOriginalStatus = node.TODO;
            SetDescriptions(Localizer.Message("toggle_TODO"));
        }
Ejemplo n.º 4
0
        public ObiConfiguration(ObiForm form, ProjectView.ProjectView projectView, Settings settings) : this()
        {
            m_Settings    = settings;
            m_ProjectView = projectView;
            m_Form        = form;
            this.Text     = this.Text + " " + Application.ProductVersion;
            if (m_Settings.ObiFont != this.Font.Name)
            {
                this.Font = new Font(m_Settings.ObiFont, this.Font.Size, FontStyle.Regular); //@fontconfig
            }
            InitializeInputDevices();
            LoadProfilesToComboboxes();
            if (m_cb_SelectProfile.Items.Count > 0)
            {
                m_cb_SelectProfile.SelectedIndex = 0;
            }

            if (m_cb_SelectShortcutsProfile.Items.Count > 0)
            {
                m_cb_SelectShortcutsProfile.SelectedIndex = 0;
            }


            m_tb_ObiConfigInstructions.Text = Localizer.Message("ConfigureObi");
            string path = "C:\\Obi Projects";

            m_ProjectDirectoryPath  = path;
            m_DirectoryTextbox.Text = m_ProjectDirectoryPath;
        }
Ejemplo n.º 5
0
 public AddEntry(ProjectView.ProjectView view)
     : base(view)
 {
     mEntry = view.Presentation.MetadataFactory.CreateMetadata();
     mEntry.NameContentAttribute = new MetadataAttribute();
     SetDescriptions(Localizer.Message("add_metadata_entry"));
 }
Ejemplo n.º 6
0
        private MetadataSelection mSelectionAfter;  // selection after the deletion

        public DeleteEntry(ProjectView.ProjectView view)
            : base(view)
        {
            mEntry          = ((MetadataSelection)view.Selection).Item.Entry;
            mSelectionAfter = null;
            SetDescriptions(Localizer.Message("delete_metadata_entry"));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Append commands to transfer the attributes of a node to another (used, TODO, role, page number)
        /// </summary>
        public static void AppendCopyNodeAttributes(CompositeCommand command, ProjectView.ProjectView view,
                                                    EmptyNode from, EmptyNode to)
        {
            if (from.TODO && !to.TODO)
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.ToggleNodeTODO(view, to));
            }
            if ((!from.Used && to.Used) && (to.Role_ != EmptyNode.Role.Page && to.Role_ != EmptyNode.Role.Heading))
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.ToggleNodeUsed(view, to));
            }

            // role of next phrase is copied to selected phrase only when next phrase is page, heading or silence.
            // The priority is highest for page, followed by heading followed by silence. If next phrase is of higher priority only then its role is copied.
            if (from.Role_ == EmptyNode.Role.Page && to.Role_ != EmptyNode.Role.Page)
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.SetPageNumber(view, to, from.PageNumber.Clone()));
            }
            else if ((to.Role_ != EmptyNode.Role.Heading && to.Role_ != EmptyNode.Role.Page) &&
                     (from.Role_ != EmptyNode.Role.Plain &&
                      (from.Role_ != EmptyNode.Role.Silence || to is PhraseNode)))
            {
                if (from.Role_ == EmptyNode.Role.Heading && to.Role_ != EmptyNode.Role.Page)
                {
                    command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AssignRole(view, from, EmptyNode.Role.Plain, null));
                    command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AssignRole(view, to, EmptyNode.Role.Heading, null));
                }
                else
                {
                    command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AssignRole(view, to, from.Role_, from.CustomRole));
                }
            }
        }
Ejemplo n.º 8
0
 public static CompositeCommand GetMergeCommand(ProjectView.ProjectView view, EmptyNode node, EmptyNode next)
 {
     if (node != null && next != null)
     {
         CompositeCommand command =
             view.Presentation.CreateCompositeCommand(Localizer.Message("merge_phrase_with_next"));
         if (node is PhraseNode)
         {
             AppendCopyNodeAttributes(command, view, next, node);
             if (next is PhraseNode)
             {
                 command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.MergeAudio(view, (PhraseNode)node, (PhraseNode)next));
             }
             else
             {
                 command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.Delete(view, next));
             }
         }
         else
         {
             AppendCopyNodeAttributes(command, view, node, next);
             command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.Delete(view, node));
         }
         return(command);
     }
     return(null);
 }
Ejemplo n.º 9
0
        public Paste(ProjectView.ProjectView view, double pasteTime)
            : base(view)
        {
            mNode = view.SelectedNodeAs <PhraseNode>();
            //AudioSelection selection = (AudioSelection)view.Selection;
            mMediaBefore = mNode.Audio.Copy();
            mMediaAfter  = mMediaBefore.Copy();
            urakawa.media.data.audio.ManagedAudioMedia copy;
            if (view.Clipboard is AudioClipboard)
            {
                AudioClipboard clipboard = (AudioClipboard)view.Clipboard;

                copy = view.Presentation.MediaFactory.CreateManagedAudioMedia();
                WavAudioMediaData mediaData = ((WavAudioMediaData)((PhraseNode)clipboard.Node).Audio.AudioMediaData).Copy(
                    new Time((long)(clipboard.AudioRange.SelectionBeginTime * Time.TIME_UNIT)),
                    new Time((long)(clipboard.AudioRange.SelectionEndTime * Time.TIME_UNIT))
                    );
                copy.AudioMediaData = mediaData;
            }
            else
            {
                copy = ((PhraseNode)view.Clipboard.Node).Audio.Copy();
            }
            urakawa.media.data.audio.ManagedAudioMedia after;

            after = mMediaAfter.Split(new Time((long)(pasteTime * Time.TIME_UNIT)));

            double begin = mMediaAfter.Duration.AsMilliseconds;

            mSelectionAfter = new AudioSelection(mNode, view.Selection.Control,
                                                 new AudioRange(begin, begin + copy.Duration.AsMilliseconds));
            mMediaAfter.AudioMediaData.MergeWith(copy.AudioMediaData);
            mMediaAfter.AudioMediaData.MergeWith(after.AudioMediaData);
            SetDescriptions(Localizer.Message("paste_audio"));
        }
Ejemplo n.º 10
0
        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
            }
        }
Ejemplo n.º 11
0
 public Copy(ProjectView.ProjectView view, PhraseNode node, AudioRange range)
     : base(view)
 {
     mOldClipboard = view.Clipboard;
     mNewClipboard = new AudioClipboard(node, range);
     SetDescriptions(Localizer.Message("copy_audio"));
 }
Ejemplo n.º 12
0
        private int mIndex;        // index of the node that we actually want to delete

        public DeleteWithOffset(ProjectView.ProjectView view, ObiNode node, int offset)
            : base(view)
        {
            mNode    = node;
            mParent  = node.ParentAs <ObiNode>();
            mDeleted = null;
            mIndex   = mParent.Children.IndexOf(mNode) + offset;
        }
Ejemplo n.º 13
0
 public ModifyName(ProjectView.ProjectView view, urakawa.metadata.Metadata entry, string name)
     : base(view)
 {
     mEntry        = entry;
     mPreviousName = mEntry.NameContentAttribute.Name;
     mNewName      = name;
     SetDescriptions(Localizer.Message("modify_metadata_name"));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Add an existing node to a parent node at the given index.
 /// </summary>
 public AddNode(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index) : base(view, "")
 {
     mNode      = node;
     mParent    = parent;
     mIndex     = index;
     mSelection = view.Selection != null && view.Selection.Control is ProjectView.ContentView ?
                  new NodeSelection(mNode, view.Selection.Control) : view.Selection;
 }
Ejemplo n.º 15
0
        public static CompositeCommand GetSplitCommand(ProjectView.ProjectView view, PhraseNode phrase, double time)
        {
            CompositeCommand command =
                view.Presentation.CreateCompositeCommand(Localizer.Message("split_phrase"));

            AppendSplitCommandWithProperties(view, command, phrase, time, false);
            return(command);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Add comment to a node.
 /// </summary>
 public AddComment(ProjectView.ProjectView view, EmptyNode node, string comment)
     : base(view)
 {
     mNode             = node;
     m_CommentPrevious = node.CommentText;
     m_Comment         = comment;
     //SetDescriptions(Localizer.Message("toggle_TODO"));
 }
Ejemplo n.º 17
0
 public ChooseMergeOrChangeLevel(ProjectView.ProjectView View)
     : this()
 {
     if (!View.CanMergeStripWithNext)
     {
         m_rbMerge.Enabled = false;
     }
 }
Ejemplo n.º 18
0
        private string mNewLabel;   // the new label for the node

        public RenameSection(ProjectView.ProjectView view, SectionNode section, string label)
            : base(view)
        {
            mNode     = section;
            mOldLabel = mNode.Label;
            mNewLabel = label;

            SetDescriptions(Localizer.Message("rename_section"));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Create a new command for a view with a label.
 /// </summary>
 public Command(ProjectView.ProjectView view, string label)
 {
     mView                = view;
     mSelectionBefore     = mView.Selection;
     mLabel               = label;
     mRedo                = false;
     UpdateSelection      = true;
     m_ProgressPercentage = -1; //@singleSection
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Add a new section node in the context of the previous selection. Pass along the control
 /// in which the node is added as the selection might be null. The section node is created
 /// here and will be added when the command is executed.
 /// </summary>
 public AddSectionNode(ProjectView.ProjectView view, IControlWithRenamableSelection control) : base(view)
 {
     mNode = view.Presentation.CreateSectionNode();
     SetParentAndIndex(view);
     mNode.Used = mParent.Used;
     mControl   = control;
     view.SelectAndRenameSelection(new NodeSelection(mNode, mControl));
     SetDescriptions(Localizer.Message("add_section"));
 }
Ejemplo n.º 21
0
 public ModifyContent(ProjectView.ProjectView view, urakawa.metadata.Metadata entry, string content)
     : base(view)
 {
     mEntry = entry;
     //mPreviousContent = mEntry.getContent();
     mPreviousContent = mEntry.NameContentAttribute.Value;//sdk2
     mNewContent      = content;
     SetDescriptions(Localizer.Message("modify_metadata_content"));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Add an existing node to a parent node at the given index.
 /// </summary>
 public UpdateAudioMedia(ProjectView.ProjectView view, PhraseNode node, ManagedAudioMedia media, bool updateSelection) : base(view, "")
 {
     m_Node = node;
     m_OriginalManagedAudioMedia = node.Audio;
     m_ManagedAudioMedia         = media;
     UpdateSelection             = updateSelection;
     mSelection = view.Selection != null && view.Selection.Control is ProjectView.ContentView ?
                  new NodeSelection(m_Node, view.Selection.Control) : view.Selection;
 }
Ejemplo n.º 23
0
 public AudioProcessingNoiseReduction(ProjectView.ProjectView projectView, bool isSelectionNull)
 {
     InitializeComponent();
     m_SelectPresetComboBox.SelectedIndex = 1;
     m_ProjectView               = projectView;
     m_IsSelectionNull           = isSelectionNull;
     helpProvider1.HelpNamespace = Localizer.Message("CHMhelp_file_name");
     helpProvider1.SetHelpNavigator(this, HelpNavigator.Topic);
     helpProvider1.SetHelpKeyword(this, "HTML Files/Creating a DTB/Working with Audio/Audio processing.htm");
 }
Ejemplo n.º 24
0
        public MergeAudio(ProjectView.ProjectView view, PhraseNode node, PhraseNode next)
            : base(view)
        {
            mNode     = node;
            mNextNode = next;

            // allow setting split time while executing command if the current node does not have audio yet. it is useful for composite commands
            mSplitTime = mNode.Audio != null? mNode.Audio.Duration : null; // new Time instance (no shared)

            m_IsNextNodeRooted = mNextNode.IsRooted;
        }
Ejemplo n.º 25
0
        private PageNumber mOldPageNumber;  // old page number (if previous kind was page)

        /// <summary>
        /// Change the type (either regular kind or custom type) of a node.
        /// </summary>
        public AssignRole(ProjectView.ProjectView view, EmptyNode node, EmptyNode.Role role, string customRole)
            : base(view)
        {
            mNode          = node;
            mRole          = role;
            mCustomRole    = customRole;
            mOldRole       = mNode.Role_;
            mOldCustomRole = mNode.CustomRole;
            mOldPageNumber = mNode.PageNumber;
            SetDescriptions(Localizer.Message("assign_role"));
        }
Ejemplo n.º 26
0
 public ProjectProperties(ProjectView.ProjectView View)
 {
     InitializeComponent();
     mView = View;
     helpProvider1.HelpNamespace = Localizer.Message("CHMhelp_file_name");
     helpProvider1.SetHelpNavigator(this, HelpNavigator.Topic);
     helpProvider1.SetHelpKeyword(this, "HTML Files/Creating a DTB/Creating and Working with Projects/Project Properties.htm");
     if (mView.ObiForm.Settings.ObiFont != this.Font.Name)
     {
         this.Font = new Font(View.ObiForm.Settings.ObiFont, this.Font.Size, FontStyle.Regular);//@fontconfig
     }
 }
Ejemplo n.º 27
0
 // Set parent and index for the new node
 protected virtual void SetParentAndIndex(ProjectView.ProjectView view)
 {
     if (view.Selection == null)
     {
         mParent = (ObiNode)view.Presentation.RootNode;
         mIndex  = mParent.SectionChildCount;
     }
     else
     {
         mParent = view.Selection.ParentForNewNode(mNode);
         mIndex  = view.Selection.IndexForNewNode(mNode);
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Merge the selected phrase with the following phrase.
        /// </summary>
        //public MergeAudio(ProjectView.ProjectView view):
        //    this(view, (PhraseNode)view.Selection.Node.ParentAs<ObiNode>().PhraseChild(view.Selection.Node.Index + 1)) {}

        /// <summary>
        /// Merge two nodes; the "next" one is removed after merging.
        /// </summary>
        public static void Merge(ProjectView.ProjectView view, PhraseNode node, PhraseNode next, bool updateSelection)
        {
            if (next.IsRooted)
            {
                next.Detach();
            }
            node.MergeAudioWith(next.Audio);
            if (updateSelection)
            {
                view.SelectedBlockNode = node;
            }
            view.UpdateBlocksLabelInStrip(node.AncestorAs <SectionNode>());
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Create a new source view for the current project view.
 /// </summary>
 public ShowSource(ProjectView.ProjectView view) : this()
 {
     mView = view;
     Text  = String.Format("{0} - {1}", Text, mView.Presentation.Title);
     UpdateView();
     mView.Presentation.UndoRedoManager.CommandDone   += new EventHandler <urakawa.events.undo.DoneEventArgs>(ShowSource_commandDone);
     mView.Presentation.UndoRedoManager.CommandReDone += new EventHandler <urakawa.events.undo.ReDoneEventArgs>(ShowSource_commandReDone);
     mView.Presentation.UndoRedoManager.CommandUnDone += new EventHandler <urakawa.events.undo.UnDoneEventArgs>(ShowSource_commandUnDone);
     if (mView.ObiForm.Settings.ObiFont != this.Font.Name)
     {
         this.Font = new Font(mView.ObiForm.Settings.ObiFont, this.Font.Size, FontStyle.Regular);//@fontconfig
     }
 }
Ejemplo n.º 30
0
 public Delete(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index, bool update) : base(view)
 {
     mNode   = node;
     mParent = parent;
     mIndex  = index;
     if (view.Selection != null && view.Selection.Node == node)
     {
         mAfter = GetPostDeleteSelection();
     }
     else
     {
         mAfter = view.Selection;
     }
 }