Exemplo n.º 1
0
 /// <summary>
 /// Update text with message color defined as green/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="Text">
 /// Message
 /// </param>
 /// <param name="tom">
 /// Type of Message
 /// </param>
 public static void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
 {
     if (splashScreen != null)
     {
         splashScreen.UdpateStatusTextWithStatus(Text, tom);
     }
 }
Exemplo n.º 2
0
 public static void UpdateStatusTextWithStatus(int iIndex, string Text, TypeOfMessage objTypeOfMessage)
 {
     if (null != m_objDialogLoadingWindow)
     {
         m_objDialogLoadingWindow.UpdateStatusTextWithStatus(iIndex, Text, objTypeOfMessage);
     }
 }
        public void BuildMessageList(string Msg, TypeOfMessage typeOfMsg, ref List <MessagesExt> ListOfMsgs)
        {
            MessagesExt m = new MessagesExt()
            {
                Message   = Msg,
                TypeOfMsg = typeOfMsg
            };

            //switch (typeOfMsg)
            //{
            //    case TypeOfMessage.Information:
            //        m.Css = "text-info";
            //        break;
            //    case TypeOfMessage.Success:
            //        m.Css = "text-success";
            //        break;
            //    case TypeOfMessage.Warning:
            //        m.Css = "text-warning";
            //        break;
            //    case TypeOfMessage.Error:
            //        m.Css = "text-danger";
            //        break;
            //    default:
            //        break;
            //}

            if (ListOfMsgs.Count == 0)
            {
                ListOfMsgs = new List <MessagesExt>();
            }

            ListOfMsgs.Add(m);
        }
Exemplo n.º 4
0
 public ChatMessage(string name, string message, TypeOfMessage typeOfMessage)
 {
     Username      = name;
     Text          = message;
     TypeOfMessage = typeOfMessage;
     CreatedUtc    = DateTime.Now;
 }
Exemplo n.º 5
0
        public async Task SendMessageToAllChat(string username, string message, TypeOfMessage typeOfMessage = TypeOfMessage.Chat)
        {
            var user = _users.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);

            Regex regex = new Regex(@"^/(slap|buzz|alert) ([A-Za-z0-9\s]*)$");
            Match match = regex.Match(message);

            if (match.Success)
            {
                var targetedUsername = match.Groups[2].Value;
                var targetedUser     = _users.FirstOrDefault(x => x.Name == targetedUsername);
                if (targetedUser != null)
                {
                    await Clients.Client(targetedUser.ConnectionId).SendAsync("BuzzPlayer");
                    await SendMessageToAllChat("Server", $"User {user.Name} has buzzed player {targetedUser.Name} ", TypeOfMessage.Server);
                }
                else
                {
                    await SendMessageToAllChat("Server", $"Player not found", TypeOfMessage.Server);
                }
                return;
            }

            var msg = new ChatMessage(username, message, typeOfMessage);
            await Clients.All.SendAsync("SendMessageToAllChat", msg);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Update text with message color defined as green/yellow/red/ for success/warning/failure
        /// </summary>
        /// <param name="Text">Message</param>
        /// <param name="tom">Type of Message</param>
        public void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new StringParameterWithStatusDelegate(UdpateStatusTextWithStatus), new object[] { Text, tom });
                return;
            }
            // Must be on the UI thread if we've got this far
            switch (tom)
            {
            case TypeOfMessage.Error:
                //rtBox.ForeColor = Color.Red;
                //rtBox.SelectionFont = new Font("微软雅黑", 12);
                rtBox.SelectionColor = Color.Red;

                break;

            case TypeOfMessage.Warning:
                //rtBox.ForeColor = Color.Yellow;
                //rtBox.SelectionFont = new Font("微软雅黑", 12);
                rtBox.SelectionColor = Color.Yellow;
                break;

            case TypeOfMessage.Success:
                //rtBox.ForeColor = Color.Green;
                //rtBox.SelectionFont = new Font("微软雅黑", 12);
                rtBox.SelectionColor = Color.Green;
                break;
            }
            rtBox.HideSelection = false;
            rtBox.AppendText(Text + "\r\n");
            rtBox.Focus();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Update text with message color defined as green/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="Text">Message</param>
 /// <param name="tom">Type of Message</param>
 public static void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
 {
     if (sf != null)
     {
         sf.UdpateStatusTextWithStatus(Text, tom);
     }
 }
Exemplo n.º 8
0
        protected override void ExecuteBasedOnType(byte[] bytes, TypeOfMessage type, IPEndPoint refEp)
        {
            switch (type)
            {
            case TypeOfMessage.CreateGame:
                CreateGameResponse(bytes, refEp);
                break;

            case TypeOfMessage.Registration:
                RegistrationResponse(bytes, refEp);
                break;

            case TypeOfMessage.RequestGameList:
                RequestGameListResponse(bytes, refEp);
                break;

            case TypeOfMessage.RequestGameListReply:
                RequestGameListResponse(bytes, refEp);
                break;

            case TypeOfMessage.StartGame:
                StartGameResponse(bytes, refEp);
                break;

            case TypeOfMessage.JoinGame:
                JoinGameResponse(bytes, refEp);
                break;
            }
        }
Exemplo n.º 9
0
 public Notification(string message,
                     string reference,
                     object value,
                     TypeOfMessage type)
     : this(null, message, reference, value, type)
 {
 }
Exemplo n.º 10
0
        public void UdpateStatusTextWithStatus(string text, TypeOfMessage tom)
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new StringParameterWithStatusDelegate(UdpateStatusTextWithStatus), text, tom);
                return;
            }
            // Must be on the UI thread if we've got this far
            switch (tom)
            {
            case TypeOfMessage.Error:
                label2.ForeColor = Color.Red;
                break;

            case TypeOfMessage.Warning:
                label2.ForeColor = Color.Yellow;
                break;

            case TypeOfMessage.Success:
                label2.ForeColor = Color.Green;
                break;
            }
            label2.Text = text;
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Update text with message color defined as green/yellow/red/ for success/warning/failure
        /// </summary>
        /// <param name="Text">Message</param>
        /// <param name="tom">Type of Message</param>
        public void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new StringParameterWithStatusDelegate(UdpateStatusTextWithStatus), new object[] { Text, tom });
                return;
            }
            // Must be on the UI thread if we've got this far
            switch (tom)
            {
            case TypeOfMessage.Error:
                LoadingStatus.ForeColor = Color.Red;
                break;

            case TypeOfMessage.Warning:
                LoadingStatus.ForeColor = Color.Yellow;
                break;

            case TypeOfMessage.Success:
                LoadingStatus.ForeColor = Color.Black;
                break;
            }
            LoadingStatus.Text = Text;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Update text with message color defined as green/yellow/red/ for success/warning/failure
        /// </summary>
        /// <param name="Text">Message</param>
        /// <param name="tom">Type of Message</param>
        public void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new StringParameterWithStatusDelegate(UdpateStatusTextWithStatus), new object[] { Text, tom });
                return;
            }
            // Must be on the UI thread if we've got this far
            switch (tom)
            {
            case TypeOfMessage.Error:
                label1.ForeColor = options.ErrorColor;
                break;

            case TypeOfMessage.Warning:
                label1.ForeColor = options.WarningColor;
                break;

            case TypeOfMessage.Success:
                label1.ForeColor = options.SuccessColor;
                break;
            }
            label1.Text = Text;
        }
Exemplo n.º 13
0
 public ChatMessage(string user, string text, TypeOfMessage typeOfMessage)
 {
     this.Username      = user;;
     this.Text          = text;
     this.TypeOfMessage = typeOfMessage;
     this.CreatedUtc    = DateTime.UtcNow;
 }
Exemplo n.º 14
0
 public static void OnBroadcastMessage(string eventName, TypeOfMessage type)
 {
     if (type == TypeOfMessage.requireReceiver && !tableName.ContainsKey(eventName))
     {
         throw new BroadcasterInner.MessageException(string.Format("Sending message {0} but no listener found.", eventName));
     }
 }
Exemplo n.º 15
0
        public void UpdateStatusTextWithStatus(int iIndex, string Text, TypeOfMessage objTypeOfMessage)
        {
            if (100 <= iIndex)
            {
                iIndex = 99;
            }
            if (InvokeRequired)
            {
                BeginInvoke(new StringParamterWithStatusDelegate(UpdateStatusTextWithStatus), new object[] { iIndex, Text, objTypeOfMessage });
                return;
            }

            switch (objTypeOfMessage)
            {
            case TypeOfMessage.Success:
                labelMessage.ForeColor = Color.Green;
                break;

            case TypeOfMessage.Warning:
                labelMessage.ForeColor = Color.Yellow;
                break;

            case TypeOfMessage.Error:
                labelMessage.ForeColor = Color.Red;
                break;
            }
            labelMessage.Text  = Text;
            progressBar1.Value = iIndex;

            this.pictureProgress.Refresh();
            Application.DoEvents();
            //this.labelPercent.Text = string.Format( "{0:D3} %", iIndex );
        }
Exemplo n.º 16
0
        public void VerbosityHighLoggerTest(string message, TypeOfMessage type)
        {
            ConsoleLogger _logger = new ConsoleLogger(Verbosity.VerbosityTypes.high, new ConsoleConfiguration());


            var formatedMessage = _logger.BuildMessage(message, type);

            // as JobLogger verbosity is high,
            //should log any message
            Assert.True(formatedMessage != string.Empty);
        }
Exemplo n.º 17
0
        public void VerbosityLowLoggerTest(string message, TypeOfMessage type)
        {
            ConsoleLogger _logger         = new ConsoleLogger(Verbosity.VerbosityTypes.low, new ConsoleConfiguration());
            var           formatedMessage = _logger.BuildMessage(message, type);

            //BuildMessage return empty if  verbosity of the message isn't into JobLogger profile
            if (type == TypeOfMessage.message)
            {
                Assert.True(formatedMessage != string.Empty);
            }
        }
Exemplo n.º 18
0
        public void VerbosityMediumLoggerTest(string message, TypeOfMessage type)
        {
            ConsoleLogger _logger = new ConsoleLogger(Verbosity.VerbosityTypes.high, new ConsoleConfiguration());

            var formatedMessage = _logger.BuildMessage(message, type);

            if (type == TypeOfMessage.message || type == TypeOfMessage.warning)
            {
                Assert.True(formatedMessage != string.Empty);
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Update text with message color defined as green/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="text">Message</param>
 /// <param name="tom">Type of Message</param>
 public static void UpdateStatusTextWithStatus(string text, TypeOfMessage tom)
 {
     try
     {
         if (_sf != null)
         {
             _sf.UdpateStatusTextWithStatus(text, tom);
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 20
0
        protected override void ExecuteBasedOnType
            (byte[] bytes, TypeOfMessage type, IPEndPoint refEp)
        {
            switch (type)
            {
            case TypeOfMessage.ConnectGameServerMsg:
                ConnectGameServerResponse(bytes, refEp);
                break;

            case TypeOfMessage.SelectCard:
                SelectCardResponse(bytes);
                break;

            default:
                break;
            }
        }
Exemplo n.º 21
0
        public static void SendEvent(string eventName, TypeOfMessage messageType)
        {
            BroadcasterInner.OnBroadcastMessage(eventName, messageType);
            Delegate type;

            if (tableName.TryGetValue(eventName, out type))
            {
                Call c = type as Call;
                if (c != null)
                {
                    c();
                }
                else
                {
                    throw BroadcasterInner.GenerateMessageException(eventName);
                }
            }
        }
Exemplo n.º 22
0
        public virtual string BuildMessage(string message, TypeOfMessage type)
        {
            var formatedMessage = "";

            //we check if the param is a valid message
            ValidateMessage(message);
            //check if we have to log this type of message
            if (VerbosityMapping[Verbosity].Contains(type))
            {
                // take off any blank space
                var _trimmedMessage = message.Trim();
                //give format
                formatedMessage = string.Format("{0} : {1} - {2}",
                                                DateTime.Now.ToShortDateString(),
                                                type.ToString(),
                                                _trimmedMessage);
            }
            return(formatedMessage);
        }
Exemplo n.º 23
0
        private string GetTitle(TypeOfMessage typeOfMessage)
        {
            switch (typeOfMessage)
            {
            case TypeOfMessage.Error:
                return(CustomMessages.Error);

            case TypeOfMessage.Information:
                return(CustomMessages.Information);

            case TypeOfMessage.Warning:
                return(CustomMessages.Warning);

            case TypeOfMessage.Question:
                return(CustomMessages.AcceptionAction);

            default:
                return(string.Empty);
            }
        }
 /// <summary>
 /// Update text with message color defined as green/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="Text">Message</param>
 /// <param name="tom">Type of Message</param>
 public static void UpdateStatusTextWithStatus(string Text, TypeOfMessage tom)
 {
     while (sf == null)
     {
         Thread.Sleep(20);                // Wait for this to work...
     }
     while (sf.Opacity != 1)
     {
         Thread.Sleep(20);                     // Wait for it to show.
     }
     if (sf != null)
     {
         sf.UpdateStatusTextWithStatus(Text, tom);
         if (tom == TypeOfMessage.Error)
         {
             sf.Progress.EndColor   = Color.FromArgb(211, 0, 0);
             sf.Progress.StartColor = Color.FromArgb(211, 0, 0);
         }
     }
 }
Exemplo n.º 25
0
        protected override void ExecuteBasedOnType(byte[] bytes, TypeOfMessage type, IPEndPoint refEp)
        {
            Debug.WriteLine("TYPE:" + type);
            switch (type)
            {
            case TypeOfMessage.LobbyHeartbeat:
                LobbyHeartBeatResponse(bytes, refEp);
                break;

            case TypeOfMessage.ConnectInfoMsg:
                ConnectInfoResponse(bytes, refEp);
                break;

            case TypeOfMessage.PassCard:
                PassCardResponse(bytes, refEp);
                break;

            default:
                EnqueueMessage(bytes);
                break;
            }
        }
Exemplo n.º 26
0
        public async Task SendMessageToAllChat(string username, string message, TypeOfMessage typeOfMessage = TypeOfMessage.Chat)
        {
            var user = _users.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);

            Regex regex = new Regex(@"^/(slap|buzz|alert) ([A-Za-z0-9\s]*)$");
            Match match = regex.Match(message);

            if (match.Success)
            {
                var targetedUsername = match.Groups[2].Value;
                var targetedUser     = _users.FirstOrDefault(x => x.Name == targetedUsername);

                if (targetedUser != null)
                {
                    var canBeBuzzedAfter = targetedUser.LastBuzzedUtc.AddSeconds(Constants.MINIMUM_TIME_SECONDS_BETWEEN_BUZZ);
                    if (DateTime.Now > canBeBuzzedAfter)
                    {
                        targetedUser.LastBuzzedUtc = DateTime.Now;
                        await Clients.Client(targetedUser.ConnectionId).SendAsync("BuzzPlayer");
                        await SendMessageToAllChat("Server", $"User {user.Name} has buzzed player {targetedUser.Name} ", TypeOfMessage.Server);
                    }
                    else
                    {
                        var msgDto = new ChatMessage("Server", $"User {targetedUser.Name} was not buzzed! Wait {Constants.MINIMUM_TIME_SECONDS_BETWEEN_BUZZ} seconds.", TypeOfMessage.Server);
                        await Clients.Caller.SendAsync("SendMessageToAllChat", msgDto);
                    }
                }
                else
                {
                    var msgDto = new ChatMessage("Server", $"User {targetedUsername} was not found!", TypeOfMessage.Server);
                    await Clients.Caller.SendAsync("SendMessageToAllChat", msgDto);
                }
                return;
            }

            var msg = new ChatMessage(username, message, typeOfMessage);
            await Clients.All.SendAsync("SendMessageToAllChat", msg);
        }
Exemplo n.º 27
0
        public void UpdateStatusTextWithStatus(string Text, TypeOfMessage tom)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new StringParameterWithStatusDelegate(UpdateStatusTextWithStatus), new object[] { Text, tom });
                return;
            }
            switch (tom)
            {
            case TypeOfMessage.Error:
                label1.ForeColor = Color.Red;
                break;

            case TypeOfMessage.Warning:
                label1.ForeColor = Color.Yellow;
                break;

            case TypeOfMessage.Success:
                label1.ForeColor = Color.AliceBlue;
                break;
            }
            label1.Text = Text;
        }
Exemplo n.º 28
0
        /// <summary>
        /// Update text with message color defined as green/yellow/red/ for success/warning/failure
        /// </summary>
        /// <param name="Text">Message</param>
        /// <param name="tom">Type of Message</param>
        public void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
        {
            if (InvokeRequired)
            {
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new StringParameterWithStatusDelegate(UdpateStatusTextWithStatus), new object[] { Text, tom });
                return;
            }
            // Must be on the UI thread if we've got this far
            switch (tom)
            {
                case TypeOfMessage.Error:
                    label1.ForeColor = Color.Red;
                    break;
                case TypeOfMessage.Warning:
                    label1.ForeColor = Color.Yellow;
                    break;
                case TypeOfMessage.Success:
                    label1.ForeColor = Color.Green;
                    break;
            }
            label1.Text = Text;

        }
Exemplo n.º 29
0
 /// <summary>
 /// Update text with message color defined as green/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="text">Message</param>
 /// <param name="tom">Type of Message</param>
 public static void UpdateStatusTextWithStatus(string text, TypeOfMessage tom)
 {
     try
     {
         if (_sf != null)
             _sf.UdpateStatusTextWithStatus(text, tom);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 30
0
 /// <summary>
 /// Update text with message color defined as white/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="Text">Message</param>
 /// <param name="tom">Type of Message</param>
 public void UdpateStatusTextWithStatus(string Text, TypeOfMessage tom)
 {
     if (InvokeRequired)
     {
         // We're not in the UI thread, so we need to call BeginInvoke
         BeginInvoke(new StringParameterWithStatusDelegate(this.UdpateStatusTextWithStatus), new object[] { Text, tom });
         return;
     }
     switch (tom)
     {
         case TypeOfMessage.Error:
             this.labelStatus.ForeColor = Color.Red;
             break;
         case TypeOfMessage.Warning:
             this.labelStatus.ForeColor = Color.Yellow;
             break;
         case TypeOfMessage.Success:
             this.labelStatus.ForeColor = Color.AntiqueWhite;
             break;
     }
     this.labelStatus.Text = Text;
 }
Exemplo n.º 31
0
 public void AddNotification(string message, string reference, object value, TypeOfMessage type)
 {
     this._notifications.Add(new Notification(message, reference, value, type));
 }
Exemplo n.º 32
0
 public void AddNotification(string message, TypeOfMessage type)
 {
     this._notifications.Add(new Notification(message, type));
 }
Exemplo n.º 33
0
 public CfgMessage(string cfgValue, TypeOfMessage type, int temp)
 {
     CfgValue    = cfgValue;
     MessageType = type;
     CfgCount    = temp;
 }
Exemplo n.º 34
0
 /// <summary>
 /// Update text with message color defined as green/yellow/red/ for success/warning/failure
 /// </summary>
 /// <param name="Text">Message</param>
 /// <param name="tom">Type of Message</param>
 public static void UdpateStatusTextWithStatus(string Text,TypeOfMessage tom)
 {
     if (sf != null)
         sf.UdpateStatusTextWithStatus(Text, tom);
 }