private void ltvBricks_DrawItem(object sender, DrawListViewItemEventArgs e) { BrickListItem item = e.Item as BrickListItem; //e.Bounds = new Rectangle(e.Bounds.X, e.Bounds.Y, item.Brick.Image.Width,item.Brick.Image.Height); e.Graphics.DrawImage(item.Brick.Image, e.Bounds); }
private void ltvBricks_SelectedIndexChanged(object sender, EventArgs e) { if (ltvBricks.SelectedItems.Count != 0) { BrickListItem item = ltvBricks.SelectedItems[0] as BrickListItem; this.brk = item.Brick; } }
private List <Brick> GetBricks() { List <Brick> lstRet = new List <Brick>(); for (int i = 0; i < ltvBricks.Items.Count; i++) { BrickListItem item = ltvBricks.Items[i] as BrickListItem; lstRet.Add(item.Brick); } return(lstRet); }
private void btnAddBrick_Click(object sender, EventArgs e) { if (ofdMapEdit.ShowDialog() == DialogResult.OK) { foreach (string fileName in ofdMapEdit.FileNames) { Brick brk = new Brick(); brk.ImagePath = fileName; brk.Image = Bitmap.FromFile(brk.ImagePath); BrickListItem item = new BrickListItem(); item.Brick = brk; item.Text = FileControler.GetFileName(brk.ImagePath); this.ltvBricks.Items.Add(item); } } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = FileControler.FILTER; if (ofd.ShowDialog() == DialogResult.OK && System.IO.File.Exists(ofd.FileName)) { this.IsNew = false; this.MapPath = ofd.FileName; this.BrickPath = FileControler.GetPath(ofd.FileName) + "Bricks\\"; MapResponse response = FileControler.Open(ofd.FileName); this.pcmMapPaint.TileHeigth = response.TileHeight; this.pcmMapPaint.TileWidth = response.TileWidth; this.pcmMapPaint.QtdColumns = response.Matrix.Columns; this.pcmMapPaint.QtdRows = response.Matrix.Rows; this.pcmMapPaint.Cells = response.Matrix; this.ltvBricks.Items.Clear(); for (int i = 0; i < response.Bricks.Count; i++) { Brick brk = response.Bricks[i]; brk.IsNew = false; brk.Image = Bitmap.FromFile(this.BrickPath + brk.ImagePath); BrickListItem item = new BrickListItem(); item.Brick = brk; item.Text = brk.ImagePath; this.ltvBricks.Items.Add(item); } this.pcmMapPaint.Invalidate(); dudWidth.Text = this.pcmMapPaint.TileHeigth.ToString(); dudHeigth.Text = this.pcmMapPaint.TileWidth.ToString(); nudColumns.Value = this.pcmMapPaint.QtdColumns; nudRows.Value = this.pcmMapPaint.QtdRows; this.lblSize.Text = pcmMapPaint.Width.ToString() + "x" + pcmMapPaint.Height.ToString(); } }