[xiph-commits] r7071 - trunk/oggdsf/src/tools/DNPlay

illiminable at dactyl.lonelymoon.com illiminable
Fri Jul 9 03:50:14 PDT 2004


Author: illiminable
Date: Fri Jul  9 03:50:14 2004
New Revision: 7071

Modified:
trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs
trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx
Log:
* Tidied the player interface up a bit, still ugly !
* Added a progress bar and duration box.
* Made the exit item on the menu do something.

Modified: trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs
===================================================================
--- trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs	2004-07-09 09:15:18 UTC (rev 7070)
+++ trunk/oggdsf/src/tools/DNPlay/frmDNPlay.cs	2004-07-09 10:50:13 UTC (rev 7071)
@@ -22,22 +22,59 @@
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.Button cmdPlay;
-		/// <summary>
-		/// Required designer variable.
-		/// </summary>
-		private System.ComponentModel.Container components = null;
+		private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label lblFileLocation;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.OpenFileDialog dlgOpenFile;
private System.Windows.Forms.Button cmdStop;
private System.Windows.Forms.Button cmdPause;
+		private System.Windows.Forms.Label lblDuration;
+		private System.Windows.Forms.Timer tmrUpdateDuration;
+		private System.Windows.Forms.Label lblProgressBkgd;
+		private System.Windows.Forms.Label lblProgressFgnd;

//My Variables...
protected DSPlay mPlayer;
-		private System.Windows.Forms.Label lblDuration;
protected Int64 mFileDuration;
+		protected Int64 mLastSync;
+		protected Int64 mNumTicks;
//

+		//My member functions
+		protected void setDurationText(Int64 inDuration)
+		{
+			lblDuration.Text = "";
+			Int64 locSeconds = inDuration / 10000000;
+			Int64 locMinutes = locSeconds / 60;
+			Int64 locHours = locSeconds / 3600;
+			locSeconds = locSeconds % 60;
+			if (locHours != 0)
+			{
+				lblDuration.Text = locHours.ToString() + ":";
+				if (locMinutes < 10)
+				{
+					lblDuration.Text += "0";
+				}
+			}
+
+			lblDuration.Text += locMinutes.ToString() + ":";
+
+			if (locSeconds < 10)
+			{
+				lblDuration.Text += "0";
+			}
+			lblDuration.Text += locSeconds.ToString();
+		}
+
+		protected void updateProgressBar()
+		{
+			double locProgRatio =  Convert.ToDouble(mLastSync + (mNumTicks * 10000000)) / mFileDuration;
+
+			Int32 locProgWidth = Convert.ToInt32(locProgRatio * lblProgressBkgd.Width);
+			lblProgressFgnd.Width = locProgWidth;
+		}
+		//
+
public frmDNPlay()
{
//
@@ -49,6 +86,7 @@
// TODO: Add any constructor code after InitializeComponent call
//
mPlayer = new DSPlay();
+			lblProgressFgnd.Width = 0;
}

/// <summary>
@@ -73,13 +111,14 @@
/// </summary>
private void InitializeComponent()
{
+			this.components = new System.ComponentModel.Container();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
-			this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
+			this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.cmdPlay = new System.Windows.Forms.Button();
this.lblFileLocation = new System.Windows.Forms.Label();
@@ -88,6 +127,9 @@
this.cmdStop = new System.Windows.Forms.Button();
this.cmdPause = new System.Windows.Forms.Button();
this.lblDuration = new System.Windows.Forms.Label();
+			this.tmrUpdateDuration = new System.Windows.Forms.Timer(this.components);
+			this.lblProgressBkgd = new System.Windows.Forms.Label();
+			this.lblProgressFgnd = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// mainMenu1
@@ -106,13 +148,6 @@
this.menuItem6});
this.menuItem1.Text = "&File";
//
-			// menuItem2
-			//
-			this.menuItem2.Index = 1;
-			this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-																					  this.menuItem7});
-			this.menuItem2.Text = "Help";
-			//
// menuItem3
//
this.menuItem3.Index = 0;
@@ -133,7 +168,15 @@
//
this.menuItem6.Index = 3;
this.menuItem6.Text = "E&xit";
+			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
+			// menuItem2
+			//
+			this.menuItem2.Index = 1;
+			this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+																					  this.menuItem7});
+			this.menuItem2.Text = "Help";
+			//
// menuItem7
//
this.menuItem7.Index = 0;
@@ -141,9 +184,9 @@
//
// cmdPlay
//
-			this.cmdPlay.Location = new System.Drawing.Point(24, 80);
+			this.cmdPlay.Location = new System.Drawing.Point(8, 56);
this.cmdPlay.Name = "cmdPlay";
-			this.cmdPlay.Size = new System.Drawing.Size(80, 24);
+			this.cmdPlay.Size = new System.Drawing.Size(56, 24);
this.cmdPlay.TabIndex = 0;
this.cmdPlay.Text = "&Play";
this.cmdPlay.Click += new System.EventHandler(this.cmdPlay_Click);
@@ -170,34 +213,61 @@
//
// cmdStop
//
-			this.cmdStop.Location = new System.Drawing.Point(120, 80);
+			this.cmdStop.Location = new System.Drawing.Point(72, 56);
this.cmdStop.Name = "cmdStop";
-			this.cmdStop.Size = new System.Drawing.Size(72, 24);
+			this.cmdStop.Size = new System.Drawing.Size(56, 24);
this.cmdStop.TabIndex = 5;
this.cmdStop.Text = "&Stop";
this.cmdStop.Click += new System.EventHandler(this.cmdStop_Click);
//
// cmdPause
//
-			this.cmdPause.Location = new System.Drawing.Point(208, 80);
+			this.cmdPause.Location = new System.Drawing.Point(136, 56);
this.cmdPause.Name = "cmdPause";
-			this.cmdPause.Size = new System.Drawing.Size(72, 24);
+			this.cmdPause.Size = new System.Drawing.Size(56, 24);
this.cmdPause.TabIndex = 6;
this.cmdPause.Text = "Pa&use";
this.cmdPause.Click += new System.EventHandler(this.cmdPause_Click);
//
// lblDuration
//
-			this.lblDuration.Location = new System.Drawing.Point(344, 32);
+			this.lblDuration.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+			this.lblDuration.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+			this.lblDuration.Location = new System.Drawing.Point(296, 56);
this.lblDuration.Name = "lblDuration";
-			this.lblDuration.Size = new System.Drawing.Size(112, 24);
+			this.lblDuration.Size = new System.Drawing.Size(168, 24);
this.lblDuration.TabIndex = 7;
+			this.lblDuration.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
+			// tmrUpdateDuration
+			//
+			this.tmrUpdateDuration.Interval = 1000;
+			this.tmrUpdateDuration.Tick += new System.EventHandler(this.tmrUpdateDuration_Tick);
+			//
+			// lblProgressBkgd
+			//
+			this.lblProgressBkgd.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+			this.lblProgressBkgd.Location = new System.Drawing.Point(8, 32);
+			this.lblProgressBkgd.Name = "lblProgressBkgd";
+			this.lblProgressBkgd.Size = new System.Drawing.Size(456, 16);
+			this.lblProgressBkgd.TabIndex = 8;
+			//
+			// lblProgressFgnd
+			//
+			this.lblProgressFgnd.BackColor = System.Drawing.Color.SeaGreen;
+			this.lblProgressFgnd.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+			this.lblProgressFgnd.Location = new System.Drawing.Point(8, 32);
+			this.lblProgressFgnd.Name = "lblProgressFgnd";
+			this.lblProgressFgnd.Size = new System.Drawing.Size(272, 16);
+			this.lblProgressFgnd.TabIndex = 9;
+			//
// frmDNPlay
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
-			this.ClientSize = new System.Drawing.Size(472, 129);
+			this.ClientSize = new System.Drawing.Size(472, 89);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
+																		  this.lblProgressFgnd,
+																		  this.lblProgressBkgd,
this.lblDuration,
this.cmdPause,
this.cmdStop,
@@ -225,6 +295,7 @@
private void cmdPlay_Click(object sender, System.EventArgs e)
{
mPlayer.play();
+			tmrUpdateDuration.Enabled = true;
}


@@ -239,18 +310,24 @@
bool locRes = mPlayer.loadFile(dlgOpenFile.FileName);
//Error check
mFileDuration = mPlayer.fileDuration();
-				lblDuration.Text = mFileDuration.ToString();
+				setDurationText(mFileDuration);
+				//lblDuration.Text = mFileDuration.ToString();
+
+				mNumTicks = 0;
+				mLastSync = 0;
}

}

private void cmdStop_Click(object sender, System.EventArgs e)
{
+			tmrUpdateDuration.Enabled = false;
mPlayer.stop();
}

private void cmdPause_Click(object sender, System.EventArgs e)
{
+			tmrUpdateDuration.Enabled = false;
mPlayer.pause();
}

@@ -258,5 +335,16 @@
{

}
+
+		private void tmrUpdateDuration_Tick(object sender, System.EventArgs e)
+		{
+			mNumTicks++;
+			updateProgressBar();
+		}
+
+		private void menuItem6_Click(object sender, System.EventArgs e)
+		{
+			this.Close();
+		}
}
}

Modified: trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx
===================================================================
--- trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx	2004-07-09 09:15:18 UTC (rev 7070)
+++ trunk/oggdsf/src/tools/DNPlay/frmDNPlay.resx	2004-07-09 10:50:13 UTC (rev 7071)
@@ -102,6 +102,9 @@
<data name="dlgOpenFile.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 17</value>
</data>
+  <data name="tmrUpdateDuration.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>236, 17</value>
+  </data>
<data name="$this.Name">
<value>frmDNPlay</value>
</data>



More information about the commits mailing list