00001 using System;
00002 using System.Drawing;
00003 using System.Collections;
00004 using System.ComponentModel;
00005 using System.Windows.Forms;
00006 using System.Data;
00007
00008 namespace iOCE
00009 {
00013 public class frmMain : System.Windows.Forms.Form
00014 {
00015 private System.Windows.Forms.MainMenu mnuMain;
00016 private System.Windows.Forms.MenuItem mnuFile;
00017 private System.Windows.Forms.MenuItem mnuFileOpen;
00018 private System.Windows.Forms.MenuItem menuItem1;
00019 private System.Windows.Forms.MenuItem mnuFileExit;
00020 private System.Windows.Forms.Label lblVendor;
00021 private System.Windows.Forms.GroupBox groupBox1;
00022 private System.Windows.Forms.TextBox txtVendorString;
00023 private System.Windows.Forms.ColumnHeader colKey;
00024 private System.Windows.Forms.ColumnHeader colValue;
00028 private System.ComponentModel.Container components = null;
00029 private System.Windows.Forms.OpenFileDialog dlgOpenFile;
00030 private System.Windows.Forms.ListView lsvUserComments;
00031 private System.Windows.Forms.Button cmdAdd;
00032 private System.Windows.Forms.Button cmdRemove;
00033 private System.Windows.Forms.Button cmdEdit;
00034 private System.Windows.Forms.Button cmdApply;
00035 private System.Windows.Forms.Button cmdRevert;
00036
00037
00038 private illiminable.Ogg.libVorbisCommentDotNET.DNFileComments mFileComments;
00039
00040 private void fillFields()
00041 {
00042 txtVendorString.Text = mFileComments.getStreamComment(0).comments().vendorString();
00043 String[] locSubItems = null;
00044 ListViewItem locItem = null;
00045
00046 for (int i = 0; i < mFileComments.getStreamComment(0).comments().numUserComments(); i++)
00047 {
00048 locSubItems = new String[2];
00049
00050 locSubItems[0] = mFileComments.getStreamComment(0).comments().getUserComment(i).key();
00051 locSubItems[1] = mFileComments.getStreamComment(0).comments().getUserComment(i).value();
00052 locItem = new ListViewItem(locSubItems);
00053 lsvUserComments.Items.Add(locItem);
00054 }
00055
00056 }
00057
00058 private void editSelectedUserComment()
00059 {
00060 ListView.SelectedListViewItemCollection locSelected = lsvUserComments.SelectedItems;
00061
00062 if (locSelected.Count == 1)
00063 {
00064 ListViewItem locItem = locSelected[0];
00065 ListViewItem.ListViewSubItemCollection locSubItems = locItem.SubItems;
00066
00067 frmAddComment locAddForm = new frmAddComment();
00068 locAddForm.Text = "Edit Comment...";
00069 locAddForm.Key = locSubItems[0].Text;
00070 locAddForm.Value = locSubItems[1].Text;
00071
00072
00073 locAddForm.ShowDialog();
00074 if (locAddForm.wasOK == true)
00075 {
00076 String[] locSubItemStr = new String[2];
00077 locSubItemStr[0] = locAddForm.Key;
00078 locSubItemStr[1] = locAddForm.Value;
00079 lsvUserComments.Items.Remove(locItem);
00080 locItem = new ListViewItem(locSubItemStr);
00081
00082 lsvUserComments.Items.Add(locItem);
00083 }
00084 }
00085
00086
00087 }
00088
00089 private void addUserComment()
00090 {
00091 ListViewItem locItem = null;
00092
00093 frmAddComment locAddForm = new frmAddComment();
00094 locAddForm.ShowDialog();
00095 if (locAddForm.wasOK == true)
00096 {
00097 String[] locSubItems = new String[2];
00098 locSubItems[0] = locAddForm.Key;
00099 locSubItems[1] = locAddForm.Value;
00100 locItem = new ListViewItem(locSubItems);
00101 lsvUserComments.Items.Add(locItem);
00102 }
00103 }
00104
00105 private void removeSelectedUserComment()
00106 {
00107
00108 ListView.SelectedListViewItemCollection locSelected = lsvUserComments.SelectedItems;
00109
00110 if (locSelected.Count == 1)
00111 {
00112
00113 int locIndex = lsvUserComments.SelectedIndices[0];
00114
00115
00116 lsvUserComments.Items.Remove(locSelected[0]);
00117
00118
00119 if (locIndex < lsvUserComments.Items.Count)
00120 {
00121
00122 lsvUserComments.Items[locIndex].Selected = true;
00123 }
00124 else if (lsvUserComments.Items.Count != 0)
00125 {
00126
00127 lsvUserComments.Items[lsvUserComments.Items.Count - 1].Selected = true;
00128 }
00129 }
00130
00131 }
00132 public frmMain()
00133 {
00134
00135
00136
00137 InitializeComponent();
00138
00139
00140
00141
00142 }
00143
00147 protected override void Dispose( bool disposing )
00148 {
00149 if( disposing )
00150 {
00151 if (components != null)
00152 {
00153 components.Dispose();
00154 }
00155 }
00156 base.Dispose( disposing );
00157 }
00158
00159 #region Windows Form Designer generated code
00164 private void InitializeComponent()
00165 {
00166 this.mnuMain = new System.Windows.Forms.MainMenu();
00167 this.mnuFile = new System.Windows.Forms.MenuItem();
00168 this.mnuFileOpen = new System.Windows.Forms.MenuItem();
00169 this.menuItem1 = new System.Windows.Forms.MenuItem();
00170 this.mnuFileExit = new System.Windows.Forms.MenuItem();
00171 this.lblVendor = new System.Windows.Forms.Label();
00172 this.groupBox1 = new System.Windows.Forms.GroupBox();
00173 this.cmdEdit = new System.Windows.Forms.Button();
00174 this.cmdRemove = new System.Windows.Forms.Button();
00175 this.cmdAdd = new System.Windows.Forms.Button();
00176 this.lsvUserComments = new System.Windows.Forms.ListView();
00177 this.colKey = new System.Windows.Forms.ColumnHeader();
00178 this.colValue = new System.Windows.Forms.ColumnHeader();
00179 this.txtVendorString = new System.Windows.Forms.TextBox();
00180 this.dlgOpenFile = new System.Windows.Forms.OpenFileDialog();
00181 this.cmdApply = new System.Windows.Forms.Button();
00182 this.cmdRevert = new System.Windows.Forms.Button();
00183 this.groupBox1.SuspendLayout();
00184 this.SuspendLayout();
00185
00186
00187
00188 this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00189 this.mnuFile});
00190
00191
00192
00193 this.mnuFile.Index = 0;
00194 this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00195 this.mnuFileOpen,
00196 this.menuItem1,
00197 this.mnuFileExit});
00198 this.mnuFile.Text = "&File";
00199
00200
00201
00202 this.mnuFileOpen.Checked = true;
00203 this.mnuFileOpen.Index = 0;
00204 this.mnuFileOpen.Text = "&Open";
00205 this.mnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click);
00206
00207
00208
00209 this.menuItem1.Index = 1;
00210 this.menuItem1.Text = "-";
00211
00212
00213
00214 this.mnuFileExit.Index = 2;
00215 this.mnuFileExit.Text = "E&xit";
00216
00217
00218
00219 this.lblVendor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00220 this.lblVendor.Location = new System.Drawing.Point(16, 24);
00221 this.lblVendor.Name = "lblVendor";
00222 this.lblVendor.Size = new System.Drawing.Size(88, 16);
00223 this.lblVendor.TabIndex = 0;
00224 this.lblVendor.Text = "Vendor String";
00225
00226
00227
00228 this.groupBox1.Controls.Add(this.cmdEdit);
00229 this.groupBox1.Controls.Add(this.cmdRemove);
00230 this.groupBox1.Controls.Add(this.cmdAdd);
00231 this.groupBox1.Controls.Add(this.lsvUserComments);
00232 this.groupBox1.Controls.Add(this.txtVendorString);
00233 this.groupBox1.Controls.Add(this.lblVendor);
00234 this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00235 this.groupBox1.Location = new System.Drawing.Point(16, 48);
00236 this.groupBox1.Name = "groupBox1";
00237 this.groupBox1.Size = new System.Drawing.Size(632, 224);
00238 this.groupBox1.TabIndex = 1;
00239 this.groupBox1.TabStop = false;
00240 this.groupBox1.Text = "Vorbis Comments";
00241
00242
00243
00244 this.cmdEdit.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00245 this.cmdEdit.Location = new System.Drawing.Point(440, 192);
00246 this.cmdEdit.Name = "cmdEdit";
00247 this.cmdEdit.Size = new System.Drawing.Size(80, 24);
00248 this.cmdEdit.TabIndex = 5;
00249 this.cmdEdit.Text = "&Edit...";
00250 this.cmdEdit.Click += new System.EventHandler(this.cmdEdit_Click);
00251
00252
00253
00254 this.cmdRemove.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00255 this.cmdRemove.Location = new System.Drawing.Point(536, 192);
00256 this.cmdRemove.Name = "cmdRemove";
00257 this.cmdRemove.Size = new System.Drawing.Size(80, 24);
00258 this.cmdRemove.TabIndex = 4;
00259 this.cmdRemove.Text = "&Remove";
00260 this.cmdRemove.Click += new System.EventHandler(this.cmdRemove_Click);
00261
00262
00263
00264 this.cmdAdd.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00265 this.cmdAdd.Location = new System.Drawing.Point(344, 192);
00266 this.cmdAdd.Name = "cmdAdd";
00267 this.cmdAdd.Size = new System.Drawing.Size(80, 24);
00268 this.cmdAdd.TabIndex = 3;
00269 this.cmdAdd.Text = "&Add...";
00270 this.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
00271
00272
00273
00274 this.lsvUserComments.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
00275 this.colKey,
00276 this.colValue});
00277 this.lsvUserComments.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00278 this.lsvUserComments.FullRowSelect = true;
00279 this.lsvUserComments.GridLines = true;
00280 this.lsvUserComments.Location = new System.Drawing.Point(16, 48);
00281 this.lsvUserComments.MultiSelect = false;
00282 this.lsvUserComments.Name = "lsvUserComments";
00283 this.lsvUserComments.Size = new System.Drawing.Size(600, 128);
00284 this.lsvUserComments.Sorting = System.Windows.Forms.SortOrder.Ascending;
00285 this.lsvUserComments.TabIndex = 2;
00286 this.lsvUserComments.View = System.Windows.Forms.View.Details;
00287 this.lsvUserComments.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lsvUserComments_KeyDown);
00288 this.lsvUserComments.DoubleClick += new System.EventHandler(this.lsvUserComments_DoubleClick);
00289
00290
00291
00292 this.colKey.Text = "Key";
00293 this.colKey.Width = 162;
00294
00295
00296
00297 this.colValue.Text = "Value";
00298 this.colValue.Width = 433;
00299
00300
00301
00302 this.txtVendorString.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
00303 this.txtVendorString.Location = new System.Drawing.Point(104, 20);
00304 this.txtVendorString.Name = "txtVendorString";
00305 this.txtVendorString.Size = new System.Drawing.Size(512, 20);
00306 this.txtVendorString.TabIndex = 1;
00307 this.txtVendorString.Text = "";
00308
00309
00310
00311 this.cmdApply.Location = new System.Drawing.Point(456, 280);
00312 this.cmdApply.Name = "cmdApply";
00313 this.cmdApply.Size = new System.Drawing.Size(80, 24);
00314 this.cmdApply.TabIndex = 2;
00315 this.cmdApply.Text = "A&pply";
00316
00317
00318
00319 this.cmdRevert.Location = new System.Drawing.Point(552, 280);
00320 this.cmdRevert.Name = "cmdRevert";
00321 this.cmdRevert.Size = new System.Drawing.Size(80, 24);
00322 this.cmdRevert.TabIndex = 3;
00323 this.cmdRevert.Text = "Re&vert";
00324
00325
00326
00327 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00328 this.ClientSize = new System.Drawing.Size(664, 313);
00329 this.Controls.Add(this.cmdRevert);
00330 this.Controls.Add(this.cmdApply);
00331 this.Controls.Add(this.groupBox1);
00332 this.Menu = this.mnuMain;
00333 this.Name = "frmMain";
00334 this.Text = "Ogg Comment Editor";
00335 this.Load += new System.EventHandler(this.frmMain_Load);
00336 this.groupBox1.ResumeLayout(false);
00337 this.ResumeLayout(false);
00338
00339 }
00340 #endregion
00341
00345 [STAThread]
00346 static void Main()
00347 {
00348 Application.Run(new frmMain());
00349 }
00350
00351 private void frmMain_Load(object sender, System.EventArgs e)
00352 {
00353 mFileComments = new illiminable.Ogg.libVorbisCommentDotNET.DNFileComments();
00354 }
00355
00356 private void mnuFileOpen_Click(object sender, System.EventArgs e)
00357 {
00358 dlgOpenFile.ShowDialog();
00359
00360 mFileComments.loadFile(dlgOpenFile.FileName);
00361
00362 fillFields();
00363 }
00364
00365
00366
00367 private void cmdAdd_Click(object sender, System.EventArgs e)
00368 {
00369 addUserComment();
00370 }
00371
00372 private void cmdEdit_Click(object sender, System.EventArgs e)
00373 {
00374 editSelectedUserComment();
00375 }
00376
00377 private void cmdRemove_Click(object sender, System.EventArgs e)
00378 {
00379 removeSelectedUserComment();
00380 }
00381
00382 private void lsvUserComments_DoubleClick(object sender, System.EventArgs e)
00383 {
00384 editSelectedUserComment();
00385 }
00386
00387 private void lsvUserComments_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
00388 {
00389 switch(e.KeyCode) {
00390
00391 case Keys.Delete:
00392 removeSelectedUserComment();
00393 e.Handled = true;
00394 break;
00395 case Keys.Insert:
00396 addUserComment();
00397 e.Handled = true;
00398 break;
00399 case Keys.Enter:
00400 editSelectedUserComment();
00401 e.Handled = true;
00402 break;
00403
00404 }
00405 }
00406
00407
00408 }
00409 }