public ViewerConfigViewModel(ViewerConfig config = null, Action <ViewerConfig> callback = null) { Config = null != config?config.Clone() : new ViewerConfig(); Accepted = false; Callback = callback; }
public static void Init(ViewerConfig viewerConfig, DoOnUIThread doOnUIThread) { if (null != Instance) { throw new NotSupportedException(); } Instance = new AppViewModel(viewerConfig, doOnUIThread); }
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 void CopyFrom(ViewerConfig config) { if (null == config) { throw new ArgumentNullException("config"); } EngineCommandLine = config.EngineCommandLine; EngineType = config.EngineType; HexOrientation = config.HexOrientation; NotationType = config.NotationType; DisablePiecesInHandWithNoMoves = config.DisablePiecesInHandWithNoMoves; DisablePiecesInPlayWithNoMoves = config.DisablePiecesInPlayWithNoMoves; HighlightTargetMove = config.HighlightTargetMove; HighlightValidMoves = config.HighlightValidMoves; HighlightLastMovePlayed = config.HighlightLastMovePlayed; BlockInvalidMoves = config.BlockInvalidMoves; RequireMoveConfirmation = config.RequireMoveConfirmation; }
public ViewerConfig Clone() { ViewerConfig clone = new ViewerConfig { EngineCommandLine = EngineCommandLine, EngineType = EngineType, HexOrientation = HexOrientation, NotationType = NotationType, DisablePiecesInHandWithNoMoves = DisablePiecesInHandWithNoMoves, DisablePiecesInPlayWithNoMoves = DisablePiecesInPlayWithNoMoves, HighlightTargetMove = HighlightTargetMove, HighlightValidMoves = HighlightValidMoves, HighlightLastMovePlayed = HighlightLastMovePlayed, BlockInvalidMoves = BlockInvalidMoves, RequireMoveConfirmation = RequireMoveConfirmation }; return(clone); }
public ViewerConfigMessage(ViewerConfig config = null, Action <ViewerConfig> callback = null) : base() { ViewerConfigVM = new ViewerConfigViewModel(config, callback); }