Пример #1
0
        public Window CreateWindow()
        {
            // Create a window object and set its size to the
            // size of the display.
            mainWindow = new Window();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width = SystemMetrics.ScreenWidth;

            // Create a single panel control.
            Panel panel = new Panel();

            Image image = new Image(Resources.GetBitmap(Resources.BitmapResources.Racer));
            image.HorizontalAlignment = HorizontalAlignment.Center;
            image.VerticalAlignment = VerticalAlignment.Center;
            panel.Children.Add(image);

            Font font = Resources.GetFont(Resources.FontResources.small);
            Text text = new Text(font, "I am a racer.");
            text.ForeColor = Colors.Red;
            text.TextContent = Resources.GetString(Resources.StringResources.String1);
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.VerticalAlignment = VerticalAlignment.Center;
            panel.Children.Add(text);

            // Add the text control to the window.
            mainWindow.Child = panel;

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            return mainWindow;
        }
Пример #2
0
        public TabControl()
        {
            Orientation = Orientation.Vertical;

            pnlHeaders = new WrapPanel(Orientation.Horizontal);
            Children.Add(pnlHeaders);

            pnlContent = new Panel();
            Children.Add(pnlContent);
        }
Пример #3
0
        public Window CreateWindow()
        {
            // Create a window object and set its size to the
            // size of the display.
            mainWindow = new Window();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width = SystemMetrics.ScreenWidth;

            Text help = new Text();
            help.Font = Resources.GetFont(Resources.FontResources.nina14);
            help.TextContent = "Buttons: UP resets, SEL Syncs, DOWN schedules";
            help.HorizontalAlignment = HorizontalAlignment.Center;
            help.VerticalAlignment = VerticalAlignment.Top;

            time.Font = Resources.GetFont(Resources.FontResources.small);
            time.TextContent = "Initializing...";
            time.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            time.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;

            // Add the text controls to the window.
            Panel panel = new Panel();
            panel.Children.Add(help);
            panel.Children.Add(time);
            mainWindow.Child = panel;

            // Connect the button handler to all of the buttons.
            mainWindow.AddHandler(Buttons.ButtonUpEvent, new RoutedEventHandler(OnButtonUp), false);

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            clockTimer = new DispatcherTimer(mainWindow.Dispatcher);
            clockTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
            clockTimer.Tick += new EventHandler(ClockTimer_Tick);

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            TimeService.SystemTimeChanged += new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);
            TimeService.TimeSyncFailed += new TimeSyncFailedEventHandler(TimeService_TimeSyncFailed);

            clockTimer.Start();

            return mainWindow;
        }
Пример #4
0
        public MFTestResults UIElement_RootUIElementTest25()
        {
            Log.Comment("Gets the RootUIElement of child rectangle and panel");
            Log.Comment("Verifies RootUIElement is WindowManager.Instance");
            Log.Comment("Creates a new Panel, creates a rectangle and add it as a child of the panel");
            Log.Comment("Gets the RootUIElement of the new rectangle and panel");
            Log.Comment("Verifies RootUIElement is the new Panle");
            MFTestResults testResult = MFTestResults.Pass;
            Panel p = new Panel();
            Rectangle r = new Rectangle();
            p.Children.Add(r);
            UIElement[] uiElets = new UIElement[] { _rect, _panel, r, p };
            //corresponding root UIElements
            UIElement[] roots = new UIElement[] { WindowManager.Instance, WindowManager.Instance, p, p };
            for (int i = 0; i < uiElets.Length; i++)
            {
                Log.Comment("Getting the RootUIElement of '" +
                    uiElets[i].GetType() + "' and Verifying");
                if (uiElets[i].RootUIElement != roots[i])
                {
                    Log.Comment("Failure : expected RootUIElement '" +
                        roots + "' but got '" + uiElets[i].RootUIElement + "'");
                    testResult = MFTestResults.Fail;
                }
            }

            return testResult;
        }
Пример #5
0
        public MFTestResults UIElement_ParentTest26()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Log.Comment("Getting the rectangle parent and verifying");
            if (_rect.Parent != _panel)
            {
                Log.Comment("Failure : expected parent'" + _panel +
                    "' but got '" + _rect.Parent + "'");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Getting the panel parent and verifying");
            if (_panel.Parent != mainWindow)
            {
                Log.Comment("Failure : expected parent'" + mainWindow +
                   "' but got '" + _panel.Parent + "'");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Creating a new Panel, adding a new Rectangle as its child");
            Panel p = new Panel();
            Rectangle r = new Rectangle();
            p.Children.Add(r);
            Log.Comment("Getting the Parent and verifying it's the Panel");
            if (r.Parent != p)
            {
                Log.Comment("Failure : expected parent'" + p +
                 "' but got '" + r.Parent + "'");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Removing the child Rectangle");
            p.Children.Remove(r);
            Log.Comment("verifying the removed rectangle parent is null");
            if (r.Parent != null)
            {
                Log.Comment("Failure : expected parent'null' but got '" + r.Parent + "'");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
Пример #6
0
        public MFTestResults UIElement_GetDesiredSizeTest9()
        {
            MFTestResults testResult = MFTestResults.Pass;
            UIElement elt = new Panel();
            elt.Visibility = Visibility.Visible;
            int wd, ht;
            int[] eltW = new int[] { 0, midX, _width, _width + 1, int.MaxValue };
            int[] eltH = new int[] { 0, midY, _height, _height + 1, int.MaxValue };
            int[] w = new int[] { 0, _random.Next(midX), midX / 2, midX, midX + _random.Next(midX), _width };
            int[] h = new int[] { 0, _random.Next(midY), midY / 2, midY, midY + _random.Next(midY), _height };
            for (int i = 0; i < eltW.Length; i++)
            {
                elt.Width = eltW[i];
                elt.Height = eltH[i];
                Log.Comment("UIElement Width = " + elt.Width + ", Height = " + elt.Height);
                for (int j = 0; j < w.Length; j++)
                {
                    elt.Measure(w[j], h[j]);
                    elt.GetDesiredSize(out wd, out ht);
                    if (((w[j] < elt.Width) && (wd != w[j])) ||
                        ((h[j] < elt.Height) && (ht != h[j])))
                    {
                        Log.Comment("expected desired width/height = '" + w[j] + "/" + h[j] + "' but got '" +
                            wd + "/" + ht + "' for available width/height '" + w[j] + "/" + h[j] + "'");
                        testResult = MFTestResults.Fail;
                    }
                    else if (((w[j] >= elt.Width) && (wd != elt.Width)) ||
                        ((h[j] >= elt.Height) && (ht != elt.Height)))
                    {
                        Log.Comment("expected desired width/height = '" + elt.Width + "/" + elt.Height + "' but got '" +
                          wd + "/" + ht + "' for available width/height '" + w[j] + "/" + h[j] + "'");
                        testResult = MFTestResults.Fail;
                    }
                }
            }
            Log.Comment("Verifying Desirede width/height returns zero when UIElement is collapsed");
            elt.Visibility = Visibility.Collapsed;
            elt.Width = _random.Next(_width) + 1;
            elt.Height = _random.Next(_height) + 1;
            elt.Measure(_random.Next(_width) + 1, _random.Next(_width) + 1);
            elt.GetDesiredSize(out wd, out ht);
            if ((wd != 0) || (ht != 0))
            {
                Log.Comment("expected desired width/height = '0/0' when " +
                    "UIElement is collapsed but got '" + wd + "/" + ht + "'");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
Пример #7
0
        public MFTestResults UIElement_GetMarginTest12()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Log.Comment("Setting a UIElement margin, Getting Margin and verifying");
            int l, t, r, b;
            int[] mgs = new int[] { 0, -1, 1, _random.Next(midX), midX, _width, int.MaxValue, int.MinValue };
            UIElement _UIElt = new Panel();
            for (int i = 0; i < mgs.Length; i++)
            {
                _UIElt.SetMargin(mgs[i]);
                _UIElt.GetMargin(out l, out t, out r, out b);
                if (l != mgs[i] || t != mgs[i] || r != mgs[i] || b != mgs[i])
                {
                    Log.Comment("Expected Margins '(" + mgs[i] + ", " + mgs[i] +
                        ", " + mgs[i] + ", " + mgs[i] + ")'");
                    testResult = MFTestResults.Fail;
                }
            }

            return testResult;
        }
Пример #8
0
        object UpdateLayoutTest(object obj)
        {
            MFTestResults tResult = MFTestResults.Pass;
            _panel.InvalidateArrange();
            _panel.InvalidateMeasure();
            _panel.UpdateLayout();
            if (!_panel.IsMeasureValid || !_panel.IsArrangeValid)
            {
                tResult = MFTestResults.Fail;
            }
            Text t1 = new Text(_font, "Text 1");
            t1.ForeColor = Colors.Red;
            Text t2 = new Text(_font, "Text 2");
            Rectangle r = new Rectangle();
            r.Width = rWidth / 2;
            r.Height = rHeight / 2;
            r.Fill = new SolidColorBrush(Colors.Blue);
            Panel childPanel = new Panel();
            childPanel.Children.Add(t1);
            _panel.Children.Add(childPanel);
            _panel.Children.Add(t2);
            _panel.Children.Add(r);
            UIElement[] elts = new UIElement[] { childPanel, t2, r };
            foreach (UIElement elt in elts)
            {
                elt.InvalidateArrange();
                elt.InvalidateMeasure();
                _panel.UpdateLayout();
                if (!elt.IsArrangeValid || !elt.IsMeasureValid)
                {
                    Log.Comment("Failure: Updating a child UIElement type '" +
                        elt.ToString() + "' and verifying");
                    tResult = MFTestResults.Fail;
                }
            }
            t1.InvalidateArrange();
            t1.InvalidateMeasure();
            _panel.UpdateLayout();
            if (!t1.IsArrangeValid || !t1.IsMeasureValid)
            {
                Log.Comment("Failure: Updating child of child panel and verifying");
                tResult = MFTestResults.Fail;
            }

            childPanel.Children.Remove(t1);
            t1.InvalidateArrange();
            t1.InvalidateMeasure();
            _panel.UpdateLayout();
            if (t1.IsArrangeValid || t1.IsMeasureValid)
            {
                Log.Comment("Failure: Updating removed UIElement shouldn't validate");
                tResult = MFTestResults.Fail;
            }

            return tResult;
        }
Пример #9
0
        object CreateUI(object obj)
        {
            _panel = new Panel();
            _panel.Width = pWidth;
            _panel.Height = pHeight;
            _panel.Visibility = _panelVisibilty;

            _rect = new Rectangle();
            _rect.Width = rWidth;
            _rect.Height = rHeight;
            _rect.VerticalAlignment = vAlignment;
            _rect.HorizontalAlignment = hAlignment;
            _rect.Fill = new SolidColorBrush(_color);
            _rect.Visibility = _rectVisibility;
            _panel.Children.Add(_rect);
            if (setMargin)
            {
                _rect.SetMargin(left, top, right, bottom);
            }
            if (addText)
            {
                _txt = new Text(_font, txtStr);
                _txt.HorizontalAlignment = HorizontalAlignment.Right;
                _txt.VerticalAlignment = VerticalAlignment.Bottom;
                _panel.Children.Add(_txt);
            }

            checkAccess = _panel.CheckAccess();
            mainWindow.Child = _panel;
            return null;
        }
Пример #10
0
        public MFTestResults UIElement_IsEnabledChangedTest28()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Panel parentPanel = new Panel();
            Panel childPanel = new Panel();
            Rectangle _uiElementUnderTest = new Rectangle();
            parentPanel.Children.Add(childPanel);
            childPanel.Children.Add(_uiElementUnderTest);
            _uiElementUnderTest.IsEnabledChanged += new PropertyChangedEventHandler(EnabledChangedHandler);
            Log.Comment("Setting IsEnabled to true, and verifying");
            Log.Comment("No notification, since by default IsEnabled is true");
            autoEvent.Reset();
            _uiElementUnderTest.IsEnabled = true;
            Log.Comment("Waiting and verifying");
            if (autoEvent.WaitOne(1000, true))
            {
                Log.Comment("Failure : PropertyChangedEventHandler shouldn't be notified");
                testResult = MFTestResults.Fail;
            }
            if ((bool)_enabledHandlerState)
            {
                Log.Comment("Failure : IsEnable property changed");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Changing the IsEnabled property to false");
            _uiElementUnderTest.IsEnabled = false;
            Log.Comment("Waiting and verifying");
            if (!autoEvent.WaitOne(1000, true))
            {
                Log.Comment("Failure : PropertyChangedEventHandler not notified");
                testResult = MFTestResults.Fail;
            }
            if ((bool)_enabledHandlerState)
            {
                Log.Comment("Failure : IsEnable property not changed");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Changing the IsEnabled property back to true");
            _uiElementUnderTest.IsEnabled = true;
            Log.Comment("Waiting and verifying");
            if (!autoEvent.WaitOne(1000, true))
            {
                Log.Comment("Failure : PropertyChangedEventHandler not notified");
                testResult = MFTestResults.Fail;
            }
            if (!(bool)_enabledHandlerState)
            {
                Log.Comment("Failure : IsEnable property not changed");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
Пример #11
0
        public MFTestResults UIElement_IsEnabledTest27()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Panel parentPanel = new Panel();
            Panel childPanel = new Panel();
            Rectangle _uiElementUnderTest = new Rectangle();
            parentPanel.Children.Add(childPanel);
            childPanel.Children.Add(_uiElementUnderTest);
            Log.Comment("Verifying default value of UIElement.IsEnabled is true");
            if (!_uiElementUnderTest.IsEnabled)
            {
                Log.Comment("Failure : by defalut IsEnable returned false");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Disabling the parent and verifying");
            childPanel.IsEnabled = false;
            if (_uiElementUnderTest.IsEnabled)
            {
                Log.Comment("Disabling parent should also disable child");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Enabling the parent and verifying");
            childPanel.IsEnabled = true;
            if (!_uiElementUnderTest.IsEnabled)
            {
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Disabling the RootUIElement and verifying");
            parentPanel.IsEnabled = false;
            if (_uiElementUnderTest.IsEnabled)
            {
                Log.Comment("Disabling RootUIElement should also disable child");
                testResult = MFTestResults.Fail;
            }
            Log.Comment("Enabling the RootUIElement and verifying");
            parentPanel.IsEnabled = true;
            if (!_uiElementUnderTest.IsEnabled)
            {
                Log.Comment("Enabling RootUIElement should also disable child");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
Пример #12
0
        object ChildrenAddTest(object obj)
        {
            MFTestResults tResult = MFTestResults.Pass;

            Panel _panel = new Panel();
            Text txt1 = new Text(_font, "1st Text");
            txt1.HorizontalAlignment = HorizontalAlignment.Right;
            _panel.Children.Add(txt1);
            _panel.Children.Add(new Text(_font, "2nd Text"));
            Rectangle _rect = new Rectangle();
            _rect.Width = _rectW;
            _rect.Height = _rectH;
            _rect.Fill = new SolidColorBrush(_color);
            _panel.Children.Add(_rect);

            mainWindow.Child = _panel;

            if (_panel.Children[0] != txt1)
            {
                Log.Comment("Failure : _panel.Children[0] != txt1 ");
                tResult = MFTestResults.Fail;
            }
            if ((_panel.Children[1] as Text).TextContent != "2nd Text")
            {
                Log.Comment("Expected (_panel.Children[1] as Text).TextContent" +
                    " '2nd Text' but got '" + (_panel.Children[1] as Text).TextContent + "'");
                tResult = MFTestResults.Fail;
            }
            if (_panel.Children[2] != _rect)
            {
                Log.Comment("Failure : _panel.Children[2] != _rect ");
                tResult = MFTestResults.Fail;
            }
            if (_remove)
            {
                _panel.Children.Remove(_rect);
            }
            if (_clear)
            {
                _panel.Children.Clear();
                if (_panel.Children.Count != 0)
                {
                    Log.Comment("After Clearing the panel expected children count = '0' but got '" +
                        _panel.Children.Count + "'");
                    tResult = MFTestResults.Fail;
                }
            }
            return tResult;
        }