Пример #1
0
 public FieldText(string fieldName) : base(fieldName, EFieldType.eFieldText)
 {
     Color = new TextColor();
     Bold = false;
     Italic = false;
     Underline = false;
 }
Пример #2
0
        private void ConvertDataSetToFieldInformationList(DataSet ds)
        {
            BindingList<FieldInformation> newFieldInformationList = new BindingList<FieldInformation>();

            foreach (DataTable table in ds.Tables)
            {
                for (int row = 0; row < table.Rows.Count; row++)
                {
                    string colName = string.Empty;

                    int no = -1;
                    string fieldName = string.Empty;
                    float left = -1;
                    float top = -1;
                    float right = -1;
                    float bottom = -1;
                    EUnit eUnit = EUnit.ePSPoint;
                    EAlignment eAlignment = EAlignment.eLeft;
                    EFieldType eFieldType = EFieldType.eFieldText;

                    string fontName = string.Empty;
                    double fontSize = 0.0;
                    TextColor color = new TextColor();

                    bool bold = false;
                    bool italic = false;
                    bool underline = false;
                    bool autofit = false;

                    for (int col = 0; col < table.Rows.Count; col++)
                    {
                        switch (table.Columns[col].ColumnName)
                        {
                            case "No#":
                                no = int.Parse(table.Rows[row][col].ToString());
                                break;
                            case "Field Name":
                                fieldName = table.Rows[row][col].ToString();
                                break;
                            case "Left":
                                left = float.Parse(table.Rows[row][col].ToString());
                                break;
                            case "Top":
                                top = float.Parse(table.Rows[row][col].ToString());
                                break;
                            case "Right":
                                right = float.Parse(table.Rows[row][col].ToString());
                                break;
                            case "Bottom":
                                bottom = float.Parse(table.Rows[row][col].ToString());
                                break;
                            case "Unit":
                                //TODO
                                eUnit = EUnit.ePSPoint;
                                break;
                            case "Alignment":
                                eAlignment = Converter.StringToEAlignment(table.Rows[row][col].ToString());
                                break;
                            case "Field Type":
                                eFieldType = Converter.StringToEFieldType(table.Rows[row][col].ToString());
                                break;
                            case "Font Name":
                                fontName = table.Rows[row][col].ToString();
                                break;
                            case "Font Size":
                                fontSize = (double)table.Rows[row][col];
                                break;
                            case "Color":
                                //TODO
                                color.ColorNamespace = EColorNamespace.eRGB;
                                break;
                            case "Red":
                                color.Red = (double)table.Rows[row][col];
                                break;
                            case "Green":
                                color.Green = (double)table.Rows[row][col];
                                break;
                            case "Blue":
                                color.Blue = (double)table.Rows[row][col];
                                break;
                            case "Cyan":
                                color.Cyan = (double)table.Rows[row][col];
                                break;
                            case "Magenta":
                                color.Magenta = (double)table.Rows[row][col];
                                break;
                            case "Yellow":
                                color.Yellow = (double)table.Rows[row][col];
                                break;
                            case "Black":
                                color.Black = (double)table.Rows[row][col];
                                break;
                            case "Gray":
                                color.Gray = (double)table.Rows[row][col];
                                break;
                            case "Bold":
                                bold = Converter.Yes(table.Rows[row][col].ToString());
                                break;
                            case "Italic":
                                italic = Converter.Yes(table.Rows[row][col].ToString());
                                break;
                            case "Underline":
                                underline = Converter.Yes(table.Rows[row][col].ToString());
                                break;
                            case "Auto Fit":
                                autofit = Converter.Yes(table.Rows[row][col].ToString());
                                break;
                            default:
                                break;
                        }
                    }

                    if (eFieldType == EFieldType.eFieldText)
                    {
                        FieldText fieldText = new FieldText(fieldName);

                        fieldText.Position = RectangleF.FromLTRB(left, top, right, bottom);
                        fieldText.Unit = eUnit;
                        fieldText.Alignment = eAlignment;

                        fieldText.FontName = fontName;
                        fieldText.FontSize = fontSize;
                        fieldText.Color = color;

                        fieldText.Bold = bold;
                        fieldText.Italic = italic;
                        fieldText.Underline = underline;

                        fieldInformationList.Add(fieldText);
                    }
                    else if (eFieldType == EFieldType.eFieldImage)
                    {
                        FieldImage fieldImage = new FieldImage(fieldName);

                        fieldImage.Position = RectangleF.FromLTRB(left, top, right, bottom);
                        fieldImage.Unit = eUnit;
                        fieldImage.Alignment = eAlignment;

                        fieldImage.AutoFit = autofit;

                        fieldInformationList.Add(fieldImage);
                    }

                    
                }
            }
        }