Exemple #1
0
        private void CreateMonoBlack()
        {
            TextLightColor = Colors.White;
            TextDarkColor = Colors.DarkGray;

            ButtonBorderColor = Colors.LightGray;
            ButtonLightBrush = new LinearGradientBrush(ColorUtility.ColorFromRGB(169, 169, 169), ColorUtility.ColorFromRGB(126, 126, 126), 500, 0, 500, 1000);
            ButtonDarkBrush = new LinearGradientBrush(ColorUtility.ColorFromRGB(105, 105, 105), ColorUtility.ColorFromRGB(10, 10, 10), 500, 0, 500, 1000);
        }
        private MFTestResults LinearGradientBrushTest(Color start, Color end, int x1, int y1, int x2, int y2)
        {
            MFTestResults tResult = MFTestResults.Pass;
            Point pt = new Point(w, w);
            int p1x = x1 * w / LinearGradientBrush.RelativeBoundingBoxSize,
                p1y = y1 * w / LinearGradientBrush.RelativeBoundingBoxSize,
                p2x = x2 * w / LinearGradientBrush.RelativeBoundingBoxSize,
                p2y = y2 * w / LinearGradientBrush.RelativeBoundingBoxSize;
            _brush = new LinearGradientBrush(start, end, x1, y1, x2, y2);
            Log.Comment("Drawing : Rectangle, w = " + pt.x.ToString() + " h = " + pt.y.ToString());
            
            Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                new DispatcherOperationCallback(DrawRectangle), pt);
            autoEvent.WaitOne();
            
            Log.Comment("Verifying the color changes along the gradient");
            _rectangle.PointToScreen(ref p1x, ref p1y);
            _rectangle.PointToScreen(ref p2x, ref p2y);
            int temp1 = p1x + 1, temp2 = p1y + 1;
            Color c1 = _panel._pBitmap.GetPixel(temp1, temp2), c2;

            //try dividing by 10
            int stepX = (p2x - p1x) / 5, stepY = (p2y - p1y) / 5;
            int iMax = temp1 + p2x - p1x;
            for (temp1 = temp1 + stepX, temp2 = temp2 + stepY; temp1 < iMax - 2; temp1 += stepX, temp2 += stepY)
            {
                c2 = _panel._pBitmap.GetPixel(temp1, temp2);
                if (c2 <= c1)
                {
                    Log.Comment("Expected color value increases along gradient but got color " +
                        c2.ToString() + " after color " + c1.ToString() + " at (" + temp1.ToString() + ", " + temp2.ToString() + ")");
                    tResult = MFTestResults.Fail;
                }
                c1 = _panel._pBitmap.GetPixel(temp1, temp2);
            }
            return tResult;
        }
        public Border AddTitleBar(string title, Font font, GT.Color foreColor, GT.Color startColor, GT.Color endColor)
        {
            Brush backgroundBrush = null;
            if (startColor == endColor)
                backgroundBrush = new SolidColorBrush(startColor);
            else
                backgroundBrush = new LinearGradientBrush(startColor, endColor);

            return AddTitleBar(title, font, foreColor, backgroundBrush);
        }