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); } } } }
private void panel1_MouseUp(object sender, MouseEventArgs e) { mousePressed = false; if (eAction == EMouseActions.eCreate) { if (startPoint != endPoint) { Rectangle rect = GetRectangle(startPoint, endPoint); if (IntersectsWithFieldInformation(rect) == false) { FieldText fieldText = new FieldText("fieldtext" + (fieldInformationList.Count + 1).ToString()); fieldText.Position = rect; this.fieldInformationList.Add(fieldText); listBoxFieldInformation.Invalidate(); listBoxFieldInformation.SelectedItem = fieldText; } } } else if (eAction == EMouseActions.eMove) { if (IntersectsWithFieldInformation(fieldInformationList[selectedFieldInfoIndex].Position, selectedFieldInfoIndex) == true) { fieldInformationList[selectedFieldInfoIndex].Position = originalRect; } } previewRect = Rectangle.Empty; customPanel1.Invalidate(); Cursor.Clip = new Rectangle(0, 0, 0, 0); }