-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
102 lines (70 loc) · 3.1 KB
/
Program.cs
File metadata and controls
102 lines (70 loc) · 3.1 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
using StudyJournalPro.Properties.Localization;
using StudyJournalPro.StudyJournalPro.Business;
using StudyJournalPro.StudyJournalPro.DataAccess;
using StudyJournalPro.StudyJournalPro.Presentation;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace StudyJournalPro
{
internal static class Program
{
private static Mutex mutex = null;
// Windows API importlarý
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private const int SW_RESTORE = 9;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Ayarlarda saklanan dil kodunu oku (ör. "tr-TR" veya "en-US")
// Kullanýcýnýn son seçtiði dili uygula
string savedCulture = Properties.Settings.Default.AppLanguage;
//MessageBox.Show("Uygulama baþlangýcýnda okunan dil: '" + savedCulture + "'");
if (!string.IsNullOrEmpty(savedCulture))
{
try
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(savedCulture); //new System.Globalization.CultureInfo(savedCulture);
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(savedCulture);
}
catch
{
}
}
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
const string appName = "StudyJournalPro";
mutex = new Mutex(true, appName, out bool createdNew);
if (!createdNew)
{
// Çalýþan uygulamanýn ana penceresini bul
IntPtr hWnd = FindWindow(null, Localization.lblAppName); // <-- Form'un Title Text'i ile eþleþmeli
if (hWnd != IntPtr.Zero)
{
// Eðer gizliyse geri getir
ShowWindow(hWnd, SW_RESTORE);
// Öne al
SetForegroundWindow(hWnd);
}
return;
}
ApplicationConfiguration.Initialize();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Business katmaný için repository oluþtur
IChronometerRepository repository = new SQLiteChronometerRepository();
// Business servisini oluþtur (Dependency Injection)
IChronometerService kronometreService = new ChronometerManager(repository);
// Formu sadece service üzerinden baþlat
Application.Run(new SideBarForm(kronometreService));// eski versiyon
}
}
}