From: <ju...@us...> - 2006-08-01 05:59:43
|
Revision: 706 Author: julienq Date: 2006-07-31 22:59:22 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/urakawa/?rev=706&view=rev Log Message: ----------- Play selected asset. Modified Paths: -------------- trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs trunk/urakawa/application/Obi/Obi/ObiForm.cs trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs Modified: trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/Dialogs/Play.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -7,13 +7,19 @@ using System.Windows.Forms; using VirtualAudioBackend; +using urakawa.core; +using urakawa.media; + namespace Obi.Dialogs { public partial class Play : Form { - public Play() + private CoreNode mNode; // the node whose asset we want to play + + public Play(CoreNode node) { InitializeComponent(); + mNode = node; } private void btnStop_Click(object sender, EventArgs e) @@ -22,8 +28,6 @@ this.Close(); } - AudioClip Clip; - AudioMediaAsset ob_AudioMedia; AudioPlayer ob_play =new AudioPlayer(); private void btnPlay_Click(object sender, EventArgs e) @@ -33,10 +37,6 @@ // if (i == 1) { - Clip = new AudioClip("c:\\atest\\a\\a1.wav"); - ArrayList al = new ArrayList(); - al.Add(Clip); - ob_AudioMedia = new AudioMediaAsset(al); VuMeter ob_VuMeter = new VuMeter(); @@ -49,7 +49,7 @@ ob_play.GetOutputDevices(); ob_play.SetDevice(this , 0); - ob_play.Play(ob_AudioMedia); + ob_play.Play(Project.GetAudioMediaAsset(mNode)); btnPlay.Text = "&Pause"; tmUpdateCurrentTime.Enabled = true; } @@ -75,8 +75,8 @@ private void Play_Load(object sender, EventArgs e) { - MessageBox.Show("Openning Play Diaglog"); - //txtDisplayAsset.Text = + MessageBox.Show("Openning Play Diaglog"); + txtDisplayAsset.Text = ((TextMedia)Project.GetMediaForChannel(mNode, Project.AnnotationChannel)).getText(); } Modified: trunk/urakawa/application/Obi/Obi/ObiForm.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/ObiForm.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -678,13 +678,5 @@ FormUpdateUndoRedoLabels(); } } - - private void btnPlay_Click(object sender, EventArgs e) - { - Play ob_PlayDialog = new Play(); - ob_PlayDialog.Show(); - } - - } } \ No newline at end of file Modified: trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.Designer.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -30,7 +30,6 @@ { this.mAnnotationLabel = new System.Windows.Forms.Label(); this.mTimeLabel = new System.Windows.Forms.Label(); - this.mPlayLabel = new System.Windows.Forms.LinkLabel(); this.SuspendLayout(); // // mAnnotationLabel @@ -53,28 +52,17 @@ this.mTimeLabel.TabIndex = 1; this.mTimeLabel.Text = "(time)"; // - // mPlayLabel - // - this.mPlayLabel.AutoSize = true; - this.mPlayLabel.Location = new System.Drawing.Point(3, 39); - this.mPlayLabel.Margin = new System.Windows.Forms.Padding(3); - this.mPlayLabel.Name = "mPlayLabel"; - this.mPlayLabel.Size = new System.Drawing.Size(27, 12); - this.mPlayLabel.TabIndex = 2; - this.mPlayLabel.TabStop = true; - this.mPlayLabel.Text = "Play"; - // // AudioBlock // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.BackColor = System.Drawing.Color.MistyRose; - this.Controls.Add(this.mPlayLabel); this.Controls.Add(this.mTimeLabel); this.Controls.Add(this.mAnnotationLabel); this.Margin = new System.Windows.Forms.Padding(0, 0, 1, 0); this.Name = "AudioBlock"; + this.Click += new System.EventHandler(this.AudioBlock_Click); this.ResumeLayout(false); this.PerformLayout(); @@ -84,6 +72,5 @@ private System.Windows.Forms.Label mAnnotationLabel; private System.Windows.Forms.Label mTimeLabel; - private System.Windows.Forms.LinkLabel mPlayLabel; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/AudioBlock.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -13,6 +13,29 @@ { public partial class AudioBlock : UserControl { + private StripManagerPanel mManager; // the manager for this block + private CoreNode mNode; // the phrase node for this block + + public StripManagerPanel Manager + { + set + { + mManager = value; + } + } + + public CoreNode Node + { + get + { + return mNode; + } + set + { + mNode = value; + } + } + public string Annotation { set @@ -33,5 +56,20 @@ { InitializeComponent(); } + + internal void MarkDeselected() + { + BackColor = Color.MistyRose; + } + + internal void MarkSelected() + { + BackColor = Color.LightPink; + } + + private void AudioBlock_Click(object sender, EventArgs e) + { + mManager.SelectedPhrase = mNode; + } } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/SectionStrip.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -54,13 +54,13 @@ private void SectionStrip_Click(object sender, EventArgs e) { - if (mManager.SelectedNode == mNode) + if (mManager.SelectedSection == mNode) { StartRenaming(); } else { - mManager.SelectedNode = mNode; + mManager.SelectedSection = mNode; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.Designer.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -34,8 +34,9 @@ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.addStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.renameStripToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.importAssetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.playAssetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -70,10 +71,11 @@ this.addStripToolStripMenuItem, this.renameStripToolStripMenuItem, this.toolStripSeparator1, - this.importAssetToolStripMenuItem}); + this.importAssetToolStripMenuItem, + this.playAssetToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.ShowImageMargin = false; - this.contextMenuStrip1.Size = new System.Drawing.Size(128, 98); + this.contextMenuStrip1.Size = new System.Drawing.Size(128, 120); // // addStripToolStripMenuItem // @@ -89,6 +91,11 @@ this.renameStripToolStripMenuItem.Text = "&Rename strip"; this.renameStripToolStripMenuItem.Click += new System.EventHandler(this.renameStripToolStripMenuItem_Click); // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(124, 6); + // // importAssetToolStripMenuItem // this.importAssetToolStripMenuItem.Name = "importAssetToolStripMenuItem"; @@ -96,10 +103,12 @@ this.importAssetToolStripMenuItem.Text = "&Import asset"; this.importAssetToolStripMenuItem.Click += new System.EventHandler(this.importAssetToolStripMenuItem_Click); // - // toolStripSeparator1 + // playAssetToolStripMenuItem // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(124, 6); + this.playAssetToolStripMenuItem.Name = "playAssetToolStripMenuItem"; + this.playAssetToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.playAssetToolStripMenuItem.Text = "&Play asset"; + this.playAssetToolStripMenuItem.Click += new System.EventHandler(this.playAssetToolStripMenuItem_Click); // // StripManagerPanel // @@ -124,5 +133,6 @@ private System.Windows.Forms.ToolStripMenuItem renameStripToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem importAssetToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem playAssetToolStripMenuItem; } } Modified: trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs =================================================================== --- trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-08-01 05:29:33 UTC (rev 705) +++ trunk/urakawa/application/Obi/Obi/UserControls/StripManagerPanel.cs 2006-08-01 05:59:22 UTC (rev 706) @@ -16,27 +16,30 @@ /// </summary> public partial class StripManagerPanel : UserControl, ICoreNodeVisitor { - private Dictionary<CoreNode, SectionStrip> mNodeMap; // find a strip for a given node - private CoreNode mSelectedNode; // the selected node + private Dictionary<CoreNode, SectionStrip> mSectionNodeMap; // find a section strip for a given node + private CoreNode mSelectedSection; // the selected node + private Dictionary<CoreNode, AudioBlock> mPhraseNodeMap; // find an audio block for a given phrase node + private CoreNode mSelectedPhrase; // the selected audio block + public event Events.Node.RequestToAddSiblingNodeHandler AddSiblingSection; public event Events.Node.RequestToRenameNodeHandler RenameSection; public event Events.Strip.RequestToImportAssetHandler ImportPhrase; public event Events.Strip.SelectedHandler SelectedStrip; - public CoreNode SelectedNode + public CoreNode SelectedSection { get { - return mSelectedNode; + return mSelectedSection; } set { - if (mSelectedNode != null) mNodeMap[mSelectedNode].MarkDeselected(); - mSelectedNode = value; - if (mSelectedNode != null) + if (mSelectedSection != null) mSectionNodeMap[mSelectedSection].MarkDeselected(); + mSelectedSection = value; + if (mSelectedSection != null) { - mNodeMap[mSelectedNode].MarkSelected(); + mSectionNodeMap[mSelectedSection].MarkSelected(); renameStripToolStripMenuItem.Enabled = true; SelectedStrip(this, new Events.Strip.SelectedEventArgs(true)); } @@ -48,11 +51,30 @@ } } + public CoreNode SelectedPhrase + { + get + { + return mSelectedPhrase; + } + set + { + if (mSelectedPhrase != null) mPhraseNodeMap[mSelectedPhrase].MarkDeselected(); + mSelectedPhrase = value; + if (mSelectedPhrase != null) + { + mPhraseNodeMap[mSelectedPhrase].MarkSelected(); + } + } + } + public StripManagerPanel() { InitializeComponent(); - mNodeMap = new Dictionary<CoreNode, SectionStrip>(); - mSelectedNode = null; + mSectionNodeMap = new Dictionary<CoreNode, SectionStrip>(); + mSelectedSection = null; + mPhraseNodeMap = new Dictionary<CoreNode, AudioBlock>(); + mSelectedPhrase = null; } /// <summary> @@ -62,10 +84,10 @@ /// </summary> public void SynchronizeWithCoreTree(CoreNode root) { - mNodeMap.Clear(); + mSectionNodeMap.Clear(); mFlowLayoutPanel.Controls.Clear(); root.acceptDepthFirst(this); - SelectedNode = null; + SelectedSection = null; } #region Synchronization visitor @@ -92,14 +114,17 @@ strip.Label = Project.GetTextMedia((CoreNode)node).getText(); strip.Manager = this; strip.Node = (CoreNode)node; - mNodeMap[(CoreNode)node] = strip; + mSectionNodeMap[(CoreNode)node] = strip; mFlowLayoutPanel.Controls.Add(strip); - SelectedNode = strip.Node; + SelectedSection = strip.Node; } else if (Project.GetNodeType((CoreNode)node) == NodeType.PhraseNode) { - SectionStrip strip = mNodeMap[mSelectedNode]; + SectionStrip strip = mSectionNodeMap[mSelectedSection]; AudioBlock block = new AudioBlock(); + block.Manager = this; + block.Node = (CoreNode)node; + mPhraseNodeMap[(CoreNode)node] = block; TextMedia annotation = (TextMedia)Project.GetMediaForChannel((CoreNode)node, Project.AnnotationChannel); block.Annotation = annotation.getText(); block.Time = (Project.GetAudioMediaAsset((CoreNode)node).LengthInMilliseconds / 1000).ToString() + "s"; @@ -123,16 +148,16 @@ strip.Label = Project.GetTextMedia(node).getText(); strip.Manager = this; strip.Node = node; - mNodeMap[node] = strip; + mSectionNodeMap[node] = strip; mFlowLayoutPanel.Controls.Add(strip); mFlowLayoutPanel.Controls.SetChildIndex(strip, position); - SelectedNode = node; + SelectedSection = node; if (rename) strip.StartRenaming(); } internal void SyncRenamedNode(object sender, Events.Node.RenameNodeEventArgs e) { - SectionStrip strip = mNodeMap[e.Node]; + SectionStrip strip = mSectionNodeMap[e.Node]; strip.Label = e.Label; } @@ -147,7 +172,7 @@ e.Node.acceptDepthFirst(visitor); foreach (CoreNode node in visitor.Nodes) { - SectionStrip strip = mNodeMap[node]; + SectionStrip strip = mSectionNodeMap[node]; mFlowLayoutPanel.Controls.Remove(strip); } } @@ -155,10 +180,13 @@ internal void SyncImportedAsset(object sender, Events.Node.NodeEventArgs e) { - if (e.Node != null && mSelectedNode != null) + if (e.Node != null && mSelectedSection != null) { - SectionStrip strip = mNodeMap[mSelectedNode]; + SectionStrip strip = mSectionNodeMap[mSelectedSection]; AudioBlock block = new AudioBlock(); + block.Manager = this; + block.Node = e.Node; + mPhraseNodeMap[e.Node] = block; TextMedia annotation = (TextMedia)Project.GetMediaForChannel(e.Node, Project.AnnotationChannel); block.Annotation = annotation.getText(); block.Time = (Project.GetAudioMediaAsset(e.Node).LengthInMilliseconds / 1000).ToString() + "s"; @@ -168,7 +196,7 @@ internal void SyncMovedNode(object sender, Events.Node.MovedNodeEventArgs e) { - SectionStrip strip = mNodeMap[e.Node]; + SectionStrip strip = mSectionNodeMap[e.Node]; mFlowLayoutPanel.Controls.SetChildIndex(strip, e.Position); } @@ -178,30 +206,44 @@ internal void addStripToolStripMenuItem_Click(object sender, EventArgs e) { - AddSiblingSection(this, new Events.Node.NodeEventArgs(this, mSelectedNode)); + AddSiblingSection(this, new Events.Node.NodeEventArgs(this, mSelectedSection)); } internal void renameStripToolStripMenuItem_Click(object sender, EventArgs e) { - if (mSelectedNode != null) + if (mSelectedSection != null) { - mNodeMap[mSelectedNode].StartRenaming(); + mSectionNodeMap[mSelectedSection].StartRenaming(); } } internal void importAssetToolStripMenuItem_Click(object sender, EventArgs e) { - if (SelectedNode != null) + if (SelectedSection != null) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "WAVE file (*.wav)|*.wav|Any file|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { - ImportPhrase(this, new Events.Strip.ImportAssetEventArgs(mSelectedNode, dialog.FileName)); + ImportPhrase(this, new Events.Strip.ImportAssetEventArgs(mSelectedSection, dialog.FileName)); } } } + /// <summary> + /// Play the currently selected audio block. (JQ) + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void playAssetToolStripMenuItem_Click(object sender, EventArgs e) + { + if (mSelectedPhrase != null) + { + Dialogs.Play dialog = new Dialogs.Play(mSelectedPhrase); + dialog.ShowDialog(); + } + } + #endregion /// <summary> @@ -216,12 +258,12 @@ private void mFlowLayoutPanel_Click(object sender, EventArgs e) { - SelectedNode = null; + SelectedSection = null; } private void mFlowLayoutPanel_Leave(object sender, EventArgs e) { - SelectedNode = null; + SelectedSection = null; } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |