public void UpdateView() { this.ViewUpdating = true; ShellControlHelper.PropertyDescriptorUpdate(this, this._entity); FormElementPictureBoxEntityDev entity = (FormElementPictureBoxEntityDev)_formElement; PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(this); PropertyDescriptor pds; pds = pdc.Find("Image", false); if (pds != null) { if (String.IsNullOrEmpty(entity.Img) == false) { ImageResourceInfo imageResource = _resourceComponentService.GetImageResource(entity.Img); if (imageResource != null) { Image image = imageResource.GetImage(); pds.SetValue(this, image); } } else { pds.SetValue(this, null); } } ShellControlHelper.SetProperty(this, "SizeMode", entity.SizeMode); this.ViewUpdating = false; }
public ImageListViewController(ImageListView imageListView) { _imageListView = imageListView; _imageListView.AllowDrop = false; _imageListView.AllowMultiSelection = true; _getImage = new ImageListViewItem.GetImageHandler((key) => { ImageResourceInfo resourceInfo = (ImageResourceInfo)key; return(resourceInfo.GetImage()); }); }
protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); graphics.FillRectangle(Brushes.White, cellBounds.X + 1, cellBounds.Y + 1, cellBounds.Width - 2, cellBounds.Height - 2); int imageLocationX = cellBounds.X + 2; int imageLocationY = cellBounds.Y + 2; int imageSizeW = 16; int imageSizeH = 16; Rectangle imageBounds = new Rectangle(imageLocationX, imageLocationY, imageSizeW, imageSizeH); int textLocationX = imageLocationX + imageSizeW + 2; int textLocationY = cellBounds.Y + 4; Point textLoation = new Point(textLocationX, textLocationY); if (this.Value != null && this.Value.ToString() != String.Empty) { string resourceName = this.Value.ToString(); Image imageDraw; if (_resourceService.Container(resourceName)) { ImageResourceInfo imageResource = _resourceService.GetImageResource(resourceName); Image image = imageResource.GetImage(); imageDraw = DrawingTool.GetScaleImage(image, imageSizeW, imageSizeH); if (image != imageDraw) { image.Dispose(); } } else { imageDraw = DrawingTool.Mark.FileNotFind(imageBounds.Size); } try { graphics.DrawImage(imageDraw, imageBounds); } catch (Exception exception) { Debug.Assert(false, exception.Message); imageDraw = DrawingTool.Mark.FileNotFind(imageBounds.Size); graphics.DrawImage(imageDraw, imageBounds); } imageDraw.Dispose(); Font font = new Font(cellStyle.Font, cellStyle.Font.Style | FontStyle.Bold); Brush textBrush = new SolidBrush(cellStyle.ForeColor); graphics.DrawString(resourceName, font, textBrush, textLoation); font.Dispose(); textBrush.Dispose(); } }
private void _listBoxController_SelectedItemChanged(object sender, EventArgs e) { _selectedImageResource = _listBoxController.GetSelectedItem <ImageResourceInfo>(); if (_selectedImageResource == null) { if (this.pictureBoxPreview.Image != null) { this.pictureBoxPreview.Image = null; } return; } if (_imageCache.Keys.Contains(_selectedImageResource) == false) { Image thumbnailImage = DrawingTool.GetAutoScaleThumbnailImage( _selectedImageResource.GetImage(), this.pictureBoxPreview.Width, this.pictureBoxPreview.Height); _imageCache.Add(_selectedImageResource, thumbnailImage); } this.pictureBoxPreview.Image = _imageCache[_selectedImageResource]; }