aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs
blob: 396068ab637abe49f0fdb54900bd97690595564a (plain)
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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Tango.FSE.Common;
using Tango.FSE.Common.Helpers;
using Tango.Integration.Operation;
using Tango.Logging;
using Tango.Settings;

namespace Tango.FSE.UI
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private LogManager LogManager = LogManager.Default;

        public App() : base()
        {
            if (!DesignModeHelper.IsInDesignMode())
            {
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"/MahApps.Metro;component/Styles/Colors.xaml", UriKind.Relative) });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"/MahApps.Metro;component/Styles/Accents/BaseDark.xaml", UriKind.Relative) });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"/MahApps.Metro;component/Styles/VS/Colors.xaml", UriKind.Relative) });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"/MahApps.Metro;component/Styles/VS/Styles.xaml", UriKind.Relative) });
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri(@"/MahApps.Metro;component/Styles/Controls.xaml", UriKind.Relative) });
            }
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            ThreadPool.SetMaxThreads(1000, 1000);

            //If no debugger is attached and the argument -debug was passed launch the debugger.
            if (e.Args.Contains("-debug") && !Debugger.IsAttached)
            {
                Debugger.Launch();
            }

            //LogManager.RegisterLogger(new ConsoleLogger("Tango PPC Debug"));
            LogManager.RegisterLogger(new FileLogger() { EnableAutoLogRemoval = true, EnableMaxFileSizeLimit = true });
            LogManager.RegisterLogger(new VSOutputLogger());

            //Configure machine operator logger.
            var operatorLogger = MachineOperator.EmbeddedLogManager.RegisteredLoggers.SingleOrDefault(x => x is FileLogger) as FileLogger;
            if (operatorLogger != null)
            {
                operatorLogger.EnableAutoLogRemoval = true;
                operatorLogger.EnableMaxFileSizeLimit = true;
            }

            LogManager.Log("Application Started...");

            var settings = SettingsManager.Default.GetOrCreate<FSESettings>();

            //if (settings.LoggingCategories.Count == 0)
            //{
            //    settings.LoggingCategories.Add(LogCategory.Critical);
            //    settings.LoggingCategories.Add(LogCategory.Error);
            //    settings.LoggingCategories.Add(LogCategory.Info);
            //    settings.LoggingCategories.Add(LogCategory.Warning);
            //}

            settings.Save();

            //LogManager.Categories.AddRange(settings.LoggingCategories);

            WebRequest.DefaultWebProxy = null;

            base.OnStartup(e);
        }
    }
}