public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { message = message.NotNulle() ? message.HtmlEncode() : (await output.GetChildContentAsync()).GetContent(); if (message.IsNulle() && header.IsNulle()) { return; } output.TagName = "div"; string bsTypeStr = AlertKind.Name(); icon = icon.NullIfEmptyTrimmed(); if (icon.IsNulle()) { icon = GetAlertIcon(); } if (dismissible) { bsTypeStr += " alert-dismissible"; } cssClass = string.Concat(cssClass, cssClass.IsNulle() ? null : " ", "alert alert-", bsTypeStr); output.Attributes.Add("class", cssClass); output.Attributes.Add("role", "alert"); StringBuilder sb = new StringBuilder(); if (dismissible) { sb.Append( "<button type =\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">\r\n" + " <span aria-hidden=\"true\">×</span>\r\n" + "</button>\r\n"); } if (header.IsNulle()) { sb.AppendLine($"<i class='fa fa-{icon}'></i> {message}"); } else { string headerText = !headerAsHtml?header.HtmlEncode() : header; sb.Append( $"<h3><i class='fa fa-{icon}'></i> {headerText}</h3>\r\n" + "<hr/>\r\n" + $"{message}\r\n"); } output.Content.SetHtmlContent(sb.ToString()); }
public AlertItem(AlertKind alertKind, string message, string title = null) { if (String.IsNullOrWhiteSpace(message)) { throw new ArgumentNullException(nameof(message)); } Kind = alertKind; Message = message; Title = title; }
public void Alert(string caption, string message = "", AlertKind alertKind = AlertKind.Primary) { Opacity = 0.0; StartPosition = FormStartPosition.Manual; string instance; for (int i = 1; i < 10; i++) { instance = "noty" + i.ToString(); Noty f = (Noty)Application.OpenForms[instance]; if (f == null) { this.Name = instance; _x = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15; _y = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i - 5 * i; Location = new Point(_x, _y); break; } } _x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5; Caption.Text = caption; Message.Text = message; switch (alertKind) { case AlertKind.Primary: Icon.Image = Resources.info; SetBackColor(93, 156, 236); // blue jeans SetBorderColor(74, 137, 220); // hover SetCaptionColor(21, 61, 115); break; case AlertKind.Secondary: Icon.Image = Resources.info; SetBackColor(101, 109, 120); // dark gray SetBorderColor(67, 74, 84); // hover SetCaptionColor(27, 30, 36); break; case AlertKind.Success: Icon.Image = Resources.success; SetBackColor(160, 212, 104); // grass SetBorderColor(140, 193, 82); // hover SetCaptionColor(49, 89, 5); break; case AlertKind.Info: Icon.Image = Resources.info; SetBackColor(79, 193, 233); // aqua SetBorderColor(59, 175, 218); // hover SetCaptionColor(12, 98, 130); break; case AlertKind.Warning: Icon.Image = Resources.warning; SetBackColor(255, 206, 84); // sunflower SetBorderColor(252, 187, 66); // hover SetCaptionColor(161, 107, 10); break; case AlertKind.Error: Icon.Image = Resources.error; SetBackColor(237, 85, 101); // grapefruit SetBorderColor(218, 68, 83); // hover SetCaptionColor(110, 21, 30); break; case AlertKind.Reminder: Icon.Image = Resources.warning; SetBackColor(252, 110, 81); // grapefruit SetBorderColor(233, 87, 63); // hover SetCaptionColor(135, 31, 14); break; default: Icon.Image = Resources.info; SetBackColor(93, 156, 236); // blue jeans SetBorderColor(74, 137, 220); // hover SetCaptionColor(32, 77, 138); break; } Show(); _action = ActionKind.Start; timer.Interval = 1; timer.Start(); }
public async Task AddAlert(AlertKind alertKind, string message, string title = null) { Queue.Add(new AlertItem(alertKind, message, title)); await OnItemsChanged.Invoke(); }
public void Alert(string caption, string message, AlertKind alertKind) { Noty n = new Noty(); n.Alert(caption, message, alertKind); }