public SeparatorListBoxItem() { Rectangle rect = new Rectangle(); rect.Height = 1; rect.Stroke = new Pen(Colors.Gray); this.Child = rect; this.IsSelectable = false; this.SetMargin(2); }
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; Canvas canvas = new Canvas(); // Create a single text control and add it to the canvas Font font = Resources.GetFont(Resources.FontResources.small); Text text = new Text(font, "I am a racer."); Canvas.SetLeft(text, 50); Canvas.SetTop(text, 200); canvas.Children.Add(text); // Create an image and add it to the canvas Bitmap racer = Resources.GetBitmap(Resources.BitmapResources.Racer); Image image = new Image(racer); Canvas.SetLeft(image, 10); Canvas.SetTop(image, 10); canvas.Children.Add(image); // Create a rectangle shape and add it to the canvas Rectangle rect = new Rectangle(); rect.Fill = new SolidColorBrush(Colors.Blue); rect.Width = 100; rect.Height = 50; Canvas.SetLeft(rect, 200); Canvas.SetTop(rect, 50); canvas.Children.Add(rect); // Add the canvas to the window. mainWindow.Child = canvas; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; return mainWindow; }
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; StackPanel panel = new StackPanel(Orientation.Vertical); // Create a single text control and add it to the panel Font font = Resources.GetFont(Resources.FontResources.small); Text text = new Text(font, "I am a racer."); text.HorizontalAlignment = HorizontalAlignment.Left; panel.Children.Add(text); // Create an image and add it to the panel Bitmap racer = Resources.GetBitmap(Resources.BitmapResources.Racer); Image image = new Image(racer); image.HorizontalAlignment = HorizontalAlignment.Left; panel.Children.Add(image); // Create a rectangle shape and add it to the panel Rectangle rect = new Rectangle(); rect.HorizontalAlignment = HorizontalAlignment.Left; rect.Fill = new SolidColorBrush(Colors.Blue); rect.Width = 100; rect.Height = 50; panel.Children.Add(rect); // Add the panel to the window. mainWindow.Child = panel; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; return mainWindow; }
object Canvas_AllSet(object obj) { _canvas = new Canvas(); Rectangle _rect1 = new Rectangle(); _rect1.Width = _rectW; _rect1.Height = _rectH; _rect1.Fill = new SolidColorBrush(c1); Canvas.SetLeft(_rect1, hLength); Canvas.SetTop(_rect1, vLength); Rectangle _rect2 = new Rectangle(); _rect2.Width = _rectW; _rect2.Height = _rectH; _rect2.Fill = new SolidColorBrush(c2); Canvas.SetRight(_rect2, hLength); Canvas.SetTop(_rect2, vLength); Rectangle _rect3 = new Rectangle(); _rect3.Width = _rectW; _rect3.Height = _rectH; _rect3.Fill = new SolidColorBrush(c3); Canvas.SetLeft(_rect3, hLength); Canvas.SetBottom(_rect3, vLength); Rectangle _rect4 = new Rectangle(); _rect4.Width = _rectW; _rect4.Height = _rectH; _rect4.Fill = new SolidColorBrush(c4); Canvas.SetRight(_rect4, hLength); Canvas.SetBottom(_rect4, vLength); _canvas.Children.Add(_rect1); _canvas.Children.Add(_rect2); _canvas.Children.Add(_rect3); _canvas.Children.Add(_rect4); mainWindow.Child = _canvas; return null; }
object Canvas_UpdateWindow(object obj) { _canvas = new Canvas(); //Setting the Width & Height of the Canvas //by default the Canvas is at the center both from Horizontal and Vertical _canvas.Width = _cWidth; _canvas.Height = _cHeight; if (!_null) { _rect1 = new Rectangle(); _rect1.Width = _rectW; _rect1.Height = _rectH; _rect1.Fill = new SolidColorBrush(_fillColor); } if (_left) { try { Canvas.SetLeft(_rect1, _lt); gLeft = Canvas.GetLeft(_rect1); } catch (Exception ex) { Log.Comment("Caught " + ex.Message + " when Canvas.SetLeft(UIElemnt, " + _lt + ")"); _argumentException = true; } } else if (_top) { try { Canvas.SetTop(_rect1, _tp); gTop = Canvas.GetTop(_rect1); } catch (Exception ex) { Log.Comment("Caught " + ex.Message + " when Canvas.SetTop(UIElemnt, " + _tp + ")"); _argumentException = true; } } else if (_right) { try { Canvas.SetRight(_rect1, _rt); gRight = Canvas.GetRight(_rect1); } catch (Exception ex) { Log.Comment("Caught " + ex.Message + " when Canvas.SetRight(UIElemnt, " + _rt + ")"); _argumentException = true; } } else if (_bottom) { try { Canvas.SetBottom(_rect1, _bt); gBottom = Canvas.GetBottom(_rect1); } catch (Exception ex) { Log.Comment("Caught " + ex.Message + " when Canvas.SetBottom(UIElemnt, " + _bt + ")"); _argumentException = true; } } if (_rect1 != null) { _canvas.Children.Add(_rect1); } mainWindow.Child = _canvas; return null; }
protected override void Reset() { //variables to store Canvas.GetXxxx(UIElement) gLeft = 0; gTop = 0; gRight = 0; gBottom = 0; //Rectangle Width & Height _lt = 0; _tp = 0; _rt = 0; _bt = 0; _left = false; _top = false; _right = false; _bottom = false; _null = false; _canvas = null; _rect1 = null; _fillColor = Colors.Green; }
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; }
object DrawRectangle(object arg) { Point pt = arg as Point; _rectangle = new Rectangle(); try { _rectangle.Width = pt.x; _rectangle.Height = pt.y; } catch (Exception e) { Log.Comment("Caught : " + e.Message + " when setting Width = " + pt.x + " and Height = " + pt.y); eCounter++; } _rectangle.Stroke = _pen; _rectangle.Fill = _brush; Master_Shapes._panel.Children.Add(_rectangle); return null; }
public void DrawCanvas() { Canvas canvas = new Canvas(); Text OkText = new Text("OK"); OkText.Font = Resources.GetFont(Resources.FontResources.NinaB); OkText.ForeColor = Colors.DarkGray; SimpleButton OkButton = new SimpleButton(OkText, 100, 50); OkButton.NormalBackgroundColor = Colors.Green; OkButton.Click += new EventHandler(Ok_Click); Text CancelText = new Text("Cancel"); CancelText.Font = Resources.GetFont(Resources.FontResources.NinaB); CancelText.ForeColor = Colors.DarkGray; SimpleButton CancelButton = new SimpleButton(CancelText, 100, 50); CancelButton.NormalBackgroundColor = Colors.Red; CancelButton.Click += new EventHandler(Cancel_Click); SimpleButton[] digits = new SimpleButton[10]; for (int i = 0; i < digits.Length; i++) { Text t = new Text(i.ToString()); t.Font = Resources.GetFont(Resources.FontResources.NinaB); t.ForeColor = Colors.DarkGray; digits[i] = new SimpleButton(t, 50, 50); digits[i].Click += new EventHandler(Value_Click); } Rectangle TextBox = new Rectangle(130, 50); TextBox.Stroke = new Pen(Colors.Gray); Value = new Text(""); Value.Font = Resources.GetFont(Resources.FontResources.NinaB); Value.ForeColor = Colors.DarkGray; Canvas.SetLeft(OkButton, 160); Canvas.SetTop(CancelButton, 50); Canvas.SetLeft(CancelButton, 160); Canvas.SetTop(TextBox, 25); Canvas.SetLeft(TextBox, 10); Canvas.SetTop(Value, 45); Canvas.SetLeft(Value, 20); Canvas.SetTop(digits[1], 100); Canvas.SetLeft(digits[1], 10); Canvas.SetTop(digits[2], 100); Canvas.SetLeft(digits[2], 60); Canvas.SetTop(digits[3], 100); Canvas.SetLeft(digits[3], 110); Canvas.SetTop(digits[4], 100); Canvas.SetLeft(digits[4], 160); Canvas.SetTop(digits[5], 100); Canvas.SetLeft(digits[5], 210); Canvas.SetTop(digits[6], 150); Canvas.SetLeft(digits[6], 10); Canvas.SetTop(digits[7], 150); Canvas.SetLeft(digits[7], 60); Canvas.SetTop(digits[8], 150); Canvas.SetLeft(digits[8], 110); Canvas.SetTop(digits[9], 150); Canvas.SetLeft(digits[9], 160); Canvas.SetTop(digits[0], 150); Canvas.SetLeft(digits[0], 210); canvas.Children.Add(TextBox); canvas.Children.Add(Value); canvas.Children.Add(OkButton); canvas.Children.Add(CancelButton); foreach (SimpleButton s in digits) canvas.Children.Add(s); canvas.SetMargin(20, 20, 20, 20); spWindow.Child = canvas; spWindow.Visibility = Visibility.Visible; }
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; }
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; }
object ListBox_UpdateWindow(object obj) { maxW = 0; lbx = new ListBox(); lbis = new ListBoxItem[_colors.Length]; Random random = new Random(); for (int i = 0; i < _colors.Length; i++) { lbis[i] = new ListBoxItem(); Rectangle rect = new Rectangle(); int wd = _rectW + random.Next(100); if (wd > maxW) { maxW = wd; } if (uniformW) { rect.Width = _rectW; } else { rect.Width = wd; } rect.Height = _rectH; rect.Fill = new SolidColorBrush(_colors[i]); lbis[i].Child = rect; lbx.Items.Add(lbis[i]); } lbx.VerticalOffset = _vOffset; lbx.HorizontalOffset = _hOffset; lbx.SelectedIndex = index; lbxItemColl = lbx.Items; _getSelectedIndex = lbx.SelectedIndex; _getSelectedItem = lbx.SelectedItem; mainWindow.Child = lbx; return null; }
private object DrawRectangle(object arg) { Point pt = arg as Point; _rectangle = new Rectangle(); try { _rectangle.Width = pt.x; _rectangle.Height = pt.y; _rectangle.HorizontalAlignment = HorizontalAlignment.Center; _rectangle.VerticalAlignment = VerticalAlignment.Center; } catch (Exception e) { Log.Comment("Caught : " + e.Message + " when setting Width = " + pt.x + " and Height = " + pt.y); } _rectangle.Stroke = _pen; _rectangle.Fill = _brush; Master_Media._panel.Children.Add(_rectangle); return null; }
public void DrawCanvas() { Canvas canvas = new Canvas(); Text title = new Text(); title.Font = Resources.GetFont(Resources.FontResources.NinaB); title.ForeColor = Colors.DarkGray; title.TextContent = "Settings"; title.SetMargin(5); Text backtext = new Text(); backtext.Font = Resources.GetFont(Resources.FontResources.NinaB); backtext.ForeColor = Colors.DarkGray; backtext.TextContent = "Back"; backtext.SetMargin(5); SimpleButton back = new SimpleButton(backtext, 60, 25); back.Click += new EventHandler(back_Click); Text updateTimeInfo = new Text("Update Time"); updateTimeInfo.Font = Resources.GetFont(Resources.FontResources.NinaB); updateTimeInfo.ForeColor = Colors.DarkGray; Text plustext = new Text("+"); plustext.Font = Resources.GetFont(Resources.FontResources.NinaB); plustext.ForeColor = Colors.DarkGray; SimpleButton plusButton = new SimpleButton(plustext, 60, 25); plusButton.Width = plusButton.Height; plusButton.Click += new EventHandler(plus_Click); Text minustext = new Text("-"); minustext.Font = Resources.GetFont(Resources.FontResources.NinaB); minustext.ForeColor = Colors.DarkGray; SimpleButton minusButton = new SimpleButton(minustext, 60, 25); minusButton.Width = plusButton.Height; minusButton.Click += new EventHandler(minus_Click); Text metricInfo = new Text("Measurement"); metricInfo.Font = Resources.GetFont(Resources.FontResources.NinaB); metricInfo.ForeColor = Colors.DarkGray; Text metricC = new Text("Celsius"); metricC.Font = Resources.GetFont(Resources.FontResources.NinaB); metricC.ForeColor = Colors.DarkGray; CButton = new SimpleButton(metricC, 60, 25); if (!HwDevices.fahrenheit) CButton.NormalBackgroundColor = Colors.Blue; CButton.Click += new EventHandler(C_Click); Text metricF = new Text("Fahrenheit"); metricF.Font = Resources.GetFont(Resources.FontResources.NinaB); metricF.ForeColor = Colors.DarkGray; FButton = new SimpleButton(metricF, 80, 25); if(HwDevices.fahrenheit) FButton.NormalBackgroundColor=Colors.Blue; FButton.Click += new EventHandler(F_Click); Text LocationIdInfo = new Text("Location ID:" + HwDevices.WOEID); LocationIdInfo.Font = Resources.GetFont(Resources.FontResources.NinaB); LocationIdInfo.ForeColor = Colors.DarkGray; Text ChangeLocationText = new Text("Change"); ChangeLocationText.Font = Resources.GetFont(Resources.FontResources.NinaB); ChangeLocationText.ForeColor = Colors.DarkGray; SimpleButton ChangeLocationButton = new SimpleButton(ChangeLocationText, 60, 25); ChangeLocationButton.Click += new EventHandler(Location_Click); Rectangle valueRectangle = new Rectangle(2 * minusButton.Height, minusButton.Height); valueRectangle.Stroke = new Pen(Colors.Gray); updatetext = new Text(""+HwDevices.getUpdateTime()); updatetext.Font = Resources.GetFont(Resources.FontResources.NinaB); updatetext.ForeColor = Colors.DarkGray; Canvas.SetTop(updatetext, 83); Canvas.SetLeft(updatetext, 150); Canvas.SetTop(valueRectangle, 80); Canvas.SetLeft(valueRectangle, 130); Canvas.SetTop(plusButton, 80); Canvas.SetLeft(plusButton, 187); Canvas.SetTop(minusButton, 80); Canvas.SetLeft(minusButton, 100); Canvas.SetTop(updateTimeInfo, 80); Canvas.SetTop(back, 175); Canvas.SetLeft(back, 220); Canvas.SetTop(CButton, 110); Canvas.SetLeft(CButton, 100); Canvas.SetTop(FButton, 110); Canvas.SetLeft(FButton, 170); Canvas.SetTop(metricInfo, 110); Canvas.SetTop(LocationIdInfo, 140); Canvas.SetTop(ChangeLocationButton, 140); Canvas.SetLeft(ChangeLocationButton, 170); canvas.Children.Add(title); canvas.Children.Add(back); canvas.Children.Add(updateTimeInfo); canvas.Children.Add(plusButton); canvas.Children.Add(minusButton); canvas.Children.Add(valueRectangle); canvas.Children.Add(updatetext); canvas.Children.Add(metricInfo); canvas.Children.Add(CButton); canvas.Children.Add(FButton); canvas.Children.Add(LocationIdInfo); canvas.Children.Add(ChangeLocationButton); canvas.SetMargin(20, 20, 20, 20); spWindow.Child = canvas; spWindow.Visibility = Visibility.Visible; }
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; }
private bool NullReferenceExceptionTest(ref bool alignemt, ref int length) { _argumentException = false; _rect1 = null; _null = true; alignemt = true; length = new Random().Next(100); UpdateWindow(); return _argumentException; }
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; }
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; }
object StackPanel_UpdateWindow(object obj) { if (_defaultConstructor) { stp = new StackPanel(); } else { stp = new StackPanel(_setOrientation); } Rectangle[] _rects = new Rectangle[_colors.Length]; int len = _rects.Length; for (int i = 0; i < len; i++) { _rects[i] = new Rectangle(); _rects[i].Width = _width / len; _rects[i].Height = _height / len; _rects[i].Fill = new SolidColorBrush(_colors[i]); } for (int i = 0; i < _rects.Length; i++) { stp.Children.Add(_rects[i]); } if (_oHorizontal) { stp.Orientation = Orientation.Horizontal; } if (_oVertical) { stp.Orientation = Orientation.Vertical; } _getOrientation = stp.Orientation; mainWindow.Child = stp; return null; }
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; }
void SetupUI() { // initialize window mainWindow = display.WPFWindow; // setup the layout layout = new Canvas(); Border background = new Border(); background.Background = new SolidColorBrush(Colors.Black); background.Height = 240; background.Width = 320; layout.Children.Add(background); Canvas.SetLeft(background, 0); Canvas.SetTop(background, 0); //add the tongue tongue = new Rectangle(tongueWidth, 40); tongue.Fill = new SolidColorBrush(Colors.Red); layout.Children.Add(tongue); //add the snowflake snowflake = new Rectangle(10, 10); snowflake.Fill = new SolidColorBrush(Colors.White); layout.Children.Add(snowflake); // add the text area label = new Text(); label.Height = 240; label.Width = 320; label.ForeColor = Colors.White; label.Font = Resources.GetFont(Resources.FontResources.NinaB); layout.Children.Add(label); Canvas.SetLeft(label, 0); Canvas.SetTop(label, 0); mainWindow.Child = layout; }
object ScrollViewer_UpdateWindow(object obj) { scv = new ScrollViewer(); scv.Width = _scvWidth; scv.Height = _scvHeight; scv.Background = new SolidColorBrush(_scvBground); scv.LineHeight = _lineHeight; scv.LineWidth = _lineWidth; scv.HorizontalOffset = _hOffset; scv.VerticalOffset = _vOffset; scv.ScrollingStyle = _style; scv.VerticalAlignment = VerticalAlignment.Center; scv.HorizontalAlignment = HorizontalAlignment.Center; Canvas _canvas = new Canvas(); _canvas.Width = _canWidth; _canvas.Height = _canHeight; _canvas.VerticalAlignment = VerticalAlignment.Top; _canvas.HorizontalAlignment = HorizontalAlignment.Left; //Adding child elt to Canvas _rect = new Rectangle(); _rect.Width = _rectW; _rect.Height = _rectH; _rect.Fill = new SolidColorBrush(_color); _canvas.Children.Add(_rect); Canvas.SetTop(_rect, cTop); Canvas.SetLeft(_rect, cLeft); //Adding the StackPanel to ScrollViewer scv.Child = _canvas; if (_lineDown) { for (int i = 0; i < scrollCount; i++) { scv.LineDown(); } } if (_lineUp) { for (int i = 0; i < scrollCount; i++) { scv.LineUp(); } } if (_lineRight) { for (int i = 0; i < scrollCount; i++) { scv.LineRight(); } } if (_lineLeft) { for (int i = 0; i < scrollCount; i++) { scv.LineLeft(); } } //Adding the ScrollViewer to the Window mainWindow.Child = scv; _getHOffset = scv.HorizontalOffset; _getVOffset = scv.VerticalOffset; _getLineHeight = scv.LineHeight; _getLineWidth = scv.LineWidth; return null; }