Exemplo n.º 1
0
        /// <summary>
        /// crate the HTML for the opening of the colum
        /// </summary>
        /// <returns></returns>
        private string BuildOpeningColumHTML()
        {
            columcount++;
            columSize size = getNextColSize();
            string    columTypeString;
            string    columSizetring = "";

            if (size != columSize.full)
            {
                columSizetring = " " + size.ToString() + "Column ";
            }
            columTypeString = "column" + columSizetring;
            return("<div class=\"" + columTypeString + "\" >");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds Columns in the outputHTML buffer
        /// Should always call  HtmlBufferFlush() after use;
        /// </summary>
        /// <param name="infoToAdd"></param>
        /// <param name="size"></param>
        public void ColumBuilder(string infoToAdd, bool extraBlockSpace = true)
        {
            int       newNumberOfLines = 0;
            int       stringSize       = CalcNumberOfLines(infoToAdd);
            columSize size             = getNextColSize();

            if (HTMLBuffer == null)
            {
                HTMLBuffer = new StringBuilder();
                HTMLBuffer.Append(BuildOpeningColumHTML());
                htmlBufferLines = 0;
            }
            //Check if the string size is longer than maximum allowed for one column
            if (stringSize > MAX_LINE_PER_MED_COLUM || (stringSize > MAX_LINE_PER_COLUM && size == columSize.full))
            {
                //If we are adding the "Scientific Backgroud field"
                if (infoToAdd.Contains("Scientific Background:"))
                {
                    //Make the fiels appear in smaller font size
                    infoToAdd = "<span style=\"font-size:11px; color:white;\">" + infoToAdd + "</span>";
                }
                else //If we are adding other database field
                {
                    //if the column is full
                    if (size == columSize.full)
                    {
                        infoToAdd = infoToAdd.Substring(0, MAX_LINE_PER_COLUM * MAX_CAHR_PER_LINE);
                    }
                    else
                    {
                        infoToAdd = infoToAdd.Substring(0, MAX_LINE_PER_MED_COLUM * MAX_CAHR_PER_LINE);
                    }
                }
            }
            //update number of lines
            newNumberOfLines = htmlBufferLines + CalcNumberOfLines(infoToAdd);

            //if we are adding the "Scientific Background" field and it exceeds the maximum size allowed per one column
            if (infoToAdd.Contains("Scientific Background:") && ((newNumberOfLines > MAX_LINE_PER_COLUM && size == columSize.full) || newNumberOfLines > MAX_LINE_PER_MED_COLUM))
            {
                //add data to the new column
                HTMLBuffer.Append(infoToAdd);
                //close the column
                HtmlBufferFlush();
                //update new number of lines
                newNumberOfLines = htmlBufferLines + CalcNumberOfLines(infoToAdd);
            }
            else
            {
                //if the number of lines we are adding is less or equal to maximum allowed per one column
                if (newNumberOfLines <= MAX_LINE_PER_MED_COLUM || (newNumberOfLines <= MAX_LINE_PER_COLUM && size == columSize.full))
                {
                    //add new data
                    HTMLBuffer.Append(infoToAdd);

                    //if the field that we've added is "Product Use" or "Protein SigNET", the next field to add will be the "Scientific Background", and the "Scientific Backgroud" fiels exceeds the maximum allowed size per one column
                    if ((infoToAdd.Contains("Product Use:") || infoToAdd.Contains("Protein SigNET:")) && (!String.IsNullOrWhiteSpace(GetDBValue("Scientific_Background"))))
                    {
                        //close current column
                        HtmlBufferFlush();
                    }
                    else
                    {
                        //if there is extra space in the column and the number of lines we are adding does not exceed maximum number of lines allowed
                        if (extraBlockSpace && (newNumberOfLines != MAX_LINE_PER_MED_COLUM || (newNumberOfLines != MAX_LINE_PER_COLUM && size == columSize.full)))
                        {
                            //append line breaks
                            HTMLBuffer.Append(" <br /> <br />");
                            //increment number of lines so it includes html line breaks
                            newNumberOfLines++;
                        }
                    }
                    htmlBufferLines = newNumberOfLines;
                }
                else
                {
                    HtmlBufferFlush();
                    ColumBuilder(infoToAdd);
                }
            }
        }