Пример #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //this.DispatcherUnhandledException += App_DispatcherUnhandledException;
            //ISeedDataService seedData = DependencyResolver.Kernel.Get<ISeedDataService>();
            //seedData.PopulateData();

            //Create a custom principal with an anonymous identity at startup
            CustomPrincipal customPrincipal = new CustomPrincipal();

            AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal);

            EventManager.RegisterClassHandler(typeof(TextBox), TextBox.PreviewKeyDownEvent, new KeyEventHandler(Grid_PreviewKeyDown));
            EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotFocusEvent, new RoutedEventHandler(Texbox_GotFocusEvent));
            EventManager.RegisterClassHandler(typeof(PasswordBox), PasswordBox.PreviewKeyDownEvent, new KeyEventHandler(Grid_PreviewKeyDown));
            EventManager.RegisterClassHandler(typeof(DatePicker), DatePicker.PreviewKeyDownEvent, new KeyEventHandler(Grid_PreviewKeyDown));
            EventManager.RegisterClassHandler(typeof(ComboBox), DatePicker.PreviewKeyDownEvent, new KeyEventHandler(Grid_PreviewKeyDown));

            ResourceDictionary dict = new ResourceDictionary();

            dict.Source = new Uri("\\Resources\\Languages\\StringResources-GER.xaml", UriKind.Relative);
            this.Resources.MergedDictionaries.Add(dict);

            base.OnStartup(e);

            try
            {
                AppConfigurationHelper.ReadConfig();

                WpfApiHandler.BaseApiUrl = AppConfigurationHelper.Configuration.ApiUrl;
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //Show the login view
            LoginWindow loginWindow = new LoginWindow();

            loginWindow.Show();
        }