forked from starlest/PJSM.ERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
63 lines (55 loc) · 1.73 KB
/
MainWindow.xaml.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
using FirstFloor.ModernUI.Presentation;
using System.Windows.Media;
namespace PUJASM.ERP
{
using System;
using System.ComponentModel;
using System.Configuration;
using System.Threading;
using FirstFloor.ModernUI;
using Utilities;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
private readonly string _connectionString;
public MainWindow()
{
ModernUIHelper.TrySetPerMonitorDpiAware();
AppearanceManager.Current.AccentColor = Colors.Red;
InitializeComponent();
_connectionString =
ConfigurationManager.ConnectionStrings["ERPContext"].ConnectionString.Substring(7).Split(';')[0];
RunUpdateTitleLoop();
}
private void RunUpdateTitleLoop()
{
var worker = new BackgroundWorker();
worker.DoWork += worker_DoWork;
worker.RunWorkerAsync();
}
private void worker_DoWork(object sender, DoWorkEventArgs e)
{
while (true)
{
Thread.Sleep(1000);
Dispatcher.Invoke(() =>
{
try
{
SetTitle();
}
catch (Exception)
{
// ignored
}
});
}
}
private void SetTitle()
{
Title = "Puja Supermarket - User: " + ", Server: " + _connectionString + ", Date: " + UtilityMethods.GetCurrentDate().ToString("dd-MM-yyyy");
}
}
}