public DrawImageUnscaledAndClipped ( Image image, |
||
image | Image | |
rect | ||
return | void |
///<summary> /// RenderButton ///</summary> ///<param name="g"></param> ///<param name="image"></param> ///<param name="buttonBounds"></param> ///<param name="clipBounds"></param> static public Size RenderButton(Graphics g, Image image, Rectangle buttonBounds, Rectangle clipBounds) { if (image != null && buttonBounds.IsEmpty == false) { Rectangle r = buttonBounds; r.Width++; r.Height++; if (r.Width > image.Width) { r.X += (r.Width - image.Width)/2; r.Width = image.Width; } if (r.Height > image.Height) { r.Y += (r.Height - image.Height)/2; r.Height = image.Height; } r.Intersect(clipBounds); g.DrawImageUnscaledAndClipped(image, r); return (r.Size); } return (Size.Empty); }
/// <summary> /// Draws an image centred on the specified graphics context. /// </summary> /// <param name="g">The graphics context on which the image is to be centred and drawn.</param> /// <param name="image">The image to be centred and drawn.</param> protected void DrawImageCentered(System.Drawing.Graphics g, Image image) { Size bounds = this.Size; Size size = image.Size; Point offset = new Point((bounds.Width - size.Width) / 2, (bounds.Height - size.Height) / 2); g.DrawImageUnscaledAndClipped(image, new Rectangle(offset, image.Size)); }
public void DrawMap(Graphics device) { foreach (Tile tile in mapTiles) { device.DrawImageUnscaledAndClipped(tile.TileImg, new Rectangle(tile.TileLocation, new Size(40, 40))); //device.DrawImage(t.img, t.loc); } }
public override void DrawIcon(Graphics g, Rectangle bounds) { if (IsRoot) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.arrow.png"), bounds); } else { ObjectIconRenderer.Render(analysis.TargetObject, g, bounds); } }
public void DrawImageUnscaledAndClipped(Image image, Rectangle rect) { Bitmap currentBitmap = new Bitmap(rect.Width, rect.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(currentBitmap); g.DrawImageUnscaledAndClipped(image, new Rectangle(0, 0, rect.Width, rect.Height)); this.DrawImage(currentBitmap, rect); }
public override void DrawFrame(ConcurrentGifsCommand.Frame currentFrame, Graphics gfx) { if (currentFrame.Start < _startTime) return; var newBackground = Image.FromStream(this.GetType().Assembly.GetManifestResourceStream( "Gifenstein.Resources.AllRightGentlemen_impressed.png")); gfx.DrawImageUnscaledAndClipped(newBackground, new Rectangle(0, VerticalOffset, newBackground.Width, newBackground.Height)); base.DrawFrame(currentFrame, gfx); }
public static void RenderType(ITypeDefOrRef type, Graphics g, Rectangle bounds) { var typeDef = type as TypeDef; if (typeDef == null) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.type.png"), bounds); return; } Image icon, visibility; icon = Resources.GetResource<Image>("Icons.ObjModel.type.png"); if (typeDef.IsInterface) { icon = Resources.GetResource<Image>("Icons.ObjModel.interface.png"); } else if (typeDef.BaseType != null) { if (typeDef.IsEnum) { icon = Resources.GetResource<Image>("Icons.ObjModel.enum.png"); } else if (typeDef.IsValueType && !typeDef.IsAbstract) { icon = Resources.GetResource<Image>("Icons.ObjModel.valuetype.png"); } else if (typeDef.IsDelegate()) { icon = Resources.GetResource<Image>("Icons.ObjModel.delegate.png"); } } switch (typeDef.Visibility) { case TypeAttributes.NotPublic: case TypeAttributes.NestedAssembly: case TypeAttributes.NestedFamANDAssem: visibility = Resources.GetResource<Image>("Icons.ObjModel.internal.png"); break; case TypeAttributes.NestedPrivate: visibility = Resources.GetResource<Image>("Icons.ObjModel.private.png"); break; case TypeAttributes.NestedFamily: visibility = Resources.GetResource<Image>("Icons.ObjModel.protected.png"); break; case TypeAttributes.NestedFamORAssem: visibility = Resources.GetResource<Image>("Icons.ObjModel.famasm.png"); break; case TypeAttributes.Public: case TypeAttributes.NestedPublic: default: visibility = null; break; } g.DrawImageUnscaledAndClipped(icon, bounds); if (visibility != null) g.DrawImageUnscaledAndClipped(visibility, bounds); }
public override void Draw(System.Drawing.Graphics g) { if (IsVisible) { g.TranslateTransform(Location.X + 50, Location.Y + 50); g.DrawArc(new System.Drawing.Pen(new SolidBrush(Color.FromArgb(Convert.ToInt32(255 * Animation), Color.Blue)), 8), new RectangleF(-50, -50, 100, 100), -90, Animation * 360); nearestItem = GetNearestItem(); for (int i = 0; i < actions.Count; i++) { g.RotateTransform(-360 * i / actions.Count); g.TranslateTransform(100, 0); g.RotateTransform(360 * i / actions.Count); if (i != nearestItem) { g.ScaleTransform(0.75f, 0.75f); } Actions[i].Draw(g, Animation); if (i != nearestItem) { g.ScaleTransform(1f / 0.75f, 1f / 0.75f); } g.RotateTransform(-360 * i / actions.Count); g.TranslateTransform(-100, 0); g.RotateTransform(360 * i / actions.Count); } float angle = Game.GetPointAngle(new Point(Convert.ToInt32(Location.X) + 50, Convert.ToInt32(Location.Y) + 50), Program.game.MousePosition); float length = Game.GetPointLength(new Point(Convert.ToInt32(Location.X) + 50, Convert.ToInt32(Location.Y) + 50), Program.game.MousePosition); PointF translateLength = Game.LengthDir(64, -angle); if (length > 50) { g.TranslateTransform(translateLength.X, translateLength.Y); g.RotateTransform(-angle); g.TranslateTransform(-16, -16); g.DrawImageUnscaledAndClipped(Properties.Resources.Arrow, new Rectangle(0, 0, Properties.Resources.Arrow.Width, Properties.Resources.Arrow.Height)); g.TranslateTransform(16, 16); g.RotateTransform(angle); g.TranslateTransform(-translateLength.X, -translateLength.Y); } //g.DrawImageUnscaledAndClipped() //g.DrawString(nearestItem.ToString(), new Font("Segoe UI", 14), Brushes.Blue, new PointF(0, 0)); g.TranslateTransform(-Location.X, -Location.Y); g.ResetTransform(); } }
/// <summary> /// Draw rectangle /// </summary> /// <param name="g"></param> public override void Draw(Graphics g) { var property = Property as GridProperty; var brush = new SolidBrush(PropertyUtility.ParseToColor(property.BackgroudColor)); var pen = new Pen(PropertyUtility.ParseToColor(property.BorderColor), PropertyUtility.ParseToNumber(property.BorderThickness)); var rect = GraphicUtility.GetNormalizedRectangle(Rect); var drawRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); var treeImage = ImageUtility.ReadDataGrid(new Size(rect.Width, rect.Height)); g.DrawRectangle(pen, rect); g.FillRectangle(brush, rect); g.DrawImageUnscaledAndClipped(treeImage, rect); treeImage.Dispose(); pen.Dispose(); }
/// <summary> /// Creates an icon using the specified icon resource and resource resolver. /// </summary> /// <param name="iconSize">The size of the desired icon.</param> /// <param name="resourceResolver">The resource resolver with which to resolve the requested icon resource.</param> /// <returns>An <see cref="Image"/> constructed from the requested resource.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="resourceResolver"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="resourceResolver"/> was unable to resolve the requested icon resource.</exception> public override Image CreateIcon(IconSize iconSize, IResourceResolver resourceResolver) { Image iconBase = base.CreateIcon(iconSize, resourceResolver); if (this.ShowMouseButtonIconOverlay) { Image iconOverlay = GetButtonOverlay(iconSize); if (iconOverlay != null) { using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(iconBase)) { g.DrawImageUnscaledAndClipped(iconOverlay, new Rectangle(Point.Empty, iconBase.Size)); } iconOverlay.Dispose(); } } return(iconBase); }
/// <summary> /// Cell painting /// </summary> /// <param name="graphics"></param> /// <param name="clipBounds"></param> /// <param name="cellBounds"></param> /// <param name="rowIndex"></param> /// <param name="elementState"></param> /// <param name="value"></param> /// <param name="formattedValue"></param> /// <param name="errorText"></param> /// <param name="cellStyle"></param> /// <param name="advancedBorderStyle"></param> /// <param name="paintParts"></param> protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { if (DataGridView != null) { // First paint the borders of the cell if (PartsSet(paintParts, DataGridViewPaintParts.Border)) PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle); // Now paint the background and content if (PartsSet(paintParts, DataGridViewPaintParts.Background)) { Rectangle rBk = GetBackBounds(cellBounds, advancedBorderStyle); if (rBk.Height > 0 && rBk.Width > 0) { DataGridViewProgressBarXColumn oc = (DataGridViewProgressBarXColumn)OwningColumn; Bitmap bm = oc.GetCellBitmap(cellBounds); if (bm != null) { using (Graphics g = Graphics.FromImage(bm)) { PaintButtonBackground(g, cellStyle, rBk); PaintButtonContent(cellBounds, rowIndex, formattedValue, cellStyle, paintParts, bm); graphics.DrawImageUnscaledAndClipped(bm, rBk); } if ((DataGridView.ShowCellErrors == true) && (paintParts & DataGridViewPaintParts.ErrorIcon) == DataGridViewPaintParts.ErrorIcon) { base.PaintErrorIcon(graphics, clipBounds, cellBounds, errorText); } } } } } }
protected override void RenderProgressBar(float progress, System.Drawing.Graphics g) { g.DrawImageUnscaledAndClipped(_tray, new Rectangle(Point.Empty, _tray.Size)); if (progress <= 0f) { // paint nothing } else if (progress >= 1f) { // paint the full bar DrawImageCentered(g, _bar); } else { // paint a portion of the bar using the alpha channel of the marquee mask using (Bitmap bar = new Bitmap(_bar)) { int cols = _bar.Size.Width; int rows = _bar.Size.Height; int size = rows * cols; for (int i = 0; i < size; i++) { int x = i % cols; int offsetX = x - _offset; int y = i / cols; if (offsetX >= 0 && offsetX < _mask.Width) { var c = bar.GetPixel(x, y); bar.SetPixel(x, y, Color.FromArgb(_mask.GetPixel(offsetX, y).A *c.A / 255, c)); } else { bar.SetPixel(x, y, Color.Transparent); } } DrawImageCentered(g, bar); } } DrawImageCentered(g, _border); }
/// <summary> /// Draw rectangle /// </summary> /// <param name="g"></param> public override void Draw(Graphics g) { var property = Property as ImageProperty; var brush = new SolidBrush(PropertyUtility.ParseToColor(property.BackgroudColor)); var pen = new Pen(PropertyUtility.ParseToColor(property.BorderColor), PropertyUtility.ParseToNumber(property.BorderThickness)); var rect = GraphicUtility.GetNormalizedRectangle(Rect); var drawRect = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height); var imagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, property.BackgroudImage); var treeImage = ImageUtility.ReadImage(imagePath, new Size(rect.Width, rect.Height)); g.DrawRectangle(pen, rect); g.FillRectangle(brush, rect); g.DrawImageUnscaledAndClipped(treeImage, rect); treeImage.Dispose(); pen.Dispose(); }
protected override void RenderProgressBar(float progress, System.Drawing.Graphics g) { g.DrawImageUnscaledAndClipped(_tray, new Rectangle(Point.Empty, _tray.Size)); using (Bitmap bar = new Bitmap(_bar)) { int cols = _bar.Size.Width; int rows = _bar.Size.Height; int size = rows * cols; int max = (int)(progress * cols); for (int i = 0; i < size; i++) { if (i % cols > max) { bar.SetPixel(i % cols, i / cols, Color.Transparent); } } DrawImageCentered(g, bar); } DrawImageCentered(g, _border); }
protected override void RenderProgressBar(float progress, System.Drawing.Graphics g) { int max = (int)(progress * _tray.Width); if (progress >= 1f) { max = _blockCount * _blockWidth; } using (Bitmap blocks = new Bitmap(_tray)) { // draw the blocks to a temporary buffer using (System.Drawing.Graphics gBlocks = System.Drawing.Graphics.FromImage(blocks)) { for (int x = 0; x < max; x += _blockWidth) { gBlocks.DrawImageUnscaledAndClipped(_block, new Rectangle(new Point(x, _blockOffsetY), _block.Size)); } } // remask the blocks using the tray as a guideline int cols = _tray.Size.Width; int rows = _tray.Size.Height; int size = rows * cols; for (int i = 0; i < size; i++) { int x = i % cols; int y = i / cols; blocks.SetPixel(x, y, Color.FromArgb(_tray.GetPixel(x, y).A, blocks.GetPixel(x, y))); } // paint the temporary buffer onto the real buffer DrawImageCentered(g, blocks); } DrawImageCentered(g, _border); }
public void Render(MapControl mapCtrl, Graphics buffer, Rectangle area) { if (_textBrush == null) { _textBrush = new SolidBrush(mapCtrl.ForeColor); } int startTileX, startTileY, tilesCntX, tilesCntY; _map.InvalidateArea(area, out startTileX, out startTileY, out tilesCntX, out tilesCntY); for (int x = startTileX; x < startTileX + tilesCntX; x++) { for (int y = startTileY; y < startTileY + tilesCntY; y++) { Rectangle destRect = new Rectangle(x * _map.TileWidth - area.X, y * _map.TileHeight - area.Y, _map.TileWidth, _map.TileHeight); buffer.DrawImageUnscaledAndClipped(_map[x, y], destRect); if (mapCtrl.ShowTileNumber) { buffer.DrawString(string.Format("{0}:{1}", x, y), mapCtrl.Font, _textBrush, destRect, _textFormat); } } } }
public new void draw(Graphics g) { if (_resize) g.DrawImage(_image, rect()); else g.DrawImageUnscaledAndClipped(_image, rect()); Pen p = new Pen(_forecolor); if (selected) p.Width = 2; p.DashStyle = ds; g.DrawRectangle(p, rect()); }
public static Bitmap DrawToBitmap(IPresentationImage image, ExportImageParams exportParams) { Platform.CheckForNullReference(image, "image"); Platform.CheckForNullReference(exportParams, "exportParams"); if (!(image is ISpatialTransformProvider) || !(image is IImageGraphicProvider)) { throw new ArgumentException("The image must implement IImageGraphicProvider and have a valid ImageSpatialTransform in order to be exported."); } if (exportParams.ExportOption == ExportOption.TrueSize) { var imageSopProvider = image as IImageSopProvider; var pixelSpacing = imageSopProvider == null ? null : imageSopProvider.Frame.NormalizedPixelSpacing; if (pixelSpacing == null || pixelSpacing.IsNull) { throw new ArgumentException("The image does not contain pixel spacing information. TrueSize export is not possible."); } } ImageSpatialTransform transform = ((ISpatialTransformProvider)image).SpatialTransform as ImageSpatialTransform; if (transform == null) { throw new ArgumentException("The image must have a valid ImageSpatialTransform in order to be exported."); } if (exportParams.ExportOption == ExportOption.TrueSize) { return(DrawTrueSizeImageToBitmap(image, exportParams.OutputSize, exportParams.Dpi)); } if (exportParams.SizeMode == SizeMode.Scale) { // TODO: Refactor ImageExporter, so there only the displayRectangle and OutputRectangle are provided // Scale can be automatically figured out. // A "Padded" option can be provided to distinguish between the current Fixed and ScaleToFit options // TODO: Refactor ImageExporter, so there are separate exporters for each ExportOption. // The ExportImageParams is getting too many options and not all of them are applicable to each exporter // Instead, each exporter should have its own parameters. if (exportParams.ExportOption == ExportOption.Wysiwyg) { return(DrawWysiwygImageToBitmap(image, exportParams.DisplayRectangle, exportParams.Scale, exportParams.Dpi)); } else { return(DrawCompleteImageToBitmap(image, exportParams.Scale, exportParams.Dpi)); } } else if (exportParams.SizeMode == SizeMode.ScaleToFit) { if (exportParams.ExportOption == ExportOption.Wysiwyg) { var scale = ScaleToFit(exportParams.DisplayRectangle.Size, exportParams.OutputSize); return(DrawWysiwygImageToBitmap(image, exportParams.DisplayRectangle, scale, exportParams.Dpi)); } else { var sourceImage = (IImageGraphicProvider)image; var scale = ScaleToFit(new Size(sourceImage.ImageGraphic.Columns, sourceImage.ImageGraphic.Rows), exportParams.OutputSize); return(DrawCompleteImageToBitmap(image, scale, exportParams.Dpi)); } } else { Bitmap paddedImage = new Bitmap(exportParams.OutputSize.Width, exportParams.OutputSize.Height); using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(paddedImage)) { // paint background using (Brush b = new SolidBrush(exportParams.BackgroundColor)) { graphics.FillRectangle(b, new Rectangle(Point.Empty, exportParams.OutputSize)); } // paint image portion Bitmap bmp; if (exportParams.ExportOption == ExportOption.Wysiwyg) { float scale = ScaleToFit(exportParams.DisplayRectangle.Size, exportParams.OutputSize); bmp = DrawWysiwygImageToBitmap(image, exportParams.DisplayRectangle, scale, exportParams.Dpi); } else { IImageGraphicProvider sourceImage = (IImageGraphicProvider)image; float scale = ScaleToFit(new Size(sourceImage.ImageGraphic.Columns, sourceImage.ImageGraphic.Rows), exportParams.OutputSize); bmp = DrawCompleteImageToBitmap(image, scale, exportParams.Dpi); } graphics.DrawImageUnscaledAndClipped(bmp, new Rectangle(CenterRectangles(bmp.Size, exportParams.OutputSize), bmp.Size)); bmp.Dispose(); } return(paddedImage); } }
public override void Draw(Graphics g, float zoom, PointF offset, PointF zoomPosition, Point tbOffset) { RectangleF rect = Helpers.NormalizedRect(currentRectangle.Location, new PointF(currentRectangle.Right, currentRectangle.Bottom)); int x0 = (int)(rect.Left * zoom + offset.X); int y0 = (int)(rect.Top * zoom + offset.Y); var x1 = (int)(rect.Width * zoom); var y1 = (int)(rect.Height * zoom); textAreaRect = new Rectangle(x0, y0, x1, y1); if (x1 == 0 || y1 == 0) return; var arrow = new Point((int)(arrowPoint.point.X * zoom + offset.X), (int)(arrowPoint.point.Y * zoom + offset.Y)); if (ImageViewPort.CastShadow) { GraphicsPath pth2 = Create(x0 + (int)(3 * zoom), y0 + (int)(3 * zoom), (int)textAreaRect.Width, (int)textAreaRect.Height, 7, true, arrow); using (Brush backBrush = new SolidBrush(Color.FromArgb(64, 0, 0, 0))) { g.FillPath(backBrush, pth2); } } var pth = Create(x0, y0, (int)textAreaRect.Width, (int)textAreaRect.Height, 7, true, arrow); using (Brush backBrush = new SolidBrush(backColor)) { using (var pen = new Pen(borderColor)) { pen.Width = borderSize; g.FillPath(backBrush, pth); g.DrawPath(pen, pth); } } var tmpRect = new Rectangle((int)textAreaRect.Location.X + 4, (int)textAreaRect.Location.Y + 4, (int)textAreaRect.Size.Width - 8, (int)textAreaRect.Size.Height - 8); if (EditMode) { if(needToUpdateTb) { tpText.Size = new Size(tmpRect.Width, tmpRect.Height); tpText.Location = new Point(tmpRect.Location.X + tbOffset.X, tmpRect.Location.Y + tbOffset.Y); needToUpdateTb = false; } } else if (textAreaImage != null) { g.DrawImageUnscaledAndClipped(textAreaImage, tmpRect); } }
public static void RenderAssembly(IAssembly assembly, Graphics g, Rectangle bounds) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.assembly.png"), bounds); }
public override void DrawIcon(Graphics g, Rectangle bounds) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.error.png"), bounds); }
protected virtual void PaintTabText(Graphics g, int index) { float gap = 0; var image = GetTabImage(index); var rect = base.GetTabRect(index); var bounds = new RectangleF( (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); if (image != null) { if (IsHorizontal) gap = (bounds.Height - (float)image.Height) / 2f; else gap = (bounds.Width - (float)image.Width) / 2f; } var sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; sf.Trimming = StringTrimming.EllipsisCharacter; sf.FormatFlags |= StringFormatFlags.LineLimit; if (!IsHorizontal) sf.FormatFlags |= StringFormatFlags.DirectionVertical; if (image == null) // simple: just center the text in the tab { using (SolidBrush brush = new SolidBrush(textColor)) g.DrawString( base.TabPages[index].Text, Font, brush, (RectangleF)base.GetTabRect(index), sf); } else // We have an image, we try to measure the text. { var rectf = (RectangleF)base.GetTabRect(index); var text = base.TabPages[index].Text; var maxAvailableArea = SizeF.Empty; if (IsHorizontal) maxAvailableArea = new SizeF(rectf.Width - 3f * gap - (float)image.Width, (float)image.Height); else maxAvailableArea = new SizeF((float)image.Width, rectf.Height - 3f * gap - (float)image.Height); SizeF textSize = g.MeasureString(text, Font, maxAvailableArea, sf); if (textSize.Width > maxAvailableArea.Width) textSize.Width = maxAvailableArea.Width; if (textSize.Height > maxAvailableArea.Height) textSize.Height = maxAvailableArea.Height; SizeF imageAndTextSize = SizeF.Empty; if (IsHorizontal) { imageAndTextSize.Width = (float)image.Width + gap + textSize.Width; imageAndTextSize.Height = (float)image.Height > textSize.Height ? (float)image.Height : textSize.Height; } else { imageAndTextSize.Height = (float)image.Height + gap + textSize.Height; imageAndTextSize.Width = (float)image.Width > textSize.Width ? (float)image.Width : textSize.Width; } RectangleF imageAndTextBounds = new RectangleF( bounds.X + (bounds.Width - imageAndTextSize.Width) / 2f, bounds.Y + (bounds.Height - imageAndTextSize.Height) / 2f, imageAndTextSize.Width, imageAndTextSize.Height); // Draw the image var imageBounds = new Rectangle( (int)imageAndTextBounds.X, (int)imageAndTextBounds.Y, image.Width, image.Height); g.DrawImageUnscaledAndClipped(image, imageBounds); // Draw the text var textBounds = RectangleF.Empty; if (IsHorizontal) textBounds = new RectangleF( imageAndTextBounds.X + (float)image.Width + gap, imageAndTextBounds.Y, imageAndTextBounds.Width - ((float)image.Width + gap), imageAndTextBounds.Height); else textBounds = new RectangleF( imageAndTextBounds.X, imageAndTextBounds.Y + (float)image.Height + gap, imageAndTextBounds.Width, imageAndTextBounds.Height - ((float)image.Height + gap)); using (SolidBrush brush = new SolidBrush(textColor)) g.DrawString( base.TabPages[index].Text, Font, brush, textBounds, sf); } }
public static void RenderEvent(EventDef ev, Graphics g, Rectangle bounds) { Image visibility; switch (ev.GetVisibility()) { case MethodAttributes.CompilerControlled: case MethodAttributes.Private: visibility = Resources.GetResource<Image>("Icons.ObjModel.private.png"); break; case MethodAttributes.FamANDAssem: case MethodAttributes.Assembly: visibility = Resources.GetResource<Image>("Icons.ObjModel.internal.png"); break; case MethodAttributes.Family: visibility = Resources.GetResource<Image>("Icons.ObjModel.protected.png"); break; case MethodAttributes.FamORAssem: visibility = Resources.GetResource<Image>("Icons.ObjModel.famasm.png"); break; case MethodAttributes.Public: default: visibility = null; break; } g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.event.png"), bounds); if (visibility != null) g.DrawImageUnscaledAndClipped(visibility, bounds); if (ev.GetAccessors().Any(m => m.IsStatic)) g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.static.png"), bounds); }
public virtual void DoOnPaint(Graphics.IGraphics e) { StringFormat alginment = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Near }; int i = 0, c = 0; foreach (Class.Structure mStr in currentGame.MStructures) { c = 0; int cCard = 0; if (mStr.lstCards.Count == 0) { // Empty field e.DrawRectangle(new Pen(Color.Violet), new Rectangle(i * (this.info.Distance + this.info.Width), this.info.Y + 10, 100, 150)); i++; // Because \/ there will be continued!!!! continue; } foreach (Class.Cart mCart in mStr.lstCards) { int x = i * (this.info.Width + this.info.Distance); int y = this.info.Y + 10 + (c * 10); if (!mCart.Active) e.FillRectangle(new SolidBrush(this.info.ActiveCardsColor), new Rectangle(x, y, this.info.Width, 5)); else { Rectangle actCard; if (mStr.lstCards.IndexOf(mCart) == mStr.lstCards.Count - 1) actCard = new Rectangle(i * (this.info.Width + this.info.Distance), y + (cCard * this.info.Distance2), this.info.Width, this.info.Height); else actCard = new Rectangle(i * (this.info.Width + this.info.Distance), y + (cCard * this.info.Distance2), this.info.Width, this.info.Distance2 * 2); e.DrawImageUnscaledAndClipped(mCart.ToImage(), actCard); if (mCart.Selection) e.DrawRectangle(new Pen(this.info.SelectColor, 3), actCard); int fact = 3; if (mCart.IsTipp) e.DrawRectangle(new Pen(this.info.TipColor, 1), new Rectangle(actCard.X + fact, actCard.Y + fact, actCard.Width - fact * 2, actCard.Height - fact * 2)); cCard++; } c++; } i++; } // Draw winning cards for (int f = 1; f <= this.currentGame.WinningCards.Length; f++) { Rectangle currentRectangle = new Rectangle(this.Width - (this.info.Distance * f) - (this.info.Width * f), this.Height - this.info.Distance - this.info.Height, this.info.Width, this.info.Height); if (this.currentGame.WinningCards[f - 1] != null) { // Draw card e.DrawImage(this.currentGame.WinningCards[f - 1].ToImage(), currentRectangle); } else { // Draw rectangle e.FillRectangle(Brushes.Green, currentRectangle); } } if (currentGame.EndOfGame) e.DrawString("Sie haben gewonnen!", new Font("Segoe UI", 36, FontStyle.Regular), new SolidBrush(this.info.FontColor), this.DisplayRectangle, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); }
public override void DrawIcon(Graphics g, Rectangle bounds) { if (Module.ModuleDef != null && Module.ModuleDef.Assembly != null) g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.assembly.png"), bounds); else g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.module.png"), bounds); }
/// <summary> /// Expands the image by giving it a border by repeating the outermost pixel edges /// </summary> /// <param name="image"></param> /// <returns></returns> public static Bitmap ExpandImageBorder(Image image, int atlasPadding, bool clear) { if (image == null) { return(null); } Bitmap bitmap = new Bitmap(image.Width + (atlasPadding * 2), image.Height + (atlasPadding * 2)); System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap); // Entire image graphics.DrawImageUnscaledAndClipped(image, new Rectangle(atlasPadding, atlasPadding, image.Width, image.Height)); graphics.Dispose(); if (!clear) { Bitmap src = new Bitmap(image); for (int i = 0; i < atlasPadding; i++) { // Top for (int x = 0; x < src.Width; x++) { bitmap.SetPixel(x + atlasPadding, i, src.GetPixel(x, 0)); } // Bottom for (int x = 0; x < src.Width; x++) { bitmap.SetPixel(x + atlasPadding, bitmap.Height - 1 - i, src.GetPixel(x, src.Height - 1)); } // Left for (int y = 0; y < src.Height; y++) { bitmap.SetPixel(i, y + atlasPadding, src.GetPixel(0, y)); } // Right for (int y = 0; y < src.Height; y++) { bitmap.SetPixel(bitmap.Width - 1 - i, y + atlasPadding, src.GetPixel(src.Width - 1, y)); } // Corners for (int j = 0; j < atlasPadding; j++) { // TL bitmap.SetPixel(i, j, src.GetPixel(0, 0)); // BL bitmap.SetPixel(i, bitmap.Height - 1 - j, src.GetPixel(0, src.Height - 1)); // TR bitmap.SetPixel(bitmap.Width - 1 - i, j, src.GetPixel(src.Width - 1, 0)); // BR bitmap.SetPixel(bitmap.Width - 1 - i, bitmap.Height - 1 - j, src.GetPixel(src.Width - 1, src.Height - 1)); } } src.Dispose(); } return(bitmap); }
public override void OnRender(Graphics g) { System.Drawing.Rectangle rect = new System.Drawing.Rectangle(base.LocalPosition.X, base.LocalPosition.Y, img.Width, img.Height); g.DrawImageUnscaledAndClipped(img, rect); }
public static void RenderField(IField field, Graphics g, Rectangle bounds) { var fieldDef = field as FieldDef; if (fieldDef == null) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.field.png"), bounds); return; } Image visibility; switch (fieldDef.Access) { case FieldAttributes.CompilerControlled: case FieldAttributes.Private: visibility = Resources.GetResource<Image>("Icons.ObjModel.private.png"); break; case FieldAttributes.FamANDAssem: case FieldAttributes.Assembly: visibility = Resources.GetResource<Image>("Icons.ObjModel.internal.png"); break; case FieldAttributes.Family: visibility = Resources.GetResource<Image>("Icons.ObjModel.protected.png"); break; case FieldAttributes.FamORAssem: visibility = Resources.GetResource<Image>("Icons.ObjModel.famasm.png"); break; case FieldAttributes.Public: default: visibility = null; break; } if (fieldDef.IsStatic) { if (fieldDef.DeclaringType.IsEnum) g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.constant.png"), bounds); else { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.field.png"), bounds); if (visibility != null) g.DrawImageUnscaledAndClipped(visibility, bounds); g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.static.png"), bounds); } } else { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.field.png"), bounds); if (visibility != null) g.DrawImageUnscaledAndClipped(visibility, bounds); } }
public static void RenderProperty(PropertyDef property, Graphics g, Rectangle bounds) { Image icon, visibility; icon = Resources.GetResource<Image>("Icons.ObjModel.property.png"); if (property.SetMethod == null) { icon = Resources.GetResource<Image>("Icons.ObjModel.readonly.png"); } else if (property.GetMethod == null) { icon = Resources.GetResource<Image>("Icons.ObjModel.writeonly.png"); } switch (property.GetVisibility()) { case MethodAttributes.CompilerControlled: case MethodAttributes.Private: visibility = Resources.GetResource<Image>("Icons.ObjModel.private.png"); break; case MethodAttributes.FamANDAssem: case MethodAttributes.Assembly: visibility = Resources.GetResource<Image>("Icons.ObjModel.internal.png"); break; case MethodAttributes.Family: visibility = Resources.GetResource<Image>("Icons.ObjModel.protected.png"); break; case MethodAttributes.FamORAssem: visibility = Resources.GetResource<Image>("Icons.ObjModel.famasm.png"); break; case MethodAttributes.Public: default: visibility = null; break; } g.DrawImageUnscaledAndClipped(icon, bounds); if (visibility != null) g.DrawImageUnscaledAndClipped(visibility, bounds); if (property.GetAccessors().Any(m => m.IsStatic)) g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.static.png"), bounds); }
/// <summary> /// Draws certain tab. /// </summary> /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw tab control.</param> /// <param name="index">Index of the tab being drawn.</param> /// <param name="state">State of the tab item.</param> /// <param name="tabRect">The <see cref="T:System.Drawing.Rectangle"/> object specifying tab bounds.</param> /// <param name="textFmt">The <see cref="T:System.Drawing.StringFormat"/> object specifying text formatting /// in the tab.</param> private void DrawTabItem(Graphics g, int index, TabItemState state, Rectangle tabRect, StringFormat textFmt) { //if scroller is visible and the tab is fully placed under it we don't need to draw such tab if (fUpDown.X <= 0 || tabRect.X < fUpDown.X) { /* We will draw our tab on the bitmap and then will transfer image on the control * graphic context.*/ using (Bitmap bmp = new Bitmap(tabRect.Width, tabRect.Height)) { Rectangle drawRect = new Rectangle(0, 0, tabRect.Width, tabRect.Height); using (Graphics bitmapContext = Graphics.FromImage(bmp)) { TabRenderer.DrawTabItem(bitmapContext, drawRect, state); if (state == TabItemState.Selected && tabRect.X == 0) { int corrY = bmp.Height - 1; bmp.SetPixel(0, corrY, bmp.GetPixel(0, corrY - 1)); } /* Important moment. If tab alignment is bottom we should flip image to display tab * correctly.*/ if (this.Alignment == TabAlignment.Bottom) bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); Rectangle focusRect = Rectangle.Inflate(drawRect, -3, -3); //focus rect TabPage pg = this.TabPages[index]; //tab page whose tab we're drawing //trying to get tab image if any Image pagePict = GetImageByIndexOrKey(pg.ImageIndex, pg.ImageKey); if (pagePict != null) { //If tab image is present we should draw it. Point imgLoc = state == TabItemState.Selected ? new Point(8, 2) : new Point(6, 2); if (this.Alignment == TabAlignment.Bottom) imgLoc.Y = drawRect.Bottom - 2 - pagePict.Height; bitmapContext.DrawImageUnscaled(pagePict, imgLoc); //Correcting rectangle for drawing text. drawRect.X += imgLoc.X + pagePict.Width; drawRect.Width -= imgLoc.X + pagePict.Width; } //drawing tab text using (Brush b = new SolidBrush(SystemColors.ControlText)) bitmapContext.DrawString(pg.Text, this.Font, b, (RectangleF)drawRect, textFmt); //and finally drawing focus rect(if needed) if (this.Focused && state == TabItemState.Selected) ControlPaint.DrawFocusRectangle(bitmapContext, focusRect); } //If the tab has part under scroller we shouldn't draw that part. int shift = state == TabItemState.Selected ? 2 : 0; if (fUpDown.X > 0 && fUpDown.X >= tabRect.X - shift && fUpDown.X < tabRect.Right + shift) tabRect.Width -= tabRect.Right - fUpDown.X + shift; g.DrawImageUnscaledAndClipped(bmp, tabRect); } } }
public void Paint(Graphics graphics, bool active) { int x = boundingBox.Left; int y = boundingBox.Top; // Draw background first if the button is active. if (active) { Bitmap background = Resources.collapsing_panel_grid_bg; int bgX = x + (boundingBox.Width - background.Width) / 2; int bgY = y + (boundingBox.Height - background.Height) / 2; graphics.DrawImageUnscaled(background, bgX, bgY); // Move the button image down and right a bit to create the "pressed" effect. x++; y++; } // Center images in the available space. x += (boundingBox.Width - bitmap.Width) / 2; y += (boundingBox.Height - bitmap.Height) / 2; graphics.DrawImageUnscaled(bitmap, x, y); // Draw a left border line if not active. if (!active) { Bitmap boundary = Resources.collapsing_panel_header_tab_left_flat; graphics.DrawImageUnscaledAndClipped(boundary, new Rectangle(x, y, boundary.Width, boundingBox.Height)); } }
public static void RenderMethod(IMethod method, Graphics g, Rectangle bounds) { var methodDef = method as MethodDef; if (methodDef == null) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.method.png"), bounds); return; } Image icon, visibility; icon = Resources.GetResource<Image>("Icons.ObjModel.method.png"); if (methodDef.IsConstructor) { icon = Resources.GetResource<Image>("Icons.ObjModel.constructor.png"); } else if (methodDef.IsVirtual && !methodDef.IsAbstract) { icon = Resources.GetResource<Image>("Icons.ObjModel.override.png"); } switch (methodDef.Access) { case MethodAttributes.CompilerControlled: case MethodAttributes.Private: visibility = Resources.GetResource<Image>("Icons.ObjModel.private.png"); break; case MethodAttributes.FamANDAssem: case MethodAttributes.Assembly: visibility = Resources.GetResource<Image>("Icons.ObjModel.internal.png"); break; case MethodAttributes.Family: visibility = Resources.GetResource<Image>("Icons.ObjModel.protected.png"); break; case MethodAttributes.FamORAssem: visibility = Resources.GetResource<Image>("Icons.ObjModel.famasm.png"); break; case MethodAttributes.Public: default: visibility = null; break; } g.DrawImageUnscaledAndClipped(icon, bounds); if (visibility != null) g.DrawImageUnscaledAndClipped(visibility, bounds); if (methodDef.IsStatic) g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.static.png"), bounds); }
/// <summary> /// �����м����ָʾѪ����־��ש�� /// </summary> /// <param name="paper">����ש���graphics</param> public void Draw(Graphics paper) { Rectangle brickRect = new Rectangle(x, y, width, height); Image brickImage = materials[type]; paper.DrawImageUnscaledAndClipped(brickImage,brickRect); //��ש�� paper.DrawRectangle(Pens.Black, x, y, width, height); //��ש��ı� int radius = height/3; Rectangle trafficLight = new Rectangle(Centre.X - radius, Centre.Y - radius, 2 * radius, 2 * radius); paper.FillEllipse(strengthBrush[strength], trafficLight); //����ָʾ�� paper.DrawEllipse(Pens.Black, trafficLight); //ָʾ�Ʊ߽� }
/// <summary> /// Draws the button. /// </summary> /// <param name="graphics"> /// The graphics context used to draw the button. /// </param> public void Draw(Graphics graphics) { // Return if the button is not visible if (!this.IsVisible) { return; } // Draw button image switch (this.State) { case ButtonState.Standard: graphics.DrawImageUnscaledAndClipped(this.StandardImage, this.PositionAndSize); break; case ButtonState.Hovered: graphics.DrawImageUnscaledAndClipped(this.HoverImage, this.PositionAndSize); break; case ButtonState.Pressed: graphics.DrawImageUnscaledAndClipped(this.PressedImage, this.PositionAndSize); break; } // Draw text if any if (this.Text != string.Empty) { graphics.DrawString(this.Text, this.TextFont, new SolidBrush(this.TextColor), this.PositionAndSize); } }
private void RenderRowImage(Graphics g, GridPanel panel, TextRowVisualStyle style, Rectangle r) { if (r.Width > 0 && r.Height > 0) { Image image = style.GetImage(panel); if (image != null) g.DrawImageUnscaledAndClipped(image, r); } }
public override void DrawBackground(Graphics gfx) { gfx.DrawImageUnscaledAndClipped(_image, new Rectangle(0, VerticalOffset, _image.Width, _image.Height)); }
private void DrawBackground (Graphics g, Rectangle bounds, Image image, ImageLayout layout) { // Center and Tile don't matter if the image is larger than the control if (layout == ImageLayout.Center || layout == ImageLayout.Tile) if (image.Size.Width >= bounds.Size.Width && image.Size.Height >= bounds.Size.Height) layout = ImageLayout.None; switch (layout) { case ImageLayout.None: g.DrawImageUnscaledAndClipped (image, bounds); break; case ImageLayout.Tile: int x = 0; int y = 0; while (y < bounds.Height) { while (x < bounds.Width) { g.DrawImageUnscaledAndClipped (image, bounds); x += image.Width; } x = 0; y += image.Height; } break; case ImageLayout.Center: Rectangle r = new Rectangle ((bounds.Size.Width - image.Size.Width) / 2, (bounds.Size.Height - image.Size.Height) / 2, image.Width, image.Height); g.DrawImageUnscaledAndClipped (image, r); break; case ImageLayout.Stretch: g.DrawImage (image, bounds); break; case ImageLayout.Zoom: if (((float)image.Height / (float)image.Width) < ((float)bounds.Height / (float)bounds.Width)) { Rectangle rzoom = new Rectangle (0, 0, bounds.Width, (int)((float)bounds.Width * ((float)image.Height / (float)image.Width))); rzoom.Y = (bounds.Height - rzoom.Height)/ 2; g.DrawImage (image, rzoom); } else { Rectangle rzoom = new Rectangle (0, 0, (int)((float)bounds.Height * ((float)image.Width / (float)image.Height)), bounds.Height); rzoom.X = (bounds.Width - rzoom.Width) / 2; g.DrawImage (image, rzoom); } break; } }
private void DrawBorder(Graphics g) { g.DrawImage(this.BorderLeft, new Rectangle(0, this.TitleBarPanel.Height, this.BorderLeft.Width, base.Height - (this.TitleBarPanel.Height + this.BorderBottomLeft.Height))); g.DrawImage(this.BorderRight, new Rectangle(base.Width - this.BorderRight.Width, this.TitleBarPanel.Height, this.BorderRight.Width, base.Height - (this.TitleBarPanel.Height + this.BorderBottomRight.Height))); int num = base.Width / this.BorderBottom.Width; if ((base.Width % num) > 0) { num++; } for (int i = 0; i < num; i++) { g.DrawImageUnscaledAndClipped(this.BorderBottom, new Rectangle(i * this.BorderBottom.Width, base.Height - this.BorderBottom.Height, this.BorderBottom.Width, this.BorderBottom.Height)); } g.DrawImage(this.BorderBottomLeft, new Rectangle(0, base.Height - this.BorderBottomLeft.Height, this.BorderBottomLeft.Width, this.BorderBottomLeft.Height)); g.DrawImage(this.BorderBottomRight, new Rectangle(base.Width - this.BorderBottomRight.Width, base.Height - this.BorderBottomRight.Height, this.BorderBottomRight.Width, this.BorderBottomRight.Height)); }
public string _LookupChar(ref Bitmap bmp, string chr, int w, int h, int x, string site) { string rv; rv = ""; string[] xlines; ArrayList lines = new ArrayList(); dataentry = 1; string newlines; if (chr.IndexOf("1") > 0) { xlines = chr.Split('#'); // $lines = StringSplit($chr, "#") ++ autoit line *** foreach (string s in xlines) { lines.Add(s); } //DisplayAList(lines); if (lines.Count > 0) { while ((lines.Count >= 1) && (lines[0].ToString().IndexOf("1") == -1)) { lines.RemoveAt(0);// _ArrayDelete($lines, 1) ++ autoit line *** } while (((lines.Count) >= 1) && (lines[(lines.Count) - 1].ToString().IndexOf("1") == -1)) { lines.RemoveAt(lines.Count - 1); } newlines = ""; for (int ix = 0; ix < lines[0].ToString().Length; ix++) { for (int ax = 0; ax < lines.Count; ax++) { newlines = newlines + lines[ax].ToString().Substring(ix, 1);// $newlines = $newlines & StringMid($lines[$a], $i, 1) ++ autoit line } newlines = newlines + "#"; } xlines = newlines.Split('#');// $lines = StringSplit($newlines, "#") +++ autoit line lines.Clear(); foreach (string s in xlines) { lines.Add(s); } while ((lines.Count >= 1) && (lines[0].ToString().IndexOf("1") == -1)) { lines.RemoveAt(0);// _ArrayDelete($lines, 1) ++ autoit line *** } while (((lines.Count) >= 1) && (lines[(lines.Count) - 1].ToString().IndexOf("1") == -1)) { lines.RemoveAt(lines.Count - 1); } newlines = ""; chr = ""; for (int i = 0; i < lines.Count; i++) { chr = chr + lines[i].ToString() + "#"; } //Console.WriteLine("Reading from " + site + "Chars"); rv = FileFunctions.IniRead(scrapeini, site + "Chars", chr, ""); } else { FileFunctions.fConsoleWrite("Not enough lines to be a scan:" + chr); } if (dataentry == 1 && rv == "") { // SplashTextOn("ScanArea", "", $w, $h, $x, $y, 17) ++ autoit line //au3.SplashTextOn("ScanArea", "", w, h, x, y, 17); //au3.WinSetTrans("ScanArea", "", 130); //PlaySound(Application.StartupPath + "/Alert.wav", 0, 0); // WeylandsOCR.OCRInput = new WeylandsOCR.OCRInput(); string value = ""; Bitmap subBMP = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb); System.Drawing.Graphics GFX = Graphics.FromImage(subBMP); Rectangle xyz = new Rectangle(x, 0, w, h); GFX.DrawImageUnscaledAndClipped(bmp, xyz); GFX.Dispose(); if (ScanInputBox(ref bmp, x, chr, "OCR Self-Correction", "What character is referenced here?", ref value) == DialogResult.OK) { if (value.Trim().Length > 0) { //Console.WriteLine("Writing to " + site + "Chars"); FileFunctions.IniWrite(scrapeini, site + "Chars", chr, value); rv = value; } } } else if (rv == "") { //if (FileFunctions.IniRead(scrapeini, "Unknown", chr, "") == "") // IniWrite($scrapeini, "Unknown", $chr , @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC) +++ autoit line // FileFunctions.IniWrite(scrapeini, "Unknown", chr, DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString()); } } return(rv); }
public static void RenderModule(IModule module, Graphics g, Rectangle bounds) { g.DrawImageUnscaledAndClipped(Resources.GetResource<Image>("Icons.ObjModel.module.png"), bounds); }