Ejemplo n.º 1
0
        public void StartAlert(AlertClass alertClass)
        {
            _xmlWriter.WriteStartElement("alert", Namespaces.Maml);
            switch (alertClass)
            {
            case AlertClass.Note:
                _xmlWriter.WriteAttributeString("class", "note");
                break;

            default:
                throw ExceptionBuilder.UnhandledCaseLabel(alertClass);
            }
        }
Ejemplo n.º 2
0
 public GrowlApplication(Growl.Connector.Application app, List <NotificationType> notiTypes)
 {
     // Create the actual window
     windowHandle    = IntPtr.Zero;
     alertClasses    = new List <AlertClass>();
     alertClassIcons = new Dictionary <string, string>();
     this.CreateHandle(cp);
     windowHandle = this.Handle;
     this.SNARL_GLOBAL_MESSAGE = Snarl.SnarlConnector.GetGlobalMsg();
     this.application          = app;
     foreach (NotificationType alertClass in notiTypes)
     {
         AlertClass newClass = new AlertClass(alertClass);
         alertClasses.Add(newClass);
         alertClassIcons.Add(newClass.notificationType.Name, newClass.defaultIconLocation);
     }
     pathToIcon = IconFetcher.getPathToIcon(app);
     registerWithSnarl();
 }
Ejemplo n.º 3
0
 public void StartAlert(AlertClass alertClass)
 {
     _xmlWriter.WriteStartElement("alert", Namespaces.Maml);
     switch (alertClass)
     {
         case AlertClass.Note:
             _xmlWriter.WriteAttributeString("class", "note");
             break;
         default:
             throw ExceptionBuilder.UnhandledCaseLabel(alertClass);
     }
 }
 public void AddAlert(AlertClass alertClass)
 {
     this.alertClassList.Add(alertClass);
 }
        public string ConstructElementAndBody(TagHelperOutput output)
        {
            var icon = ResolveIcon(Icon);

            if (Icon.StartsWith(DangerIcon))
            {
                icon = string.Concat(FaWarningIcon, StringSpace, BsTextDangerClass); // force to error color
            }

            if (Dismissible && !AlertClass.Contains(BsAlertDismissibleClass))
            {
                AlertClass += string.Concat(StringSpace, BsAlertDismissibleClass);
            }

            BuildAlertCss();

            output.TagName = HtmlConstants.Elements.Div;
            output.Attributes.Add(HtmlConstants.Attributes.ClassAttribute, CssClass);
            output.Attributes.Add(HtmlConstants.Attributes.RoleAttribute, "alert");

            var htmlContentStringBuilder = new StringBuilder();

            if (Dismissible)
            {
                var dismissButtonBuilder = new TagBuilder(HtmlConstants.Elements.Button)
                {
                    TagRenderMode = TagRenderMode.Normal
                };
                dismissButtonBuilder.MergeAttribute("data-dismiss", "alert");
                dismissButtonBuilder.MergeAttribute("aria-label", "close");
                dismissButtonBuilder.MergeAttribute(HtmlConstants.Attributes.TypeAttribute, "button");
                dismissButtonBuilder.InnerHtml.AppendHtml("<span aria-hidden='true'>&times;</span>");
                dismissButtonBuilder.AddCssClass("close");

                htmlContentStringBuilder.Append(dismissButtonBuilder.ProcessTagBuilderAsString());
            }

            string messageText = !MessageAsHtml?System.Net.WebUtility.HtmlEncode(Message) : Message;

            string headerText = !HeaderAsHtml?System.Net.WebUtility.HtmlEncode(Header) : Header;

            if (string.IsNullOrEmpty(Header))
            {
                if (!string.IsNullOrEmpty(icon))
                {
                    htmlContentStringBuilder.Append($"<i class='fa fa-{icon}'></i>&nbsp;");
                }

                htmlContentStringBuilder.Append($"{messageText}");
            }
            else
            {
                htmlContentStringBuilder.Append("<h4 class='alert-heading'>");

                htmlContentStringBuilder.Append(
                    string.IsNullOrEmpty(icon)
                        ? $"{headerText}</h4><hr/>{messageText}"
                        : $"{headerText}</h4><hr/><i class='fa fa-{icon}'></i>&nbsp;{messageText}"
                    );
            }

            return(htmlContentStringBuilder.ToString());
        }