public ImageButton(ImageBrush child, int width, int height) { this.Width = width; this.Height = height; NormalBackgroundColor = OnBackgroundColor = child; BorderColor = Colors.DarkGray; }
public Icon(Bitmap bitmap, int iconSize, ushort opacity) { brush = new ImageBrush(bitmap); brush.Stretch = Stretch.Fill; IconSize = iconSize; Opacity = opacity; }
public MFTestResults ImageBrush_Test2() { MFTestResults testResult = MFTestResults.Pass; if (ClearingPanel() != MFTestResults.Pass) { return MFTestResults.Fail; } try { Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Yellow_flower); _brush = new ImageBrush(bmp); Log.Comment("Filling a Rectangle with an ImageBrush and verifying"); testResult = ImageBrushTest(bmp); } catch (Exception ex) { Log.Comment("Caught : " + ex.Message); return MFTestResults.Fail; } return testResult; }
public MFTestResults ImageBrush_BitmapSourceTest3() { MFTestResults testResult = MFTestResults.Pass; if (ClearingPanel() != MFTestResults.Pass) { return MFTestResults.Fail; } try { Bitmap flower = Resources.GetBitmap(Resources.BitmapResources.Yellow_flower); Log.Comment("Filling Rectangle with an ImageBrush"); _brush = new ImageBrush(flower); if (ImageBrushTest(flower) != MFTestResults.Pass) { Log.Comment("Failure filling the Rectangle with ImageBrush"); testResult = MFTestResults.Fail; } Bitmap cartoon = Resources.GetBitmap(Resources.BitmapResources.Tom_Jerry); Log.Comment("Changing the ImageBrush BitmapSource and verifying"); ((ImageBrush)_brush).BitmapSource = cartoon; if (ImageBrushTest(cartoon) != MFTestResults.Pass) { Log.Comment("Failure on changing the ImageBrush BitmapSource and verifying"); testResult = MFTestResults.Fail; } } catch (Exception ex) { Log.Comment("Caught : " + ex.Message); return MFTestResults.Fail; } return testResult; }
public MFTestResults ImageBrush_StretchTest4() { MFTestResults testResult = MFTestResults.Pass; if (ClearingPanel() != MFTestResults.Pass) { return MFTestResults.Fail; } try { Bitmap smallFlower = Resources.GetBitmap(Resources.BitmapResources.Yellow_flower_small); int w = 4 * smallFlower.Width, h = 4 * smallFlower.Height; _pen = new Pen(Colors.Black, 1); _brush = new ImageBrush(smallFlower); ((ImageBrush)_brush).Stretch = Stretch.None; Log.Comment("Drawing Rectangle : w = " + w.ToString() + ", h = " + h.ToString()); Log.Comment("filling the Rectangle with ImageBrush not stretched"); Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5), new DispatcherOperationCallback(DrawRectangle), new Point(w, h)); autoEvent.WaitOne(); Log.Comment("Initializing 40 Random Points inside Rectangle but not on the image"); Point[] chkPoints = GetRandomPoints_InRectangle(40, (_rectangle.ActualWidth / 2) - 1, (_rectangle.ActualHeight / 2) - 1, midX, midY); Log.Comment("Verifying pixel color around the center are white"); if (VerifyingPixelColor(chkPoints, Colors.White) != MFTestResults.Pass) { testResult = MFTestResults.Fail; } ((ImageBrush)_brush).Stretch = Stretch.Fill; Log.Comment("Drawing Rectangle : w = " + w.ToString() + ", h = " + h.ToString()); Log.Comment("filling the Rectangle with ImageBrush Stretched and Verifying"); Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5), new DispatcherOperationCallback(DrawRectangle), new Point(w, h)); autoEvent.WaitOne(); for (int i = 0; i < chkPoints.Length; i++) { if (_panel._pBitmap.GetPixel(chkPoints[i].x, chkPoints[i].y) == Colors.White) { testResult = MFTestResults.Fail; Log.Comment("Failure : Not expected to see White color at (" + chkPoints[i].x.ToString() + ", " + chkPoints[i].y.ToString() + ") after ImageBrush stretched"); } } } catch (Exception ex) { Log.Comment("Caught : " + ex.Message); return MFTestResults.Fail; } return testResult; }
public Bitmap this[string bitmapID] { get { if (!brushes.Contains(bitmapID) || (ImageBrush)brushes[bitmapID] == null) return null; else return ((ImageBrush)brushes[bitmapID]).BitmapSource; } set { if (brushes.Contains(bitmapID)) ((ImageBrush)brushes[bitmapID]).BitmapSource = value; else { ImageBrush brush = new ImageBrush(value); brush.Stretch = Stretch.Fill; brushes.Add(bitmapID, brush); } } }