private void Initialize() { if (_background == null) { byte[] pixelData = new byte[4 * _size.Width * _size.Height]; for (int n = 0; n < pixelData.Length; n += 4) { byte[] pixel = BitConverter.GetBytes(Color.FromArgb(196, 85, 85, 85).ToArgb()); pixelData[n + 0] = pixel[0]; pixelData[n + 1] = pixel[1]; pixelData[n + 2] = pixel[2]; pixelData[n + 3] = pixel[3]; } base.Graphics.Add(_background = new ColorImageGraphic(_size.Height, _size.Width, pixelData)); } if (_progressBarGraphic == null) { base.Graphics.Add(_progressBarGraphic = ProgressBarGraphic.Create(_style)); var offset = Center(_size, _progressBarGraphic.Size) + new Size(0, 10); _progressBarGraphic.SpatialTransform.TranslationX = offset.X; _progressBarGraphic.SpatialTransform.TranslationY = offset.Y; } if (_progressTextGraphic == null) { base.Graphics.Add(_progressTextGraphic = new InvariantTextPrimitive()); var offset = Center(_size, new Size(1, 1)) - new Size(0, 15); _progressTextGraphic.SpatialTransform.TranslationX = offset.X; _progressTextGraphic.SpatialTransform.TranslationY = offset.Y; } }
private void Initialize() { if (_background == null) { var pixelCount = _size.Width * _size.Height; var pixelData = new byte[4 * pixelCount]; var fillColor = Color.FromArgb(196, 85, 85, 85).ToArgb(); unsafe { fixed(byte *pPixelBytes = pixelData) { var pPixels = (int *)pPixelBytes; for (var n = 0; n < pixelCount; ++n) { pPixels[n] = fillColor; } } } base.Graphics.Add(_background = new ColorImageGraphic(_size.Height, _size.Width, pixelData)); } if (_progressBarGraphic == null) { base.Graphics.Add(_progressBarGraphic = ProgressBarGraphic.Create(_style)); var offset = Center(_size, _progressBarGraphic.Size) + new Size(0, 10); _progressBarGraphic.SpatialTransform.TranslationX = offset.X; _progressBarGraphic.SpatialTransform.TranslationY = offset.Y; } if (_progressTextGraphic == null) { base.Graphics.Add(_progressTextGraphic = new InvariantTextPrimitive()); var offset = Center(_size, new Size(1, 1)) - new Size(0, 15); _progressTextGraphic.SpatialTransform.TranslationX = offset.X; _progressTextGraphic.SpatialTransform.TranslationY = offset.Y; } }