public static void SetUserMessage(this Controller vc, UserMessageType messageType, string messageText) { // vc.ViewBag.MessageType = messageType; // vc.ViewBag.MessageValue = messageText; vc.TempData["messageValue"] = messageText; vc.TempData["messageType"] = messageType; }
protected void RaiseMessage(string message, UserMessageType userMessageType) { if (MessageRaised != null) { MessageRaised(this, new UserMessageEventArgs(message, userMessageType)); } }
/// <summary> /// Displays a message to the user about any possible errors, warnings and the randomizantion process /// </summary> /// <param name="message">The message to be printed</param> /// <param name="messagetype">The type of message: Error, waring, information or sucess</param> private void PrintUserMessage(string message, UserMessageType messagetype = UserMessageType.Information) { // Create label with the message Label messagelabel = new Label() { Font = this.Font, AutoSize = true, Dock = DockStyle.Top, Text = message }; // Set the color based on the "severity" of the message switch (messagetype) { case UserMessageType.Sucess: messagelabel.ForeColor = Color.Green; break; case UserMessageType.Warning: messagelabel.ForeColor = Color.DarkOrange; break; case UserMessageType.Error: messagelabel.ForeColor = Color.Red; break; } // Print the message this.MessagesFlowPanel.Controls.Add(messagelabel); this.MessagesFlowPanel.VerticalScroll.Value = this.MessagesFlowPanel.VerticalScroll.Maximum; }
public UserMessage(string title, string message, UserMessageType messageType) { this.CreatedDateTimeUtc = DateTime.UtcNow; this.Title = title; this.Message = message; this.MessageType = messageType; }
public async Task <IActionResult> Edit(int id, [Bind("UserMessageTypeId,UserMessageTypeName")] UserMessageType userMessageType) { if (id != userMessageType.UserMessageTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userMessageType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserMessageTypeExists(userMessageType.UserMessageTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userMessageType)); }
/// <summary> /// 给多个用户发通知 /// </summary> /// <param name="userNames">用户名</param> /// <param name="messagetype">消息类型</param> /// <param name="title">标题</param> /// <param name="contents">内容</param> public NotificationManager(string[] userNames, UserMessageType messagetype, string title, string contents) { if (userNames != null && userNames.Count() > 0) { notifications = new List <UserNotification>(); var userId = ""; foreach (var item in userNames) { userId = getUserId(item); if (!string.IsNullOrEmpty(userId)) { notifications.Add(new UserNotification { Title = title, MessageType = messagetype, Contents = contents, CreationDate = DateTime.Now, IsDelete = false, IsRead = false, UserId = userId, UserName = item }); } } } }
public void NotifyUserMessaged(string message, UserMessageType type) { if (UserMessaged != null) { UserMessaged(this, new UserMessagedEventArgs(message, type)); } }
public static byte UserMessageTypeToByte(DemoInfo demoInfo, UserMessageType m) { if (demoInfo.UserMessageTypesReverseLookup.TryGetValue(m, out int i)) { return((byte)i); } throw new ArgumentException($"no user message found for {m}"); }
public void AddMessage(string message, UserMessageType type) { m_messages.Add(new UserMessage(message, type)); if (m_messageAdded != null) { m_messageAdded(new UserMessageEventArgs(message, type)); } }
/* Okay, this is pretty wacky. First I read a byte, and based off of that I try to determine the type of * user message. If I don't have a lookup list for whatever game this is or the type seems bogus, I log an * error. Otherwise, create the message instance, and if it's not empty, try to parse it. If parsing fails, * log an error. Finally, if not all bits of the message are parsed, then it's likely that I did something * wrong, (since it seems like the user messages use up all the bits in the message) so log an error. */ protected override void Parse(ref BitStreamReader bsr) { byte typeVal = bsr.ReadByte(); MessageType = UserMessage.ByteToUserMessageType(DemoInfo, typeVal); uint messageLength = bsr.ReadUInt(DemoInfo.UserMessageLengthBits); string?errorStr = null; var uMessageReader = bsr.SplitAndSkip(messageLength); switch (MessageType) { case UserMessageType.Unknown: errorStr = $"There is no SvcUserMessage list for this game, type {typeVal} was found"; break; case UserMessageType.Invalid: errorStr = $"SvcUserMessage with value {typeVal} is invalid"; break; default: UserMessage = SvcUserMessageFactory.CreateUserMessage(DemoRef, MessageType) !; if (UserMessage == null) { errorStr = $"Unimplemented SvcUserMessage: {MessageType}"; _unimplemented = true; } else { try { // empty messages might still have 1-2 bytes, might need to do something 'bout that if (UserMessage.ParseStream(uMessageReader) != 0) { errorStr = $"{GetType().Name} - {MessageType} ({typeVal}) didn't parse all bits"; } } catch (Exception e) { errorStr = $"{GetType().Name} - {MessageType} ({typeVal}) " + $"threw exception during parsing, message: {e.Message}"; } } break; } #region error logging // if parsing fails, just convert to an unknown type - the byte array that it will print is still useful if (errorStr != null) { int rem = uMessageReader.BitsRemaining; DemoRef.LogError($"{errorStr}, ({rem} bit{(rem == 1 ? "" : "s")}) - " + $"{uMessageReader.FromBeginning().ToHexString()}"); UserMessage = new UnknownUserMessage(DemoRef); UserMessage.ParseStream(uMessageReader); } #endregion }
/// <summary> /// Adds a message to the user's user message alerts (top) /// </summary> /// <param name="controller"></param> /// <param name="title"></param> /// <param name="message"></param> /// <param name="userMessageType"></param> public static void AddUserMessage(this System.Web.Mvc.TempDataDictionary tempData, string title, string message, UserMessageType userMessageType) { if (!tempData.ContainsKey("UserMessages")) { tempData.Add("UserMessages", new List<UserMessage>()); } List<UserMessage> userMessages = (List<UserMessage>)tempData["UserMessages"]; userMessages.Add(new UserMessage(title, message, userMessageType)); }
public static UserMessage Create(string message = "", string title = "", UserMessageType type = UserMessageType.Info) { return(new UserMessage { Message = message, Title = title, Type = type }); }
/// <summary> /// Adds a message to the footer message alerts (bottom) /// </summary> /// <param name="controller"></param> /// <param name="title"></param> /// <param name="message"></param> /// <param name="userMessageType"></param> public virtual void AddUserMessageBottom(string title, string message, UserMessageType userMessageType) { if (!this.TempData.ContainsKey("UserMessagesBottom")) { this.TempData.Add("UserMessagesBottom", new List <UserMessage>()); } List <UserMessage> userMessagesBottom = (List <UserMessage>) this.TempData["UserMessagesBottom"]; userMessagesBottom.Add(new UserMessage(title, message, userMessageType)); }
public async Task <IActionResult> Create([Bind("UserMessageTypeId,UserMessageTypeName")] UserMessageType userMessageType) { if (ModelState.IsValid) { _context.Add(userMessageType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userMessageType)); }
//[Transaction] public void SaveMessage(string fromUser, string message, UserMessageType type, string toUser) { var userMessage = new UserMessage { From = fromUser, To = toUser, Message = message, Type = type, CreatedAt = DateTime.Now, Checked = false, }; //userMessageDao.Add(userMessage); }
public void AddMessage(UserMessageType type, string message, string title) { var messages = new List <UserMessageModel> { new UserMessageModel() { Message = message, Title = title, Type = type } }; TempData["Notifications"] = messages; }
public static void AddUserMessage(HttpContext context,string title, UserMessageType type, string message) { IList<UserMessage> messages; if (!context.Items.ContainsKey("UserMessage")) { messages = new List<UserMessage>(); } else { messages = (List<UserMessage>)context.Items["UserMessage"]; } messages.Add(new UserMessage() { Message = message, Title = title, Type = type }); }
public static UserMessage?CreateUserMessage( SourceDemo?demoRef, UserMessageType messageType) { if (EmptyMessages.Contains(messageType)) { return(new EmptyUserMessage(demoRef)); } return(messageType switch { UserMessageType.CloseCaption => new CloseCaption(demoRef), UserMessageType.AchievementEvent => new AchievementEvent(demoRef), UserMessageType.SayText2 => new SayText2(demoRef), UserMessageType.Shake => new Shake(demoRef), UserMessageType.Fade => new Fade(demoRef), UserMessageType.Damage => new Damage(demoRef), UserMessageType.Rumble => new Rumble(demoRef), UserMessageType.ResetHUD => new ResetHUD(demoRef), UserMessageType.LogoTimeMsg => new LogoTimeMsg(demoRef), UserMessageType.Battery => new Battery(demoRef), UserMessageType.Geiger => new Geiger(demoRef), UserMessageType.KillCam => new KillCam(demoRef), UserMessageType.EntityPortalled => new EntityPortalled(demoRef), UserMessageType.HUDMsg => new HudMsg(demoRef), UserMessageType.KeyHintText => new KeyHintText(demoRef), UserMessageType.Train => new Train(demoRef), UserMessageType.VGUIMenu => new VguiMenu(demoRef), UserMessageType.TextMsg => new TextMsg(demoRef), UserMessageType.PortalFX_Surface => new PortalFxSurface(demoRef), UserMessageType.VoiceMask => new VoiceMask(demoRef), UserMessageType.SayText => new SayText(demoRef), UserMessageType.MPMapCompleted => new MpMapCompleted(demoRef), UserMessageType.MPMapIncomplete => new MpMapIncomplete(demoRef), UserMessageType.MPMapCompletedData => new MpMapCompletedData(demoRef), UserMessageType.MPTauntEarned => new MpTauntEarned(demoRef), UserMessageType.MPTauntLocked => new MpTauntLocked(demoRef), UserMessageType.HudText => new HudText(demoRef), UserMessageType.PaintWorld => new PaintWorld(demoRef), UserMessageType.PaintEntity => new PaintEntity(demoRef), UserMessageType.HapSetConst => new HapSetConstForce(demoRef), UserMessageType.HapSetDrag => new HapSetDrag(demoRef), UserMessageType.HapPunch => new HapPunch(demoRef), UserMessageType.SPHapWeapEvent => new SpHapWeaponEvent(demoRef), _ => null // I do a check for this so that I don't have to allocate the unknown type twice });
/// <summary> /// Инициализация таблицы "Типы пользовательских сообщений" /// </summary> /// <param name="serviceProvider"></param> /// <param name="configuration"></param> /// <returns></returns> public static async Task CreateUserMessageTypes(IServiceProvider serviceProvider, IConfiguration configuration) { using (var serviceScope = serviceProvider.GetRequiredService <Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope()) { AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>(); #region Инициализация таблицы "Типы пользовательских сообщений" if (!await context.UserMessageTypes.AnyAsync()) { var mt01 = new UserMessageType { UserMessageTypeId = 1, UserMessageTypeName = "Простое сообщение" }; var mt02 = new UserMessageType { UserMessageTypeId = 2, UserMessageTypeName = "Информирование" }; var mt03 = new UserMessageType { UserMessageTypeId = 3, UserMessageTypeName = "Задание по дисциплине" }; await context.UserMessageTypes.AddRangeAsync( mt01, mt02, mt03 ); await context.SaveChangesAsync(); } #endregion } }
public UserMessage(string message, UserMessageType messageType) { Message = message; MessageType = messageType; }
public UserMessage() { Message = string.Empty; MessageType = UserMessageType.Information; }
/// <summary> /// Конструирует обхект сообщения. /// </summary> /// <param name="dateTime">Дата время сообщения.</param> /// <param name="type">Тип сообщения.</param> /// <param name="text"></param> public UserMessage(DateTime dateTime, UserMessageType type, string text) { DateTime = dateTime; Type = type; Text = text; }
public void ShowMessage(string message, UserMessageType messageType, bool stubborn) { ShowMessage(message, messageType); }
public void DetectType() { string text = Text.ToLower().Trim(); if (text.IsUrl()) { Type = UserMessageType.Url; return; } else if (text.IsEmail()) { Type = UserMessageType.Email; return; } else if (text.EndsWith("=?")) { Text = text.GetFromBeginTo("="); Type = UserMessageType.MathExpression; return; } else if (text.IsYouTubeUrl() || text.IsYouTubeWatchUrl()) { Type = UserMessageType.YouTubeUrl; return; } else if (text.Contains("?")) { if (text.EndsWith("?")) { Type = UserMessageType.Question; return; } else { string _endToken = text.GetFromEndTo("?"); if (_endToken.IsLangCode()) { Type = UserMessageType.Translate; return; } else if (_endToken.IsCurrencyCode()) { Type = UserMessageType.ChangeCurrency; return; } } } else if (text.StartsWith("search")) { Type = UserMessageType.Search; return; } else if (text.StartsWith("#")) { Type = UserMessageType.DatabaseCommand; return; } else if (text.StartsWith("image")) { Type = UserMessageType.ImageSearch; return; } else if (text == "hi") { Type = UserMessageType.SayHello; return; } else if (text == "bye") { Type = UserMessageType.SayGoodbye; return; } else { Type = UserMessageType.Other; return; } }
public UserMessage(UserMessageType type, string message) { Type = type; Message = message; }
public void ShowMessage(string message, UserMessageType messageType) { Console.WriteLine(message + " " + messageType); }
public UserMessagedEventArgs(string message, UserMessageType type) { Message = message; Type = type; }
public void ShowMessage(string msg, UserMessageType type) { Dialog.ShowMessage(msg, type); }
/// <summary> /// Add a message to the list /// </summary> /// <param name="message">The message to add</param> /// <param name="type">The type of user message</param> public void AddMessage(string message, UserMessageType type) { m_messages.Add(new UserMessage(message, type)); }
/// <summary> /// .ctor /// </summary> /// <param name="message">Single message for the builder</param> /// <param name="type"></param> public UserMessageBuilder(string message, UserMessageType type) : this() { m_messages.Add(new UserMessage(message, type)); }
private void ShowMessage(string message, UserMessageType messageType) { Scout.Core.UserInteraction.Dialog.ShowMessage(message, messageType); }
/// <summary> /// Adds a message to the footer message alerts (bottom) /// </summary> /// <param name="controller"></param> /// <param name="title"></param> /// <param name="message"></param> /// <param name="userMessageType"></param> public virtual void AddUserMessageBottom(string title, string message, UserMessageType userMessageType) { if (!this.TempData.ContainsKey("UserMessagesBottom")) { this.TempData.Add("UserMessagesBottom", new List<UserMessage>()); } List<UserMessage> userMessagesBottom = (List<UserMessage>)this.TempData["UserMessagesBottom"]; userMessagesBottom.Add(new UserMessage(title, message, userMessageType)); }