Skip to content

Commit 54f615a

Browse files
author
Nicolay B. aka RD_AAOW
committed
Assembly v 2.11.1p (18.07.20)
1 parent eeb0a3b commit 54f615a

File tree

4 files changed

+184
-12
lines changed

4 files changed

+184
-12
lines changed

Changes.log

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Font finder changes log
22

3+
Version 2.11.1p:
4+
• Updated application info interface (more convenient font is used for now);
5+
• Added a button to access the Application development policy and EULA in the application info interface (due to ADP update);
6+
• Added automatic check for updates to the application info interface
7+
38
Version 2.11h:
49
• New application info interface implemented
510

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FontFinder v 2.11h
1+
# FontFinder v 2.11.1p
22

33
A tool for finding font by its image
44

src/AboutForm.cs

+172-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System;
2+
using System.ComponentModel;
23
using System.Diagnostics;
34
using System.Drawing;
5+
using System.IO;
6+
using System.Net;
47
using System.Reflection;
58
using System.Windows.Forms;
69

@@ -13,6 +16,18 @@ public partial class AboutForm:Form
1316
{
1417
// Переменные
1518
private string projectLink, updatesLink, userManualLink;
19+
private SupportedLanguages al;
20+
private string updatesMessage = "";
21+
22+
/// <summary>
23+
/// Основная Git-ссылка
24+
/// </summary>
25+
public const string DefaultGitLink = "https://github.com/adslbarxatov/";
26+
27+
/// <summary>
28+
/// Часть ссылки на раздел Git-обновлений
29+
/// </summary>
30+
public const string GitUpdatesSublink = "/releases";
1631

1732
/// <summary>
1833
/// Конструктор. Запускает форму
@@ -25,35 +40,53 @@ public partial class AboutForm:Form
2540
/// кнопка отключается, если это значение не задано</param>
2641
/// <param name="UserManualLink">Ссылка на страницу руководства пользователя;
2742
/// кнопка отключается, если это значение не задано</param>
28-
public AboutForm (SupportedLanguages InterfaceLanguage,
29-
string ProjectLink, string UpdatesLink, string UserManualLink,
30-
string Description)
43+
public AboutForm (SupportedLanguages InterfaceLanguage, string ProjectLink,
44+
string UpdatesLink, string UserManualLink, string Description)
3145
{
3246
// Инициализация
3347
InitializeComponent ();
48+
al = InterfaceLanguage;
3449

3550
// Настройка контролов
36-
switch (InterfaceLanguage)
51+
switch (al)
3752
{
3853
case SupportedLanguages.ru_ru:
39-
UserManualButton.Text = "Руководство пользователя";
40-
ProjectPageButton.Text = "Веб-страница проекта";
41-
UpdatesPageButton.Text = "Веб-страница обновлений";
54+
UserManualButton.Text = "Руководство";
55+
ProjectPageButton.Text = "О проекте";
56+
UpdatesPageButton.Text = "Обновления";
57+
ADPButton.Text = "Политика и EULA";
58+
AvailableUpdatesLabel.Text = "проверяются...";
59+
4260
this.Text = "О программе";
4361
break;
4462

4563
default: // en_us
4664
UserManualButton.Text = "User manual";
4765
ProjectPageButton.Text = "Project webpage";
4866
UpdatesPageButton.Text = "Updates webpage";
67+
ADPButton.Text = "Policy and EULA";
68+
AvailableUpdatesLabel.Text = "checking...";
69+
4970
this.Text = "About application";
5071
break;
5172
}
5273

5374
// Получение параметров
5475
userManualLink = ((UserManualLink == null) ? "" : UserManualLink);
55-
projectLink = ((ProjectLink == null) ? "" : ProjectLink);
56-
updatesLink = ((UpdatesLink == null) ? "" : UpdatesLink);
76+
77+
if (ProjectLink == null)
78+
projectLink = "";
79+
else if (ProjectLink == "*")
80+
projectLink = DefaultGitLink + ProgramDescription.AssemblyMainName;
81+
else
82+
projectLink = ProjectLink;
83+
84+
if (UpdatesLink == null)
85+
updatesLink = "";
86+
else if (UpdatesLink == "*")
87+
updatesLink = DefaultGitLink + ProgramDescription.AssemblyMainName + GitUpdatesSublink;
88+
else
89+
updatesLink = UpdatesLink;
5790

5891
DescriptionBox.Text = ((Description == null) ? "" : Description);
5992

@@ -70,19 +103,26 @@ public AboutForm (SupportedLanguages InterfaceLanguage,
70103
ProjectPageButton.Enabled = (projectLink != "");
71104
UpdatesPageButton.Enabled = (updatesLink != "");
72105

106+
// Запуск проверки обновлений
107+
HardWorkExecutor hwe = new HardWorkExecutor (UpdatesChecker, null, "");
108+
UpdatesTimer.Enabled = true;
109+
73110
// Запуск
74111
this.ShowDialog ();
75112
}
76113

77114
/// <summary>
78115
/// Конструктор. Открывает указанную ссылку без запуска формы
79116
/// </summary>
80-
/// <param name="Link">Ссылка для отображения</param>
117+
/// <param name="Link">Ссылка для отображения (если null, запускается стандартная)</param>
81118
public AboutForm (string Link)
82119
{
83120
try
84121
{
85-
Process.Start (Link);
122+
if (Link == null)
123+
Process.Start (DefaultGitLink + ProgramDescription.AssemblyMainName + GitUpdatesSublink);
124+
else
125+
Process.Start (Link);
86126
}
87127
catch
88128
{
@@ -137,5 +177,126 @@ private void UpdatesPageButton_Click (object sender, EventArgs e)
137177
{
138178
}
139179
}
180+
181+
private void ADP_Click (object sender, EventArgs e)
182+
{
183+
try
184+
{
185+
Process.Start ("https://vk.com/@rdaaow_fupl-adp");
186+
}
187+
catch
188+
{
189+
}
190+
}
191+
192+
// Метод-исполнитель проверки обновлений
193+
private void UpdatesChecker (object sender, DoWorkEventArgs e)
194+
{
195+
// Настройка безопасности соединения
196+
ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xFC0;
197+
// Принудительно открывает TLS1.0, TLS1.1 и TLS1.2; блокирует SSL3
198+
199+
// Запрос обновлений пакета
200+
HttpWebRequest rq = (HttpWebRequest)WebRequest.Create (projectLink);
201+
rq.Method = "GET";
202+
rq.KeepAlive = false;
203+
rq.Timeout = 10000;
204+
205+
// Отправка запроса
206+
HttpWebResponse resp = null;
207+
string html = "";
208+
try
209+
{
210+
resp = (HttpWebResponse)rq.GetResponse ();
211+
}
212+
catch
213+
{
214+
goto htmlError;
215+
}
216+
217+
// Чтение ответа
218+
StreamReader SR = new StreamReader (resp.GetResponseStream ());
219+
html = SR.ReadToEnd ();
220+
SR.Close ();
221+
resp.Close ();
222+
223+
// Разбор ответа (извлечение версий и PCC)
224+
string version = "";
225+
string[] htmlMarkers = { "</a>" + ProgramDescription.AssemblyMainName, "</h1>" };
226+
227+
int i = html.IndexOf (htmlMarkers[0]);
228+
if (i < 0)
229+
goto htmlError;
230+
231+
i += htmlMarkers[0].Length;
232+
233+
int j = html.IndexOf (htmlMarkers[1], i);
234+
if ((j < 0) || (j <= i))
235+
goto htmlError;
236+
237+
version = html.Substring (i, j - i).Trim ();
238+
239+
// Отображение результата
240+
switch (al)
241+
{
242+
case SupportedLanguages.ru_ru:
243+
if (ProgramDescription.AssemblyTitle.EndsWith (version))
244+
updatesMessage = "обновлений нет";
245+
else
246+
updatesMessage = "доступна " + version;
247+
break;
248+
249+
default: // en_us
250+
if (ProgramDescription.AssemblyTitle.EndsWith (version))
251+
updatesMessage = "no updates";
252+
else
253+
updatesMessage = version + " available";
254+
break;
255+
}
256+
257+
258+
e.Result = 0;
259+
return;
260+
261+
// Есть проблема при загрузке страницы. Отмена
262+
htmlError:
263+
switch (al)
264+
{
265+
case SupportedLanguages.ru_ru:
266+
updatesMessage = "недоступны";
267+
break;
268+
269+
default: // en_us
270+
updatesMessage = "unavailable";
271+
break;
272+
}
273+
274+
e.Result = -2;
275+
return;
276+
}
277+
278+
// Контроль сообщения об обновлении
279+
private void UpdatesTimer_Tick (object sender, EventArgs e)
280+
{
281+
if (updatesMessage != "")
282+
{
283+
if (AvailableUpdatesLabel.Text == "")
284+
{
285+
AvailableUpdatesLabel.Text = updatesMessage;
286+
if (!updatesMessage.Contains ("."))
287+
{
288+
UpdatesTimer.Enabled = false;
289+
}
290+
else
291+
{
292+
UpdatesTimer.Interval = 1000;
293+
}
294+
}
295+
else
296+
{
297+
AvailableUpdatesLabel.Text = "";
298+
}
299+
}
300+
}
140301
}
141302
}

src/HardWorkExecutor.cs

+6
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ private void InitializeProgressBar ()
6464
{
6565
// Настройка контролов
6666
InitializeComponent ();
67+
#if SIMPLE_HWE
68+
this.BackColor = Color.FromKnownColor (KnownColor.Control);
69+
StateLabel.ForeColor = AbortButton.ForeColor = Color.FromArgb (0, 0, 0);
70+
AbortButton.BackColor = Color.FromKnownColor (KnownColor.Control);
71+
#else
6772
this.BackColor = ProgramDescription.MasterBackColor;
6873
StateLabel.ForeColor = AbortButton.ForeColor = ProgramDescription.MasterTextColor;
6974
AbortButton.BackColor = ProgramDescription.MasterButtonColor;
75+
#endif
7076

7177
// Инициализация
7278
progress = new Bitmap (this.Width - 20, 30);

0 commit comments

Comments
 (0)