Esempio n. 1
0
 protected virtual void ExportHTMLCellContent(CellContext context, System.Xml.XmlTextWriter writer)
 {
     if (context.Cell.View is Cells.Views.CheckBox)
     {
         Cells.Models.ICheckBox      checkModel = (Cells.Models.ICheckBox)context.Cell.Model.FindModel(typeof(Cells.Models.ICheckBox));
         Cells.Models.CheckBoxStatus status     = checkModel.GetCheckBoxStatus(context);
         ExportHTML_Element_Font(writer, status.Caption, context.Cell.View.GetDrawingFont(context.Grid));
     }
     else
     {
         ExportHTML_Element_Font(writer, context.DisplayText, context.Cell.View.GetDrawingFont(context.Grid));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Export the specified cell to HTML
        /// </summary>
        /// <param name="context"></param>
        /// <param name="writer"></param>
        protected virtual void ExportHTMLCell(CellContext context, System.Xml.XmlTextWriter writer)
        {
            if (context.Cell == null)
            {
                //start element td
                writer.WriteStartElement("td");
                writer.WriteRaw("&nbsp;");
            }
            else
            {
                #region TD style
                Range rangeCell = context.Grid.PositionToCellRange(context.Position);
                if (rangeCell.Start != context.Position)
                {
                    return;
                }

                //start element td
                writer.WriteStartElement("td");

                //check for rowspan and colspan
                if (rangeCell.ColumnsCount > 1 || rangeCell.RowsCount > 1)
                {
                    //colspan, rowspan
                    writer.WriteAttributeString("colspan", rangeCell.ColumnsCount.ToString());
                    writer.WriteAttributeString("rowspan", rangeCell.RowsCount.ToString());
                }

                if (context.Cell.View is Cells.Views.Cell)
                {
                    Cells.Views.Cell viewCell = (Cells.Views.Cell)context.Cell.View;

                    //write backcolor
                    if ((Mode & ExportHTMLMode.CellBackColor) == ExportHTMLMode.CellBackColor)
                    {
                        writer.WriteAttributeString("bgcolor", ColorToHTML(context.Cell.View.BackColor));
                    }

                    string l_Style = "";

                    //border
                    l_Style = BorderToHTMLStyle(viewCell.Border);

                    //style
                    writer.WriteAttributeString("style", l_Style);

                    //alignment
                    writer.WriteAttributeString("align", DevAge.Windows.Forms.Utilities.ContentToHorizontalAlignment(viewCell.TextAlignment).ToString().ToLower());
                    if (DevAge.Drawing.Utilities.IsBottom(viewCell.TextAlignment))
                    {
                        writer.WriteAttributeString("valign", "bottom");
                    }
                    else if (DevAge.Drawing.Utilities.IsTop(viewCell.TextAlignment))
                    {
                        writer.WriteAttributeString("valign", "top");
                    }
                    else if (DevAge.Drawing.Utilities.IsMiddle(viewCell.TextAlignment))
                    {
                        writer.WriteAttributeString("valign", "middle");
                    }
                }
                #endregion

                if (context.Cell.View is Cells.Views.CheckBox)
                {
                    Cells.Models.ICheckBox      checkModel = (Cells.Models.ICheckBox)context.Cell.Model.FindModel(typeof(Cells.Models.ICheckBox));
                    Cells.Models.CheckBoxStatus status     = checkModel.GetCheckBoxStatus(context);
                    if (status.Checked == true)
                    {
                        writer.WriteRaw("<input type=\"checkbox\" checked>");
                    }
                    else
                    {
                        writer.WriteRaw("<input type=\"checkbox\">");
                    }
                }

                #region Font
                if (context.Cell.View is Cells.Views.Cell)
                {
                    //Read the image
                    System.Drawing.Image img      = null;
                    Cells.Models.IImage  imgModel = (Cells.Models.IImage)context.Cell.Model.FindModel(typeof(Cells.Models.IImage));
                    if (imgModel != null)
                    {
                        img = imgModel.GetImage(context);
                    }


                    Cells.Views.Cell viewCell = (Cells.Views.Cell)context.Cell.View;

                    if (img != null)
                    {
                        writer.WriteStartElement("img");

                        writer.WriteAttributeString("align", DevAge.Windows.Forms.Utilities.ContentToHorizontalAlignment(viewCell.ImageAlignment).ToString().ToLower());
                        writer.WriteAttributeString("src", ExportImage(img));

                        //img
                        writer.WriteEndElement();
                    }

                    writer.WriteStartElement("font");

                    writer.WriteAttributeString("color", ColorToHTML(viewCell.ForeColor));

                    ExportHTMLCellContent(context, writer);

                    //font
                    writer.WriteEndElement();
                }
                else
                {
                    ExportHTMLCellContent(context, writer);
                }
                #endregion

                //td
                writer.WriteEndElement();
            }
        }