private Window CreateWindow() { // Create a window object and set its size to the // size of the display. Window window = new Window(); window.Height = SystemMetrics.ScreenHeight; window.Width = SystemMetrics.ScreenWidth; // Create a single text control. Text text = new Text(); text.TextContent = this.temperature.ToString(); text.Font = Resources.GetFont(Resources.FontResources.small); text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center; // Add the text control to the window. window.Child = text; // Connect the button handler to all of the buttons. window.AddHandler(Buttons.ButtonUpEvent, new RoutedEventHandler(OnButtonUp), false); // Set the window visibility to visible. window.Visibility = Visibility.Visible; // Attach the button focus to the window. Buttons.Focus(window); this.text = text; return window; }
public CalibrationWindow(Font font, string txt) { Height = SystemMetrics.ScreenHeight; Width = SystemMetrics.ScreenWidth; Visibility = Visibility.Visible; //Buttons.Focus(this); pen = new Pen(ColorUtility.ColorFromRGB(255, 0, 0), 1); Text text = new Text(); text.Font = font; text.ForeColor = Colors.Blue; text.TextContent = txt; text.TextWrap = true; text.SetMargin(0, 0, 0, SystemMetrics.ScreenHeight / 2); text.TextAlignment = TextAlignment.Center; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Child = text; CalibrationManager.PrepareCalibrationPoints(); CalibrationManager.StartCalibration(); idx = 0; Invalidate(); }
public UpDownComboBox(Font font, int width) { Width = width; Orientation = Orientation.Horizontal; HorizontalAlignment = HorizontalAlignment.Stretch; btnDown = new Button(font, " < ", null, Colors.White); btnDown.ShowBorder = true; btnDown.HorizontalAlignment = HorizontalAlignment.Left; btnDown.Clicked += new EventHandler(btnDown_Clicked); Children.Add(btnDown); text = new Text(font, ""); text.ForeColor = Color.White; text.HorizontalAlignment = HorizontalAlignment.Stretch; text.VerticalAlignment = VerticalAlignment.Center; text.TextAlignment = TextAlignment.Center; text.TextWrap = false; Children.Add(text); btnUp = new Button(font, " > ", null, Colors.White); btnUp.ShowBorder = true; btnUp.HorizontalAlignment = HorizontalAlignment.Right; btnUp.Clicked += new EventHandler(btnUp_Clicked); Children.Add(btnUp); }
public FileBrowserItem(string label, Font font) { this.font = font; Width = SystemMetrics.ScreenWidth; Height = 30; iconOffset = (Height - iconSize) / 2; selectedBrush = new SolidColorBrush(Colors.Blue); fileName = label; fileType = String.Empty; filePath = String.Empty; Text text = new Text(font, label); text.ForeColor = Color.White; text.Height = font.Height; text.Width = Width; text.VerticalAlignment = VerticalAlignment.Top; int top = (Height - font.Height) / 2; text.SetMargin(Height + iconOffset, top, 0, 0); Child = text; UpdateIcon(); }
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 aborder for the text Border textBorder = new Border(); textBorder.SetBorderThickness(1, 5, 1, 5); textBorder.BorderBrush = new SolidColorBrush(Colors.Blue); Canvas.SetLeft(textBorder, 20); Canvas.SetTop(textBorder, 150); // Create a single text control and add it to the canvas Font font = Resources.GetFont(Resources.FontResources.NinaB); Text text = new Text(font, "Text with a border"); textBorder.Child = text; // Add the text to the border // Add the border to the canvas canvas.Children.Add(textBorder); // 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; // 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; }
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 text control. Text text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.small); text.TextContent = "Displaying a text is one of the most common tasks you need to do with your display. So it is worth looking at the Text and TextFlow classes."; //text.Height = 100; //text.Width = 50; text.TextWrap = true; text.Trimming = Microsoft.SPOT.Presentation.Media.TextTrimming.WordEllipsis; text.TextAlignment = Microsoft.SPOT.Presentation.Media.TextAlignment.Right; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Right; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center; // Add the text control to the window. mainWindow.Child = text; // Connect the button handler to all of the buttons. mainWindow.AddHandler(Buttons.ButtonUpEvent, new ButtonEventHandler(OnButtonUp), false); // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Attach the button focus to the window. Buttons.Focus(mainWindow); 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; // Create a single text control. Text text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.NinaB); text.TextContent = "Touch me!"; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; // Subscribe to touch events text.StylusDown += new StylusEventHandler(text_StylusDown); text.StylusMove += new StylusEventHandler(text_StylusMove); text.StylusUp += new StylusEventHandler(text_StylusUp); // Add the text control to the window. mainWindow.Child = text; // 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; // Create a single text control. this.textElement = new Text(); this.textElement.Font = Resources.GetFont(Resources.FontResources.NinaB); this.textElement.TextContent = this.count.ToString(); this.textElement.HorizontalAlignment = HorizontalAlignment.Center; this.textElement.VerticalAlignment = VerticalAlignment.Center; // Add the text control to the window. mainWindow.Child = this.textElement; this.dispatcherTimer = new DispatcherTimer(this.textElement.Dispatcher); this.dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); this.dispatcherTimer.Interval = new TimeSpan(0, 0, 1); //one second this.dispatcherTimer.Start(); // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Attach the button focus to the window. Buttons.Focus(mainWindow); return mainWindow; }
public TestRunView() { mainPanel = new StackPanel(Orientation.Vertical) { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; var passedPanel = new StackPanel(Orientation.Horizontal); var passedLabel = new Text(Resources.GetFont(Resources.FontResources.nina14), "Passed: ") { ForeColor = Colors.Green }; passedPanel.Children.Add(passedLabel); passedCount = new Text(Resources.GetFont(Resources.FontResources.nina14), "0"); passedPanel.Children.Add(passedCount); mainPanel.Children.Add(passedPanel); var failedPanel = new StackPanel(Orientation.Horizontal); var failedLabel = new Text(Resources.GetFont(Resources.FontResources.nina14), "Failed: "); failedLabel.ForeColor = Colors.Green; failedPanel.Children.Add(failedLabel); failedCount = new Text(Resources.GetFont(Resources.FontResources.nina14), "0"); failedPanel.Children.Add(failedCount); mainPanel.Children.Add(failedPanel); completeLabel = new Text(Resources.GetFont(Resources.FontResources.nina14), "Test run complete!"); completeLabel.Visibility = Visibility.Hidden; mainPanel.Children.Add(completeLabel); this.Child = mainPanel; }
public FirstWindow() { this.Height = SystemMetrics.ScreenHeight; this.Width = SystemMetrics.ScreenWidth; // Create a single text control. Text text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.small); text.ForeColor = Color.Black; text.TextContent = "First Window - press button to show second window"; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; // Add the text control to the window. this.Child = text; // Set the window visibility to visible. this.Visibility = Visibility.Visible; // Attach the button focus to the window. Buttons.Focus(this); // add button event handler AddHandler(Buttons.ButtonUpEvent, new ButtonEventHandler(OnButtonUp), false); }
/// <summary> /// Create the UI elements /// </summary> public void SetupUI() { temperatureDisplayLabel = new Text() { Font = Resources.GetFont(Resources.FontResources.Arial_24_Bold), Width = displayWidth, TextAlignment = TextAlignment.Center, ForeColor = GT.Color.White, TextContent = theModel.AverageTemperature.ToString() + theModel.TemperatureDegreeSymbol }; heartbeatLabel = new Text() { Font = Resources.GetFont(Resources.FontResources.Arial_24_Bold), Width = 20, TextAlignment = TextAlignment.Left, ForeColor = GT.Color.White, TextContent = "." }; this.AddChild(heartbeatLabel); this.AddChild(temperatureDisplayLabel, 40, 0); imageWidth = idleBitmap.Width; this.AddChild(statusImage, 120, screenCenter - imageWidth / 2); statusImage.Bitmap = idleBitmap; }
void setupUI() { touchScreen = display_T35.WPFWindow; //setup layout Canvas 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 label console = new Text("Hello World!"); console.Height = 100; console.Width = 320; console.ForeColor = Colors.Green; console.Font = Resources.GetFont(Resources.FontResources.NinaB); console.TextAlignment = TextAlignment.Left; layout.Children.Add(console); Canvas.SetLeft(console, 0); Canvas.SetTop(console, 10); touchScreen.Child = layout; }
public ConsoleUi(string windowTitle) { var panel = new StackPanel(); _timeText = new Text(_arial14, windowTitle) { TextAlignment = TextAlignment.Right, VerticalAlignment = VerticalAlignment.Top, ForeColor = ColorUtility.ColorFromRGB(255, 255, 0) }; panel.Children.Add(_timeText); var scroll = new ScrollViewer { Height = SystemMetrics.ScreenHeight - _arial14.Height, Width = SystemMetrics.ScreenWidth, ScrollingStyle = ScrollingStyle.Last, Background = null, LineHeight = _small.Height }; panel.Children.Add(scroll); _log = new TextFlow { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; scroll.Child = _log; Background = _solidBlack; Child = panel; }
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 text control. Text text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.small); text.TextContent = Resources.GetString(Resources.StringResources.String1); text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Border border = new Border(); border.SetBorderThickness(10); // set a 10 pixel border for r,l,t,b border.BorderBrush = new LinearGradientBrush(Colors.White, Colors.Blue, 0, 0, SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight); border.Child = text; // Add the text element to the border control // Add the text control to the window. mainWindow.Child = border; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; return mainWindow; }
public void set_text(string text, Font font, Color font_colour, int margin=5) { Text text_element = new Text(font, text); text_element.Width = Width; text_element.ForeColor = font_colour; text_element.SetMargin(margin); this.Child = text_element; }
public HighlightableTextListBoxItem(Font font, string content) : base() { // create and remember a text element from the given font and text content this.text = new Text(font, content); this.text.SetMargin(2); // set the margin for the text this.Child = this.text; // add as child content }
public TestRunView() { Child = new StackPanel(Orientation.Vertical) { Width = SystemMetrics.ScreenWidth, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Children = { new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14, " ** uScoober Runner ** ") { ForeColor = Colors.Purple, HorizontalAlignment = HorizontalAlignment.Center }, new StackPanel(Orientation.Horizontal) { HorizontalAlignment = HorizontalAlignment.Center, Children = { new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14, "Passed:") { ForeColor = Colors.Green, HorizontalAlignment = HorizontalAlignment.Right }, (_pass = new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14,"0") { ForeColor = Colors.Green, HorizontalAlignment = HorizontalAlignment.Left }), new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14, " Failed:") { ForeColor = Colors.Red }, (_fail = new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14,"0") { ForeColor = Colors.Red }) } }, new StackPanel(Orientation.Horizontal) { Children = { new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14, " Testing: "), (_currentTest = new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14," [Queued]") { TextWrap = true }) } }, (_duration = new Microsoft.SPOT.Presentation.Controls.Text(Nina.Nina14,string.Empty)), (_failurePanel = new StackPanel(Orientation.Vertical)) }, Visibility = Visibility.Visible }; }
public Room(MulticolorLed lights, Display_T35 screen, Motion_Sensor motion_Sensor, MulticolorLed door, MulticolorLed curtains, Camera camera, Button door_button, Text messageText) { this.lights = lights; this.screen = screen; this.motion_Sensor = motion_Sensor; this.door = door; this.curtains = curtains; this.camera = camera; this.door_button = door_button; this.messageText = messageText; }
public SimpleButton(Text child, int width, int height) { Text = child.TextContent; Child=child; Child.HorizontalAlignment = HorizontalAlignment.Center; Child.VerticalAlignment = VerticalAlignment.Center; this.Width = width; this.Height = height; NormalBackgroundColor = Colors.Cyan; OnBackgroundColor = Colors.Blue; BorderColor = Colors.DarkGray; }
public UpDownButton(string buttonLabel, string initialValue) { this.buttonLabel = buttonLabel; buttonValue = initialValue; Border buttonBorder = new Border(); buttonBorder.SetMargin(5); buttonBorder.Background = new SolidColorBrush(GT.Color.White); buttonBorder.SetBorderThickness(1); buttonBorder.BorderBrush = new SolidColorBrush(GT.Color.Black); buttonBorder.Width = 95; StackPanel upDwnButtonPanel = new StackPanel(Orientation.Vertical); buttonText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = buttonLabel, VerticalAlignment = VerticalAlignment.Center, }; StackPanel buttonPanel = new StackPanel(Orientation.Vertical); buttonPanel.SetMargin(4); arrowUpImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundUpButtonSmall)); arrowUpImage.HorizontalAlignment = HorizontalAlignment.Center; arrowUpImage.TouchDown += new TouchEventHandler(arrowUpImage_TouchDown); valueText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = buttonValue, VerticalAlignment = VerticalAlignment.Center, }; arrowDwnImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundDwnButtonSmall)); arrowDwnImage.HorizontalAlignment = HorizontalAlignment.Center; arrowDwnImage.TouchDown += new TouchEventHandler(arrowDwnImage_TouchDown); buttonPanel.Children.Add(arrowUpImage); buttonPanel.Children.Add(valueText); buttonPanel.Children.Add(arrowDwnImage); upDwnButtonPanel.Children.Add(buttonText); upDwnButtonPanel.Children.Add(buttonPanel); buttonBorder.Child = upDwnButtonPanel; this.Child = buttonBorder; }
/// <summary>This method is run when the mainboard is powered up or reset</summary> public void ProgramStarted() { Debug.Print("Program Started"); this.canvas = new Canvas(); this.text = new Text(Resources.GetFont(Resources.FontResources.NinaB), "Starting..."); this.canvas.Children.Add(this.text); this.window = this.oledDisplay.WPFWindow; this.window.Child = this.canvas; this.temperatureHumidity.MeasurementComplete += new TemperatureHumidity.MeasurementCompleteEventHandler(this.TemperatureHumidityMeasurementComplete); this.temperatureHumidity.StartContinuousMeasurements(); }
private MyWindow CreateWindow() { // Create a window object and set its size to the // size of the display. mainWindow = new MyWindow(); mainWindow.Height = _height; mainWindow.Width = _width; Text t = new Text(_font, "Presentaion Tests !"); t.VerticalAlignment = VerticalAlignment.Center; t.HorizontalAlignment = HorizontalAlignment.Center; mainWindow.Child = t; // 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; 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; }
public RadioButton(Font font, string txt, bool isChecked) { Orientation = Orientation.Horizontal; this.isChecked = isChecked; image = new Image(); image.VerticalAlignment = VerticalAlignment.Center; SetImage(); Children.Add(image); text = new Text(font, txt); text.ForeColor = Color.White; text.VerticalAlignment = VerticalAlignment.Center; text.TextWrap = false; text.SetMargin(textMargin, 0, 0, 0); Children.Add(text); }
public Window CreateWindow() { // Create a window object and set its size to the // size of the display. mainWindow = new Window(); _panel = new MyPanel(); mainWindow.Height = SystemMetrics.ScreenHeight; mainWindow.Width = SystemMetrics.ScreenWidth; Text t = new Text(Resources.GetFont(Resources.FontResources.small), "Shape Tests !"); t.VerticalAlignment = VerticalAlignment.Center; t.HorizontalAlignment = HorizontalAlignment.Center; _panel.Children.Add(t); mainWindow.Child = _panel; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; return mainWindow; }
/// <summary> /// Creates all WPF controls of the element /// </summary> private void InitializeComponents() { levelCaption = new Text(Resources.GetString(Resources.StringResources.Level)); levelCaption.Font = Resources.GetFont(Resources.FontResources.NinaB); levelCaption.HorizontalAlignment = HorizontalAlignment.Right; levelCaption.ForeColor = Color.White; levelLabel = new Text("0"); levelLabel.Font = Resources.GetFont(Resources.FontResources.NinaB); levelLabel.HorizontalAlignment = HorizontalAlignment.Right; levelLabel.ForeColor = Color.White; linesCaption = new Text(Resources.GetString(Resources.StringResources.LinesCompleted)); linesCaption.Font = Resources.GetFont(Resources.FontResources.NinaB); linesCaption.HorizontalAlignment = HorizontalAlignment.Right; linesCaption.ForeColor = Color.White; linesLabel = new Text("0"); linesLabel.Font = Resources.GetFont(Resources.FontResources.NinaB); linesLabel.HorizontalAlignment = HorizontalAlignment.Right; linesLabel.ForeColor = Color.White; scoreCaption = new Text(Resources.GetString(Resources.StringResources.Score)); scoreCaption.Font = Resources.GetFont(Resources.FontResources.NinaB); scoreCaption.HorizontalAlignment = HorizontalAlignment.Right; scoreCaption.ForeColor = Color.White; scoreLabel = new Text("0"); scoreLabel.Font = Resources.GetFont(Resources.FontResources.NinaB); scoreLabel.HorizontalAlignment = HorizontalAlignment.Right; scoreLabel.ForeColor = Color.White; mainStack = new StackPanel(Orientation.Vertical); mainStack.Children.Add(levelCaption); mainStack.Children.Add(levelLabel); mainStack.Children.Add(linesCaption); mainStack.Children.Add(linesLabel); mainStack.Children.Add(scoreCaption); mainStack.Children.Add(scoreLabel); this.Children.Add(mainStack); }
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; }
/// <summary> /// <para><paramref name="height"/>: Height of the button</para> /// <para><paramref name="width"/>: Width of the button</para> /// <para><paramref name="content"/>: Text content of the button</para> /// <para>To make text content displayed, Font should be set using <c>SetFont()</c> method</para> /// </summary> /// <param name="height"></param> /// <param name="width"></param> /// <param name="content"></param> public MicroButton(int height, int width, string content/*, Font buttonFont*/) { btnStateNormal = Colors.Black; btnStatePressed = Colors.DarkGray; //btnText.Font = buttonFont; Height = height; Width = width; border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.Height = this.Height; ; border.Width = this.Width; ; border.Background = new SolidColorBrush(Colors.Black); this.Children.Add(border); btnText = new Text(); btnText.ForeColor = Colors.White; btnText.TextContent = content; btnText.VerticalAlignment = VerticalAlignment.Center; btnText.HorizontalAlignment = HorizontalAlignment.Center; border.Child = btnText; }
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; }
void SetupUI() { // 1) init window mainWindow = display.WPFWindow; mainWindow.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(mainWindow_TouchDown); // 2) setup the layout Canvas 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); // 3) add the image display imageDisplay = new Border(); imageDisplay.Height = 240; imageDisplay.Width = 320; layout.Children.Add(imageDisplay); Canvas.SetLeft(imageDisplay, 0); Canvas.SetTop(imageDisplay, 0); // 4) add the text label label = new Text("testing"); label.Height = 240; label.Width = 320; label.ForeColor = Colors.White; label.Font = Resources.GetFont(Resources.FontResources.NinaB); label.TextAlignment = TextAlignment.Center; label.Visibility = Visibility.Collapsed; layout.Children.Add(label); Canvas.SetLeft(label, 0); Canvas.SetTop(label, 0); mainWindow.Child = layout; }