Пример #1
0
        /// <summary>
        /// Empahses a portion of a string with color, bold, italics, or underline
        /// </summary>
        /// <param name="inputStr">The entire input string</param>
        /// <param name="portionToEmphasize">The porition of the input string to emphasize; if inputStr = portionToEmphasize,
        /// then the entire string is emphasized</param>
        /// <param name="fontColor">Font color to use in emphasis; set to "" to leave default</param>
        /// <param name="isBold">set TRUE for bold effect</param>
        /// <param name="isItalic">set TRUE for italic effect</param>
        /// <param name="isUnderline">set TRUE for underline effect</param>
        /// <returns></returns>
        public static string EmphasizeText(string inputStr, string portionToEmphasize, string fontColor = "",
                                           Boolean isBold = false, Boolean isItalic = false, Boolean isUnderline = false)
        {
            try
            {
                string newPortionToEmphasize = portionToEmphasize;
                if (fontColor != "")
                {
                    inputStr = inputStr.Replace(portionToEmphasize, "<span " +
                                                DynControls.encodeProperty("style", "color:red") + ">" + portionToEmphasize + "</span>");
                }
                if (isBold)
                {
                    newPortionToEmphasize = "<b>" + newPortionToEmphasize + "</b>";
                }
                if (isItalic)
                {
                    portionToEmphasize = "<i>" + newPortionToEmphasize + "</i>";
                }
                if (isUnderline)
                {
                    portionToEmphasize = "<u>" + newPortionToEmphasize + "</u>";
                }
                if (portionToEmphasize != newPortionToEmphasize)
                {
                    inputStr = inputStr.Replace(portionToEmphasize, newPortionToEmphasize);
                }

                return(inputStr);
            }
            catch (Exception ex)
            {
                return(inputStr);
            }
        }
Пример #2
0
 public static string HTMLHeading(string headingText, string headingLevel, string align = "",
                                  string cssClass = "")
 {
     try
     {
         string qAlign = DynControls.encodeProperty("align", align);
         string qClass = DynControls.encodeProperty("class", cssClass);
         return("<" + headingLevel + " " + qClass + qAlign + ">" + headingText + "</" + headingLevel + ">");
     } catch (Exception ex)
     {
         return("<p>Error in HTMLStrings.HTMLHeading: " + ex.Message + "</p>");
     }
 }
Пример #3
0
        /// <summary>
        /// Returns stylized text for a heading:
        /// First Character is Size Medium, all others are Small.
        /// All letters are capitalized
        /// </summary>
        /// <param name="headingText">The heading text</param>
        /// <param name="headingLevel">Heading level, e.g., h1, h2, etc.</param>
        /// <param name="cssclass">Optional css class</param>
        /// <returns></returns>
        public static string HTMLHeadingStyle1(string headingText, string headingLevel, string cssclass = "", string id = "")
        {
            string qClass = "";
            string qID    = "";

            qClass = DynControls.encodeProperty("class", cssclass);
            qID    = DynControls.encodeProperty("class", id);
            string start = headingText.Substring(0, 1).ToUpper();
            string rest  = headingText.Substring(1, headingText.Length - 1).ToUpper();

            return("<" + headingLevel + " " + qClass + qID +
                   "<span " + DynControls.encodeProperty("style", "font-size: medium") + ">" +
                   start + "</span>" +
                   "<span " + DynControls.encodeProperty("style", "font-size: small") + ">" +
                   rest + "</span></h2>");
        }
Пример #4
0
        /// <summary>
        /// Sends an event string for server-side events
        /// </summary>
        /// <param name="msg">Payload for a data event (the message)</param>
        /// <param name="eventName">Payload for an event event (the event Name)</param>
        /// <param name="eventId">Payload for an id even (the event ID number)</param>
        /// <param name="includeDate">Set TRUE to put date string before payload</param>
        /// <param name="endData">When TRUE, data events terminate with "\n\n", which signals the event is over.</param>
        /// <param name="flush">Set TRUE to sennd the contents in the response stream immediately</param>
        public void send(string msg          = "", string eventName  = "", string eventId  = "",
                         Boolean includeDate = true, Boolean endData = true, Boolean flush = true)
        {
            //Work around until I figure out how to handle SSE correctly
            log(msg, includeDate, true, false);
            return;

            try
            {
                if (eventId != "")
                {
                    m_r.Write("id: " + eventId + "\n");
                }
                if (eventName != "")
                {
                    m_r.Write("event: " + eventName + "\n");
                }
                if (msg != "")
                {
                    if (includeDate)
                    {
                        m_r.Write("data: " + DateTime.UtcNow.ToString() + "\n");
                    }
                    string terminator = "";
                    if (endData)
                    {
                        terminator = "\n";
                    }
                    m_r.Write("data: " + msg + "\n" + terminator);
                    if (flush)
                    {
                        m_r.Flush();
                    }
                }
            } catch (Exception ex)
            {
                m_r.Write(ex.Message + DynControls.html_linebreak_string() +
                          ex.StackTrace.Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()));
                m_r.Flush();
            }
        }
Пример #5
0
 /// <summary>
 /// Renders the contents of this object as an html string for a table row.
 /// </summary>
 /// <returns></returns>
 public string ToHTML()
 {
     try
     {
         StringBuilder sB           = new StringBuilder();
         string        openTag      = "<tr ";
         string        closeTag     = "</tr>";
         string        propID       = encodeProperty("id", m_id);
         string        propCssClass = encodeProperty("class", m_cssClass);
         string        display      = DynControls.DecodeDisplayValue(m_displayStyle);
         sB.Append(openTag + propID + propCssClass + display + " >");
         for (int i = 0; i < m_Cells.Length; i++)
         {
             sB.Append(m_Cells[i].ToHTML());
         }
         sB.Append(closeTag);
         return(sB.ToString());
     }
     catch (Exception ex)
     {
         return("<td>" + ex.ToString() + "</td>");
     }
 }
Пример #6
0
 /// <summary>
 /// Puts the message into this object's stringbuilder.
 /// </summary>
 /// <param name="msg">The message to log</param>
 /// <param name="includeDate">et TRUE to put date string before payload</param>
 /// <param name="encloseInP"></param>
 /// <param name="endWithLinBreak"></param>
 public void log(string msg, Boolean includeDate = true,
                 Boolean encloseInP = true, Boolean endWithLinBreak = false)
 {
     try
     {
         if (includeDate)
         {
             msg = DateTime.UtcNow.ToString() + ": " + msg;
         }
         if (endWithLinBreak)
         {
             msg = msg + DynControls.html_linebreak_string();
         }
         if (encloseInP)
         {
             msg = "<p>" + msg + "</p>";
         }
         m_SB.Insert(0, msg);
     } catch (Exception ex)
     {
         m_SB.Append(ex.Message + DynControls.html_linebreak_string() +
                     ex.StackTrace.Replace(AAAK.vbCRLF, DynControls.html_linebreak_string()));
     }
 }
Пример #7
0
            /// <summary>
            /// Renders the contents of this object as an html string for a table cell.
            /// </summary>
            /// <returns></returns>
            public string ToHTML()
            {
                try
                {
                    string cellContents = "";
                    string displayStyle = "";
                    string openTag      = "<td ";
                    string closeTag     = "</td>";
                    if (m_isHeaderCell)
                    {
                        openTag  = "<th ";
                        closeTag = "</th>";
                    }
                    string propID       = encodeProperty("id", m_id);
                    string propCssClass = encodeProperty("class", m_cssClass);
                    string propSpan     = encodeProperty("colspan", m_span.ToString());
                    string tTip         = encodeProperty("title", m_toolTip);
                    if (m_displayStyle != "")
                    {
                        displayStyle = encodeProperty("style", m_displayStyle);
                    }
                    else if (m_fill)
                    {
                        displayStyle = encodeProperty("style", "width:100%;height:100%");
                    }

                    //What do we do with the content string?  Leave it as is or put it in a control?
                    if (m_cntlID != "")
                    {
                        if (m_lstOpts != null)
                        {
                            //Combobox
                            cellContents = DynControls.html_combobox_string(m_cntlID, m_lstOpts, m_cntlCSSClass, false,
                                                                            m_contentString, true, AAAK.DISPLAYTYPES.BLOCK, "", !m_UserInputEnabled,
                                                                            false, m_selectionRequiredIfNoDefault);
                        }
                        else if (m_btnText != "")
                        {
                            //button
                            cellContents = DynControls.html_button_string(m_cntlID, m_btnText, m_cntlCSSClass, true,
                                                                          AAAK.DISPLAYTYPES.BLOCK, "", "", !m_UserInputEnabled);
                        }
                        else if (m_cntlID != "")
                        {
                            //if we have a control ID, but button text = "" and there is no list of options, we must have a textbox
                            cellContents = DynControls.html_txtbox_string(m_cntlID, m_cntlCSSClass, m_contentString, true,
                                                                          AAAK.DISPLAYTYPES.BLOCK, "", !m_UserInputEnabled);
                        }
                    }
                    else
                    {
                        //as is
                        cellContents = m_contentString;
                    }

                    return(openTag + propID + propCssClass + propSpan + tTip + displayStyle + ">" + cellContents + closeTag);
                } catch (Exception ex)
                {
                    return("<td>" + ex.ToString() + "</td>");
                }
            }