Skip to content

Commit

Permalink
Kész
Browse files Browse the repository at this point in the history
  • Loading branch information
hdani1337 committed Feb 20, 2021
1 parent cd14616 commit 27375b3
Show file tree
Hide file tree
Showing 17 changed files with 245 additions and 201 deletions.
1 change: 1 addition & 0 deletions .idea/.idea.TyperHelper/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 36 additions & 29 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 83 additions & 65 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace TyperHelper
{
Expand All @@ -32,8 +33,8 @@ public Form1()
{
InitializeComponent();
chooseFile.FileName = "";
initLists();
_mainHandler = new MainHandler(this);
checkStart();
}

private void initLists()
Expand All @@ -44,7 +45,7 @@ private void initLists()
foreach (Process p in processes)
if(!string.IsNullOrEmpty(p.MainWindowTitle))
{
processNames.Add(p.ProcessName);
processNames.Add("["+p.ProcessName.Substring(0,1).ToUpper()+p.ProcessName.Substring(1,p.ProcessName.Length-1)+"]: " + p.MainWindowTitle);
processesVisible.Add(p);
}

Expand All @@ -53,32 +54,41 @@ private void initLists()

private void chooseFile_FileOk(object sender, CancelEventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
chooseFile.ShowDialog();

while (!chooseFile.FileName.EndsWith(".txt")) {
MessageBox.Show("Kérlek .txt kiterjesztésű fájlt válassz ki!", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error);
chooseFile.ShowDialog();
if (!chooseFile.FileName.EndsWith(".txt"))
{
MessageBox.Show("Kérlek .txt kiterjesztésű fájlt válassz ki!", "Hiba!", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
szovegInput.ReadOnly = true;
textTypedCheck.Checked = true;
szovegInput.Text = "Kiválaszott fájl:\n" + chooseFile.FileName;
}

szovegInput.ReadOnly = true;
szovegInput.Text = "Kiválaszott fájl:\n" + chooseFile.FileName;
label1.Visible = false;
}

private void progresses_SelectedIndexChanged(object sender, EventArgs e)
{
if (processesVisible != null)
if (processesVisible != null){
selectedProcess = processesVisible[progresses.SelectedIndex];
processSelectedCheck.Checked = true;
checkStart();
}
}

private void progresses_Click(object sender, EventArgs e)
{

initLists();
}

public void setButtons(bool enabled)
{
enterAfter.Enabled = enabled;
enterBefore.Enabled = enabled;
button1.Enabled = enabled;
startButton.Enabled = enabled;
progresses.Enabled = enabled;
numericUpDown.Enabled = enabled;
}

private void startButton_Click(object sender, EventArgs e)
Expand All @@ -87,57 +97,65 @@ private void startButton_Click(object sender, EventArgs e)
allTextLength = 0;
text = new List<string>();
breaks = new List<int>();
startButton.Enabled = false;
_mainHandler.progressValue = 0;

Int32.TryParse(textBox1.Text, out latency);
setButtons(false);

if (latency != 0)
latency = (int) numericUpDown.Value;

if (chooseFile.FileName == "")
text = szovegInput.Text.Split('\r').ToList();
else
{
try
{
text = File.ReadAllLines(chooseFile.FileName).ToList();
}
catch (Exception err)
{
MessageBox.Show(err.Message, "Hiba!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

for (int ind = 0; ind < text.Count; ind++)
{
if (chooseFile.FileName == "")
if (szovegInput.Text == "") _mainHandler.noText();
else
{
text = szovegInput.Text.Split('\r').ToList();
for (int ind = 0; ind < text.Count; ind++)
{
for (int typed = 0; typed < text[ind].Length; typed++)
{
allTextLength++;
}
breaks.Add(allTextLength);
}
enterAfter.Enabled = false;
enterBefore.Enabled = false;
button1.Enabled = false;
startButton.Enabled = false;
}
else
for (int typed = 0; typed < text[ind].Length; typed++)
{
try
{
text = File.ReadAllLines(chooseFile.FileName).ToList();
for (int ind = 0; ind < text.Count; ind++)
{
for (int typed = 0; typed < text[ind].Length; typed++)
{
allTextLength++;
}
}
enterAfter.Enabled = false;
enterBefore.Enabled = false;
button1.Enabled = false;
startButton.Enabled = false;
}
catch (Exception err)
{
MessageBox.Show(err.Message, "Hiba!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
allTextLength++;
}
_mainHandler.write();
startButton.Enabled = true;
}else _mainHandler.latencyIsNull();

breaks.Add(allTextLength);
}

progressBar1.Maximum = allTextLength;

_mainHandler.write();
}

private void szovegInput_TextChanged(object sender, EventArgs e)
{
textTypedCheck.Checked = (szovegInput.Text.Length > 0);
checkStart();
}

private void tableLayoutPanel9_Paint(object sender, PaintEventArgs e)
{

}

private void numericUpDown_ValueChanged(object sender, EventArgs e)
{
latencyCheck.Checked = (numericUpDown.Value > 0);
checkStart();
}

private void button1_Click_1(object sender, EventArgs e)
{
chooseFile.ShowDialog();
}

private void checkStart()
{
startButton.Enabled = (textTypedCheck.Checked && latencyCheck.Checked && processSelectedCheck.Checked);
}
}
}
Loading

0 comments on commit 27375b3

Please sign in to comment.