コード例 #1
0
 private void App_Exit(object sender, ExitEventArgs e)
 {
     try
     {
         AppVM.Close();
         MessageHandlers.UnregisterMessageHandlers(this);
     }
     catch (Exception ex)
     {
         ExceptionUtils.HandleException(ex);
     }
 }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: vavachi/Chordious
        public App(string userConfigPath = null)
        {
            MessageHandlers.RegisterMessageHandlers(this);

#if PORTABLE
            UserConfigPath = !string.IsNullOrWhiteSpace(userConfigPath) ? userConfigPath : DefaultUserConfigFileName;
#else
            UserConfigPath = !string.IsNullOrWhiteSpace(userConfigPath) ? userConfigPath : GetAppDataUserConfigPath();
#endif

            string userFile = UserConfigPath;

            AppViewModel.Init(Assembly.GetEntryAssembly(), () =>
            {
                return(GetResourceStream(new Uri("pack://application:,,,/Chordious.WPF.xml")).Stream);
            }, () =>
            {
                return(new FileStream(userFile, FileMode.Open));
            }, () =>
            {
                return(new FileStream(userFile, FileMode.Create));
            }, ImageUtils.SvgTextToBitmapImage
                              , ImageUtils.SvgTextToClipboard
                              , (action) =>
            {
                Dispatcher.Invoke(action);
            }
                              , GetFonts
                              , userFile);

            AppVM.LoadAppConfig();

            if (!File.Exists(userFile))
            {
                // Makes sure that LoadUserConfig will be successful
                AppVM.SaveUserConfig();
            }

            AppVM.LoadUserConfig(HandleUserConfigLoadException);

            // Makes sure textboxes accept localized inputs
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            Exit += App_Exit;
        }
コード例 #3
0
        public App(string userConfigPath = null)
        {
            MessageHandlers.RegisterMessageHandlers(this);

            UserConfigPath = GetUserConfigPath(userConfigPath, true);

            AppViewModel.Init(Assembly.GetEntryAssembly(), this, UserConfigPath);

            AppVM.LoadAppConfig();

            if (!File.Exists(UserConfigPath))
            {
                // Makes sure that LoadUserConfig will be successful
                AppVM.SaveUserConfig();
            }

            AppVM.LoadUserConfig(HandleUserConfigLoadException);

            // Makes sure textboxes accept localized inputs
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            Exit += App_Exit;
        }