Get file and folder working

This commit is contained in:
Matt Nadareski
2016-03-29 23:20:35 -07:00
parent e50a8f4628
commit ecbce776fc
2 changed files with 52 additions and 30 deletions

View File

@@ -44,10 +44,10 @@
this.oldCheckBox = new System.Windows.Forms.CheckBox(); this.oldCheckBox = new System.Windows.Forms.CheckBox();
this.renameCheckBox = new System.Windows.Forms.CheckBox(); this.renameCheckBox = new System.Windows.Forms.CheckBox();
this.importDatLabel = new System.Windows.Forms.Label(); this.importDatLabel = new System.Windows.Forms.Label();
this.fileOrFolderLabel = new System.Windows.Forms.Label();
this.importTextBox = new System.Windows.Forms.TextBox(); this.importTextBox = new System.Windows.Forms.TextBox();
this.exploreButton = new System.Windows.Forms.Button(); this.fileButton = new System.Windows.Forms.Button();
this.importButton = new System.Windows.Forms.Button(); this.importButton = new System.Windows.Forms.Button();
this.folderButton = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -198,50 +198,51 @@
this.importDatLabel.TabIndex = 12; this.importDatLabel.TabIndex = 12;
this.importDatLabel.Text = "Import DAT"; this.importDatLabel.Text = "Import DAT";
// //
// fileOrFolderLabel
//
this.fileOrFolderLabel.AutoSize = true;
this.fileOrFolderLabel.Location = new System.Drawing.Point(15, 197);
this.fileOrFolderLabel.Name = "fileOrFolderLabel";
this.fileOrFolderLabel.Size = new System.Drawing.Size(70, 13);
this.fileOrFolderLabel.TabIndex = 13;
this.fileOrFolderLabel.Text = "File or Folder:";
//
// importTextBox // importTextBox
// //
this.importTextBox.Location = new System.Drawing.Point(91, 194); this.importTextBox.Location = new System.Drawing.Point(100, 201);
this.importTextBox.Name = "importTextBox"; this.importTextBox.Name = "importTextBox";
this.importTextBox.Size = new System.Drawing.Size(264, 20); this.importTextBox.Size = new System.Drawing.Size(405, 20);
this.importTextBox.TabIndex = 14; this.importTextBox.TabIndex = 14;
// //
// exploreButton // fileButton
// //
this.exploreButton.Location = new System.Drawing.Point(361, 192); this.fileButton.Location = new System.Drawing.Point(511, 199);
this.exploreButton.Name = "exploreButton"; this.fileButton.Name = "fileButton";
this.exploreButton.Size = new System.Drawing.Size(58, 23); this.fileButton.Size = new System.Drawing.Size(33, 23);
this.exploreButton.TabIndex = 15; this.fileButton.TabIndex = 15;
this.exploreButton.Text = "Explore"; this.fileButton.Text = "File";
this.exploreButton.UseVisualStyleBackColor = true; this.fileButton.UseVisualStyleBackColor = true;
this.exploreButton.Click += new System.EventHandler(this.exploreButton_Click); this.fileButton.Click += new System.EventHandler(this.fileButton_Click);
// //
// importButton // importButton
// //
this.importButton.Location = new System.Drawing.Point(426, 192); this.importButton.Location = new System.Drawing.Point(15, 199);
this.importButton.Name = "importButton"; this.importButton.Name = "importButton";
this.importButton.Size = new System.Drawing.Size(75, 23); this.importButton.Size = new System.Drawing.Size(75, 23);
this.importButton.TabIndex = 16; this.importButton.TabIndex = 16;
this.importButton.Text = "Import"; this.importButton.Text = "Import";
this.importButton.UseVisualStyleBackColor = true; this.importButton.UseVisualStyleBackColor = true;
// //
// folderButton
//
this.folderButton.Location = new System.Drawing.Point(550, 199);
this.folderButton.Name = "folderButton";
this.folderButton.Size = new System.Drawing.Size(46, 23);
this.folderButton.TabIndex = 17;
this.folderButton.Text = "Folder";
this.folderButton.UseVisualStyleBackColor = true;
this.folderButton.Click += new System.EventHandler(this.folderButton_Click);
//
// SabreToolsUI // SabreToolsUI
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(681, 477); this.ClientSize = new System.Drawing.Size(681, 477);
this.Controls.Add(this.folderButton);
this.Controls.Add(this.importButton); this.Controls.Add(this.importButton);
this.Controls.Add(this.exploreButton); this.Controls.Add(this.fileButton);
this.Controls.Add(this.importTextBox); this.Controls.Add(this.importTextBox);
this.Controls.Add(this.fileOrFolderLabel);
this.Controls.Add(this.importDatLabel); this.Controls.Add(this.importDatLabel);
this.Controls.Add(this.renameCheckBox); this.Controls.Add(this.renameCheckBox);
this.Controls.Add(this.oldCheckBox); this.Controls.Add(this.oldCheckBox);
@@ -281,10 +282,10 @@
private System.Windows.Forms.CheckBox oldCheckBox; private System.Windows.Forms.CheckBox oldCheckBox;
private System.Windows.Forms.CheckBox renameCheckBox; private System.Windows.Forms.CheckBox renameCheckBox;
private System.Windows.Forms.Label importDatLabel; private System.Windows.Forms.Label importDatLabel;
private System.Windows.Forms.Label fileOrFolderLabel;
private System.Windows.Forms.TextBox importTextBox; private System.Windows.Forms.TextBox importTextBox;
private System.Windows.Forms.Button exploreButton; private System.Windows.Forms.Button fileButton;
private System.Windows.Forms.Button importButton; private System.Windows.Forms.Button importButton;
private System.Windows.Forms.Button folderButton;
} }
} }

View File

@@ -74,7 +74,7 @@ namespace SabreTools
Process.Start("DATabase.exe", "-l -ga"); Process.Start("DATabase.exe", "-l -ga");
} }
private void exploreButton_Click(object sender, EventArgs e) private void fileButton_Click(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog(); OpenFileDialog ofd = new OpenFileDialog();
@@ -88,11 +88,32 @@ namespace SabreTools
ofd.InitialDirectory = Environment.CurrentDirectory; ofd.InitialDirectory = Environment.CurrentDirectory;
} }
// Set the new folder, if applicable // Set the new file, if applicable
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
{ {
importTextBox.Text = ofd.FileName; importTextBox.Text = ofd.FileName;
} }
} }
private void folderButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
// Set the proper starting folder
if (importTextBox.Text != "")
{
fbd.SelectedPath = Path.GetDirectoryName(importTextBox.Text);
}
else
{
fbd.SelectedPath = Environment.CurrentDirectory;
}
// Set the new folder, if applicable
if (fbd.ShowDialog() == DialogResult.OK)
{
importTextBox.Text = fbd.SelectedPath;
}
}
} }
} }