Beispiel #1
0
        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;
        }
Beispiel #2
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;
        }