Exemplo n.º 1
0
        public BrumAlert(string message, Color foregroundColor, Color backgroundColor, AlertType type, int delay, AlertLocation alertLocation)
        {
            InitializeComponent();
            lblMessage.Text    = message;
            this.alertLocation = alertLocation;

            switch (type)
            {
            case AlertType.Success:
                pbMain.Image = Resources.success_white;
                break;

            case AlertType.Info:
                pbMain.Image = Resources.info_white;
                break;

            case AlertType.Warning:
                pbMain.Image = Resources.warning_white;
                break;

            case AlertType.Error:
                pbMain.Image = Resources.error_white;
                break;

            default:
                throw new Exception("Unkown setting!");
            }
            BackColor            = backgroundColor;
            lblMessage.ForeColor = foregroundColor;

            Show();
            timerClose.Interval = delay;
            timerClose.Start();
        }
Exemplo n.º 2
0
        public static MvcHtmlString GetAlerts(this HtmlHelper helper, AlertType alertType, AlertLocation alertLocation)
        {
            var alertData = helper.ViewContext.TempData.InitializeAlertData();

            List<string> messages = alertData[alertLocation][alertType];
            if (messages.Count > 0)
            {
                var outerBuilder = new TagBuilder("div");
                outerBuilder.AddCssClass("container-fluid");
                foreach (var message in messages)
                {
                    var builder = new TagBuilder("div");
                    builder.AddCssClass("alert");
                    builder.AddCssClass("in");
                    builder.AddCssClass("fade");
                    builder.AddCssClass(alertType.GetDescription());

                    builder.SetInnerText(message);

                    var closeButton = new TagBuilder("a");
                    closeButton.AddCssClass("close");
                    closeButton.MergeAttribute("data-dismiss", "alert");
                    closeButton.MergeAttribute("href", "#");
                    closeButton.InnerHtml += "&times;";

                    builder.InnerHtml += closeButton.ToString(TagRenderMode.Normal);

                    outerBuilder.InnerHtml += builder.ToString(TagRenderMode.Normal);
                }
                return outerBuilder.ToString(TagRenderMode.Normal).ToMvcHtmlString();
            }

            return string.Empty.ToMvcHtmlString();
        }
        private static void AddMessage(TempDataDictionary tempData, AlertType type, string message,
            AlertLocation location)
        {
            var alertData = tempData.InitializeAlertData();

            alertData[location][type].Add(message);

            tempData["AlertData"] = alertData;
        }
Exemplo n.º 4
0
        private static void AddMessage(TempDataDictionary tempData, AlertType type, string message,
                                       AlertLocation location)
        {
            var alertData = tempData.InitializeAlertData();

            alertData[location][type].Add(message);

            tempData["AlertData"] = alertData;
        }
Exemplo n.º 5
0
        public BrumAlert(string message, Color foregroundColor, Color backgroundColor, Bitmap image, int delay, AlertLocation alertLocation)
        {
            InitializeComponent();
            lblMessage.Text    = message;
            this.alertLocation = alertLocation;

            pbMain.Image         = image;
            BackColor            = backgroundColor;
            lblMessage.ForeColor = foregroundColor;

            Show();
            timerClose.Interval = delay;
            timerClose.Start();
        }
Exemplo n.º 6
0
        public BrumAlert(string message, AlertType type, int delay, AlertLocation alertLocation)
        {
            InitializeComponent();
            lblMessage.Text    = message;
            this.alertLocation = alertLocation;

            switch (type)
            {
            case AlertType.Success:
                pbMain.Image         = Resources.success_white;
                BackColor            = Color.LimeGreen;
                ForeColor            = Color.White;
                lblMessage.ForeColor = Color.White;
                break;

            case AlertType.Info:
                pbMain.Image         = Resources.info_white;
                BackColor            = Color.DeepSkyBlue;
                ForeColor            = Color.White;
                lblMessage.ForeColor = Color.White;
                break;

            case AlertType.Warning:
                pbMain.Image         = Resources.warning_white;
                BackColor            = Color.Orange;
                ForeColor            = Color.White;
                lblMessage.ForeColor = Color.White;
                break;

            case AlertType.Error:
                pbMain.Image         = Resources.error_white;
                BackColor            = Color.Crimson;
                ForeColor            = Color.WhiteSmoke;
                lblMessage.ForeColor = Color.White;
                break;

            default:
                throw new Exception("Unkown setting!");
            }

            Show();
            timerClose.Interval = delay;
            timerClose.Start();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Open custom alert with pre-set icon
 /// </summary>
 /// <param name="message">Alert message text</param>
 /// <param name="foregroundColor">Text color</param>
 /// <param name="backgroundColor">Background color</param>
 /// <param name="type">Alert type for pre-set image</param>
 /// <param name="delay">Delay in miliseconds. Default 2000 miliseconds</param>
 /// <param name="alertLocation"Alert location. Default BottomRight></param>
 public static void OpenAlert(string message, Color foregroundColor, Color backgroundColor, AlertType type, int delay = 2000, AlertLocation alertLocation = AlertLocation.BottomRight)
 {
     BrumAlert alert = new BrumAlert(message, foregroundColor, backgroundColor, type, delay, alertLocation);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Default alert factory.
 /// </summary>
 /// <param name="message">Alert message text</param>
 /// <param name="type">Alert type</param>
 /// <param name="delay">Delay in miliseconds. Default 2000 miliseconds</param>
 /// <param name="alertLocation">Alert location. Default BottomRight</param>
 public static void OpenAlert(string message, AlertType type, int delay = 2000, AlertLocation alertLocation = AlertLocation.BottomRight)
 {
     BrumAlert alert = new BrumAlert(message, type, delay, alertLocation);
 }
Exemplo n.º 9
0
 public static void AddSuccessMessage(this TempDataDictionary tempData, string message,
     AlertLocation location = AlertLocation.Top)
 {
     AddMessage(tempData, AlertType.Success, message, location);
 }
Exemplo n.º 10
0
        public static MvcHtmlString GetAlerts(this HtmlHelper helper, AlertType alertType, AlertLocation alertLocation)
        {
            var alertData = helper.ViewContext.TempData.InitializeAlertData();

            List <string> messages = alertData[alertLocation][alertType];

            if (messages.Count > 0)
            {
                var outerBuilder = new TagBuilder("div");
                outerBuilder.AddCssClass("container-fluid");
                foreach (var message in messages)
                {
                    var builder = new TagBuilder("div");
                    builder.AddCssClass("alert");
                    builder.AddCssClass("in");
                    builder.AddCssClass("fade");
                    builder.AddCssClass(alertType.GetDescription());

                    builder.SetInnerText(message);

                    var closeButton = new TagBuilder("a");
                    closeButton.AddCssClass("close");
                    closeButton.MergeAttribute("data-dismiss", "alert");
                    closeButton.MergeAttribute("href", "#");
                    closeButton.InnerHtml += "&times;";

                    builder.InnerHtml += closeButton.ToString(TagRenderMode.Normal);

                    outerBuilder.InnerHtml += builder.ToString(TagRenderMode.Normal);
                }
                return(outerBuilder.ToString(TagRenderMode.Normal).ToMvcHtmlString());
            }

            return(string.Empty.ToMvcHtmlString());
        }
Exemplo n.º 11
0
 public static void AddInfoMessage(this TempDataDictionary tempData, string message,
                                   AlertLocation location = AlertLocation.Top)
 {
     AddMessage(tempData, AlertType.Info, message, location);
 }