-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfrmConvertOrthoC.cs
192 lines (185 loc) · 8.26 KB
/
frmConvertOrthoC.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AUTHOR'S MEMO AND MIT LICENSE STATEMENT
// ///////////////////////////////////////
//
// Author: Haro Mherian, Ph.D. Mathematics, Computer Sciences, Linguistics, etc.
// This software was originally created in 2008. Being the only linguistically complete Armenian spell-checker
// tool (in both Classical and Reformed Orthographies), it was commercially available under "HySpell Armenian
// Spell-Checker" name until June 2017. It was then made open source in order to promote software development
// in the direction and advancement of the Armenian language.
// For further information, as well as, further linguistic tools, please contact: www.hyspell.com
//
// Copyright (c) 2017 hyspell.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice, along with author's memo, and permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Windows.Forms;
namespace HySpell
{
public partial class frmConvertOrthoC : Form
{
public frmConvertOrthoC()
{
InitializeComponent();
}
private void lstWords_SelectedIndexChanged(object sender, EventArgs e)
{
lstPossibleWords.Items.Clear();
ArrayList arrPossWords = new ArrayList();
int nRet = Globals.ThisAddIn.ConvertSuggestWord(lstWords.SelectedItem.ToString(), ref arrPossWords);
if (nRet == 0)
{
lstPossibleWords.Enabled = false;
txtOutputWord.Text = lstWords.SelectedItem.ToString();
}
else
{
foreach (object oItem in arrPossWords)
lstPossibleWords.Items.Add(oItem.ToString());
lstPossibleWords.Enabled = true;
lstPossibleWords.SelectedIndex = 0;
}
}
private void txtOutputWord_TextChanged(object sender, EventArgs e)
{
}
private void btnChange_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
Globals.ThisAddIn.UserSuggestedWord = txtOutputWord.Text;
Globals.ThisAddIn.SubstituteAndSelectWord(txtInputWord.Text, txtOutputWord.Text);
// reset the add-in member arrays to null
if (Globals.ThisAddIn.PossibleWords != null)
{
Globals.ThisAddIn.PossibleWords.Clear();
Globals.ThisAddIn.PossibleWords = null;
}
if (Globals.ThisAddIn.SuggestList != null)
{
Globals.ThisAddIn.SuggestList.Clear();
Globals.ThisAddIn.SuggestList = null;
}
Globals.ThisAddIn.ConvertOrthography(false);
if (Globals.ThisAddIn.TerminateOrthoConvert)
{
Cursor.Current = Cursors.Default;
this.Close();
return;
}
txtInputWord.Text = Globals.ThisAddIn.CurrentWord;
lstWords.Items.Clear();
lstWords.Enabled = true;
lstPossibleWords.Items.Clear();
lstPossibleWords.Enabled = true;
if (Globals.ThisAddIn.PossibleWords != null)
{
foreach (object oItem in Globals.ThisAddIn.PossibleWords)
lstPossibleWords.Items.Add(oItem.ToString());
}
else if (Globals.ThisAddIn.SuggestList != null)
{
if (Globals.ThisAddIn.SuggestList.Count > 0)
{
foreach (object oItem in Globals.ThisAddIn.SuggestList)
lstWords.Items.Add(oItem.ToString());
}
else
{
lstWords.Items.Add("(Ուղղագրիչը առաջարկ չունի)");
lstWords.Enabled = false;
lstPossibleWords.Enabled = false;
}
}
else
{
lstWords.Items.Add("(Ուղղագրիչը առաջարկ չունի)");
lstWords.Enabled = false;
lstPossibleWords.Enabled = false;
}
if (Globals.ThisAddIn.CurrentWord.IndexOfAny(Globals.ThisAddIn.IsArmenianHyphen) == -1)
txtOutputWord.Text = Globals.ThisAddIn.CurrentWordOutPut;
else
txtOutputWord.Text = Globals.ThisAddIn.CurrentWord;
Cursor.Current = Cursors.Default;
}
private void frmConvertOrthoC_Load(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
Globals.ThisAddIn.TerminateOrthoConvert = false;
Globals.ThisAddIn.ConvertOrthography(false);
if (Globals.ThisAddIn.TerminateOrthoConvert)
{
Cursor.Current = Cursors.Default;
this.Close();
return;
}
txtInputWord.Text = Globals.ThisAddIn.CurrentWord;
if (Globals.ThisAddIn.PossibleWords != null)
{
foreach (object oItem in Globals.ThisAddIn.PossibleWords)
lstPossibleWords.Items.Add(oItem.ToString());
}
else if (Globals.ThisAddIn.SuggestList != null)
{
if (Globals.ThisAddIn.SuggestList.Count > 0)
{
foreach (object oItem in Globals.ThisAddIn.SuggestList)
lstWords.Items.Add(oItem.ToString());
}
else
{
lstWords.Items.Add("(Ուղղագրիչը առաջարկ չունի)");
lstWords.Enabled = false;
lstPossibleWords.Enabled = false;
}
}
else
{
lstWords.Items.Add("(Ուղղագրիչը առաջարկ չունի)");
lstWords.Enabled = false;
lstPossibleWords.Enabled = false;
}
//HM---------->
if (Globals.ThisAddIn.CurrentWord.IndexOfAny(Globals.ThisAddIn.IsArmenianHyphen) == -1)
txtOutputWord.Text = Globals.ThisAddIn.CurrentWordOutPut;
else
txtOutputWord.Text = Globals.ThisAddIn.CurrentWord;
Cursor.Current = Cursors.Default;
}
private void frmConvertOrthoC_FormClosing(object sender, FormClosingEventArgs e)
{
if (Globals.ThisAddIn.SuggestList != null)
{
Globals.ThisAddIn.SuggestList.Clear();
Globals.ThisAddIn.SuggestList = null;
}
if (Globals.ThisAddIn.PossibleWords != null)
{
Globals.ThisAddIn.PossibleWords.Clear();
Globals.ThisAddIn.PossibleWords = null;
}
Globals.ThisAddIn.CurrentWord = "";
Globals.ThisAddIn.UnInitializeWrappers();
}
private void lstPossibleWords_SelectedIndexChanged(object sender, EventArgs e)
{
string[] arrPWords = lstPossibleWords.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
txtOutputWord.Text = arrPWords[0];
}
}
}