Exemplo n.º 1
0
        public static void Init(ViewerConfig viewerConfig, DoOnUIThread doOnUIThread)
        {
            if (null != Instance)
            {
                throw new NotSupportedException();
            }

            Instance = new AppViewModel(viewerConfig, doOnUIThread);
        }
Exemplo n.º 2
0
        private AppViewModel(Assembly assembly, GetConfigStream loadAppConfigStream, GetConfigStream loadUserConfigStream, GetConfigStream saveUserConfigStream, SvgTextToImage svgTextToImage, SvgTextToClipboard svgTextToClipboard, DoOnUIThread doOnUIThread, GetSystemFonts getSystemFonts, string userConfigPath)
        {
            if (null == assembly)
            {
                throw new ArgumentNullException("assembly");
            }

            if (null == loadAppConfigStream)
            {
                throw new ArgumentNullException("loadAppConfigStream");
            }

            if (null == loadUserConfigStream)
            {
                throw new ArgumentNullException("loadUserConfigStream");
            }

            if (null == saveUserConfigStream)
            {
                throw new ArgumentNullException("saveUserConfigStream");
            }

            if (null == getSystemFonts)
            {
                throw new ArgumentNullException("getSystemFonts");
            }

            AppInfo.Assembly      = assembly;
            _loadAppConfigStream  = loadAppConfigStream;
            _loadUserConfigStream = loadUserConfigStream;
            _saveUserConfigStream = saveUserConfigStream;
            GetSystemFonts        = getSystemFonts;
            UserConfigPath        = userConfigPath;

            SvgTextToImage     = svgTextToImage;
            SvgTextToClipboard = svgTextToClipboard;
            DoOnUIThread       = doOnUIThread;

            AppConfig  = new ConfigFile(DefaultConfig, ConfigFile.AppLevelKey);
            UserConfig = new ConfigFile(AppConfig, ConfigFile.UserLevelKey);
        }
Exemplo n.º 3
0
        private AppViewModel(ViewerConfig viewerConfig, DoOnUIThread doOnUIThread)
        {
            if (null == viewerConfig)
            {
                throw new ArgumentNullException("viewerConfig");
            }

            if (null == doOnUIThread)
            {
                throw new ArgumentNullException("doOnUIThread");
            }

            ViewerConfig = viewerConfig;

            DoOnUIThread = doOnUIThread;

            try
            {
                // Try starting external engine
                switch (ViewerConfig.EngineType)
                {
                case EngineType.CommandLine:
                    EngineWrapper = new CLIEngineWrapper(ViewerConfig.EngineCommandLine);
                    EngineWrapper.StartEngine();
                    break;
                }
            }
            catch (Exception ex)
            {
                EngineWrapper?.StopEngine();
                EngineWrapper          = null;
                EngineExceptionOnStart = ex;
            }

            if (null == EngineWrapper)
            {
                // No engine started, use an internal one
                EngineWrapper = new InternalEngineWrapper(ProgramTitle);
                EngineWrapper.StartEngine();
            }
        }
Exemplo n.º 4
0
        public static void Init(Assembly assembly, GetConfigStream loadAppConfigStream, GetConfigStream loadUserConfigStream, GetConfigStream saveUserConfigStream, SvgTextToImage svgTextToImage, SvgTextToClipboard svgTextToClipboard, DoOnUIThread doOnUIThread, GetSystemFonts getSystemFonts, string userConfigPath = "")
        {
            if (null != Instance)
            {
                throw new NotSupportedException();
            }

            Instance = new AppViewModel(assembly, loadAppConfigStream, loadUserConfigStream, saveUserConfigStream, svgTextToImage, svgTextToClipboard, doOnUIThread, getSystemFonts, userConfigPath);
        }