using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.IO; using System.Threading; using System.Windows.Forms; using System.Data; namespace m3uTool { /// /// Summary description for Form1. /// public class MakeSubdir : System.Windows.Forms.Form { private System.Windows.Forms.Button selectDirectoryButton; private System.Windows.Forms.TextBox m3uDirectoryTextBox; private System.Windows.Forms.TextBox outputTextBox; private System.Windows.Forms.Button m3uMakeButton; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public MakeSubdir() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m3uDirectoryTextBox = new System.Windows.Forms.TextBox(); this.outputTextBox = new System.Windows.Forms.TextBox(); this.selectDirectoryButton = new System.Windows.Forms.Button(); this.m3uMakeButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // m3uDirectoryTextBox // this.m3uDirectoryTextBox.Enabled = false; this.m3uDirectoryTextBox.Location = new System.Drawing.Point(8, 8); this.m3uDirectoryTextBox.Name = "m3uDirectoryTextBox"; this.m3uDirectoryTextBox.Size = new System.Drawing.Size(176, 20); this.m3uDirectoryTextBox.TabIndex = 0; this.m3uDirectoryTextBox.Text = ""; // // outputTextBox // this.outputTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.outputTextBox.Location = new System.Drawing.Point(8, 88); this.outputTextBox.Multiline = true; this.outputTextBox.Name = "outputTextBox"; this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.outputTextBox.Size = new System.Drawing.Size(272, 168); this.outputTextBox.TabIndex = 1; this.outputTextBox.Text = ""; // // selectDirectoryButton // this.selectDirectoryButton.Location = new System.Drawing.Point(208, 8); this.selectDirectoryButton.Name = "selectDirectoryButton"; this.selectDirectoryButton.TabIndex = 2; this.selectDirectoryButton.Text = "Select Dir..."; this.selectDirectoryButton.Click += new System.EventHandler(this.selectDirectoryButton_Click); // // m3uMakeButton // this.m3uMakeButton.Enabled = false; this.m3uMakeButton.Location = new System.Drawing.Point(208, 40); this.m3uMakeButton.Name = "m3uMakeButton"; this.m3uMakeButton.TabIndex = 3; this.m3uMakeButton.Text = "Make M3u"; this.m3uMakeButton.Click += new System.EventHandler(this.m3uMakeButton_Click); // // MakeSubdir // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.m3uMakeButton); this.Controls.Add(this.selectDirectoryButton); this.Controls.Add(this.outputTextBox); this.Controls.Add(this.m3uDirectoryTextBox); this.Name = "MakeSubdir"; this.Text = "M3u Make"; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new MakeSubdir()); } private void selectDirectoryButton_Click(object sender, System.EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult dialogResult = fbd.ShowDialog(this); if (dialogResult == DialogResult.OK) { m3uDirectoryTextBox.Text = fbd.SelectedPath; } UpdateRunButton(); } private void UpdateRunButton() { if (m3uDirectoryTextBox.Text != null && m3uDirectoryTextBox.Text!="" && Directory.Exists(m3uDirectoryTextBox.Text)) { m3uMakeButton.Enabled = true; } else m3uMakeButton.Enabled = false; } private void CreateM3uThread() { CreateM3uRecursive(new DirectoryInfo(m3uDirectoryTextBox.Text)); } private void CreateM3uRecursive(DirectoryInfo info) { CreateM3u cm3u = new CreateM3u(info); cm3u.Create(); outputTextBox.AppendText("Created " + cm3u.OutputFilename + Environment.NewLine); foreach (DirectoryInfo subDir in info.GetDirectories()) { CreateM3uRecursive(subDir); } } private void m3uMakeButton_Click(object sender, System.EventArgs e) { Thread t = new Thread(new ThreadStart(CreateM3uThread)); t.Start(); } } }