示例#1
0
        private AppViewModel(AppViewModelParameters parameters)
        {
            if (null == parameters)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            ProgramTitle             = parameters.ProgramTitle;
            FullVersion              = parameters.FullVersion;
            ViewerConfig             = parameters.ViewerConfig ?? throw new ArgumentNullException(nameof(parameters.ViewerConfig));
            DoOnUIThread             = parameters.DoOnUIThread ?? throw new ArgumentNullException(nameof(parameters.DoOnUIThread));
            TextToClipboard          = parameters.TextToClipboard ?? throw new ArgumentNullException(nameof(parameters.TextToClipboard));
            EngineWrapper            = parameters.EngineWrapper;
            InternalGameEngineConfig = parameters.InternalGameEngineConfig;

            try
            {
                EngineWrapper?.StartEngine();
            }
            catch (Exception ex)
            {
                EngineWrapper?.StopEngine();
                EngineWrapper          = null;
                EngineExceptionOnStart = ex;
            }

            if (null == EngineWrapper)
            {
                // No engine started, use an internal one
                EngineWrapper = new InternalEngineWrapper($"{ProgramTitle} v{FullVersion}", InternalGameEngineConfig);
                EngineWrapper.StartEngine();
            }

            // Now that the engine is started, load user options from viewer config
            InternalGameEngineConfig.CopyOptionsFrom(ViewerConfig.InternalGameEngineConfig);
        }