public SelectFaceArgs(ImageEntity img) : this() { this.Img = img; }
public SelectFaceArgs(ImageEntity img, object tag) : this(img) { this.Tag = tag; }
public bool Init(int imageWidth, int imageHeight, int nHSpace, int nVSpace, int nColumns, int nRows) { if (this.DesignMode) { return(false); } try { ImageEntity img; this.Images.Clear(); this.DrawImages.Clear(); try { if (!File.Exists(Path.Combine(Application.StartupPath, this.ImagePath + "Images.db"))) { foreach (string imgPath in Directory.GetFiles(Path.Combine(Application.StartupPath, this.ImagePath))) { img = new ImageEntity(imgPath); if (img.Image != null) { this.Images.Add(img); } } try { Tools.BinarySerializer(this.Images, Path.Combine(Application.StartupPath, this.ImagePath + "Images.db")); } catch (Exception ex) { Trace.WriteLine(ex); } } else { this.Images = Tools.BinaryDeserialize <List <ImageEntity> >(Path.Combine(Application.StartupPath, this.ImagePath + "Images.db")); try { foreach (var item in this.Images) { if (!File.Exists(item.FullName)) { item.IsDelete = true; } } } catch { } foreach (var imgItem in this.Images.FindAll(item => item.IsDelete)) { try { File.Delete(imgItem.FullName); } catch { } } } } catch { this.Images = new List <ImageEntity>(); } this.DrawImages = this.Images.FindAll(item => !item.IsDelete); this.Images = this.DrawImages.FindAll(item => !item.IsDelete); this.Demo.Width = imageWidth * 3 - 10; this.Demo.Height = imageHeight * 3 - 10; this._nColumns = nColumns; this._nRows = nRows; this._nHSpace = nHSpace; this._nVSpace = nVSpace; this._imageWidth = imageWidth; this._imageHeight = imageHeight; this._nItemWidth = imageWidth + nHSpace; this._nItemHeight = imageHeight + nVSpace; this._nBitmapWidth = this._nColumns * this._nItemWidth + 1; this._nBitmapHeight = this._nRows * this._nItemHeight + 1; this.Width = this._nBitmapWidth; this.Height = this._nBitmapHeight + 20; Graphics g = this.CreateGraphics(); this.PageIndex = 0; this.PageImageCount = this._nColumns * this._nRows; this.UpdatePageCount(); this.ClientRect = new Rectangle(0, 0, this.Width - 1, this.Height - 1); this.FaceRect = new RectangleF(0f, 0f, this._nBitmapWidth, this._nBitmapHeight); this.Rect = new RectangleF(1f, 1f, this._nBitmapWidth - 2, this._nBitmapHeight - 2); SizeF s = g.MeasureString("上一页", this.Font); SizeF i = g.MeasureString(string.Format("{0}/{1}", this.PageCount, this.PageCount), this.Font); SizeF z = g.MeasureString("单击右键进行管理!", this.Font); this.PageInfoRect = new RectangleF(new PointF(this.ClientRect.Width - s.Width * 2 - i.Width - 20, this.FaceRect.Height + 3), i); this.PageDownRect = new RectangleF(new PointF(this.ClientRect.Width - s.Width - 10, this.FaceRect.Height + 3), s); this.PageUpRect = new RectangleF(new PointF(this.ClientRect.Width - s.Width * 2 - 10, this.FaceRect.Height + 3), s); this.MemoRect = new RectangleF(new PointF(6, this.FaceRect.Height + 3), z); this.HoveColor = Color.Blue; this.DrawBackImage(); } catch (Exception ex) { Console.WriteLine(ex); return(false); } return(true); }