Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        /// <param name="applicationInsightHelper">AI Helper</param>
        public MainWindow(ApplicationInsightHelper applicationInsightHelper)
        {
            log4net.Config.XmlConfigurator.Configure();
            this.InitializeComponent();
            this.applicationInsightHelper = applicationInsightHelper;

            // Load Language
            this.LoadLanguage(Properties.Settings.Default.Culture);

            busyIndicator = this.prg_progress;
            MainWindow.SetProgress(false);

            if (Properties.Settings.Default.DebuggingEnabled)
            {
                Application.Current.Properties["Debugging.Enabled"] = true;
            }
            else
            {
                Application.Current.Properties["Debugging.Enabled"] = false;
            }

            if (!File.Exists(Core.Data.StorageExtensions.StoragePath))
            {
                Btn_OpenConnectionOverview.IsEnabled = false;
            }

            if (string.IsNullOrEmpty(MainWindow.EncryptionKey))
            {
                EncryptionKey encryptionKey = new EncryptionKey();
                encryptionKey.ShowDialog();

                if (!string.IsNullOrEmpty(MainWindow.EncryptionKey))
                {
                    Pages.SolutionSelector solutionSelector = new Pages.SolutionSelector();
                    solutionSelector.ReloadConnections();
                    this.menuItems            = this.GetMenu();
                    this.Lbx_Menu.ItemsSource = this.menuItems;
                    this.CheckForUpdate();
                }
                else
                {
                    this.Close();
                }
            }
        }
        /// <summary>
        /// Overwrite for the Application Startup
        /// </summary>
        /// <param name="e">The <see cref="StartupEventArgs"/> instance containing the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                this.applicationInsightHelper = new ApplicationInsightHelper();

                // We use this to get access to unhandled exceptions so we can
                // report app crashes to the Telemetry client
                var currentDomain = AppDomain.CurrentDomain;

                currentDomain.UnhandledException += this.CurrentDomain_UnhandledException;
                currentDomain.ProcessExit        += this.CurrentDomain_ProcessExit;

                // Open Application
                var mainWindow = new MainWindow(this.applicationInsightHelper);
                mainWindow.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }