示例#1
0
 public ProgressBar(Orientation orientation)
 {
     Orientation = orientation;
     Background = new SolidColorBrush(Colors.DarkGray);
     Foreground = new SolidColorBrush(Colors.White);
     Value = 0;
 }
        public MFTestResults DrawingContext_DrawRectangleTest2()
        {
            MFTestResults testResult = MFTestResults.Pass;
            xDimension = midX - 1;
            yDimension = midY - 1;
            r = midX;
            s = midY;
            _pen = new Pen(Colors.Green);
            _brush = new SolidColorBrush(Colors.Blue);
            if (ClearingPanel() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _drawRectangle = true;
            
            Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                new DispatcherOperationCallback(InvalidatePanel), null);
            autoEvent.WaitOne();
            
            Log.Comment("Initializing 40 Random Points that are inside the rectangle");
            Point[] chkPoints = GetRandomPoints_InRectangle(40, xDimension, yDimension, r + xDimension / 2, s + yDimension / 2);
            Log.Comment("Verifying the pixel colors inside the rectangle");
            testResult = VerifyingPixelColor(chkPoints, Colors.Blue);
            _drawRectangle = false;

            return testResult;
        }
示例#3
0
        public MFTestResults SolidColorBrush_Test1()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Point pt = new Point(3 * _width / 4, 3 * _height / 4);
            if (ClearingPanel() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            try
            {
                _brush = new SolidColorBrush(Colors.Blue);
                Log.Comment("Drawing Rectangle : w = " + pt.x.ToString() + ", h = " + pt.y.ToString());
                Log.Comment("and filling with SolidColorBrush");
                
                Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(DrawRectangle), pt);
                autoEvent.WaitOne();
                
                Log.Comment("Initializing 40 Random Points that are inside the rectangle");
                Point[] chkPoints = GetRandomPoints_InRectangle(40, pt.x, pt.y, midX, midY);
                Log.Comment("Verifying the pixel colors inside the rectangle");
                testResult = VerifyingPixelColor(chkPoints, Colors.Blue);
            }
            catch (Exception ex)
            {
                Log.Comment("Caught : " + ex.Message);
                return MFTestResults.Fail;
            }

            return testResult;
        }
示例#4
0
 public Level(Orientation orientation, int barCount)
 {
     Orientation = orientation;
     BarCount = barCount;
     Background = new SolidColorBrush(Colors.DarkGray);
     Foreground = new SolidColorBrush(Colors.White);
     Value = 0;
 }
        public MFTestResults PolygonTest_DefaultConstructor1()
        {
            Log.Comment("Initalizes Polygon with a  default constructor");

            _brush = new SolidColorBrush(Colors.Green);

            return PolygonConstructorTest();
        }
示例#6
0
        protected override void OnTouchDown(TouchEventArgs e)
        {
            base.OnTouchDown(e);

            parent_.SelectedItem = this;
            StateNormal = (SolidColorBrush)Background;

            this.Background = StatePressed;
        }
示例#7
0
        public ToolButton(string name, UIElement content)
        {
            this.name = name;

            brushPressed = new SolidColorBrush(ColorUtility.ColorFromRGB(128, 255, 0));
            brushPressed.Opacity = 200;

            Content = content;
        }
示例#8
0
        public Button(UIElement content)
        {
            brushUnpressed = new SolidColorBrush(Colors.Black);
            brushUnpressed.Opacity = 10;

            brushPressed = new SolidColorBrush(ColorUtility.ColorFromRGB(128, 255, 0));
            brushPressed.Opacity = 200;

            brushTransparent = new SolidColorBrush(Colors.Red);
            brushTransparent.Opacity = Bitmap.OpacityTransparent;

            border = new Pen(Colors.DarkGray, 1);

            Content = content;
        }
示例#9
0
        public MFTestResults Border_BorderThickness_BoundaryTest2()
        {
            MFTestResults testResult = MFTestResults.Pass;
            if (CleaningWindow() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _uniformThickness = true;
            _borderBrush = new SolidColorBrush(Colors.Green);
            _background = new SolidColorBrush(Colors.Blue);
            Log.Comment("Varying the Border thickness b/n boundaries and Verifying");
            int[] tkness = new int[] { 0, int.MaxValue };
            for (int i = 0; i < tkness.Length; i++)
            {
                Log.Comment("Setting Border Thickness = '" + tkness[i] + "'");
                _thickness = tkness[i];
                UpdateWindow(); 
                Log.Comment("Gettig Border thickness and verifying");
                if ((l2 != _thickness) || (t2 != _thickness) || (r2 != _thickness) || (b2 != _thickness))
                {
                    Log.Comment("Failure in Getting Border thickness");
                    Log.Comment("Expected l2 = t2 = r2 = b2 = '" + _thickness + "' but got l2 = '" +
                        l2 + "' t2 = '" + t2 + "' r2 = '" + r2 + "' b2 = '" + b2 + "'");
                    testResult = MFTestResults.Fail;
                }
                if (TestBorder(0, 0, xStart, yStart, Color.White) != MFTestResults.Pass)
                {
                    Log.Comment("Failure verifying pixel colors outside Border");
                    testResult = MFTestResults.Fail;
                }
                if (_thickness >= _wd)
                {
                    _thickness = 0;
                    _background.Color = _borderBrush.Color;
                }
                if (TestBorder(xStart, yStart, _wd, _ht, _background.Color) != MFTestResults.Pass)
                {
                    Log.Comment("Failure verifying pixel colors inside Border");
                    testResult = MFTestResults.Fail;
                }
            }

            return testResult;
        }
示例#10
0
        public BlockBrushes()
        {
            _blockBrush = new SolidColorBrush[7];

            // O
            _blockBrush[0] = new SolidColorBrush(ColorUtility.ColorFromRGB(240, 240, 0));
            // J
            _blockBrush[1] = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 0, 240));
            // L
            _blockBrush[2] = new SolidColorBrush(ColorUtility.ColorFromRGB(240, 160, 0));
            // T
            _blockBrush[3] = new SolidColorBrush(ColorUtility.ColorFromRGB(160, 0, 240));
            // Z
            _blockBrush[4] = new SolidColorBrush(ColorUtility.ColorFromRGB(240, 0, 0));
            // S
            _blockBrush[5] = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 216, 0));
            // I
            _blockBrush[6] = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 240, 240));
        }
示例#11
0
        public MFTestResults Border_BorderThicknessTest1()
        {
            MFTestResults testResult = MFTestResults.Pass;
            if (CleaningWindow() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _uniformThickness = true;
            _borderBrush = new SolidColorBrush(Colors.Green);
            _background = new SolidColorBrush(Colors.Blue);
            _thickness = _random.Next(System.Math.Min(_wd / 2, _ht / 2) - 2) + 1;
            UpdateWindow(); 
            Log.Comment("Gettig Border thickness and verifying");
            if ((l2 != _thickness) || (t2 != _thickness) || (r2 != _thickness) || (b2 != _thickness))
            {
                Log.Comment("Failure in Getting Border thickness");
                Log.Comment("Expected l2 = t2 = r2 = b2 = '" + _thickness + "' but got l2 = '" +
                    l2 + "' t2 = '" + t2 + "' r2 = '" + r2 + "' b2 = '" + b2 + "'");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Initializing random points outside, on and inside of Border");
            Log.Comment("and Verifying the pixel colors");

            if (TestBorder(0, 0, xStart, yStart, Color.White) != MFTestResults.Pass)
            {
                Log.Comment("Failure verifying pixel colors outside Border");
                testResult = MFTestResults.Fail;
            }
            if (TestBorder(xStart, yStart, _thickness, _thickness, _borderBrush.Color) != MFTestResults.Pass)
            {
                Log.Comment("Failure verifying pixel colors on the Border");
                testResult = MFTestResults.Fail;
            }
            if (TestBorder(xStart + _thickness, yStart + _thickness, _wd - (2 * _thickness),
                _ht - (2 * _thickness), _background.Color) != MFTestResults.Pass)
            {
                Log.Comment("Failure verifying pixel colors inside Border");
                testResult = MFTestResults.Fail;
            }
            _uniformThickness = false;

            return testResult;
        }
示例#12
0
        //---------------------------------------------------
        //
        // Constructors
        //
        //---------------------------------------------------
        #region Constructors

        /// <summary>
        ///     Constructs a window object
        /// </summary>
        /// <remarks>
        ///     Automatic determination of current Dispatcher. Use alternative constructor
        ///     that accepts a Dispatcher for best performance.
        /// REFACTOR -- consider specifying app default window sizes to cover Aux case for default window size.
        /// </remarks>
        ///     Initializes the Width/Height, Top/Left properties to use windows
        ///     default. Updates Application object properties if inside app.
        public Window()
        {
            //There is only one WindowManager.  All Windows currently are forced to be created
            //and to live on the same thread.
            _windowManager = WindowManager.EnsureInstance();

            _background = new SolidColorBrush(Colors.White);
            //
            // dependency property initialization.
            // we don't have them, so we just update the properties on the base class,
            // like normal *bleep* fearing developers.
            //
            // Visibility HAS to be set to Collapsed prior to adding this child to the
            // window manager, otherwise the window manager sets the focus to this window
            this.Visibility = Visibility.Collapsed;

            // register us with the window manager, like a good little boy
            _windowManager.Children.Add(this);

            Application app = Microsoft.SPOT.Application.Current;

            // check if within an app && on the same thread
            if (app != null)
            {
                if (app.Dispatcher.Thread == Dispatcher.CurrentDispatcher.Thread)
                {
                    // add to window collection
                    // use internal version since we want to update the underlying collection
                    app.WindowsInternal.Add(this);
                    if (app.MainWindow == null)
                    {
                        app.MainWindow = this;
                    }
                }
                else
                {
                    app.NonAppWindowsInternal.Add(this);
                }
            }
        }
示例#13
0
        public MFTestResults Border_NonUniformBorderThickness_ArgumentExceptionTest8()
        {
            MFTestResults testResult = MFTestResults.Pass;
            if (CleaningWindow() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _borderBrush = new SolidColorBrush(Colors.Red);
            _background = new SolidColorBrush(Colors.Blue);
            
            Log.Comment("Setting the 4 border edges to different values and verifying ArgumentException is thrown");

            _uniformThickness = false;
            _argumentException = false;
            l1 = -_random.Next(_wd / 2);
            t1 = -_random.Next(_ht / 2);
            r1 = -_random.Next(_wd / 2);
            b1 = -_random.Next(_ht / 2);

            UpdateWindow();
            
            m_evtException.WaitOne(1000, true);

            if (!_argumentException)
            {
                Log.Comment("Failure to throw exception for setting border thicknesses to a negative value");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
示例#14
0
        public MFTestResults Border_NonUniform_BorderThickness_BoundaryTest4()
        {
            MFTestResults testResult = MFTestResults.Pass;
            if (CleaningWindow() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _uniformThickness = false;
            _borderBrush = new SolidColorBrush(Colors.Red);
            _background = new SolidColorBrush(Colors.Blue);
            Log.Comment("Varying the Border thickness b/n boundaries and Verifying");
            int[] tkness = new int[] { 0, int.MaxValue };
            for (int i = 0; i < tkness.Length; i++)
            {
                Log.Comment("Setting Border Thickness = '" + tkness[i] + "'");
                l1 = tkness[i];
                t1 = tkness[i];
                r1 = tkness[i];
                b1 = tkness[i];
                UpdateWindow(); 
                Log.Comment("Gettig Border thickness and verifying");
                if ((l2 != l1) || (t2 != t1) || (r2 != r1) || (b2 != b1))
                {
                    Log.Comment("Failure in Getting Border thickness");
                    Log.Comment("Expected l2 = '" + l1 + "' but got'" + l2 + "'");
                    Log.Comment("Expected t2 = '" + t1 + "' but got'" + t2 + "'");
                    Log.Comment("Expected r2 = '" + r1 + "' but got'" + r2 + "'");
                    Log.Comment("Expected b2 = '" + b1 + "' but got'" + b2 + "'");
                    testResult = MFTestResults.Fail;
                }
                if (TestBorder(0, 0, xStart, yStart, Color.White) != MFTestResults.Pass)
                {
                    Log.Comment("Failure verifying pixel colors outside Border");
                    testResult = MFTestResults.Fail;
                }
                if ((l1 >= _wd) || (r1 >= _wd) || (t1 >= _ht) || (b1 >= _ht))
                {
                    _thickness = 0;
                    _background.Color = _borderBrush.Color;
                }
                if (TestBorder(xStart, yStart, _wd, _ht, _background.Color) != MFTestResults.Pass)
                {
                    Log.Comment("Failure verifying pixel colors inside Border");
                    testResult = MFTestResults.Fail;
                }
            }

            return testResult;
        }
示例#15
0
        public MFTestResults Border_UniformBorderThickness_ArgumentExceptionTest7()
        {
            MFTestResults testResult = MFTestResults.Pass;
            if (CleaningWindow() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _uniformThickness = true;
            _borderBrush = new SolidColorBrush(Colors.Red);
            _background = new SolidColorBrush(Colors.Blue);
            Log.Comment("Setting Border thickness to negative and verifying ArgumentException");
            _argumentException = false;
            _thickness = -_random.Next(System.Math.Min(_wd / 2, _ht / 2) - 2) + 1;
            
            UpdateWindow();

            m_evtException.WaitOne(1000, true);

            if (!_argumentException)
            {
                Log.Comment("Failure to throw exception for setting border thickness to a negative value");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
        public MFTestResults DrawingContext_DrawRectangle_ArgumentExceptionTest3()
        {
            MFTestResults testResult = MFTestResults.Pass;
            if (ClearingPanel() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }

            r = midX / 2;
            s = midY / 2;
            _pen = new Pen(Colors.Green);
            _brush = new SolidColorBrush(Colors.Blue);
            int[] dimensions = GetRandomDimensions(midX, midY);
            for (int i = 0; i < dimensions.Length / 2; i++)
            {
                // make at least one dimension negative 
                if (i == 2)
                {
                    xDimension = -dimensions[i];
                    yDimension = -dimensions[2 * i + 1];
                }
                else
                {
                    xDimension = (i % 2) == 0 ? dimensions[i] : -dimensions[i];
                    yDimension = (i % 2) != 0 ? dimensions[2 * i + 1] : -dimensions[2 * i + 1];
                }

                _argumentException = false;
                _drawRectangle = true;
                
                Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
              new DispatcherOperationCallback(InvalidatePanel), null);
                autoEvent.WaitOne();
                if (!_argumentException)
                {
                    Log.Comment("Drawing a Rectangle at (" + r + ", " + s + ") with Width = " +
                        xDimension + " and Height = " + yDimension + " didn't throw ArgumentException");
                    testResult = MFTestResults.Fail;
                }
                _drawRectangle = false;
                _argumentException = false;
            }

            return testResult;
        }
示例#17
0
 public MFTestResults Border_NonUniform_BorderThicknessTest3()
 {
     MFTestResults testResult = MFTestResults.Pass;
     if (CleaningWindow() != MFTestResults.Pass)
     {
         return MFTestResults.Fail;
     }
     _uniformThickness = false;
     _borderBrush = new SolidColorBrush(Colors.Red);
     _background = new SolidColorBrush(Colors.Blue);
     Log.Comment("Setting the 4 border edges to different thickness");
     l1 = _random.Next((_wd - 2) / 2) + 1;
     t1 = _random.Next((_ht - 2) / 2) + 1;
     r1 = _random.Next((_wd - 2) / 2) + 1;
     b1 = _random.Next((_ht - 2) / 2) + 1;
     UpdateWindow(); 
     if (TestBorder(0, 0, xStart, yStart, Color.White) != MFTestResults.Pass)
     {
         Log.Comment("Failure verifying pixel colors outside Border");
         testResult = MFTestResults.Fail;
     }
     if (TestBorder(xStart, yStart, l1, t1, _borderBrush.Color) != MFTestResults.Pass)
     {
         Log.Comment("Failure verifying pixel colors on the Border");
         testResult = MFTestResults.Fail;
     }
     if (TestBorder(xStart + l1, yStart + t1, _wd - (l1 + r1),
         _ht - (t1 + b1), _background.Color) != MFTestResults.Pass)
     {
         Log.Comment("Failure verifying pixel colors inside Border");
         testResult = MFTestResults.Fail;
     }
     return testResult;
 }
 public MFTestResults DrawingContext_ClearTest6()
 {
     MFTestResults testResult = MFTestResults.Pass;
     if (ClearingPanel() != MFTestResults.Pass)
     {
         return MFTestResults.Fail;
     }
     _drawLine = true;
     _drawRectangle = true;
     _drawEllipse = true;
     _drawPolygon = true;
     
     Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
       new DispatcherOperationCallback(InvalidatePanel), null);
     autoEvent.WaitOne();
     
     _pen = new Pen(Colors.Red);
     _brush = new SolidColorBrush(Colors.Green);
     Log.Comment("Clearing the DrawingContext");
     _drawLine = false;
     _drawRectangle = false;
     _drawEllipse = false;
     _drawPolygon = false;
     _clear = true;
     
     Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
     new DispatcherOperationCallback(InvalidatePanel), null);
     autoEvent.WaitOne();
     
     Log.Comment("Initializing 40 Random Points that are inside Polygon");
     Point[] chkPoints = GetRandomPoints_InRectangle(40, _width, _height, midX, midY);
     testResult = VerifyingPixelColor(chkPoints, Colors.Black);
     _clear = false;
     return testResult;
 }
示例#19
0
        /// <summary>
        /// Overrides the base class OnRender method, to handle drawing.
        /// </summary>
        /// <param name="dc"></param>
        public override void OnRender(DrawingContext dc)
        {
            // Call the base class.
            base.OnRender(dc);

            // Create a solid black brush.
            SolidColorBrush brush =
                new SolidColorBrush(ColorUtility.ColorFromRGB(0, 0, 0));

            // Make the brush transparent.  Display only the outside edge, which 
            // uses the pen.
            brush.Opacity = 0;

            // Draw the border around the outside.
            dc.DrawRectangle(brush, new Pen(Color.Black), 0, 0, dc.Width,
                dc.Height);
        }
示例#20
0
        public MFTestResults PolygonTest_PolygonFill5()
        {
            MFTestResults testResult = MFTestResults.Pass;

            try
            {
                if (ClearingPanel() != MFTestResults.Pass)
                {
                    return MFTestResults.Fail;
                }
                Log.Comment("Setting the Pen and Brush");
                _pen = new Pen(Colors.Red, 1);
                _brush = new SolidColorBrush(Colors.Green);

                Log.Comment("Draw a Regular Octagon");
                DrawRegularOctagon();

                autoEvent.WaitOne(); Thread.Sleep( 1000 );

                Log.Comment("Initializing 40 Random Points inside the Horizontal rectangle in the Octagon");
                int len = min / 6 + (int)(((double)min / 3) / sqrt2);
                int w1 = 2 * (len-1), h1 = (min -1) / 3;
                Point[] chkPoints1 = GetRandomPoints_InRectangle(40, w1, h1, midX - w1 / 2, midY - h1 / 2);
                Log.Comment("Veifying The pixel colors inside the Horizontal rectangle in the Octagon");
                MFTestResults tRes1 = VerifyingPixelColor(chkPoints1, Colors.Green);
                Log.Comment("Initializing 40 Random Points inside the Vertical Rectangle in the Octagon");
                int w2 = h1, h2 = w1;
                Point[] chkPoints2 = GetRandomPoints_InRectangle(40, w2, h2, midX - w2 / 2, midY - h2 / 2);
                Log.Comment("Veifying The pixel colors inside the Vertical rectangle in the Octagon");
                MFTestResults tRes2 = VerifyingPixelColor(chkPoints1, Colors.Green);
                if ((tRes1 != MFTestResults.Pass) && (tRes2 != MFTestResults.Pass))
                {
                    testResult = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Comment("Caught : " + ex.Message);
                return MFTestResults.Fail;
            }

            return testResult;
        }
        public MFTestResults DrawingContext_DrawPolygonTest7()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Point[] pts1 = new Point[] {
                new Point(35           , midY - 40    ),
                new Point(midX - 30    , midY - 40    ),
                new Point(midX         , midY + 60    ),
                new Point(midX         , midY + 60    ),
                new Point(midX + 30    , midY - 40    ),
                new Point(2 * midX - 35, midY - 40    ), 
                new Point(midX - 10    , midY         ),
                new Point(2 * midX - 35, 2 * midY - 35),
                new Point(midX         , midY + 40    ),
                new Point(35           , 2 * midY - 35),
                new Point(midX + 10    , midY         ),
            };
            Log.Comment("Initializing Drawing Points");
            pts = new int[pts1.Length * 2];

            for (int j = 0; j < pts1.Length; j++)
            {
                pts[2 * j] = pts1[j].x;
                pts[2 * j + 1] = pts1[j].y;
            }
            _pen = new Pen(Colors.Blue);
            _brush = new SolidColorBrush(Colors.Green);
            if (ClearingPanel() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _drawPolygon = true;
            autoEvent.Reset();
            Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                new DispatcherOperationCallback(InvalidatePanel), null);
            autoEvent.WaitOne();

            Log.Comment("Verifying the pixel colors on the polygon");
            if (VerifyingPixelColor(pts1, Colors.Blue) != MFTestResults.Pass)
            {
                testResult = MFTestResults.Fail;
            }
            _drawPolygon = false;

            return testResult;
        }
示例#22
0
        public MFTestResults EllipseTest_EllipseFill9()
        {
            MFTestResults testResult = MFTestResults.Pass;
            int xRad = min / 3;
            Point pt = new Point(xRad, xRad);

            try
            {
                if (ClearingPanel() != MFTestResults.Pass)
                {
                    return MFTestResults.Fail;
                }
                Log.Comment("Setting the Pen and Brush");
                _pen = new Pen(Colors.Red, 1);
                _brush = new SolidColorBrush(Colors.Green);
                Log.Comment("Invoking the Dispatcher on a panel");
                Log.Comment("Drawing a Circle(Ellipse)with radius = " + pt.x.ToString() + " and yRadius = " + pt.y.ToString());
                Master_Shapes._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(DrawEllipse), new Point(pt.x, pt.y));
                autoEvent.WaitOne(); Thread.Sleep( 100 );
                
                Log.Comment("Initializing 40 random points inside the largest square inside the circle");
                int s = (int)(2 * xRad / sqrt2);

                int x = midX - s / 2;
                int y = midY - s / 2;

                Point[] chkPoints = GetRandomPoints_InRectangle(40, s-2, s-2, x+1, y+1);
                Log.Comment("Veifying The pixel colors inside the Circle");
                if (VerifyingPixelColor(chkPoints, Colors.Green) != MFTestResults.Pass)
                {
                    testResult = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Comment("Caught : " + ex.Message);
                return MFTestResults.Fail;
            }

            return testResult;
        }
示例#23
0
        public MessageBox(Font font, int width, string message, MessageBoxButton buttonsSet, Bitmap buttonBackground, Color buttonTextColor, Color textColor)
        {
            Background = new SolidColorBrush(Colors.Black);
            Width = width;
            Visibility = Visibility.Hidden;
            SizeToContent = SizeToContent.Height;

            this.buttonsSet = buttonsSet;

            main = Application.Current.MainWindow;
            modalBlock = new DispatcherFrame();

            StackPanel pnl = new StackPanel(Orientation.Vertical);
            Child = pnl;

            txtMessage = new Text(font, message);
            txtMessage.ForeColor = textColor;
            txtMessage.HorizontalAlignment = HorizontalAlignment.Center;
            txtMessage.TextAlignment = TextAlignment.Center;
            txtMessage.TextWrap = true;
            txtMessage.SetMargin(3);
            pnl.Children.Add(txtMessage);

            StackPanel pnlButtons = new StackPanel(Orientation.Horizontal);
            pnlButtons.HorizontalAlignment = HorizontalAlignment.Center;
            pnlButtons.VerticalAlignment = VerticalAlignment.Bottom;
            pnl.Children.Add(pnlButtons);

            btn1 = new Button(font, "", null, buttonTextColor);
            btn1.Background = buttonBackground;
            btn1.ImageSize = 16;
            btn1.HorizontalAlignment = HorizontalAlignment.Center;
            btn1.SetMargin(3);
            btn1.Clicked += new EventHandler(btn1_Clicked);
            pnlButtons.Children.Add(btn1);

            btn2 = new Button(font, "", null, buttonTextColor);
            btn2.Background = buttonBackground;
            btn2.ImageSize = 16;
            btn2.HorizontalAlignment = HorizontalAlignment.Center;
            btn2.SetMargin(3);
            btn2.Clicked += new EventHandler(btn2_Clicked);
            pnlButtons.Children.Add(btn2);

            btn3 = new Button(font, "", null, buttonTextColor);
            btn3.Background = buttonBackground;
            btn3.ImageSize = 16;
            btn3.HorizontalAlignment = HorizontalAlignment.Center;
            btn3.SetMargin(3);
            btn3.Clicked += new EventHandler(btn3_Clicked);
            pnlButtons.Children.Add(btn3);

            switch (buttonsSet)
            {
                case MessageBoxButton.OK:
                    btn1.Text = "OK";
                    btn2.Visibility = btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.OKCancel:
                    btn1.Text = "OK";
                    btn2.Text = "Отмена";
                    btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.YesNo:
                    btn1.Text = "Да";
                    btn2.Text = "Нет";
                    btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.YesNoCancel:
                    btn1.Text = "Да";
                    btn2.Text = "Нет";
                    btn3.Text = "Отмена";
                    break;
            }

            //Top = (SystemMetrics.ScreenHeight - Height) / 2;
        }
示例#24
0
 public MicroListBoxItem SetStateColors(Color pressedTrue, Color pressedFalse)
 {
     StateNormal = new SolidColorBrush(pressedFalse);
     StatePressed = new SolidColorBrush(pressedTrue);
     return this;
 }
示例#25
0
            /// <summary>
            /// Constructs a MyColorPalette with the specified settings.
            /// </summary>
            /// <param name="row"></param>
            /// <param name="column"></param>
            /// <param name="width"></param>
            /// <param name="height"></param>
            public MyColorPalette(int row, int column, int width, int height)
                : base(row, column, width, height)
            {
                color = new Color[16];

                // Create the colors we will display.
                color[0] = ColorUtility.ColorFromRGB(255, 0, 0);
                color[1] = ColorUtility.ColorFromRGB(128, 0, 0);
                color[2] = ColorUtility.ColorFromRGB(64, 0, 0);
                color[3] = ColorUtility.ColorFromRGB(0, 255, 0);
                color[4] = ColorUtility.ColorFromRGB(0, 128, 0);
                color[5] = ColorUtility.ColorFromRGB(0, 64, 0);
                color[6] = ColorUtility.ColorFromRGB(0, 0, 255);
                color[7] = ColorUtility.ColorFromRGB(0, 0, 128);
                color[8] = ColorUtility.ColorFromRGB(0, 0, 64);
                color[9] = ColorUtility.ColorFromRGB(255, 255, 0);
                color[10] = ColorUtility.ColorFromRGB(128, 128, 0);
                color[11] = ColorUtility.ColorFromRGB(0, 255, 255);
                color[12] = ColorUtility.ColorFromRGB(0, 128, 128);
                color[13] = ColorUtility.ColorFromRGB(255, 0, 255);
                color[14] = ColorUtility.ColorFromRGB(128, 0, 128);
                color[15] = ColorUtility.ColorFromRGB(0, 0, 0);

                int i = 0;
                brushes = new Brush[16];

                for (i = 0; i < 16; i++)
                {
                    brushes[i] = new SolidColorBrush(color[i]);
                }
            }
示例#26
0
        public MFTestResults Brush_OpacityTest9()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Point pt1 = new Point(3 * min / 4, 3 * min / 4);
            Point pt2 = new Point(3 * _width / 4, 3 * _height / 4);
            if (ClearingPanel() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            try
            {
                //Red - BGR 0x0000ff
                _brush = new SolidColorBrush(Colors.Red);
                Log.Comment("Drawing Square with s = " + pt1.x.ToString() + " and filling with Red color");
                
                Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(DrawRectangle), pt1);
                autoEvent.WaitOne();
                

                //Yellow - BGR 0x00ffff   
                _brush = new SolidColorBrush((Color)0x00ffff);
                _brush.Opacity = 0;
                Log.Comment("Drawing Rectangle, w = " + pt2.x.ToString() + " h = " + pt2.y.ToString());
                Log.Comment("and filling with Yellow color");
                
                Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(DrawRectangle), pt2);
                autoEvent.WaitOne();
                
                Log.Comment("Initializing 40 Random Points that are inside the rectangle");
                Point[] chkPoints = GetRandomPoints_InRectangle(40, pt1.x, pt1.y, midX, midY);
                if (VerifyingPixelColor(chkPoints, Colors.Red) != MFTestResults.Pass)
                {
                    testResult = MFTestResults.Fail;
                }
                Log.Comment("Varying the Opacity from 0 to 256 and verifying the color at the center");
                Color c1 = _panel._pBitmap.GetPixel(midX, midY), c2;
                //try i <= 256, i += 16, i.e Opacity = 256
                for (int i = 0; i <= (int)Bitmap.OpacityOpaque; i += 16)
                {
                    _brush.Opacity = (ushort)i;
                    
                    Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                   new DispatcherOperationCallback(DrawRectangle), pt2);
                    autoEvent.WaitOne();
                    
                    c2 = _panel._pBitmap.GetPixel(midX, midY);
                    if (c1 > c2)
                    {
                        testResult = MFTestResults.Fail;
                    }
                }
                chkPoints = GetRandomPoints_InRectangle(40, pt1.x, pt1.y, midX, midY);
                Log.Comment("Verifying the pixel colors in the inside square");
                if (VerifyingPixelColor(chkPoints, (Color)0x00ffff) != MFTestResults.Pass)
                {
                    testResult = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Comment("Caught : " + ex.Message);
                return MFTestResults.Fail;
            }

            return testResult;
        }
示例#27
0
        public void SetupWindow()
        {
            int BtnWidth = 90;
            int BtnHeight = 50;

            GT.Color selectedFronColor = GT.Color.White;

            Font font = Resources.GetFont(Resources.FontResources.NinaB);
            unselectedBackgroundBrush = new SolidColorBrush(GT.Color.FromRGB(89, 192, 255));
            selectedONAndLoadedBackgroundBrush = new SolidColorBrush(GT.Color.FromRGB(43, 255, 121));
            selectedOFFBackgroundBrush = new SolidColorBrush(GT.Color.FromRGB(240, 28, 126));
            window = display.WPFWindow;
            canvas = new Canvas();
            window.Child = canvas;

            StackPanel stack = new StackPanel(Orientation.Horizontal);

            // ON button
            onBtnBorder = new Border();
            onBtnBorder.SetBorderThickness(0);
            onBtnBorder.Width = BtnWidth;
            onBtnBorder.Height = BtnHeight;
            onBtnBorder.Background = unselectedBackgroundBrush;

            onBtnBorder.SetMargin(12, 10, 0, 0);
            onBtnBorder.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler((s, e) =>
            {
                coffeeMachineOn();
            });

            tempText = new Text(font, "ON");
            tempText.Width = BtnWidth;
            tempText.ForeColor = selectedFronColor;
            tempText.TextAlignment = TextAlignment.Center;
            tempText.SetMargin(0, 15, 0, 0);

            onBtnBorder.Child = tempText;
            stack.Children.Add(onBtnBorder);

            // OFF button
            offBtnBorder = new Border();
            offBtnBorder.SetBorderThickness(0);
            offBtnBorder.Width = BtnWidth;
            offBtnBorder.Height = BtnHeight;

            offBtnBorder.Background = selectedOFFBackgroundBrush;

            offBtnBorder.SetMargin(12, 10, 0, 0);
            offBtnBorder.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler((s, e) =>
            {
                coffeeMachineOff();
            });

            tempText = new Text(font, "OFF");
            tempText.Width = BtnWidth;
            tempText.ForeColor = selectedFronColor;
            tempText.TextAlignment = TextAlignment.Center;
            tempText.SetMargin(0, 15, 0, 0);

            offBtnBorder.Child = tempText;
            stack.Children.Add(offBtnBorder);

            // LOADED button
            loadedBtnBorder = new Border();
            loadedBtnBorder.SetBorderThickness(0);
            loadedBtnBorder.Width = BtnWidth;
            loadedBtnBorder.Height = BtnHeight;

            loadedBtnBorder.Background = unselectedBackgroundBrush;

            loadedBtnBorder.SetMargin(12, 10, 0, 0);
            loadedBtnBorder.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler((s, e) =>
            {
                coffeeMachineLoaded();
            });

            tempText = new Text(font, "LOADED");
            tempText.Width = BtnWidth;
            tempText.ForeColor = selectedFronColor;
            tempText.TextAlignment = TextAlignment.Center;
            tempText.SetMargin(0, 15, 0, 0);

            loadedBtnBorder.Child = tempText;
            stack.Children.Add(loadedBtnBorder);

            StackPanel verticalStack = new StackPanel(Orientation.Vertical);
            verticalStack.Children.Add(stack);

            Font ff = Resources.GetFont(Resources.FontResources.moireFonts);

            timerText = new Text(ff, "off");
            timerText.Width = 320;
            timerText.ForeColor = GT.Color.FromRGB(89, 192, 255);
            timerText.TextAlignment = TextAlignment.Center;
            timerText.SetMargin(0, 35, 0, 0);
            verticalStack.Children.Add(timerText);

            canvas.Children.Add(verticalStack);
        }
 public MFTestResults DrawingContext_DrawEllipseTest4()
 {
     MFTestResults testResult = MFTestResults.Pass;
     xDimension = midX - 10;
     yDimension = midY - 10;
     r = midX;
     s = midY;
     _pen = new Pen(Colors.Red);
     _brush = new SolidColorBrush(Colors.Green);
     if (ClearingPanel() != MFTestResults.Pass)
     {
         return MFTestResults.Fail;
     }
     _drawEllipse = true;
     
     Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
         new DispatcherOperationCallback(InvalidatePanel), null);
     autoEvent.WaitOne();
     
     Log.Comment("Checking pixel colors on the ellipse");
     Point[] chkPoints1 = new Point[] { new Point(r+xDimension, s), new Point(r-xDimension, s),
     new Point(r, s+yDimension), new Point(r, s-yDimension)};
     if (VerifyingPixelColor(chkPoints1, Colors.Red) != MFTestResults.Pass)
     {
         testResult = MFTestResults.Fail;
     }
     Log.Comment("Checking pixel colors inside the ellipse");
     int minSquare = 2 * (int)(System.Math.Min(xDimension, yDimension) / 1.5);
     Log.Comment("Initializing 40 Random Points that are inside the rectangle");
     Point[] chkPoints2 = GetRandomPoints_InRectangle(40, minSquare, minSquare, r, s);
     Log.Comment("Verifying the pixel colors inside the rectangle");
     if (VerifyingPixelColor(chkPoints2, Colors.Green) != MFTestResults.Pass)
     {
         testResult = MFTestResults.Fail;
     }
     _drawEllipse = false;
     return testResult;
 }
示例#29
0
        public Border()
        {
            _borderBrush = new SolidColorBrush(Colors.Black);

            _borderLeft = _borderTop = _borderRight = _borderBottom = 1;
        }
        public MFTestResults DrawingContext_DrawPolygonTest5()
        {
            MFTestResults testResult = MFTestResults.Pass;
            int min3 = min / 3;
            Point[] pts1 = new Point[] {new Point( midX - min3, midY),new Point(midX, midY - min3),
            new Point(midX + min3, midY), new Point(midX, midY + min3)};
            Log.Comment("Initializing Drawing Points");
            pts = new int[] { pts1[0].x, pts1[0].y, pts1[1].x, pts1[1].y, pts1[2].x, pts1[2].y, pts1[3].x, pts1[3].y };
            _pen = new Pen(Colors.Blue);
            _brush = new SolidColorBrush(Colors.Green);
            if (ClearingPanel() != MFTestResults.Pass)
            {
                return MFTestResults.Fail;
            }
            _drawPolygon = true;
            
            Master_Media._panel.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                new DispatcherOperationCallback(InvalidatePanel), null);
            autoEvent.WaitOne();
            
            Log.Comment("Verifying the pixel colors on the polygon");
            if (VerifyingPixelColor(pts1, Colors.Blue) != MFTestResults.Pass)
            {
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Initializing 40 Random Points that are inside Polygon");
            Point[] chkPoints = GetRandomPoints_InRectangle(40, min3, min3, midX, midY);
            if (VerifyingPixelColor(chkPoints, Colors.Green) != MFTestResults.Pass)
            {
                testResult = MFTestResults.Fail;
            }
            _drawPolygon = false;

            return testResult;
        }