示例#1
0
        public ViewerConfigViewModel(ViewerConfig config = null, Action <ViewerConfig> callback = null)
        {
            Config = null != config?config.Clone() : new ViewerConfig();

            Accepted = false;
            Callback = callback;
        }
示例#2
0
        public static void Init(ViewerConfig viewerConfig, DoOnUIThread doOnUIThread)
        {
            if (null != Instance)
            {
                throw new NotSupportedException();
            }

            Instance = new AppViewModel(viewerConfig, doOnUIThread);
        }
示例#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();
            }
        }
示例#4
0
        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;
        }
示例#5
0
        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);
        }
示例#6
0
 public ViewerConfigMessage(ViewerConfig config = null, Action <ViewerConfig> callback = null) : base()
 {
     ViewerConfigVM = new ViewerConfigViewModel(config, callback);
 }