-
Notifications
You must be signed in to change notification settings - Fork 0
/
IOForm.cs
136 lines (133 loc) · 5.35 KB
/
IOForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SpaceFix
{
public partial class IOForm : Form
{
//Constructors
public IOForm()
{
InitializeComponent();
KeyPreview = true;
//Fixer.IfShowExpectations =
// expectationsCheckBox.Checked = true;
//dispersionNumericUpDown.Increment = .01M;
//dispersionNumericUpDown.Value = (decimal)(Dictionary.Dispersion = 0.01);
Fixer.IfShowExpectations = false;
Dictionary.Dispersion = 0;
}
//Fields
DictionaryDialog dDialog = new DictionaryDialog();
DictionaryDebugForm ddForm = new DictionaryDebugForm();
//Event handlers
private void fixItButton_Click(object sender, EventArgs e)
{
try
{ outputTextBox.Text = Fixer.FixString(inputTextBox.Text); }
catch (ArgumentException ex)
{
if (ex.ParamName == "keys")
SFMessage.Show(Messages.canNotFix);
else throw;
}
}
private void inputClearButton_Click(object sender, EventArgs e)
{
if (inputTextBox.Text != string.Empty &&
MessageBox.Show("Do you want to delete all " +
"the data from the input text box?", "Clear?",
MessageBoxButtons.OKCancel) == DialogResult.OK)
inputTextBox.Text = string.Empty;
}
private void outputClearButton_Click(object sender, EventArgs e)
{
if (outputTextBox.Text != string.Empty &&
MessageBox.Show("Do you want to delete all " +
"the data from the output text box?", "Clear?",
MessageBoxButtons.YesNo) == DialogResult.Yes)
outputTextBox.Text = string.Empty;
}
private void copyButton_Click(object sender, EventArgs e)
{
if (outputTextBox.Text != string.Empty)
Clipboard.SetText(outputTextBox.Text);
}
private void pasteButton_Click(object sender, EventArgs e)
{
string text = Clipboard.GetText();
if (text == string.Empty) return;
if (inputTextBox.Text == string.Empty ||
MessageBox.Show("The entered text will be relaced.\n" +
"Do you want to continue?", "Replace?",
MessageBoxButtons.YesNo) == DialogResult.Yes)
inputTextBox.Text = Clipboard.GetText();
}
private void IOForm_KeyDown(object sender, KeyEventArgs e)
{
//if (fixItButton.Enabled && e.Control && e.KeyCode == Keys.D)
// ddForm.Show();
//else if (e.Control && e.KeyCode == Keys.W)
// using (OpenFileDialog ofd = new OpenFileDialog())
// {
// ofd.Title = "Choose file to wreck";
// ofd.Filter = "text files (*.txt)|*.txt";
// ofd.InitialDirectory = System.IO.Path.Combine(
// (new System.IO.DirectoryInfo(Application.StartupPath)).
// Parent.Parent.Name, "SampleTexts");
// if (ofd.ShowDialog() == DialogResult.OK)
// Wrecker.WreckSpaces(ofd.FileName, 1251);
// }
//else if (e.Control && e.KeyCode == Keys.S)
//{
// Dictionary.CreateFromFile(1251, @"../../SampleTexts/SimpleSample.txt");
// fixItButton.Enabled = true;
// ddForm.RemoveText();
//}
//else if (e.Control && e.KeyCode == Keys.R)
//{
// Dictionary.CreateFromFile(1251, @"../../SampleTexts/Smallian Re'jmond - Kak zhe nazyvaetsya e'ta kniga.txt");
// fixItButton.Enabled = true;
// ddForm.RemoveText();
//}
//else if (e.Control && e.Alt && e.KeyCode == Keys.C)
//{
// Dictionary.IfCompare = false;
// fixItButton.Text = "Fix";
//}
//else if (e.Control && e.KeyCode == Keys.C)
//{
// Dictionary.IfCompare = true;//!e.Alt;
// fixItButton.Text = "Fix_c";//e.Alt ? "Fix" : "Fix_c";
//}
}
private void dictionaryButton_Click(object sender, EventArgs e)
{
switch (dDialog.ShowDialog())
{
case DialogResult.Yes:
fixItButton.Enabled = true;
ddForm.RemoveText();
break;
case DialogResult.No:
fixItButton.Enabled = false;
ddForm.RemoveText();
break;
}
}
private void expectationsCheckBox_CheckedChanged(object sender, EventArgs e)
{
Fixer.IfShowExpectations = expectationsCheckBox.Checked;
}
private void dispersionNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Dictionary.Dispersion = (double)dispersionNumericUpDown.Value;
}
}
}