-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
150 lines (130 loc) · 5.68 KB
/
Program.cs
File metadata and controls
150 lines (130 loc) · 5.68 KB
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
using AutoUpdaterDotNET;
using Microsoft.VisualBasic.Logging;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
namespace SphereServerScriptAnalyser
{
internal static class Program
{
[STAThread]
static void Main()
{
CultureInfo selectedCulture;
Assembly assembly = Assembly.GetExecutingAssembly();
// Assembly versiyonunu al
Version version = assembly.GetName().Version;
string productVersion = FileVersionInfo
.GetVersionInfo(Assembly.GetExecutingAssembly().Location)
.ProductVersion;
try
{
// 1) Kullanıcı ayarına bak
var userLang = Properties.Main.Default.Language;
if (!string.IsNullOrWhiteSpace(userLang))
{
// Settings'te kayıtlı dil varsa → onu al
selectedCulture = new CultureInfo(userLang);
}
else
{
// Settings boş → sistem kültürünü dene
var systemCulture = CultureInfo.InstalledUICulture;
if (systemCulture != null)
selectedCulture = systemCulture;
else
selectedCulture = new CultureInfo("en-US"); // fallback
}
}
catch
{
// herhangi bir hata olursa → fallback en-US
selectedCulture = new CultureInfo("en-US");
}
// Thread kültürlerini ayarla
Thread.CurrentThread.CurrentCulture = selectedCulture;
Thread.CurrentThread.CurrentUICulture = selectedCulture;
// Normal WinForms init
ApplicationConfiguration.Initialize();
Form1 frm1 = new Form1();
// Debug amaçlı form başlığında aktif dili göster
Console.WriteLine("Active culture: " + selectedCulture.Name);
//frm1.Text += $" ({selectedCulture.Name} - v{version})";
frm1.Text += $" ({selectedCulture.Name} - v{productVersion})";
Console.WriteLine($"Assembly Version: {version}");
// AutoUpdater ayarları
AutoUpdater.ShowSkipButton = false;
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
AutoUpdater.ReportErrors = true;
//AutoUpdater.Start("https://uosoft.com.tr/api/sphere/script-analyser/Updater.xml");
AutoUpdater.Start("https://raw.githubusercontent.com/canerksk/SphereServerScriptAnalyser/main/Updater.xml");
AutoUpdater.Mandatory = true;
AutoUpdater.UpdateMode = Mode.Forced;
AutoUpdater.TopMost = true;
// Burada versiyonu geçir
//AutoUpdater.InstalledVersion = version;
//AutoUpdater.InstalledVersion = new Version(productVersion);
AutoUpdater.InstalledVersion = new Version("1.0.0.0");
AutoUpdater.ShowRemindLaterButton = false;
AutoUpdater.InstallationPath = Application.StartupPath;
Application.Run(frm1);
}
public static void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
{
if (args.Error == null)
{
if (args.IsUpdateAvailable)
{
DialogResult dialogResult;
if (args.Mandatory.Value)
{
dialogResult = MessageBox.Show(
$"Yeni bir sürüm mevcut: {args.CurrentVersion}. Mevcut sürüm: {args.InstalledVersion}. Bu güncelleme zorunludur. Güncellemeyi başlatmak için Tamam'a basın.",
"Güncelleme Mevcut",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
dialogResult = MessageBox.Show(
$"Yeni bir sürüm mevcut: {args.CurrentVersion}. Mevcut sürüm: {args.InstalledVersion}. Uygulamayı şimdi güncellemek ister misiniz?",
"Güncelleme Mevcut",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
}
if (dialogResult == DialogResult.Yes || dialogResult == DialogResult.OK)
{
try
{
if (AutoUpdater.DownloadUpdate(args))
{
Application.Exit();
}
}
catch (Exception exception)
{
MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
//else
//{
//MessageBox.Show("Uygulama güncel!", "Güncelleme Yok", MessageBoxButtons.OK, MessageBoxIcon.Information);
//}
}
else
{
MessageBox.Show(
args.Error is WebException
? "Güncelleme sunucusuna ulaşılamadı. İnternet bağlantınızı kontrol edin ve tekrar deneyin."
: args.Error.Message,
"Güncelleme Kontrol Hatası",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}