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 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; }
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 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> /// <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; }
void SetupUI() { mainWindow = display.WPFWindow; // setup the layout and background 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 the image display imageDisplay = new Border(); imageDisplay.Height = 240; imageDisplay.Width = 320; layout.Children.Add(imageDisplay); Canvas.SetLeft(imageDisplay, 0); Canvas.SetTop(imageDisplay, 0); // add the text label label = new Text(""); label.Height = 50; 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; }
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; }
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); }
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 Border_UpdateWindow(object obj) { _border = new Border(); try { if (_uniformThickness) { _border.SetBorderThickness(_thickness); } else { _border.SetBorderThickness(l1, t1, r1, b1); } } catch (ArgumentException ex) { Log.Comment("Caught " + ex.Message + " when setting BorderThickness"); _argumentException = true; m_evtException.Set(); } _border.Width = _wd; _border.Height = _ht; _border.GetBorderThickness(out l2, out t2, out r2, out b2); _border.BorderBrush = _borderBrush; _border.Background = _background; mainWindow.Child = _border; return null; }
private void SetupUi() { _mainWindow = Screen.WPFWindow; var layout = new Canvas(); _imageDisplay = new Border { Height = 240, Width = 320 }; layout.Children.Add(_imageDisplay); Canvas.SetLeft(_imageDisplay, 0); Canvas.SetTop(_imageDisplay, 0); _message = new Text() { Height = 240, Width = 320, ForeColor = Colors.Black, Font = Resources.GetFont(Resources.FontResources.NinaB), TextAlignment = TextAlignment.Center, Visibility = Visibility.Visible }; layout.Children.Add(_message); Canvas.SetLeft(_message, 0); Canvas.SetTop(_message, 0); _mainWindow.Child = layout; var assembly = System.Reflection.Assembly.GetExecutingAssembly().GetName(); DisplayMessage(assembly.Name + " " + assembly.Version); }
private void SetupButton(Border button, Color color, int position) { button.Height = buttonHeight; button.Width = buttonWidth; button.Background = new SolidColorBrush(color); layout.Children.Add(button); Canvas.SetLeft(button, 2); Canvas.SetTop(button, 2 + position * (buttonHeight + 2)); }
void SetupUI() { Border whiteButton; Border yellowButton; Border redButton; Border greenButton; Border blueButton; Border blackButton; Text clearButton; // initialize window mainWindow = display.WPFWindow; // setup the layout layout = new Canvas(); background = new Image(); background.Bitmap = new Bitmap(320 - sideBarWidth, 240); background.Height = 240; background.Width = 320 - sideBarWidth; layout.Children.Add(background); Canvas.SetLeft(background, sideBarWidth); Canvas.SetTop(background, 0); whiteButton = new Border(); SetupButton(whiteButton, Colors.White, 0); whiteButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(whiteButton_TouchUp); yellowButton = new Border(); SetupButton(yellowButton, Colors.Yellow, 1); yellowButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(yellowButton_TouchUp); redButton = new Border(); SetupButton(redButton, Colors.Red, 2); redButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(redButton_TouchUp); greenButton = new Border(); SetupButton(greenButton, Colors.Green, 3); greenButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(greenButton_TouchUp); blueButton = new Border(); SetupButton(blueButton, Colors.Blue, 4); blueButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(blueButton_TouchUp); blackButton = new Border(); SetupButton(blackButton, Colors.Black, 5); blackButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(blackButton_TouchUp); clearButton = SetupClearButton(); mainWindow.Child = layout; }
void setupUI() { mainWindow = screen.WPFWindow; layout = new Canvas(); mainWindow.Child = layout; 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); ipText = new Text(Resources.GetFont(Resources.FontResources.NinaB), "IP: " + myIP); ipText.ForeColor = Color.White; layout.Children.Add(ipText); Canvas.SetLeft(ipText, 10); Canvas.SetTop(ipText, 10); Text message = new Text(Resources.GetFont(Resources.FontResources.NinaB), "Message:"); message.ForeColor = Color.White; layout.Children.Add(message); Canvas.SetLeft(message, 10); Canvas.SetTop(message, 50); messageText = new Text(Resources.GetFont(Resources.FontResources.NinaB), "message"); messageText.ForeColor = Color.White; // layout.Children.Add(messageText); Canvas.SetLeft(messageText, 10); Canvas.SetTop(messageText, 70); }
public Border AddTitleBar(string title, Font font, GT.Color foreColor, Brush backgroundBrush) { Border titleBar = new Border(); titleBar.Width = displayWidth; titleBar.Height = titlebarHeight; titleBar.Background = backgroundBrush; Text text = new Text(font, title); text.Width = displayWidth; text.ForeColor = foreColor; text.SetMargin(marginSize); text.TextAlignment = TextAlignment.Left; titleBar.Child = text; AddChild(titleBar); return titleBar; }
public void SetupUI() { #region Title Bar AddTitleBar("Settings", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Gray); #endregion // Title Bar #region Main Display Window StackPanel mainPanel = new StackPanel(Orientation.Horizontal); mainPanel.SetMargin(4); #region SetPoint Border setPointBorder = new Border(); setPointBorder.SetMargin(5); setPointBorder.Background = new SolidColorBrush(GT.Color.White); setPointBorder.SetBorderThickness(1); setPointBorder.BorderBrush = new SolidColorBrush(GT.Color.Black); setPointBorder.Width = 95; StackPanel setPointPanel = new StackPanel(Orientation.Vertical); Text setPointText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = "Set Point",// + theModel.DesiredTemperature.ToString() + theModel.TemperatureDegreeSymbol, VerticalAlignment = VerticalAlignment.Center, }; StackPanel setPointButtonPanel = new StackPanel(Orientation.Vertical); setPointButtonPanel.SetMargin(4); Image setPointUpImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundUpButtonSmall)); setPointUpImage.HorizontalAlignment = HorizontalAlignment.Center; Text setPointValueText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = theModel.DesiredTemperature.ToString() + theModel.TemperatureDegreeSymbol, VerticalAlignment = VerticalAlignment.Center, }; Image setPointDwnImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundDwnButtonSmall)); setPointDwnImage.HorizontalAlignment = HorizontalAlignment.Center; setPointButtonPanel.Children.Add(setPointUpImage); setPointButtonPanel.Children.Add(setPointValueText); setPointButtonPanel.Children.Add(setPointDwnImage); setPointPanel.Children.Add(setPointText); setPointPanel.Children.Add(setPointButtonPanel); setPointBorder.Child = setPointPanel; #endregion #region Units Border unitsBorder = new Border(); unitsBorder.SetMargin(5); unitsBorder.Background = new SolidColorBrush(GT.Color.White); unitsBorder.SetBorderThickness(1); unitsBorder.BorderBrush = new SolidColorBrush(GT.Color.Black); unitsBorder.Width = 95; StackPanel unitsPanel = new StackPanel(Orientation.Vertical); Text unitsText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = "Units", VerticalAlignment = VerticalAlignment.Center, }; StackPanel unitsButtonPanel = new StackPanel(Orientation.Vertical); unitsButtonPanel.SetMargin(4); Image unitsUpImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundUpButtonSmall)); unitsUpImage.HorizontalAlignment = HorizontalAlignment.Center; Text unitsValueText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = theModel.TemperatureDegreeSymbol, VerticalAlignment = VerticalAlignment.Center, }; Image unitsDwnImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundDwnButtonSmall)); unitsDwnImage.HorizontalAlignment = HorizontalAlignment.Center; unitsButtonPanel.Children.Add(unitsUpImage); unitsButtonPanel.Children.Add(unitsValueText); unitsButtonPanel.Children.Add(unitsDwnImage); unitsPanel.Children.Add(unitsText); unitsPanel.Children.Add(unitsButtonPanel); unitsBorder.Child = unitsPanel; #endregion #region Mode Border modeBorder = new Border(); modeBorder.SetMargin(5); modeBorder.Background = new SolidColorBrush(GT.Color.White); modeBorder.SetBorderThickness(1); modeBorder.BorderBrush = new SolidColorBrush(GT.Color.Black); modeBorder.Width = 95; StackPanel modePanel = new StackPanel(Orientation.Vertical); Text modeText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = "Mode", VerticalAlignment = VerticalAlignment.Center, }; StackPanel modeButtonPanel = new StackPanel(Orientation.Vertical); modeButtonPanel.SetMargin(4); Image modeUpImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundUpButtonSmall)); modeUpImage.HorizontalAlignment = HorizontalAlignment.Center; Text modeValueText = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_14_Bold), TextAlignment = TextAlignment.Center, TextContent = theModel.ControllerModeString, VerticalAlignment = VerticalAlignment.Center, }; Image modeDwnImage = new Image(Resources.GetBitmap(Resources.BitmapResources.GlassRoundDwnButtonSmall)); modeDwnImage.HorizontalAlignment = HorizontalAlignment.Center; modeButtonPanel.Children.Add(modeUpImage); modeButtonPanel.Children.Add(modeValueText); modeButtonPanel.Children.Add(modeDwnImage); modePanel.Children.Add(modeText); modePanel.Children.Add(modeButtonPanel); modeBorder.Child = modePanel; #endregion mainPanel.Children.Add(setPointBorder); mainPanel.Children.Add(unitsBorder); mainPanel.Children.Add(modeBorder); this.AddChild(mainPanel, 0); #endregion #region Back Button Image image = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueBackGlassSmall)); image.TouchDown += new TouchEventHandler(controller.backButton_Click); image.SetMargin(5, 3, 0, 0); this.AddChild(image, displayHeight - 45, 0); #endregion }