//在每张图片下面添加姓名 private void SetNameForPic() { int i = 0; int personCount = baseList.Count; PictureBoxLZ namePicbox = new PictureBoxLZ(); namePicbox.Location = new Point(100, 225); namePicbox.Size = new Size(115 * personCount, 30); Graphics g = namePicbox.CreateGraphics(); namePicbox.flag_Name = true; namePicbox.nameList = name_list; foreach (string name in name_list) { Font drawFont = new Font("Arial", 16); SolidBrush drawBrush = new SolidBrush(Color.Black); PointF drawPoint = new PointF(100 + 130 * i, 125.0F); g.SmoothingMode = SmoothingMode.HighQuality; g.DrawString(name, drawFont, SystemBrushes.ActiveCaptionText, drawPoint); i++; } this.Controls.Add(namePicbox); }
private void GetRectImageList() { string rectPath110B = m_faceBase.m_rootPath + "方框图\\110B.jpg"; string rectPath130B = m_faceBase.m_rootPath + "方框图\\130B.jpg"; string rectPath130R = m_faceBase.m_rootPath + "方框图\\130R.jpg"; Image rectImage110B = Image.FromFile(rectPath110B); Image rectImage130B = Image.FromFile(rectPath130B); Image rectImage130R = Image.FromFile(rectPath130R); ImageList rectImageList110B = new ImageList(); ImageList rectImageList130B = new ImageList(); ImageList rectImageList130R = new ImageList(); PictureBoxLZ rectPicBox110B = new PictureBoxLZ(); PictureBoxLZ rectPicBox130B = new PictureBoxLZ(); PictureBoxLZ rectPicBox130R = new PictureBoxLZ(); rectImageList110B.ImageSize = rectImage110B.Size; rectImageList110B.Images.Add(rectImage110B); rectPicBox110B.Image = rectImageList110B.Images[0]; rectPicBox110B.Size = new Size(110, 30); rectList.Add(rectPicBox110B); rectImageList130B.ImageSize = rectImage130B.Size; rectImageList130B.Images.Add(rectImage130B); rectPicBox130B.Image = rectImageList130B.Images[0]; rectPicBox130B.Size = new Size(130, 30); rectList.Add(rectPicBox130B); rectImageList130R.ImageSize = rectImage130R.Size; rectImageList130R.Images.Add(rectImage130R); rectPicBox130R.Image = rectImageList130R.Images[0]; rectList.Add(rectPicBox130R); }
private void SetPicLayout() { Size windowSize = this.Size; int width = windowSize.Width; int height = windowSize.Height; int i = -1; int j = 0; int t_height = 0; foreach (ImageAndPicturebox imaAndPicbox in baseList) { PictureBoxLZ pictureBox = imaAndPicbox.pictureBox; if (25 + 115 * (i + 1) > width - 120) { i = 0; j++; t_height += 150; } else { i++; } pictureBox.Location = new Point(25 + 115 * i, g_pictureSize_S + /*t_height*/ j * 150); t_height = pictureBox.Location.Y; if (pictureBox.flag_Clicked) { AddSelectFlag(pictureBox, true); } } h_label.Location = new Point(25, g_pictureSize_S + j * 150 + 150); this.Controls.Add(h_label); }
private void 标离开图片(object sender, EventArgs e) { int index = 0; foreach (ImageAndPicturebox imaAndPicbox in baseList) { PictureBoxLZ pictureBox /* = new PictureBoxLZ()*/; pictureBox = imaAndPicbox.pictureBox; ImageList imageList /*= new ImageList()*/; imageList = imaAndPicbox.imageList; if (sender.Equals(pictureBox)) { pictureBox.Invoke(new EventHandler(delegate { pictureBox.flag_MouseMove = false; if (pictureBox.flag_Clicked) { if (!pictureBox.flag_MouseMove) { pictureBox.Left += 10; pictureBox.Size = new Size(g_pictureSize_S, g_pictureSize_S); } pictureBox.Invoke(new EventHandler(delegate { Point point = pictureBox.Location; PictureBoxLZ rectPic = (PictureBoxLZ)(rectList[0]); rectPic.Location = new Point(point.X - 5, point.Y + 120); this.Controls.Remove((PictureBoxLZ)rectList[1]); this.Controls.Add(rectPic); })); pictureBox.MouseLeave -= new EventHandler(this.标离开图片); } else { if (!pictureBox.flag_MouseMove) { pictureBox.Left += 10; pictureBox.Size = new Size(g_pictureSize_S, g_pictureSize_S); this.Controls.Add(pictureBox); } pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.标滑过图片); } })); this.Controls.Remove(name_label); } index++; } }
private void FillImageList() { try { m_imageList.ImageSize = g_pictureSize; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } int i = 0; foreach (string name in name_list) { ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); string path = m_faceBase.m_rootPath + name; path += "\\" + name + "0.bmp"; Image image = Image.FromFile(path, true); // ImageList imageList = new ImageList(); // imageList.ImageSize = g_pictureSize; // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.AutoSize = false; pictureBox.Location = new Point(100 + i * 115, 100); pictureBox.Size = new Size(100, 100); pictureBox.Size = g_pictureSize; pictureBox.SizeMode = PictureBoxSizeMode.Zoom; pictureBox.Image = image; pictureBox.m_name = name; this.Controls.Add(pictureBox); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.标滑过图片); pictureBox.MouseLeave += new System.EventHandler(this.标离开图片); pictureBox.Click += new System.EventHandler(this.标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.标双击图像); m_pictureBoxList.Add(pictureBox); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); i++; } name_label.AutoSize = true; name_label.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); name_label.Location = new System.Drawing.Point(240, 61); name_label.Size = new System.Drawing.Size(0, 28); }
private void FillImageList() { try { m_imageList.ImageSize = g_pictureSize; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } int i = 0; foreach (string name in name_list) { ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); string path = m_faceBase.m_rootPath + name; path += "\\" + name + "0.bmp"; Image image = Image.FromFile(path, true); // ImageList imageList = new ImageList(); // imageList.ImageSize = g_pictureSize; // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.AutoSize = false; pictureBox.Location = new Point(100 + i * 115, 100); pictureBox.Size = new Size(100,100); pictureBox.Size = g_pictureSize; pictureBox.SizeMode=PictureBoxSizeMode.Zoom; pictureBox.Image=image; pictureBox.m_name = name; this.Controls.Add(pictureBox); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.鼠标滑过图片); pictureBox.MouseLeave += new System.EventHandler(this.鼠标离开图片); pictureBox.Click += new System.EventHandler(this.鼠标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.鼠标双击图像); m_pictureBoxList.Add(pictureBox); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); i++; } name_label.AutoSize = true; name_label.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); name_label.Location = new System.Drawing.Point(240, 61); name_label.Size = new System.Drawing.Size(0, 28); }
private void FillImageList() { try { m_imageList.ImageSize = g_pictureSize; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } int i = 0; foreach (string trainPersonImageInfo in m_personImagesInfo) { ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); string path = trainPersonImageInfo; Image image = Image.FromFile(path); // ImageList imageList = new ImageList(); // imageList.ImageSize = g_pictureSize; // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.AutoSize = false; pictureBox.SizeMode = PictureBoxSizeMode.Zoom; pictureBox.Image = image; pictureBox.m_name = trainPersonImageInfo.Substring(trainPersonImageInfo.LastIndexOf("\\") + 1); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.标滑过图片); pictureBox.MouseLeave += new EventHandler(this.标离开图片); pictureBox.Click += new System.EventHandler(this.标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.标双击图像); m_pictureBoxList.Add(pictureBox); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); old_baseList.Add(imaAndPicbox); i++; } //old_baseList = baseList; name_label.AutoSize = true; name_label.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); name_label.Location = new System.Drawing.Point(240, 61); name_label.Size = new System.Drawing.Size(0, 28); this.label_name.Text = m_name; }
private void AddOnePicbox(string newPicPath) { if (newPicPath == null && newPicPath == "") { return; } Image image = Image.FromFile(newPicPath); // ImageList imageList = new ImageList(); // imageList.ImageSize = new Size(100,100); // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; pictureBox.Size = new Size(100, 100); pictureBox.m_name = newPicPath.Substring(newPicPath.LastIndexOf("\\") + 1); Size windowSize = this.Size; int width = windowSize.Width; int height = windowSize.Height; pictureBox.Image = image; if (m_lastPicboxLocation.Y < 100) { m_lastPicboxLocation = new Point(-90, 100); } if (m_lastPicboxLocation.X > width - 235) { pictureBox.Location = new Point(25, m_lastPicboxLocation.Y + 150 - m_delta); } else { pictureBox.Location = new Point(m_lastPicboxLocation.X + 115, m_lastPicboxLocation.Y - m_delta); } m_lastPicboxLocation = new Point(pictureBox.Location.X, pictureBox.Location.Y + m_delta); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.标滑过图片); pictureBox.MouseLeave += new EventHandler(this.标离开图片); pictureBox.Click += new System.EventHandler(this.标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.标双击图像); m_pictureBoxList.Add(pictureBox); h_label.Location = new Point(25, pictureBox.Location.Y + 150); this.Controls.Add(pictureBox); ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); }
private void AddNameLable(PictureBoxLZ pictureBox) { Graphics graphics = CreateGraphics(); SizeF sizeF = graphics.MeasureString(pictureBox.m_name, name_label.Font); graphics.Dispose(); Point point = pictureBox.Location; Size size = pictureBox.Size; name_label.Location = new Point((int)(point.X + 0.5 * (size.Width - (int)sizeF.Width)), point.Y + 123); this.name_label.Text = pictureBox.m_name; this.Controls.Add(name_label); }
private void AddOnePicbox(string newPersonName) { string newPersonPicPath = m_faceBase.m_rootPath + newPersonName + "\\" + newPersonName + "0.bmp"; Image image = Image.FromFile(newPersonPicPath); // ImageList imageList = new ImageList(); // imageList.ImageSize = new Size(100, 100); // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.Size = new Size(100, 100); pictureBox.m_name = newPersonName; Size windowSize = this.Size; int width = windowSize.Width; int height = windowSize.Height; pictureBox.Image = image; if (m_lastPicboxLocation.X > width - 235) { pictureBox.Location = new Point(25, m_lastPicboxLocation.Y + 150 - m_delta); } else { pictureBox.Location = new Point(m_lastPicboxLocation.X + 115, m_lastPicboxLocation.Y - m_delta); } m_lastPicboxLocation = new Point(pictureBox.Location.X, pictureBox.Location.Y + m_delta); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.标滑过图片); pictureBox.MouseLeave += new EventHandler(this.标离开图片); pictureBox.Click += new System.EventHandler(this.标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.标双击图像); m_pictureBoxList.Add(pictureBox); h_label.Location = new Point(25, pictureBox.Location.Y + 150); this.Controls.Add(pictureBox); ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); }
private void AddSelectFlag(PictureBoxLZ pictureBox, bool formChanged = false) { Point point = pictureBox.Location; Size size = pictureBox.Size; PictureBoxLZ rectPic; if (!formChanged) { rectPic = (PictureBoxLZ)(rectList[1]); } else { rectPic = (PictureBoxLZ)(rectList[0]); } rectPic.Location = new Point(point.X - 5, point.Y + 120); this.Controls.Add(rectPic); pictureBox.flag_Clicked = true; }
private void FillImageList() { try { m_imageList.ImageSize = g_pictureSize; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } int i = 0; foreach (string trainPersonImageInfo in m_personImagesInfo) { ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); string path =trainPersonImageInfo; Image image = Image.FromFile(path); // ImageList imageList = new ImageList(); // imageList.ImageSize = g_pictureSize; // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.AutoSize = false; pictureBox.SizeMode = PictureBoxSizeMode.Zoom; pictureBox.Image = image; pictureBox.m_name = trainPersonImageInfo.Substring(trainPersonImageInfo.LastIndexOf("\\")+1); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.鼠标滑过图片); pictureBox.MouseLeave += new EventHandler(this.鼠标离开图片); pictureBox.Click += new System.EventHandler(this.鼠标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.鼠标双击图像); m_pictureBoxList.Add(pictureBox); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); old_baseList.Add(imaAndPicbox); i++; } //old_baseList = baseList; name_label.AutoSize = true; name_label.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); name_label.Location = new System.Drawing.Point(240, 61); name_label.Size = new System.Drawing.Size(0, 28); this.label_name.Text = m_name; }
private void AddOnePicbox(string newPicPath) { if (newPicPath==null&&newPicPath=="") { return; } Image image = Image.FromFile(newPicPath); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; pictureBox.Size = new Size(100, 100); pictureBox.m_name = newPicPath.Substring(newPicPath.LastIndexOf("\\") + 1); Size windowSize = this.Size; int width = windowSize.Width; int height = windowSize.Height; pictureBox.Image = image; if (m_lastPicboxLocation.Y < 100) { m_lastPicboxLocation = new Point(-90,100); } if (m_lastPicboxLocation.X > width - 235) { pictureBox.Location = new Point(25, m_lastPicboxLocation.Y + 150-m_delta); } else { pictureBox.Location = new Point(m_lastPicboxLocation.X + 115, m_lastPicboxLocation.Y-m_delta); } m_lastPicboxLocation = new Point(pictureBox.Location.X,pictureBox.Location.Y+m_delta); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.鼠标滑过图片); pictureBox.MouseLeave += new EventHandler(this.鼠标离开图片); pictureBox.Click += new System.EventHandler(this.鼠标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.鼠标双击图像); m_pictureBoxList.Add(pictureBox); h_label.Location = new Point(25, pictureBox.Location.Y + 150); this.Controls.Add(pictureBox); ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); }
private void AddOnePicbox(string newPersonName) { string newPersonPicPath = m_faceBase.m_rootPath + newPersonName + "\\" + newPersonName + "0.bmp"; Image image = Image.FromFile(newPersonPicPath); // ImageList imageList = new ImageList(); // imageList.ImageSize = new Size(100, 100); // imageList.Images.Add(image); m_imageList.Images.Add(image); PictureBoxLZ pictureBox = new PictureBoxLZ(); pictureBox.Size = new Size(100, 100); pictureBox.m_name = newPersonName; Size windowSize = this.Size; int width = windowSize.Width; int height = windowSize.Height; pictureBox.Image = image; if (m_lastPicboxLocation.X > width - 235) { pictureBox.Location = new Point(25, m_lastPicboxLocation.Y + 150 - m_delta); } else { pictureBox.Location = new Point(m_lastPicboxLocation.X + 115, m_lastPicboxLocation.Y - m_delta); } m_lastPicboxLocation = new Point(pictureBox.Location.X, pictureBox.Location.Y + m_delta); pictureBox.Cursor = Cursors.Hand; pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.鼠标滑过图片); pictureBox.MouseLeave += new EventHandler(this.鼠标离开图片); pictureBox.Click += new System.EventHandler(this.鼠标点击图片); pictureBox.DoubleClick += new System.EventHandler(this.鼠标双击图像); m_pictureBoxList.Add(pictureBox); h_label.Location = new Point(25, pictureBox.Location.Y + 150); this.Controls.Add(pictureBox); ImageAndPicturebox imaAndPicbox = new ImageAndPicturebox(); //imaAndPicbox.imageList = imageList; imaAndPicbox.pictureBox = pictureBox; baseList.Add(imaAndPicbox); }