2021-10-24 15:49:48 +00:00
|
|
|
|
using RyzStudio.Windows.Forms;
|
|
|
|
|
using System;
|
2021-10-24 16:16:37 +00:00
|
|
|
|
using System.Diagnostics;
|
2021-10-24 15:49:48 +00:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace RandomFileRunner
|
|
|
|
|
{
|
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
|
|
|
|
protected readonly Random randy;
|
|
|
|
|
|
|
|
|
|
protected OptionsForm optionsForm = null;
|
|
|
|
|
protected bool isBusy = false;
|
|
|
|
|
|
2021-10-24 16:16:37 +00:00
|
|
|
|
protected Process currentProcess = null;
|
2021-10-24 15:49:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2021-10-24 16:16:37 +00:00
|
|
|
|
textBox1.Text = "*.*";
|
|
|
|
|
memoBox1.InnerTextBox.WordWrap = false;
|
2021-10-24 15:49:48 +00:00
|
|
|
|
|
2021-10-24 16:16:37 +00:00
|
|
|
|
randy = new Random();
|
2021-10-24 15:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFormClosing(FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnFormClosing(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsBusy
|
|
|
|
|
{
|
|
|
|
|
get => isBusy;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
isBusy = value;
|
|
|
|
|
|
|
|
|
|
ThreadControl.SetValue(pictureBox1, (isBusy ? AppResource.loading_block : null));
|
2021-10-25 14:20:23 +00:00
|
|
|
|
ThreadControl.SetEnable(textBox1, !isBusy);
|
2021-10-24 15:49:48 +00:00
|
|
|
|
ThreadControl.SetEnable(button2, !isBusy);
|
2021-10-25 14:20:23 +00:00
|
|
|
|
ThreadControl.SetEnable(button3, !isBusy);
|
|
|
|
|
ThreadControl.SetEnable(button4, !isBusy);
|
|
|
|
|
ThreadControl.SetEnable(memoBox1, !isBusy);
|
|
|
|
|
ThreadControl.SetEnable(button5, !isBusy);
|
|
|
|
|
|
|
|
|
|
ThreadControl.SetEnable(button1, !isBusy);
|
2021-10-24 15:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AppSession CurrentSession { get; set; } = new AppSession();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void AddSearchItem(string line)
|
|
|
|
|
{
|
|
|
|
|
memoBox1.Text = memoBox1.Text.Trim();
|
|
|
|
|
|
|
|
|
|
// above line-break
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(memoBox1.Text)) memoBox1.Text += Environment.NewLine;
|
|
|
|
|
|
|
|
|
|
memoBox1.Text += line + Environment.NewLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Search
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void button2_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add directory
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void addDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy) return;
|
|
|
|
|
|
|
|
|
|
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
AddSearchItem(folderBrowserDialog1.SelectedPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void addFileToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy) return;
|
|
|
|
|
|
|
|
|
|
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
AddSearchItem(openFileDialog1.FileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Clear
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void button4_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy) return;
|
|
|
|
|
|
|
|
|
|
memoBox1.Text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 16:16:37 +00:00
|
|
|
|
private void memoBox1_DragOver(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy)
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.None;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-24 15:49:48 +00:00
|
|
|
|
|
2021-10-24 16:16:37 +00:00
|
|
|
|
private void memoBox1_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsBusy) return;
|
2021-10-24 15:49:48 +00:00
|
|
|
|
|
2021-10-24 16:16:37 +00:00
|
|
|
|
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
|
|
|
|
|
if (fileList == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (string item in fileList)
|
|
|
|
|
{
|
|
|
|
|
AddSearchItem(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Run next
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-10-24 16:18:23 +00:00
|
|
|
|
private void button5_MouseClick(object sender, MouseEventArgs e)
|
2021-10-24 16:16:37 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2021-10-24 15:49:48 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|