added extract button on SearchFiles form

This commit is contained in:
Asval 2019-06-01 20:02:48 +02:00
parent 218e384638
commit 0da7ad2e82
3 changed files with 79 additions and 20 deletions

View File

@ -37,6 +37,7 @@
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
@ -86,6 +87,7 @@
//
// panel1
//
this.panel1.Controls.Add(this.button2);
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.textBox1);
@ -99,7 +101,7 @@
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(708, 4);
this.button1.Location = new System.Drawing.Point(627, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
@ -124,6 +126,18 @@
this.textBox1.TabIndex = 0;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(708, 4);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 3;
this.button2.Text = "Extract";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.Button2_Click);
//
// SearchFiles
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -153,5 +167,6 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}

View File

@ -16,6 +16,8 @@ namespace FModel.Forms
private static Dictionary<string, string> _myFilteredInfosDict;
public static string SfPath;
public static bool IsClosed;
public static bool FilesToSearch;
public static string[] myItems;
public SearchFiles()
{
@ -28,6 +30,7 @@ namespace FModel.Forms
private async void SearchFiles_Load(object sender, EventArgs e)
{
IsClosed = false;
FilesToSearch = false;
_myInfosDict = new Dictionary<string, string>();
if (MainWindow.PakAsTxt != null)
@ -279,8 +282,22 @@ namespace FModel.Forms
if (true)
{
button1.Enabled = true;
button2.Enabled = true;
}
}
private void Button2_Click(object sender, EventArgs e)
{
ListView.SelectedIndexCollection col = listView1.SelectedIndices;
myItems = new string[col.Count];
for (int i = 0; i < col.Count; i++) //ADD SELECTED ITEM TO ARRAY
{
myItems[i] = listView1.Items[col[i]].Text.Substring(listView1.Items[col[i]].Text.LastIndexOf("/") + 1);
}
FilesToSearch = true;
Close();
}
}
class FileInfo

View File

@ -760,7 +760,7 @@ namespace FModel
StopWatch = new Stopwatch();
StopWatch.Start();
Utilities.CreateDefaultFolders();
ExtractAndSerializeItems(e, true);
RegisterInArray(e, true);
}
private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
@ -982,6 +982,32 @@ namespace FModel
if (node.Text == pathList[0])
ExpandMyLitleBoys(node, pathList);
}
else if (SearchFiles.FilesToSearch)
{
AddAndSelectAllItems(SearchFiles.myItems);
}
}
private void AddAndSelectAllItems(string[] myItemsToAdd)
{
listBox1.BeginUpdate();
for (int i = 0; i < myItemsToAdd.Length; i++)
{
listBox1.Items.Add(myItemsToAdd[i]);
}
for (int i = 0; i < listBox1.Items.Count; i++) { listBox1.SetSelected(i, true); }
listBox1.EndUpdate();
//same as click on extract button
scintilla1.Text = "";
pictureBox1.Image = null;
ExtractButton.Enabled = false;
OpenImageButton.Enabled = false;
StopButton.Enabled = true;
if (backgroundWorker1.IsBusy != true)
{
backgroundWorker1.RunWorkerAsync();
}
}
//EVENTS
@ -1008,23 +1034,10 @@ namespace FModel
#region EXTRACT BUTTON
//METHODS
private void ExtractAndSerializeItems(DoWorkEventArgs e, bool updateMode = false)
private void RegisterInArray(DoWorkEventArgs e, bool updateMode = false)
{
if (updateMode == false)
if (updateMode)
{
//REGISTER SELECTED ITEMS
Invoke(new Action(() =>
{
SelectedItemsArray = new string[listBox1.SelectedItems.Count];
for (int i = 0; i < listBox1.SelectedItems.Count; i++) //ADD SELECTED ITEM TO ARRAY
{
SelectedItemsArray[i] = listBox1.SelectedItems[i].ToString();
}
}));
}
else
{
//REGISTER SELECTED ITEMS
Invoke(new Action(() =>
{
SelectedItemsArray = new string[_diffToExtract.Count];
@ -1034,8 +1047,22 @@ namespace FModel
}
}));
}
else
{
Invoke(new Action(() =>
{
SelectedItemsArray = new string[listBox1.SelectedItems.Count];
for (int i = 0; i < listBox1.SelectedItems.Count; i++) //ADD SELECTED ITEM TO ARRAY
{
SelectedItemsArray[i] = listBox1.SelectedItems[i].ToString();
}
}));
}
//DO WORK
ExtractAndSerializeItems(e);
}
private void ExtractAndSerializeItems(DoWorkEventArgs e)
{
for (int i = 0; i < SelectedItemsArray.Length; i++)
{
if (backgroundWorker1.CancellationPending && backgroundWorker1.IsBusy)
@ -1599,7 +1626,7 @@ namespace FModel
StopWatch = new Stopwatch();
StopWatch.Start();
Utilities.CreateDefaultFolders();
ExtractAndSerializeItems(e);
RegisterInArray(e);
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
@ -1627,7 +1654,7 @@ namespace FModel
ExtractButton.Enabled = true;
}));
}
private void ExtractButton_Click(object sender, EventArgs e)
public void ExtractButton_Click(object sender, EventArgs e)
{
scintilla1.Text = "";
pictureBox1.Image = null;