public static void Init(ViewerConfig viewerConfig, DoOnUIThread doOnUIThread) { if (null != Instance) { throw new NotSupportedException(); } Instance = new AppViewModel(viewerConfig, doOnUIThread); }
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); }
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(); } }
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); }