public void TestArtworkWriteableBitmapAdapter() { ArtworkFactory factory = new ArtworkFactory(Install, Container); ImageSource land = factory.GetLand <ImageSource>(0); ImageSource @static = factory.GetStatic <ImageSource>(0); Guard.AssertIsNotNull(land, "Land tile 0 was not found."); Guard.AssertIsNotNull(@static, "Static 0 was not found."); }
public void TestArtworkWriteableBitmapAdapter() { ArtworkFactory factory = new ArtworkFactory(Install, Container); ImageSource land = factory.GetLand<ImageSource>(0); ImageSource @static = factory.GetStatic<ImageSource>(0); Guard.AssertIsNotNull(land, "Land tile 0 was not found."); Guard.AssertIsNotNull(@static, "Static 0 was not found."); }
public void TestArtworkBitmapAdapter() { ArtworkFactory factory = new ArtworkFactory(Install, Container); Bitmap land = factory.GetLand<Bitmap>(0); Bitmap @static = factory.GetStatic<Bitmap>(0); Guard.AssertIsNotNull(land, "Land tile 0 was not found."); Guard.AssertIsNotNull(@static, "Static 0 was not found."); }
public void TestArtworkBitmapAdapter() { var factory = new ArtworkFactory(Install, Container); var land = factory.GetLand <Bitmap>(0); var @static = factory.GetStatic <Bitmap>(0); Guard.RequireIsNotNull(land, "Land tile 0 was not found."); Guard.RequireIsNotNull(@static, "Static 0 was not found."); }
public void TestArtworkBitmapAdapter() { ArtworkFactory factory = new ArtworkFactory(Install, Container); Bitmap land = factory.GetLand <Bitmap>(0); Bitmap @static = factory.GetStatic <Bitmap>(0); Guard.AssertIsNotNull(land, "Land tile 0 was not found."); Guard.AssertIsNotNull(@static, "Static 0 was not found."); }
public void TestArtworkBitmapAdapter() { var factory = new ArtworkFactory(Install, Container); var land = factory.GetLand<Bitmap>(0); var @static = factory.GetStatic<Bitmap>(0); Guard.RequireIsNotNull(land, "Land tile 0 was not found."); Guard.RequireIsNotNull(@static, "Static 0 was not found."); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); using (Brush backBrush = new LinearGradientBrush(_cellBounds, Color.Gainsboro, Color.White, LinearGradientMode.ForwardDiagonal)) using (Brush borderBrush = new SolidBrush(Color.LightSteelBlue)) using (Pen borderPen = new Pen(borderBrush)) { int startingIndex = _scrollBar.Value * _visibleColumnsCount; for (int y = 0; y < _visibleRowsCount; y++) { e.Graphics.TranslateTransform(0, y * MAX_HEIGHT); for (int x = 0; x < _visibleColumnsCount; x++) { int index = startingIndex + ((y * _visibleColumnsCount) + x); e.Graphics.FillRectangle(backBrush, _cellBounds); if (_artworkFactory != null) { Bitmap bmp = null; if (_artworkControlType == Forms.Controls.ArtworkControlType.Land) { bmp = _artworkFactory.GetLand <Bitmap>(index); } else { bmp = _artworkFactory.GetStatic <Bitmap>(index); } if (bmp != null) { e.Graphics.DrawImageUnscaledAndClipped(bmp, _cellBounds); } } e.Graphics.DrawRectangle(borderPen, _cellBounds); e.Graphics.TranslateTransform(MAX_WIDTH, 0); } e.Graphics.ResetTransform(); } e.Graphics.ResetTransform(); } if (_artworkFactory == null) { var textRenderingHint = e.Graphics.TextRenderingHint; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; using (Brush backBrush = new SolidBrush(Color.Red)) using (Brush foreBrush = new SolidBrush(Color.Maroon)) using (StringFormat format = new StringFormat()) { format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; e.Graphics.DrawString("ArtworkControl.Factory is not set.", Font, backBrush, new RectangleF(0, 0, Width, Height), format); e.Graphics.DrawString("ArtworkControl.Factory is not set.", Font, foreBrush, new RectangleF(1, 1, Width, Height), format); } e.Graphics.TextRenderingHint = textRenderingHint; } using (Brush borderBrush = new SolidBrush(Color.LightSteelBlue)) using (Pen borderPen = new Pen(borderBrush)) { e.Graphics.DrawRectangle(borderPen, new Rectangle(0, 0, Width - 1, Height - 1)); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //if (!DesignModeUtility.IsDesignMode) //{ const int MAX_WIDTH = 48; const int MAX_HEIGHT = 48; Rectangle itemBounds = new Rectangle( 0, 0, MAX_WIDTH, MAX_HEIGHT); itemBounds.Inflate(new Size(-2, -2)); using (Brush backBrush = new LinearGradientBrush(itemBounds, Color.Gainsboro, Color.White, LinearGradientMode.ForwardDiagonal)) using (Brush borderBrush = new SolidBrush(Color.LightSteelBlue)) //(itemBounds, Color.Gainsboro, Color.White, LinearGradientMode.BackwardDiagonal)) using (Pen borderPen = new Pen(borderBrush)) { int columns = Math.Max(0, ((Width - 1) / MAX_WIDTH)); int rows = Math.Max(0, ((Height - 1) / MAX_HEIGHT)); int startingIndex = 0; for (int y = 0; y < rows; y++) { e.Graphics.TranslateTransform(0, y * MAX_HEIGHT); for (int x = 0; x < columns; x++) { int index = startingIndex + ((y * columns) + x); e.Graphics.FillRectangle(backBrush, itemBounds); e.Graphics.DrawRectangle(borderPen, itemBounds); if (_artworkFactory != null) { Bitmap bmp = null; if (_artworkControlType == Forms.Controls.ArtworkControlType.Land) { bmp = _artworkFactory.GetLand <Bitmap>(index); } else { bmp = _artworkFactory.GetStatic <Bitmap>(index); } if (bmp != null) { e.Graphics.DrawImageUnscaledAndClipped(bmp, itemBounds); } } e.Graphics.TranslateTransform(MAX_WIDTH, 0); } e.Graphics.ResetTransform(); } e.Graphics.ResetTransform(); } //} if (_artworkFactory == null) { var textRenderingHint = e.Graphics.TextRenderingHint; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; using (Brush backBrush = new SolidBrush(Color.Red)) using (Brush foreBrush = new SolidBrush(Color.Maroon)) using (StringFormat format = new StringFormat()) { format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; e.Graphics.DrawString("ArtworkControl.Factory is not set.", Font, backBrush, new RectangleF(0, 0, Width, Height), format); e.Graphics.DrawString("ArtworkControl.Factory is not set.", Font, foreBrush, new RectangleF(1, 1, Width, Height), format); } e.Graphics.TextRenderingHint = textRenderingHint; } }