private void MainPanel_Paint(object sender, PaintEventArgs e) { if (obj == null) { return; } e.Graphics.Clear(Color.Black); image = new Bitmap(e.ClipRectangle.Width, e.ClipRectangle.Height); provider = new BitmapProvider(image); graphics = new MyGraphics(provider); //graphics.Fill(Color.Black); int Width = e.ClipRectangle.Width; int Height = e.ClipRectangle.Height; Vec3f zero = new Vec3f(0, 0, 0); Vec3f ligth = new Vec3f( ((float)e.ClipRectangle.Width / 2 - x) / (Width / 2), (y - (float)e.ClipRectangle.Height / 2) / (Height / 2), z); ligth = zero - ligth; ligth.Normalize(); //graphics.DrawLine(new Vec2i(200, 200), new Vec2i(x, y), Color.White); graphics.DrawObject(obj, Color.White, ligth, c); graphics.DrawLight(ligth, Width / 2); e.Graphics.DrawImage(image, 0, 0); }
public void PrintViewClient() { SystemConfig config = FT.Commons.Cache.StaticCacheManager.GetConfig <SystemConfig>(); Code39 code39 = new Code39(); code39.WidthCU = 2; code39.LineHeight = 20; try { this.Draw11String(name, new Point(config.LeftPoint + 5, config.TopPoint)); SizeF titleSize = MyGraphics.MeasureString("1", code39.titleFont); code39.Height = code39.topHeight + code39.LineHeight + (int)titleSize.Height;//定义图片高度 Bitmap map = code39.CreateBarCode(this.idcard); string path = Application.StartupPath + "/tempcode39.jpg"; ImageHelper.SaveCoderPic(map, path); Image imagetest2 = Image.FromFile(path); Image imagetmp2 = new System.Drawing.Bitmap(imagetest2); MyGraphics.DrawImage(imagetmp2, config.LeftPoint, config.TopPoint + 20); imagetest2.Dispose(); File.Delete(path); imagetmp2.Dispose(); } catch (Exception ex) { //LogFactoryWrapper.Debug("由于证件号码有汉字,不支持code39编码!"); } }
private void CreateBox(int X, int Y, int boxSize, bool Value) { System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); if (Value) { myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); } Graphics MyGraphics; MyGraphics = pictureBox1.CreateGraphics(); MyGraphics.FillRectangle(myBrush, new Rectangle(X * boxSize, Y * boxSize, boxSize, boxSize)); /* * PictureBox PB = new PictureBox(); * Point PositionPoint = new Point(200 + (X * boxSize), 200 + (Y * boxSize)); * PB.Height = boxSize; * PB.Width = boxSize; * PB.Location = PositionPoint; * * if (Value == true) * { * PB.BackColor = Color.Black; * } * this.Controls.Add(PB);*/ }
//打印-二维条码(F5) protected void PrintF5() { this.Draw15String(comp.NickName, new Point(100, 100)); this.Draw15String(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), new Point(100, 150)); this.GetQRImage(vehicle.OthDimension).Save("2demision.jpg"); MyGraphics.DrawImage(this.GetQRImage(vehicle.OthDimension), new Rectangle(new Point(100, 200), new Size(150, 150))); //this.Draw10String("printf5", new Point(100, 100)); }
public void ShowImages(double zoom) { Miniatura z; Bitmap newBitmap; Graphics MyGraphics; Rectangle MyRectan; ImageList newImageList = new ImageList(); ListViewItem listViewItem; newImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; newImageList.Tag = "100%"; newImageList.TransparentColor = System.Drawing.Color.Transparent; newImageList.ImageSize = new Size((int)(zoom * this.defaultImageSize), (int)(zoom * this.defaultImageSize)); int maxSize = newImageList.ImageSize.Width; int scaledH, scaledW, posX, posY; this.Items.Clear(); for (int i = 0; i < miniatury.Count; i++) { z = miniatury[i]; newBitmap = new Bitmap(maxSize, maxSize); MyGraphics = Graphics.FromImage(newBitmap); if (z.Bitmap.Height > z.Bitmap.Width) { scaledH = maxSize; scaledW = (int)Math.Round((double)(z.Bitmap.Width * scaledH) / z.Bitmap.Height); posX = (maxSize - scaledW) / 2; posY = 0; } else { scaledW = maxSize; scaledH = (int)Math.Round((double)(z.Bitmap.Height * scaledW) / z.Bitmap.Width); posX = 0; posY = (maxSize - scaledH) / 2; } MyRectan = new Rectangle(posX, posY, scaledW, scaledH); using (Pen p = new Pen(Brushes.LightGray)) { MyGraphics.DrawRectangle(p, 0, 0, maxSize - 1, maxSize - 1); } MyGraphics.DrawImage(z.Bitmap, MyRectan); newBitmap.Tag = new MiniaturaTag(z.tag.Path); newImageList.Images.Add(newBitmap); listViewItem = this.Items.Add(new ListViewItem(z.tag.Filename)); listViewItem.ImageIndex = i; } // Create an new ImageList for the ListView control this.LargeImageList = newImageList; // Update the ListView control this.Refresh(); }
private void PrintSelfPhoto() { //画像片 string filename = this.GetFileName(Student.IdCardType, Student.IdCard); if (filename.Length > 0 && File.Exists(filename)) { //MyGraphics.DrawImage(this.picture, new RectangleF(647, 175, 137, 168)); MyGraphics.DrawImage(Image.FromFile(filename), new RectangleF(653, 175, 130, 160)); } }
public void ShowImages() { Zdjecie z; Bitmap newBitmap; Graphics MyGraphics; Rectangle MyRectan; ImageList newImageList = new ImageList(); ListViewItem listViewItem; int maxSize = LargeImageList.ImageSize.Width; int scaledH, scaledW, posX, posY; LargeImageList.Images.Clear(); this.Items.Clear(); for (int i = 0; i < miniatury.Count; i++) { z = (Zdjecie)miniatury[i]; newBitmap = new Bitmap(maxSize, maxSize); MyGraphics = Graphics.FromImage(newBitmap); if (z.Miniatura.Height > z.Miniatura.Width) { scaledH = maxSize; scaledW = (int)Math.Round((double)(z.Miniatura.Width * scaledH) / z.Miniatura.Height); posX = (maxSize - scaledW) / 2; posY = 0; } else { scaledW = maxSize; scaledH = (int)Math.Round((double)(z.Miniatura.Height * scaledW) / z.Miniatura.Width); posX = 0; posY = (maxSize - scaledH) / 2; } MyRectan = new Rectangle(posX, posY, scaledW, scaledH); using (Pen p = new Pen(Brushes.LightGray)) { MyGraphics.DrawRectangle(p, 0, 0, maxSize - 1, maxSize - 1); } MyGraphics.DrawImage(z.Miniatura, MyRectan); newBitmap.Tag = z; LargeImageList.Images.Add(newBitmap); listViewItem = this.Items.Add(new ListViewItem(z.NazwaPliku)); listViewItem.ImageIndex = i; } // Update the ListView control this.Refresh(); }
public void RepaintBitmap() { using (Graphics gr = Graphics.FromImage(Bitmap)) { gr.Clear(Color.White); Pen thick_pen = new Pen(Color.Black, 2); Brush brush = new SolidBrush(Color.Blue); Font drawFont = new Font("Arial", 18); SolidBrush drawBrush = new SolidBrush(Color.Purple); if (CheckIntersections() == true) { thick_pen = new Pen(Color.Red, 2); } //Test MyDrawing MyGraphics myGraphics = new MyGraphics(Bitmap); foreach (var edge in State.CurrentPolygon.Edges) { myGraphics.MyDrawLine(thick_pen, edge.ends.left.vPoint, edge.ends.right.vPoint); Point edgeMiddle = edge.EdgeMiddle; foreach (var edgeRestriction in edge.Restrictions) { gr.DrawString(edgeRestriction.ToString(), drawFont, drawBrush, edgeMiddle.X - 20, edgeMiddle.Y); } } if (State.Mode == Mode.Draw && State.MousePosition != null) { myGraphics.MyDrawLine(thick_pen, State.PrevVertex.vPoint, State.MousePosition.Value); State.MousePosition = null; } foreach (Vertex v in State.CurrentPolygon.Vertices) { gr.FillRectangle(brush, v.Rectangle); } drawFont.Dispose(); brush.Dispose(); thick_pen.Dispose(); drawBrush.Dispose(); } }
protected void PrintF3() { F3PrinterConfig config = AllPrinterConfig.GetPrinterConfig().F3Config; //this.Draw13String(Fm.Windows.Forms.CompanyInfoForm.Info.NickName, new System.Drawing.Point(610, 75)); this.DrawTitle(new System.Drawing.Point(610, 75)); int height = (config.Down - config.Up) * PixelUnit + 150; int width = (config.Right - config.Left) * PixelUnit + 150; int sep = 36; this.Draw15String(Student.Name, new Point(width, height)); this.Draw15String(Student.Sex, new Point(width + 170, height)); this.Draw15String(Convert.ToDateTime(Student.Birthday).ToString("yyyy-MM-dd"), new Point(width + 300, height)); this.Draw15String(Student.Nation, new Point(width + 550, height)); height += sep; this.Draw15String(Student.IdCardType, new Point(width, height)); StringFormat stringFormat = new StringFormat(); stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Center; for (int i = 0; i < Student.IdCard.Length; i++) { MyGraphics.DrawString(Student.IdCard[i].ToString(), body15Font, blackBrush, new RectangleF(width + 216 + 22 * i, height - 6, 22, 35), stringFormat); //MyGraphics.DrawString(idCard[i].ToString(), body9Font, blackBrush, new RectangleF(445 + 19 * i , height - 6, 19, 35), stringFormat); // MyGraphics.DrawRectangle(blackPen, 332 + 17 * i + (i / 2) * 1, height - 7, 17, 36);+ (i / 2) * 1 // this.Draw15String(idCard[i].ToString(), new Point(334 + i * tempIdSep, height)); } height += sep + 10; this.Draw15String(Student.NewCarType, new Point(width + 150, height)); if (config.PrintProfile && student.LearnType == "增驾") { this.Draw15String(Student.Profile, new Point(width + 300, height)); } height += sep; this.Draw15String(Student.Mobile, new Point(width + 300, height)); Font check = new Font("宋体", 20); this.DrawStringHor("√", check, new Point(width + 93, height + sep));//MyGraphics.DrawImageUnscaled(Image.FromFile(Gou), new Point(width + 63, height)); }
private void PrintApply() { ApplyPrinterConfig config = AllPrinterConfig.GetPrinterConfig().ApplyConfig; int height = (config.Down - config.Up) * BaseStudentPrinter.PixelUnit + 140; //int sep = 35; int sep = 31; // int width = 132; int width = (config.Right - config.Left) * BaseStudentPrinter.PixelUnit + 90; //16,2 //MyGraphics.DrawImage(this.GetQRImage(this.GetQRString()),new Point(620,860)); //14,2 if (Student.LearnType == "初学") { if (config.Allow2Dimension) { string path = Application.StartupPath + "/temp.jpg"; //string path = Application.StartupPath + "/tempcode39.jpg"; log.Debug("要打印人的姓名:" + Student.Name); log.Debug("要打印人的身份证号码:" + Student.IdCard); log.Debug("要打印人的二维条码信息为:" + Student.Dimension); ImageHelper.SaveCoderPic(this.GetQRImage(Student.Dimension), path); // MyGraphics.DrawImage(Image.FromFile(path), new Rectangle(new Point(516 + width, 720 + height), new Size(150, 150))); Image imagetest = Image.FromFile(path); Image imagetmp = new System.Drawing.Bitmap(imagetest); MyGraphics.DrawImage(imagetest, new Rectangle(new Point(356 + width, 790 + height), new Size(130, 130))); imagetest.Dispose(); File.Delete(path); imagetmp.Dispose(); } } DateTime regDate = System.DateTime.Now; if (config.PrintApplyDate) { this.Draw10String(regDate.Year + " " + regDate.Month + " " + regDate.Day, new Point(width + 567, height + 920)); } //MyGraphics.DrawImage(this.GetQRImage(this.GetQRString()), new Point(320, 460)); //画出驾校简称 //MyGraphics.DrawRectangle(blackPen, 600, 10, 680, 30); //this.DrawStringHor("驾校简称:" + Fm.Windows.Forms.CompanyInfoForm.Info.NickName, new Point(605, 55)); // this.Draw11String("驾校简称:" + Fm.Windows.Forms.CompanyInfoForm.Info.NickName, new Point(605,55)); CompanyInfo comp = StaticCacheManager.GetConfig <CompanyInfo>(); this.DrawStringHor("驾校:" + comp.NickName, new Font("黑体", 15), new Point(480 + width - config.NameLeft * BaseStudentPrinter.PixelUnit, height - 120 + config.NameDown * BaseStudentPrinter.PixelUnit)); // 画出身份证明号码的一维条码 Code39 code39 = new Code39(); code39.WidthCU = 2; code39.LineHeight = 20; try { SizeF titleSize = MyGraphics.MeasureString("1", code39.titleFont); code39.Height = code39.topHeight + code39.LineHeight + (int)titleSize.Height;//定义图片高度 Bitmap map = code39.CreateBarCode(Student.IdCard); string path = Application.StartupPath + "/tempcode39.jpg"; ImageHelper.SaveCoderPic(map, path); Image imagetest2 = Image.FromFile(path); Image imagetmp2 = new System.Drawing.Bitmap(imagetest2); MyGraphics.DrawImage(imagetmp2, new RectangleF(width - 40, height - 46, 240, 30)); imagetest2.Dispose(); File.Delete(path); imagetmp2.Dispose(); } catch (Exception ex) { //LogFactoryWrapper.Debug("由于证件号码有汉字,不支持code39编码!"); } if (config.PrintProfile && Student.LearnType != "初学") { this.Draw15String(Student.Profile, new Point(width + 555, height - 34));//+75 } this.Draw15String(Student.Name, new Point(width, height));//+75 this.Draw15String(Student.Sex, new Point(319 + width, height)); this.Draw15String(Student.Birthday, new Point(width + 436, height)); this.Draw15String(Student.Nation, new Point(606 + width, height)); height += sep - 2; if (Student.IdCardType.Length < IdCardTypeMaxLen) { this.Draw15String(Student.IdCardType, new Point(width, height + 5)); } else { this.Draw9String(Student.IdCardType, new Point(width, height + 5)); } //画身份证号码 StringFormat stringFormat = new StringFormat(); stringFormat.LineAlignment = StringAlignment.Center; stringFormat.Alignment = StringAlignment.Center; for (int i = 0; i < Student.IdCard.Length; i++) { //MyGraphics.DrawString(idCard[i].ToString(), body11Font, blackBrush, new RectangleF(332 + 17 * i+(i/2)*1, height - 7, 17, 35), stringFormat); MyGraphics.DrawString(Student.IdCard[i].ToString(), body15Font, blackBrush, new RectangleF(width + 165 + 22 * i + (i / 6) * 1, height - 7, 22, 35), stringFormat); // MyGraphics.DrawRectangle(blackPen, 332 + 17 * i + (i / 2) * 1, height - 7, 17, 36); // this.Draw11String(idCard[i].ToString(), new Point(334 + i * tempIdSep, height)); } this.PrintSelfPhoto(); height += sep - 3; //画暂住证明 if (Student.TempId != null && Student.TempId != string.Empty) { this.Draw15String("暂住证", new Point(width, height + 5)); for (int i = 0; i < Student.TempId.Length; i++) { MyGraphics.DrawString(Student.TempId[i].ToString(), body15Font, blackBrush, new RectangleF(width + 165 + 21 * i + (i / 2) * 1, height - 5, 21, 35), stringFormat); } } height += sep + 5; //string connadd = this.GetConnAddress(); // string connadd = Student.RegAddress; string connadd = Student.ConnAddress; if (connadd.Length < ConnAddressMaxLen) { this.Draw15String(connadd, new Point(width, height)); } else { this.Draw12String(connadd, new Point(width, height)); } //this.Draw15String(Student.RegAddress, new Point(width, height)); height += sep + 5; this.Draw15String(Student.Phone, new Point(width, height)); this.Draw15String(Student.Description, new Point(410 + 100, height)); height += sep + 6; this.Draw15String(Student.Mobile, new Point(width, height)); this.Draw15String(Student.PostCode, new Point(410 + 100, height)); height += sep + 10; //this.Draw11String(this.allowCar, new Point(470, height)); this.Draw15String(Student.NewCarType, new Point(width + 170 + (config.CarRight - config.CarLeft) * BaseStudentPrinter.PixelUnit, (config.CarDown - config.CarUp) * BaseStudentPrinter.PixelUnit + height + 50)); //为增驾或者初学打钩 Font check = new Font("宋体", 20); if (Student.LearnType == "初学") { // this.Draw11String("√", new Point(width+18, height+2)); this.DrawStringHor("√", check, new Point(width - 58 + (config.GouDown - config.GouUp) * BaseStudentPrinter.PixelUnit, height - 5 + (config.GouRight - config.GouLeft) * BaseStudentPrinter.PixelUnit)); } else { //this.Draw11String("√", new Point(width+18, height+sep-1)); this.DrawStringHor("√", check, new Point(width - 58 + (config.GouDown - config.GouUp) * BaseStudentPrinter.PixelUnit, height + sep - 6 + (config.GouRight - config.GouLeft) * BaseStudentPrinter.PixelUnit)); //this.Draw15String(Student.OldCarType, new Point(568 + width, height)); } }
/// <summary> /// Metoda dodajaca miniature katalogu do wyswietlenia /// </summary> /// <param name="k">Katalog do wyswietlenia</param> public void DodajKatalog(Katalog k) { string podpis; int maxSize = Config.RozmiarMiniatury; int pos; Bitmap newBitmap, tempDir; Graphics MyGraphics; Rectangle MyRectan; int scaledD; ListViewItem listViewItem; newBitmap = new Bitmap(maxSize, maxSize); MyGraphics = Graphics.FromImage(newBitmap); scaledD = Config.RozmiarMiniatury / 2; using (Pen p = new Pen(Brushes.LightGray)) { MyGraphics.DrawRectangle(p, 0, 0, maxSize - 1, maxSize - 1); } if (k.CzyDoGory == true) { if (katalog_do_gory.Width > scaledD) { tempDir = (Bitmap)katalog_do_gory.GetThumbnailImage(scaledD, scaledD, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), System.IntPtr.Zero); pos = (maxSize - scaledD) / 2; } else { tempDir = katalog_do_gory; scaledD = katalog_do_gory.Width; } listViewItem = new ListViewItem(".."); } else { if (katalog.Width > scaledD) { tempDir = (Bitmap)katalog.GetThumbnailImage(scaledD, scaledD, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), System.IntPtr.Zero); } else { tempDir = katalog; scaledD = katalog.Width; } podpis = k.Path.Substring(k.Path.LastIndexOf('\\') + 1); if (podpis.Equals("")) { podpis = k.Path; } listViewItem = new ListViewItem(podpis); } pos = (maxSize - scaledD) / 2; MyRectan = new Rectangle(pos, pos, scaledD, scaledD); MyGraphics.DrawImage(tempDir, MyRectan); LargeImageList.Images.Add(newBitmap); listViewItem.ImageIndex = LargeImageList.Images.Count - 1; listViewItem.Tag = WidokMiniatur.listViewTag.katalog; this.Items.Add(listViewItem); this.Refresh(); }