public override Bitmap draw() { bmp = new Bitmap(WIDTH,HEIGHT); canvas = bmp; clear(); //////////////////// //書式データ //////////////////// //タイトル int titleX = CENTER - lblTitle.Width / 2; int titleY = 0; lblTitle.DrawToBitmap(bmp, new Rectangle(titleX, titleY, lblTitle.Width, lblTitle.Height)); //今日の日付 int dateX = (int)(WIDTH/9*6); int dateY = (int)(HEIGHT/11*0.6); lblDate.DrawToBitmap(bmp, new Rectangle(dateX, dateY, lblDate.Width, lblDate.Height)); //受渡期日 int deliveryDateX = (int)(0); int deliveryDateY = (int)(HEIGHT / 11 * 1.55); lblDeliveryDate.DrawToBitmap(bmp, new Rectangle(deliveryDateX, deliveryDateY, lblDeliveryDate.Width, lblDeliveryDate.Height)); //工事名 int constractionNameX = (int)(0); int constractionNameY = (int)(HEIGHT / 11 * 1.85); lblConstractionName.DrawToBitmap(bmp, new Rectangle(constractionNameX, constractionNameY, lblConstractionName.Width, lblConstractionName.Height)); //支払条件 int paymentTermsX = (int)(0); int paymentTermsY = (int)(HEIGHT / 11 * 2.15); lblPaymentTerms.DrawToBitmap(bmp, new Rectangle(paymentTermsX, paymentTermsY, lblPaymentTerms.Width, lblPaymentTerms.Height)); //有効期限 int expirationDateX = (int)(0); int expirationDateY = (int)(HEIGHT / 11 * 2.45); lblExpirationDate.DrawToBitmap(bmp,new Rectangle(expirationDateX, expirationDateY, lblExpirationDate.Width, lblExpirationDate.Height)); // int totalFeeX = 0; int totalFeeY = (int)(HEIGHT / 11 * 2.75); lblTotalFee.DrawToBitmap(bmp,new Rectangle(totalFeeX,totalFeeY,lblTotalFee.Width,lblTotalFee.Height)); //////////////////// //////////////////// //自社データ 7件 //////////////////// //会社名 int myCompanyNameX = (int)(WIDTH / 9 * 5.5); int myCompanyNameY = (int)(HEIGHT / 11 * 1.3); lblMyCompanyName.DrawToBitmap(bmp, new Rectangle(myCompanyNameX,myCompanyNameY , lblMyCompanyName.Width, lblMyCompanyName.Height)); //郵便番号 int myZipCodeX = (int)(WIDTH / 9 * 5.5); int myZipCodeY = (int)(HEIGHT / 11 * 1.55); lblMyZipCode.DrawToBitmap(bmp,new Rectangle(myZipCodeX,myZipCodeY,lblMyZipCode.Width,lblMyZipCode.Height)); //住所 int myAddressX = (int)(WIDTH / 9 * 5.5); int myAddressY = (int)(HEIGHT / 11 * 1.675); lblMyAddress.DrawToBitmap(bmp, new Rectangle(myAddressX,myAddressY, lblMyAddress.Width, lblMyAddress.Height)); //代表取締役 int myCEONameX = (int)(WIDTH / 9 * 5.5); int myCEONameY = (int)(HEIGHT / 11 * 1.8); lblMyCEOName.DrawToBitmap(bmp, new Rectangle(myCEONameX, myCEONameY, lblMyCEOName.Width, lblMyCEOName.Height)); //電話番号 int myTellX = (int)(WIDTH / 9 * 5.5); int myTellY = (int)(HEIGHT / 11 * 1.925); lblMyTell.DrawToBitmap(bmp, new Rectangle(myTellX, myTellY, lblMyTell.Width, lblMyTell.Height)); //FAX int myFaxX = (int)(WIDTH / 9 * 7.25); int myFaxY = (int)(HEIGHT / 11 * 1.925); lblMyFax.DrawToBitmap(bmp, new Rectangle(myFaxX, myFaxY, lblMyFax.Width, lblMyFax.Height)); //担当者 int myChargeNameX = (int)(WIDTH / 9 * 6); int myChargeNameY = (int)(HEIGHT / 11 * 2.05); lblMyChargeName.DrawToBitmap(bmp, new Rectangle(myChargeNameX, myChargeNameY, lblMyChargeName.Width, lblMyChargeName.Height)); //////////////////// ///////////////////// //相手データ ///////////////////// //会社名 int yourCompanyNameX = 0; int yourCompanyNameY = (int)(HEIGHT / 11 * 1); lblYourCompanyName.DrawToBitmap(bmp,new Rectangle(yourCompanyNameX,yourCompanyNameY,lblYourCompanyName.Width,lblYourCompanyName.Height)); ///////////////////// ///////////////////// //商品内容詳細 ///////////////////// dgvContent.AllowUserToAddRows = true; dgvContent.Rows.Clear(); dgvContent.Rows.AddCopies(0, 24); int cellWidth = dgvContent.Width / 16; dgvContent.Columns[0].Width = cellWidth*7; dgvContent.Columns[1].Width = cellWidth*2; dgvContent.Columns[2].Width = cellWidth*1; dgvContent.Columns[3].Width = cellWidth*2; dgvContent.Columns[4].Width = cellWidth*2; int otherSum = 0; for(int i=0;i<dgvContent.Columns.Count-1;i++){ otherSum += dgvContent.Columns[i].Width; } //dgvContent.AutoSizeRowsMode=DataGridViewAutoSizeRowsMode.AllCells; dgvContent.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True; dgvContent.Columns[5].Width = dgvContent.Width-otherSum; //dgvContent.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing; int he = dgvContent.Height / dgvContent.Rows.Count; dgvContent.ColumnHeadersHeight = he; dgvContent.RowTemplate.Height = he; dgvContent.RowTemplate.Selected = false; int idx = 0; dgvContent.AllowUserToAddRows = false; dgvContent.AllowUserToResizeRows = true; dgvContent.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; for (int i = 0; i < data.DataContent.Count && i<dgvContent.Rows.Count; i++) { DataGridViewRow l = dgvContent.Rows[i]; DataGridViewRow r = data.DataContent[i]; l.Cells[0].Value = r.Cells[0].Value; l.Cells[1].Value = r.Cells[1].Value; l.Cells[2].Value = r.Cells[2].Value; l.Cells[3].Value = r.Cells[3].Value; l.Cells[4].Value = r.Cells[4].Value; l.Cells[5].Value = r.Cells[5].Value; if (l.Cells[0].Value != null) { string tNill = l.Cells[0].Value.ToString(); int nill = tNill.Replace("\r\n", "\n").Split('\n').Length-1; //l.Cells[0].Value = nill; //改行コードの数分dgvのrowをremoveする&&高さを *改行数 する l.Height = l.Height * (nill + 1); int hei = dgvContent.ColumnHeadersHeight; for (int j = 0; j < nill; j++)//改行コードが入っていた { hei += dgvContent.Rows[i].Height; } for (; true; ) { if (hei > dgvContent.Height) { dgvContent.Rows.RemoveAt(dgvContent.Rows.Count - 1); } else { break; } } } idx = i; } //dgvContent.Rows.RemoveAt(dgvContent.Rows.Count-1); if (idx != dgvContent.Rows.Count && data.DataContent.Count < dgvContent.Rows.Count) { dgvContent.Rows[idx].Cells[0].Value = "以 下 空 白"; dgvContent.Rows[idx].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } /* int dCount = data.DataContent.Count; int dsCount = dgvContent.Rows.Count; if (dCount > dsCount) { Bitmap b = new Bitmap(WIDTH, HEIGHT); base.bmp.Add(b); }*/ int dgvX = 0; int dgvY = (int)(HEIGHT / 10 * 3); dgvContent.DrawToBitmap(bmp,new Rectangle(dgvX,dgvY,dgvContent.Width,dgvContent.Height)); //////////////////// //////////////////// //その他 //////////////////// Label lblText = new Label(); Font formatFont = new Font(lblDeliveryDate.Font.FontFamily, 13f); int lblTextX = 0; int lblTextY = (int)(HEIGHT / 11 * 1.3); lblText.BackColor = Color.White; lblText.Width = (int)(WIDTH /2); lblText.Height = (int)(HEIGHT / 11 * 0.25); lblText.Font = formatFont; lblText.TextAlign = ContentAlignment.MiddleLeft; lblText.Text = "下記の通り御見積り申し上げます。"; lblText.DrawToBitmap(bmp,new Rectangle(lblTextX,lblTextY,lblText.Width,lblText.Height)); //////////////////// return bmp; }
public override List<Bitmap> draw() { Bitmap bmp = new Bitmap(WIDTH, HEIGHT); bmps.Add(bmp); bmps[0] = bmp; //bmps.Add(bmp); canvas = bmp; clear(); Graphics g = Graphics.FromImage(canvas); settingChange(); //////////////////// //書式データ //////////////////// //タイトル int titleX = CENTER - lblTitle.Width / 2; int titleY = 0; lblTitle.DrawToBitmap(bmp, new Rectangle(titleX, titleY, lblTitle.Width, lblTitle.Height)); //今日の日付 int dateX = (int)(WIDTH/5*2.5); int dateY = (int)(HEIGHT/13*1); lblDate.DrawToBitmap(bmp, new Rectangle(dateX, dateY, lblDate.Width, lblDate.Height)); //受渡期日 int deliveryDateX = (int)(0); int deliveryDateY = (int)(HEIGHT / 13 * 3.5); lblDeliveryDate.DrawToBitmap(bmp, new Rectangle(deliveryDateX, deliveryDateY, lblDeliveryDate.Width, lblDeliveryDate.Height)); //工事名 int constractionNameX = (int)(WIDTH / 3); int constractionNameY = (int)(HEIGHT / 13 * 3.5); lblConstractionName.DrawToBitmap(bmp, new Rectangle(constractionNameX, constractionNameY, lblConstractionName.Width, lblConstractionName.Height)); //支払条件 int paymentTermsX = (int)(0); int paymentTermsY = (int)(HEIGHT / 13 * 4.0); lblPaymentTerms.DrawToBitmap(bmp, new Rectangle(paymentTermsX, paymentTermsY, lblPaymentTerms.Width, lblPaymentTerms.Height)); //有効期限 int expirationDateX = (int)(WIDTH / 3); int expirationDateY = (int)(HEIGHT / 13 * 4.0); lblExpirationDate.DrawToBitmap(bmp,new Rectangle(expirationDateX, expirationDateY, lblExpirationDate.Width, lblExpirationDate.Height)); // int totalFeeX = 0; int totalFeeY = (int)(HEIGHT / 13 * 4.5); lblTotalFee.DrawToBitmap(bmp,new Rectangle(totalFeeX,totalFeeY,lblTotalFee.Width,lblTotalFee.Height)); //////////////////// //////////////////// //自社データ 7件 //////////////////// //会社名 int myCompanyNameX = (int)(WIDTH / 5 * 4); int myCompanyNameY = (int)(HEIGHT / 13 * 2); lblMyCompanyName.DrawToBitmap(bmp, new Rectangle(myCompanyNameX,myCompanyNameY , lblMyCompanyName.Width, lblMyCompanyName.Height)); //郵便番号 int myZipCodeX = (int)(WIDTH / 5 * 4); int myZipCodeY = (int)(HEIGHT / 13 * 2.7); lblMyZipCode.DrawToBitmap(bmp,new Rectangle(myZipCodeX,myZipCodeY,lblMyZipCode.Width,lblMyZipCode.Height)); //住所 int myAddressX = (int)(WIDTH / 5*4); int myAddressY = (int)(HEIGHT / 13 * 3.2); lblMyAddress.DrawToBitmap(bmp, new Rectangle(myAddressX,myAddressY, lblMyAddress.Width, lblMyAddress.Height)); //代表取締役 int myCEONameX = (int)(WIDTH / 5 * 4); int myCEONameY = (int)(HEIGHT / 13 * 3.7); if (data.VisibleCEO) { lblMyCEOName.DrawToBitmap(bmp, new Rectangle(myCEONameX, myCEONameY, lblMyCEOName.Width, lblMyCEOName.Height)); } //電話番号 int myTellX = (int)(WIDTH / 5*4); int myTellY = (int)(HEIGHT / 13 * 4.2); lblMyTell.DrawToBitmap(bmp, new Rectangle(myTellX, myTellY, lblMyTell.Width, lblMyTell.Height)); //FAX int myFaxX = (int)(WIDTH / 5*4); int myFaxY = (int)(HEIGHT / 13 * 4.7); lblMyFax.DrawToBitmap(bmp, new Rectangle(myFaxX, myFaxY, lblMyFax.Width, lblMyFax.Height)); //担当者 int myChargeNameX = (int)(WIDTH / 2*1); int myChargeNameY = (int)(HEIGHT / 13 * 4.8); lblMyChargeName.DrawToBitmap(bmp, new Rectangle(myChargeNameX, myChargeNameY, lblMyChargeName.Width, lblMyChargeName.Height)); //////////////////// ///////////////////// //相手データ ///////////////////// //会社名 int yourCompanyNameX = 0; int yourCompanyNameY = (int)(HEIGHT / 13 * 1.5); lblYourCompanyName.DrawToBitmap(bmp,new Rectangle(yourCompanyNameX,yourCompanyNameY,lblYourCompanyName.Width,lblYourCompanyName.Height)); ///////////////////// ///////////////////// //商品内容詳細 ///////////////////// dgvContent.AllowUserToAddRows = true; dgvContent.Rows.Clear(); dgvContent.Rows.AddCopies(0, pLimit-1); int cellWidth = dgvContent.Width / 16; dgvContent.Columns[0].Width = cellWidth*7; dgvContent.Columns[1].Width = cellWidth*2; dgvContent.Columns[2].Width = cellWidth*1; dgvContent.Columns[3].Width = cellWidth*2; dgvContent.Columns[4].Width = cellWidth*2; int otherSum = 0; for(int i=0;i<dgvContent.Columns.Count-1;i++){ otherSum += dgvContent.Columns[i].Width; } //dgvContent.AutoSizeRowsMode=DataGridViewAutoSizeRowsMode.AllCells; dgvContent.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True; dgvContent.Columns[5].Width = dgvContent.Width-otherSum; //dgvContent.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing; int he = dgvContent.Height / dgvContent.Rows.Count; dgvContent.ColumnHeadersHeight = he; dgvContent.RowTemplate.Height = he; dgvContent.RowTemplate.Selected = false; int idx = 0; dgvContent.AllowUserToAddRows = false; dgvContent.AllowUserToResizeRows = true; dgvContent.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; for (int i = 0; i < data.DataContent.Count && i<dgvContent.Rows.Count; i++) { DataGridViewRow l = dgvContent.Rows[i]; DataGridViewRow r = data.DataContent[i]; l.Cells[0].Value = r.Cells[0].Value; l.Cells[1].Value = r.Cells[1].Value; l.Cells[2].Value = r.Cells[2].Value; l.Cells[3].Value = r.Cells[3].Value; l.Cells[4].Value = r.Cells[4].Value; l.Cells[5].Value = r.Cells[5].Value; if (l.Cells[0].Value != null) { string tNill = l.Cells[0].Value.ToString(); int nill = tNill.Replace("\r\n", "\n").Split('\n').Length-1; //l.Cells[0].Value = nill; //改行コードの数分dgvのrowをremoveする&&高さを *改行数 する l.Height = l.Height * (nill + 1); for (int j = 0; j < nill; j++)//改行コードが入っていた { dgvContent.Rows.RemoveAt(dgvContent.Rows.Count - 1); } } idx = i; } //dgvContent.Rows.RemoveAt(dgvContent.Rows.Count-1); if (idx != dgvContent.Rows.Count && data.DataContent.Count < dgvContent.Rows.Count) { dgvContent.Rows[idx].Cells[0].Value = "以 下 空 白"; dgvContent.Rows[idx].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } int dCount = data.DataContent.Count; int dsCount = dgvContent.Rows.Count; if (dCount > dsCount && data.DataContent.Count > pLimit) { //2枚分のデータがあった printSecond(idx); } else { //1枚目だけだった } drawTax(bmp); int dgvX = 0; int dgvY = (int)(HEIGHT / 13 * 5.5); dgvContent.DrawToBitmap(bmp,new Rectangle(dgvX,dgvY,dgvContent.Width,dgvContent.Height)); //////////////////// //////////////////// //その他 //////////////////// Label lblText = new Label(); Font formatFont = new Font(lblDeliveryDate.Font.FontFamily, 12f); int lblTextX = 0; int lblTextY = (int)(HEIGHT / 13 * 2.3); lblText.BackColor = Color.White; lblText.Width = (int)(WIDTH /2); lblText.Height = (int)(HEIGHT / 13 * 0.5); lblText.Font = formatFont; lblText.TextAlign = ContentAlignment.MiddleLeft; lblText.Text = "下記の通り御見積り申し上げます。"; lblText.DrawToBitmap(bmp,new Rectangle(lblTextX,lblTextY,lblText.Width,lblText.Height)); //////////////////// Label lblSub = new Label(); lblSub.BackColor = Color.White; lblSub.Text = "備考"; int subX = 0; int subY = (int)(HEIGHT/13*12.1); int subW = (int)(WIDTH/2); int subH = (int)(HEIGHT/13*0.5); lblSub.Font = new Font(lblSub.Font.FontFamily,12); lblSub.DrawToBitmap(bmp,new Rectangle(subX,subY,subW,subH)); lblNote.BorderStyle = BorderStyle.FixedSingle; int noteX = 0; int noteY = (int)(HEIGHT / 13 * 12.6); lblNote.DrawToBitmap(bmp,new Rectangle(noteX,noteY,lblNote.Width,lblNote.Height)); //////////////////// //////////////////// // //////////////////// g.DrawRectangle(Pens.Black, titleX, titleY, lblTitle.Width, lblTitle.Height); g.DrawRectangle(Pens.Black, totalFeeX, totalFeeY, lblTotalFee.Width, lblTotalFee.Height); //////////////////// return bmps; }