示例#1
0
        /// <summary>
        /// Property changes from the monitor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PropertyChangedMonitor(object sender, PropertyChangedEventArgs e)
        {
            try
            {
                ThreadContext.InvokeOnUiThread(
                    delegate
                {
                    switch (e.PropertyName)
                    {
                    case "CmdjSentEntry":
                        ProcessValues1(MonitorQueue.CmdjSentEntry);
                        break;

                    case "Cmdj2SentEntry":
                        ProcessValues2(MonitorQueue.Cmdj2SentEntry);
                        break;
                    }
                }, _ct);
            }
            catch (Exception ex)
            {
                var monitorItem = new MonitorEntry
                {
                    Datetime = HiResDateTime.UtcNow, Device = MonitorDevice.Server, Category = MonitorCategory.Interface, Type = MonitorType.Error, Method = MethodBase.GetCurrentMethod().Name, Thread = Thread.CurrentThread.ManagedThreadId, Message = $" {ex.Message}"
                };
                MonitorLog.LogToMonitor(monitorItem);

                OpenDialog(ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Removes the window.
        /// </summary>
        /// <param name="windowId">The window identifier.</param>
        /// <param name="coordX">The coord x.</param>
        /// <param name="coordY">The coord y.</param>
        public void RemoveWindow(long windowId, int coordX, int coordY)
        {
            var args = new GameWindowEventArgs(windowId, coordX, coordY);

            Tracer.Debug(string.Format("MapEditViewModel :: Window removed callback retrieved ({0})", args));
            ThreadContext.InvokeOnUiThread(() => this.WindowRemoved(this, args));
        }
示例#3
0
        /// <summary>
        /// Keeps the game alive.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param>
        private async void KeepGameAlive(object sender, ElapsedEventArgs e)
        {
            if (!this.currentGameId.Equals(Guid.Empty))
            {
                bool isGameRunning;
                try
                {
                    isGameRunning = await this.gameConsoleServiceClient.IsGameRunningAsync(this.currentGameId);
                }
                catch (ServerUnavailableException ex)
                {
                    ApplicationHelpers.HandleServerException(ex);
                    return;
                }
                catch (Exception ex)
                {
                    this.LogError(ex.Message, ex);
                    ThreadContext.InvokeOnUiThread(() => this.RunningGameDisappeared(this, null));
                    this.keepAliveTimer.Stop();
                    return;
                }

                if (isGameRunning)
                {
                    await Tracer.Debug(string.Format("Sent keepalive for the game with the id {0}. Game is still running.", this.currentGameId));
                }
                else
                {
                    await Tracer.Debug(string.Format("Sent keepalive for the game with the id {0}. Game is no longer running.", this.currentGameId));

                    ThreadContext.InvokeOnUiThread(() => this.RunningGameDisappeared(this, null));
                    this.keepAliveTimer.Stop();
                }
            }
        }
示例#4
0
        /// <summary>
        /// Updates the name.
        /// </summary>
        /// <param name="name">The name.</param>
        public void UpdateName(string name)
        {
            var args = new UpdateNameEventArgs(name);

            Tracer.Debug(string.Format("MapEditViewModel :: Name updated callback retrieved (Name={0})", args.Name));
            ThreadContext.InvokeOnUiThread(() => this.NameUpdated(this, args));
        }
示例#5
0
        /// <summary>
        /// Updates the is playable.
        /// </summary>
        /// <param name="isPlayable">if set to <c>true</c> the map is playable.</param>
        public void UpdateIsPlayable(bool isPlayable)
        {
            var args = new UpdateIsPlayableEventArgs(isPlayable);

            Tracer.Debug(string.Format("MapEditViewModel :: Is playable callback retrieved (Flag={0})", args.IsPlayable));
            ThreadContext.InvokeOnUiThread(() => this.IsPlayableUpdated(this, args));
        }
示例#6
0
        /// <summary>
        /// Removes the hole.
        /// </summary>
        /// <param name="windowId">The window identifier.</param>
        /// <param name="windowX">The window x.</param>
        /// <param name="windowY">The window y.</param>
        /// <param name="holeId">The hole identifier.</param>
        public void RemoveHole(long windowId, int windowX, int windowY, long holeId)
        {
            var args = new GameHoleClickedEventArgs(windowId, windowX, windowY, holeId);

            Tracer.Debug(string.Format("MapEditViewModel :: Hole removed callback retrieved ({0})", args));
            ThreadContext.InvokeOnUiThread(() => this.HoleRemoved(this, args));
        }
示例#7
0
        /// <summary>
        /// Starts the round.
        /// </summary>
        /// <param name="directionX">The direction x where user clicked to start the ball.</param>
        /// <param name="directionY">The direction y where user clicked to start the ball.</param>
        public void StartRound(double directionX, double directionY)
        {
            var args = new RoundStartedEventArgs(new Vector(directionX, directionY));

            ThreadContext.InvokeOnUiThread(() => this.OnRoundStarted(args));
        }
示例#8
0
        /// <summary>
        /// Sets the start point.
        /// </summary>
        /// <param name="windowId">The windows identifier.</param>
        /// <param name="pointX">The point x.</param>
        /// <param name="pointY">The point y.</param>
        public void SetStartPoint(long windowId, double pointX, double pointY)
        {
            var args = new BallPlacedOnGameFieldEventArgs(windowId, new Point(pointX, pointY));

            ThreadContext.InvokeOnUiThread(() => this.OnStartPointSet(args));
        }
示例#9
0
 /// <summary>
 /// Cancels the game.
 /// </summary>
 public void CancelGame()
 {
     ThreadContext.InvokeOnUiThread(() => this.GameCancelled(this, null));
 }
示例#10
0
 /// <summary>
 /// An error in the game ocurrs and the game has to be canceled by the client.
 /// </summary>
 public void GameError()
 {
     ThreadContext.InvokeOnUiThread(this.OnGameError);
 }
示例#11
0
        /// <summary>
        /// Starts the game with a specific id.
        /// </summary>
        /// <param name="gameId">The game identifier.</param>
        /// <param name="map">The map.</param>
        /// <param name="opponentName">Name of the opponent.</param>
        /// <param name="visibleWindows">The visible windows.</param>
        /// <param name="startGame">if set to <c>true</c> the player who receives this callback should start the game.</param>
        public void StartGame(Guid gameId, Map map, string opponentName, IEnumerable <long> visibleWindows, bool startGame)
        {
            var args = new GameStartedEventArgs(gameId, map.ToEntity(visibleWindows), opponentName, startGame);

            ThreadContext.InvokeOnUiThread(() => this.OnGameStarted(args));
        }
示例#12
0
        /// <summary>
        /// Ends the round.
        /// </summary>
        /// <param name="score">The current score over all player rounds.</param>
        /// <param name="wasFinalRound">if set to <c>true</c> this was the final round and the game should be finished.</param>
        public void EndRound(int score, bool wasFinalRound)
        {
            var args = new RoundEndedEventArgs(score, wasFinalRound);

            ThreadContext.InvokeOnUiThread(() => this.OnRoundEnded(args));
        }