diff --git a/src/WPFEduSolution/WPFBeginner/App.xaml b/src/WPFEduSolution/WPFBeginner/App.xaml index 502643e..f239d22 100644 --- a/src/WPFEduSolution/WPFBeginner/App.xaml +++ b/src/WPFEduSolution/WPFBeginner/App.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:service="clr-namespace:WPFBeginner.Services" xmlns:conv="clr-namespace:WPFBeginner.Converters" - StartupUri="/Views/MainWindow.xaml"> + Startup="Application_Startup"> diff --git a/src/WPFEduSolution/WPFBeginner/App.xaml.cs b/src/WPFEduSolution/WPFBeginner/App.xaml.cs index 6e9bd5b..49d7ffc 100644 --- a/src/WPFEduSolution/WPFBeginner/App.xaml.cs +++ b/src/WPFEduSolution/WPFBeginner/App.xaml.cs @@ -26,38 +26,34 @@ namespace WPFBeginner public static AppSettings Config { get; private set; } - //[STAThread] - //static void Main() - //{ - //try - //{ - // var application = new App(); - // application.InitializeComponent(); // For resouce load. - // application.Run(); - //} - //catch (AlreadyExcutedAppException ex) - //{ - // MessageBox.Show("이미 실행중입니다. 종료 후, 다시 실행해주세요"); - //} - //catch (LoginFailedException ex) - //{ - // // Do not anything; - //} - //catch (Exception ex) - //{ - // // log - //} - //} - - protected override void OnStartup(StartupEventArgs e) + private void Application_Startup(object sender, StartupEventArgs e) { - base.OnStartup(e); - - //Login(); InitializeService(); + var main = new MainWindow(); + App.Current.MainWindow = main; + try + { + Login(); + + Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; + App.Current.MainWindow.Show(); + } + catch(Exception ex) + { + App.Current.MainWindow.Close(); + Environment.Exit(0); + } } - private void InitializeService() + private void UnhandledExceptionHandle(object e) + { + if(e is UnhandledExceptionEventArgs uee && uee.ExceptionObject is LoginFailedException) + { + + } + } + + private static void InitializeService() { Config = JsonSerializer.Deserialize(File.ReadAllText("appsettings.json")); @@ -78,22 +74,22 @@ namespace WPFBeginner .BuildServiceProvider()); } - private void SetTheme(string code) + private static void SetTheme(string code) { if (_currentTheme != null) - Resources.MergedDictionaries.Remove(_currentTheme); + App.Current.Resources.MergedDictionaries.Remove(_currentTheme); _currentTheme = ResourceExplorer.GetThemeResourceDic(code); - Resources.MergedDictionaries.Add(_currentTheme); + App.Current.Resources.MergedDictionaries.Add(_currentTheme); } - private void SetLanguage(string code) + private static void SetLanguage(string code) { if (_currentLanguage != null) - Resources.MergedDictionaries.Remove( _currentLanguage ); + App.Current.Resources.MergedDictionaries.Remove( _currentLanguage ); _currentLanguage = ResourceExplorer.GetLanguageResourceDic(code); - Resources.MergedDictionaries.Add(_currentLanguage); + App.Current.Resources.MergedDictionaries.Add(_currentLanguage); } private static void Login() @@ -101,9 +97,10 @@ namespace WPFBeginner var login = new LoginWindow(); var isSuccess = login.ShowDialog(); - if (isSuccess != true) + if (isSuccess != true) throw new LoginFailedException(); } } } + diff --git a/src/WPFEduSolution/WPFBeginner/Configurations/AppSettings.cs b/src/WPFEduSolution/WPFBeginner/Configurations/AppSettings.cs index 45a9963..d58bf69 100644 --- a/src/WPFEduSolution/WPFBeginner/Configurations/AppSettings.cs +++ b/src/WPFEduSolution/WPFBeginner/Configurations/AppSettings.cs @@ -48,7 +48,7 @@ namespace WPFBeginner.Configurations { var eventArg = new StringChangedEventArg() { - Old = language, + Old = theme, New = value }; diff --git a/src/WPFEduSolution/WPFBeginner/Controls/MemberInputPanel.xaml b/src/WPFEduSolution/WPFBeginner/Controls/MemberInputPanel.xaml index 243b793..b6f1aca 100644 --- a/src/WPFEduSolution/WPFBeginner/Controls/MemberInputPanel.xaml +++ b/src/WPFEduSolution/WPFBeginner/Controls/MemberInputPanel.xaml @@ -39,10 +39,10 @@ -