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 PageNewLayoutItem() { //BackgroundStackPanel panel = new BackgroundStackPanel(Orientation.Vertical); //panel.Background = Program.PanelBackground; //panel.Opacity = Program.PanelOpacity; StackPanel panel = new StackPanel(Orientation.Vertical); Child = panel; itemTypes = new RadioButtonGroup(Orientation.Vertical); itemTypes.VerticalAlignment = VerticalAlignment.Center; itemTypes.HorizontalAlignment = HorizontalAlignment.Center; panel.Children.Add(itemTypes); Font font = Program.FontRegular; itemTypes.AddButton(new RadioButton(font, "Локомотив")); itemTypes.AddButton(new RadioButton(font, "Состав")); itemTypes.AddButton(new RadioButton(font, "Стрелка")); itemTypes.AddButton(new RadioButton(font, "Сигнал")); itemTypes.AddButton(new RadioButton(font, "Поворотный круг")); itemTypes.AddButton(new RadioButton(font, "Группа аксессуаров")); itemTypes.SelectedIndex = 0; //itemTypes.Children[1].SetMargin(0, 0, 0, 15); //itemTypes.Children[1].HorizontalAlignment = HorizontalAlignment.Left; Button btnOK = new Button(Program.FontRegular, "Добавить", Resources.GetBitmap(Resources.BitmapResources.OK), Program.ButtonTextColor); btnOK.SetMargin(2); btnOK.VerticalAlignment = VerticalAlignment.Bottom; btnOK.HorizontalAlignment = HorizontalAlignment.Center; btnOK.Background = Program.ButtonBackground; btnOK.Clicked += new EventHandler(btnOK_Clicked); panel.Children.Add(btnOK); itemTypes.Height = panel.Parent.Height - btnOK.Height - 8; }
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 PageLocomotiveProperties(Locomotive locomotive) { this.locomotive = locomotive; StackPanel panel = new StackPanel(Orientation.Vertical); Child = panel; tabs = new TabControl(); tabs.AddTab(CreateTabCommon()); tabs.AddTab(CreateTabFunctions()); panel.Children.Add(tabs); StackPanel panelBottom = new StackPanel(Orientation.Horizontal); panelBottom.HorizontalAlignment = HorizontalAlignment.Center; panel.Children.Add(panelBottom); Button btnSave = new Button(Program.FontRegular, "Сохранить", Resources.GetBitmap(Resources.BitmapResources.Save), Program.ButtonTextColor); btnSave.SetMargin(2); btnSave.VerticalAlignment = VerticalAlignment.Bottom; btnSave.HorizontalAlignment = HorizontalAlignment.Center; btnSave.Background = Program.ButtonBackground; btnSave.Clicked += new EventHandler(btnSave_Clicked); panelBottom.Children.Add(btnSave); tabs.Height = panel.Parent.Height - btnSave.Height - 8; ucWriteBlock writeBlock = new ucWriteBlock(); writeBlock.VerticalAlignment = VerticalAlignment.Bottom; writeBlock.HorizontalAlignment = HorizontalAlignment.Center; writeBlock.SetMargin(5, 0, 0, 0); writeBlock.WriteClicked += new EventHandler(writeBlock_WriteClicked); panelBottom.Children.Add(writeBlock); LoadValues(); }
public ListBox() { _panel = new StackPanel(); _scrollViewer = new ScrollViewer(); _scrollViewer.Child = _panel; this.LogicalChildren.Add(_scrollViewer); }
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; int buttonWidth = SystemMetrics.ScreenWidth / 4; int buttonHeight = 20; // Create a panel to hold the list view and buttons. StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; // Create a panel to hold the buttons. StackPanel buttonPanel = new StackPanel(); buttonPanel.Orientation = Orientation.Horizontal; ButtonControl newFileButton = new ButtonControl("New File", buttonWidth, buttonHeight); newFileButton.TouchDown += new TouchEventHandler(OnNewFile); buttonPanel.Children.Add(newFileButton); ButtonControl newDirButton = new ButtonControl("New Dir", buttonWidth, buttonHeight); newDirButton.TouchDown += new TouchEventHandler(OnNewDirectory); buttonPanel.Children.Add(newDirButton); ButtonControl deleteButton = new ButtonControl("Delete", buttonWidth, buttonHeight); deleteButton.TouchDown += new TouchEventHandler(OnDeleteFile); buttonPanel.Children.Add(deleteButton); ButtonControl formatButton = new ButtonControl("Format", buttonWidth, buttonHeight); formatButton.TouchDown += new TouchEventHandler(OnFormat); buttonPanel.Children.Add(formatButton); // Create the list view. _listView = new ListView(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight - buttonHeight); _listView.AddColumn("Name", 200); _listView.AddColumn("Size", 80); _listView.AddColumn("Created", 80); _listView.SelectionChanged += new SelectionChangedEventHandler(OnItemSelected); stackPanel.Children.Add(buttonPanel); stackPanel.Children.Add(_listView); mainWindow.Child = stackPanel; // Refresh the directory and file list RefreshList(); // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Attach the button focus to the window. Buttons.Focus(mainWindow); return mainWindow; }
/// <summary> /// Constructs a MainMenuWindow for the specified program. /// </summary> /// <param name="program"></param> public MainMenuWindow(MySimpleWPFApplication program) : base(program) { // Create some colors for the text items. Color instructionTextColor = ColorUtility.ColorFromRGB(255, 255, 255); Color backgroundColor = ColorUtility.ColorFromRGB(0, 0, 0); Color upperBackgroundColor = ColorUtility.ColorFromRGB(69, 69, 69); Color unselectedItemColor = ColorUtility.ColorFromRGB(192, 192, 192); Color selectedItemColor = ColorUtility.ColorFromRGB(128, 128, 128); // The Main window contains a veritcal StackPanel. StackPanel panel = new StackPanel(Orientation.Vertical); this.Child = panel; // The top child contains a horizontal StackPanel. m_MenuItemPanel = new MenuItemPanel(this.Width, this.Height); // The top child contains the menu items. We pass in the small bitmap, // large bitmap a description and then a large bitmap to use as a common // sized bitmap for calculating the width and height of a MenuItem. MenuItem menuItem1 = new MenuItem( Resources.BitmapResources.Vertical_Stack_Panel_Icon_Small, Resources.BitmapResources.Vertical_Stack_Panel_Icon, "Vertical Stack Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem2 = new MenuItem( Resources.BitmapResources.Horizontal_Stack_Panel_Icon_Small, Resources.BitmapResources.Horizontal_Stack_Panel_Icon, "Horizontal Stack Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem3 = new MenuItem( Resources.BitmapResources.Canvas_Panel_Icon_Small, Resources.BitmapResources.Canvas_Panel_Icon, "Canvas Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem4 = new MenuItem( Resources.BitmapResources.Scrollable_Panel_Icon_Small, Resources.BitmapResources.Scrollable_Panel_Icon, "Scrollable Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem5 = new MenuItem( Resources.BitmapResources.Free_Drawing_Panel_Icon_Small, Resources.BitmapResources.Free_Drawing_Panel_Icon, "Free Drawing Panel", Resources.BitmapResources.Canvas_Panel_Icon); // Add each of the menu items to the menu item panel m_MenuItemPanel.AddMenuItem(menuItem1); m_MenuItemPanel.AddMenuItem(menuItem2); m_MenuItemPanel.AddMenuItem(menuItem3); m_MenuItemPanel.AddMenuItem(menuItem4); m_MenuItemPanel.AddMenuItem(menuItem5); // Add the menu item panel to the main window panel panel.Children.Add(m_MenuItemPanel); }
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; }
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 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; }
/// <summary> /// Constructs a StackPanelDemo for the specified program and orientation. /// </summary> /// <param name="program">The program for which to construct a demo.</param> /// <param name="orientation">The orientation of the graphical layout. /// </param> public StackPanelDemo(MySimpleWPFApplication program, Orientation orientation) : base(program) { StackPanel panel = new StackPanel(orientation); this.Child = panel; panel.Visibility = Visibility.Visible; // This is an array of different shapes to be drawn. Shape[] shapes = new Shape[] { new Ellipse(0, 0), new Line(), // A square. new Polygon(new Int32[] { 0, 0, 50, 0, 50, 50, 0, 50 }), new Rectangle(), // A custom shape. new Cross() }; // Set up the needed member values for each shape. for (Int32 x = 0; x < shapes.Length; x++) { Shape s = shapes[x]; s.Fill = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 0)); s.Stroke = new Pen(Color.Black, 2); s.Visibility = Visibility.Visible; s.HorizontalAlignment = HorizontalAlignment.Center; s.VerticalAlignment = VerticalAlignment.Center; s.Height = Height - 1; s.Width = Width - 1; if (panel.Orientation == Orientation.Horizontal) s.Width /= shapes.Length; else s.Height /= shapes.Length; panel.Children.Add(s); } }
/// <summary> /// Creates all WPF controls of the window /// </summary> private void InitializeComponents() { this.Height = SystemMetrics.ScreenHeight; this.Width = SystemMetrics.ScreenWidth; this.Background = new SolidColorBrush(Color.Black); // Tetris grid universeView = new UniverseView(gameUniverse); // Stack panel with next block and score GradientStackPanel statusStack = new GradientStackPanel(Orientation.Vertical, Color.Black, Color.White); statusStack.Width = this.Width - universeView.Width; statusStack.Height = this.Height; // Next block control NextBlockView nextBlockView = new NextBlockView(gameUniverse); nextBlockView.SetMargin(8); nextBlockView.HorizontalAlignment = HorizontalAlignment.Right; // Score panel StatisticsPanel statsPanel = new StatisticsPanel(gameUniverse.Statistics); statsPanel.SetMargin(8); statsPanel.HorizontalAlignment = HorizontalAlignment.Right; statusStack.Children.Add(nextBlockView); statusStack.Children.Add(statsPanel); // Main stack on the screeen StackPanel mainStack = new StackPanel(Orientation.Horizontal); mainStack.Children.Add(universeView); mainStack.Children.Add(statusStack); this.Child = mainStack; // Set the window visibility to visible. this.Visibility = Visibility.Visible; // Attach the button focus to the window. Buttons.Focus(this); }
private Tab CreateTabFunctions() { Tab tab = new Tab(Program.FontRegular, "tabFunctions", "Функции", null); tab.Background = Program.ButtonBackground; tab.ForeColor = Program.LabelTextColor; StackPanel panel = new StackPanel(Orientation.Vertical); panel.SetMargin(3); tab.Content = panel; return tab; }
/// <summary> /// Creates the UI elements /// </summary> public void SetupUI() { #region Title Bar AddTitleBar(Resources.GetString(Resources.StringResources.errorTitle), Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black); #endregion // Title Bar #region Main Display Window StackPanel mainPanel = new StackPanel(Orientation.Horizontal); mainPanel.SetMargin(4); // Error Message Label errorMessageText = new Text() { ForeColor = GT.Color.Red, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = "", TextAlignment = TextAlignment.Center, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; errorMessageText.SetMargin(8, 8, 8, 8); mainPanel.Children.Add(errorMessageText); this.AddChild(mainPanel, 0); #endregion // Main Display Window }
public void SetupUI() { #region Title Bar AddTitleBar(theModel.AppTitle, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black); #endregion // Title Bar #region Main Display Window StackPanel dashboardPanel = new StackPanel(Orientation.Vertical); // Current Temp Label currentTempLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = "Current Temperature: " + theModel.CurrentTemperature.ToString() + theModel.TemperatureDegreeSymbol, TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; currentTempLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(currentTempLabel); // Set Point Label setPointLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = "Set Point: " + theModel.DesiredTemperature.ToString() + theModel.TemperatureDegreeSymbol, TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; setPointLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(setPointLabel); // State Label stateLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = "Status: " + theModel.CurrentStateString, TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; stateLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(stateLabel); modeLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = "Mode: " + theModel.ControllerModeString, TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; modeLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(modeLabel); this.AddChild(dashboardPanel, 10); #region Back Button Image image = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueGlassSettingsSmall)); image.TouchDown += new TouchEventHandler(controller.settingsButton_Click); image.SetMargin(5, 3, 0, 0); this.AddChild(image, displayHeight - 45, 0); #endregion #endregion }
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; // Add a gradient color background to the window mainWindow.Background = new LinearGradientBrush(Colors.White, Colors.Red, 0, 0, mainWindow.Width, mainWindow.Height); Font normalFont = Resources.GetFont(Resources.FontResources.NinaB); Font smallFont = Resources.GetFont(Resources.FontResources.small); // Create a list box control and add text items ListBox listBox = new ListBox(); // set the width so that it fills the entire screen listBox.Child.Width = mainWindow.Width; // make the list box transparent listBox.Background = null; // make the enclosed scroll viewer transparent also // we get the scroll viewer via the child property but // need to cast it to Control in order to clear the background ((Control)listBox.Child).Background = null; // Add simple text items for (int i = 0; i < 2; ++i) { string str = "Simple text item"; Text text = new Text(normalFont, str); text.SetMargin(2); ListBoxItem item = new HighlightableListBoxItem(text); listBox.Items.Add(item); } // Add a separator listBox.Items.Add(new SeparatorListBoxItem()); // Add a text item with icon { // Create the stack panel to align the elements StackPanel stackPanel = new StackPanel(Orientation.Horizontal); // Icon Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Clock); // Make the bitmap transparent using // the color of the top left corner pixel. // Therefore the image should not be in the Bitmap and Jpeg format // because that requires to create a copy in order to make it // transparent. Use Gif instead. bmp.MakeTransparent(bmp.GetPixel(0, 0)); Image image = new Image(bmp); image.SetMargin(2); // set a margin to separate the image // vertically center the icon within the item image.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(image); // Text Text text = new Text(normalFont, "Item with a icon and text"); text.SetMargin(2); // set margin to separate the text // vertically center the icon within the item text.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(text); // Create a highlightable list box item ListBoxItem item = new HighlightableListBoxItem(stackPanel); listBox.Items.Add(item); } // Add a separator listBox.Items.Add(new SeparatorListBoxItem()); // Add two items with multiple columns // use i to add a right aligned number to the first column for (int i = 0; i <= 100; i += 50) { //create the stack panel to align the elements StackPanel stackPanel = new StackPanel(Orientation.Horizontal); // Add right aligned text Text text1 = new Text(normalFont, i.ToString()); text1.Width = 30; text1.SetMargin(2); // set margin to separate the text text1.TextAlignment = TextAlignment.Right; // vertically center the icon within the item text1.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(text1); // Icon Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Audio); // Make the bitmap transparent using // the color of the top left corner pixel. // Therefore the image should not be in the Bitmap and Jpeg format // because that requires to create a copy in order to make it // transparent. Use Gif instead. bmp.MakeTransparent(bmp.GetPixel(0, 0)); Image image = new Image(bmp); image.SetMargin(2); // set a margin to separate the image // vertically center the icon within the item image.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(image); // Text Text text = new Text(normalFont, "Item with multiple columns"); text.SetMargin(2); // set margin to separate the text // vertically center the icon within the item text.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(text); // Create a highlightable list box item ListBoxItem item = new HighlightableListBoxItem(stackPanel); listBox.Items.Add(item); } // Add a separator listBox.Items.Add(new SeparatorListBoxItem()); // Add two multi line text item for (int i = 0; i < 2; ++i) { TextFlow textFlow = new TextFlow(); textFlow.TextRuns.Add("This is the first line.", normalFont, Colors.Black); textFlow.TextRuns.Add(TextRun.EndOfLine); textFlow.TextRuns.Add("Second line.", normalFont, Colors.Green); textFlow.TextRuns.Add(TextRun.EndOfLine); textFlow.TextRuns.Add("Third line.", smallFont, Colors.Red); textFlow.SetMargin(2); ListBoxItem item = new HighlightableListBoxItem(textFlow); listBox.Items.Add(item); } // Add the text control to the window. mainWindow.Child = listBox; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Let the user select items with the up and down buttons. Buttons.Focus(listBox); // Get notified when the selected item was changed. listBox.SelectionChanged += new SelectionChangedEventHandler(listBox_SelectionChanged); // Get notified when a selected item was pressed // using the select button. listBox.AddHandler(Buttons.ButtonDownEvent, new ButtonEventHandler(listBox_ButtonDown), false); return mainWindow; }
public Window CreateUI() { Window window = new Window(); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Vertical; Text text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.FONT); text.TextContent = "Hello"; text.ForeColor = Colors.Red; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Left; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch; panel.Children.Add(text); text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.FONT); text.TextContent = "comma"; text.ForeColor = Colors.Green; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch; panel.Children.Add(text); text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.FONT); text.TextContent = "World!"; text.ForeColor = Colors.Blue; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Right; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch; panel.Children.Add(text); TextFlow textFlow = new TextFlow(); textFlow.Height = 60; textFlow.TextRuns.Add("[BEGIN] ", Resources.GetFont(Resources.FontResources.FONT), Colors.Green); textFlow.TextRuns.Add("Call me Ishmael. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Gray); textFlow.TextRuns.Add("Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Gray); textFlow.TextRuns.Add("It is a way I have of driving off the spleen, and regulating the circulation. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Gray); textFlow.TextRuns.Add("A_very_long_sentence_with_no_whitespace_that_should_trigger_an_emergency_break. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Blue); textFlow.TextRuns.Add("[END] ", Resources.GetFont(Resources.FontResources.FONT), Colors.Green); panel.Children.Add(textFlow); text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.FONT); text.TextContent = ""; text.ForeColor = Colors.Gray; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch; panel.Children.Add(text); _buttonText = text; text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.FONT); text.TextContent = ""; text.ForeColor = Colors.Gray; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch; panel.Children.Add(text); _timeText = text; window.Child = panel; window.AddHandler(Buttons.ButtonDownEvent, new RoutedEventHandler(OnButtonDown), false); window.AddHandler(Buttons.GotFocusEvent, new RoutedEventHandler(OnGotFocus), false); window.Width = SystemMetrics.ScreenWidth; window.Height = SystemMetrics.ScreenHeight; window.Visibility = Visibility.Visible; // Buttons.Focus(window); Buttons.Focus(textFlow); return window; }
/// <summary> /// Creates all WPF controls of the window /// </summary> private void InitializeComponents() { blinkTimer = new DispatcherTimer(this.Dispatcher); blinkTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); blinkTimer.Tick += new EventHandler(BlinkTimer_Tick); #region Name Characters nameStack = new StackPanel(Orientation.Horizontal); nameStack.HorizontalAlignment = HorizontalAlignment.Left; nameStack.SetMargin(0, 0, 20, 5); for (int i = 0; i < NAME_LENGTH; i++) { nameLetters[i] = new Text(); nameLetters[i].Font = Resources.GetFont(Resources.FontResources.Consolas23); nameStack.Children.Add(nameLetters[i]); } UpdateLetters(); #endregion #region Score Label scoreLabel = new Text(ScoreToString(this._score)); scoreLabel.ForeColor = normalColor; scoreLabel.Font = Resources.GetFont(Resources.FontResources.Consolas23); scoreLabel.TextAlignment = TextAlignment.Right; #endregion StackPanel mainStack = new StackPanel(Orientation.Horizontal); mainStack.HorizontalAlignment = HorizontalAlignment.Center; mainStack.Children.Add(nameStack); mainStack.Children.Add(scoreLabel); this.Child = mainStack; }
/// <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); }
private Tab CreateTabCommon() { Tab tab = new Tab(Program.FontRegular, "tabCommon", "Общие", null); tab.Background = Program.ButtonBackground; tab.ForeColor = Program.LabelTextColor; tab.IsSelected = true; StackPanel panel = new StackPanel(Orientation.Vertical); panel.SetMargin(3); //BackgroundStackPanel panel = new BackgroundStackPanel(Orientation.Vertical); //panel.Background = Program.PanelBackground; //panel.Opacity = Program.PanelOpacity; //panel.Height = 150; //panel.SetMargin(3); tab.Content = panel; Text txt; StackPanel p; txt = new Text(Program.FontRegular, "Имя:"); txt.ForeColor = Program.LabelTextColor; p = new StackPanel(Orientation.Horizontal); txtName = new Text(Program.FontRegular, ""); txtName.ForeColor = Program.LabelTextColor; txtName.VerticalAlignment = VerticalAlignment.Center; p.Children.Add(txtName); Button btnKeyboard = new Button(Program.FontRegular, " ... ", null, Program.ButtonTextColor); btnKeyboard.SetMargin(2, 0, 0, 0); btnKeyboard.VerticalAlignment = VerticalAlignment.Center; btnKeyboard.Background = Program.ButtonBackground; //btnKeyboard.Clicked += new EventHandler(btnSave_Clicked); p.Children.Add(btnKeyboard); panel.Children.Add(new ParameterValue(txt, p)); txt = new Text(Program.FontRegular, "Протокол:"); txt.ForeColor = Program.LabelTextColor; cbProtocol = new UpDownComboBox(Program.FontRegular, 120); cbProtocol.ButtonDown.Background = cbProtocol.ButtonUp.Background = Program.ButtonBackground; cbProtocol.Items.Add("DCC 14"); cbProtocol.Items.Add("DCC 28"); cbProtocol.Items.Add("DCC 128"); cbProtocol.Items.Add("Selectrix"); cbProtocol.Items.Add("Motorola 14"); cbProtocol.Items.Add("Motorola 27"); cbProtocol.Items.Add("Motorola 28"); cbProtocol.Items.Add("Motorola Fx 14"); panel.Children.Add(new ParameterValue(txt, cbProtocol)); txt = new Text(Program.FontRegular, "Адрес:"); txt.ForeColor = Program.LabelTextColor; UpDownComboBox cbProgCurrentThreshold = new UpDownComboBox(Program.FontRegular, 90); cbProgCurrentThreshold.ButtonDown.Background = cbProgCurrentThreshold.ButtonUp.Background = Program.ButtonBackground; cbProgCurrentThreshold.Items.Add(3); panel.Children.Add(new ParameterValue(txt, cbProgCurrentThreshold)); //txt = new Text(Program.FontRegular, "Выкл. при коротком замыкании во внешн. бустерах:"); //txt.ForeColor = Program.TextColor; //txt.TextWrap = true; //chbShutdownOnExternalShortCircuit = new Checkbox(Program.FontRegular); //panel.Children.Add(new ParameterValue(txt, chbShutdownOnExternalShortCircuit)); //txt = new Text(Program.FontRegular, "Калибровка экрана:"); //txt.ForeColor = Program.TextColor; //Button btnCalibrate = new Button(Program.FontRegular, "Калибровать", Resources.GetBitmap(Resources.BitmapResources.Calibrate), Colors.White); //btnCalibrate.ImageSize = 16; //btnCalibrate.Width = 90; //btnCalibrate.BackgroundImage = Program.ButtonBackground; //btnCalibrate.Clicked += new EventHandler(btnCalibrate_Clicked); //panel.Children.Add(new ParameterValue(txt, btnCalibrate)); return tab; }
public void SetupUI() { #region Title Bar AddTitleBar("Settings", Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black); #endregion // Title Bar #region Main Display Window StackPanel mainPanel = new StackPanel(Orientation.Horizontal); mainPanel.SetMargin(4); SetpointChangeButtons = new Controls.UpDownButton("Set Point", theModel.DesiredTemperature + theModel.TemperatureDegreeSymbol); UnitsChangeButtons = new Controls.UpDownButton("Units", theModel.TemperatureDegreeSymbol); ModeChangeButtons = new Controls.UpDownButton("Mode", theModel.ControllerModeString); mainPanel.Children.Add(SetpointChangeButtons); mainPanel.Children.Add(UnitsChangeButtons); mainPanel.Children.Add(ModeChangeButtons); this.AddChild(mainPanel, 0); #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); #endregion this.AddChild(image, displayHeight - 45, 0); #endregion #region Assign Handlers SetpointChangeButtons.UpButtonTouchDown += new TouchEventHandler(SetpointChangeButtons_UpButtonTouchDown); SetpointChangeButtons.DownButtonTouchDown += new TouchEventHandler(SetpointChangeButtons_DownButtonTouchDown); UnitsChangeButtons.UpButtonTouchDown += new TouchEventHandler(UnitsChangeButtons_ButtonTouchDown); UnitsChangeButtons.DownButtonTouchDown += new TouchEventHandler(UnitsChangeButtons_ButtonTouchDown); ModeChangeButtons.UpButtonTouchDown += new TouchEventHandler(ModeChangeButtons_UpButtonTouchDown); ModeChangeButtons.DownButtonTouchDown += new TouchEventHandler(ModeChangeButtons_DownButtonTouchDown); #endregion }
public MessageBox(Font font, int width, string message, MessageBoxButton buttonsSet, Bitmap buttonBackground, Color buttonTextColor, Color textColor) { Background = new SolidColorBrush(Colors.Black); Width = width; Visibility = Visibility.Hidden; SizeToContent = SizeToContent.Height; this.buttonsSet = buttonsSet; main = Application.Current.MainWindow; modalBlock = new DispatcherFrame(); StackPanel pnl = new StackPanel(Orientation.Vertical); Child = pnl; txtMessage = new Text(font, message); txtMessage.ForeColor = textColor; txtMessage.HorizontalAlignment = HorizontalAlignment.Center; txtMessage.TextAlignment = TextAlignment.Center; txtMessage.TextWrap = true; txtMessage.SetMargin(3); pnl.Children.Add(txtMessage); StackPanel pnlButtons = new StackPanel(Orientation.Horizontal); pnlButtons.HorizontalAlignment = HorizontalAlignment.Center; pnlButtons.VerticalAlignment = VerticalAlignment.Bottom; pnl.Children.Add(pnlButtons); btn1 = new Button(font, "", null, buttonTextColor); btn1.Background = buttonBackground; btn1.ImageSize = 16; btn1.HorizontalAlignment = HorizontalAlignment.Center; btn1.SetMargin(3); btn1.Clicked += new EventHandler(btn1_Clicked); pnlButtons.Children.Add(btn1); btn2 = new Button(font, "", null, buttonTextColor); btn2.Background = buttonBackground; btn2.ImageSize = 16; btn2.HorizontalAlignment = HorizontalAlignment.Center; btn2.SetMargin(3); btn2.Clicked += new EventHandler(btn2_Clicked); pnlButtons.Children.Add(btn2); btn3 = new Button(font, "", null, buttonTextColor); btn3.Background = buttonBackground; btn3.ImageSize = 16; btn3.HorizontalAlignment = HorizontalAlignment.Center; btn3.SetMargin(3); btn3.Clicked += new EventHandler(btn3_Clicked); pnlButtons.Children.Add(btn3); switch (buttonsSet) { case MessageBoxButton.OK: btn1.Text = "OK"; btn2.Visibility = btn3.Visibility = Visibility.Collapsed; break; case MessageBoxButton.OKCancel: btn1.Text = "OK"; btn2.Text = "Отмена"; btn3.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNo: btn1.Text = "Да"; btn2.Text = "Нет"; btn3.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNoCancel: btn1.Text = "Да"; btn2.Text = "Нет"; btn3.Text = "Отмена"; break; } //Top = (SystemMetrics.ScreenHeight - Height) / 2; }
///// <summary> ///// Assigns the provided TouchEventHander to the settings button ///// </summary> ///// <param name="handler"></param> //public void AttachButtonTouchHandler(TouchEventHandler handler) //{ // settingsButton.TouchDown += handler; //} /// <summary> /// Creates the UI elements /// </summary> public void SetupUI() { #region Title Bar AddTitleBar(Resources.GetString(Resources.StringResources.appTitle), Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black); #endregion // Title Bar #region Main Display Window StackPanel dashboardPanel = new StackPanel(Orientation.Vertical); // Current Temp Label currentTempLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = Resources.GetString(Resources.StringResources.currentTempLabel) + theModel.AverageTemperature.ToString() + theModel.TemperatureDegreeSymbol, TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; currentTempLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(currentTempLabel); // Set Point Label setPointLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = Resources.GetString(Resources.StringResources.setpointLabel) + theModel.AverageTemperature.ToString() + theModel.TemperatureDegreeSymbol, TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; setPointLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(setPointLabel); // State Label stateLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = Resources.GetString(Resources.StringResources.statusLabel) + theModel.CurrentStateStringTable[(int)theModel.CurrentState], TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; stateLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(stateLabel); // Mode Label modeLabel = new Text() { ForeColor = GT.Color.Black, Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold), TextContent = Resources.GetString(Resources.StringResources.currentModeLabel) + theModel.ControllerModeStringTable[(int)theModel.ControllerMode], TextAlignment = TextAlignment.Left, VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center }; modeLabel.SetMargin(0, 8, 0, 8); dashboardPanel.Children.Add(modeLabel); this.AddChild(dashboardPanel, 10); #region Settings Button settingsButton = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueGlassSettingsSmall)); settingsButton.SetMargin(5, 3, 0, 0); this.AddChild(settingsButton, displayHeight - 45, 0); #endregion // Settings Button #endregion // Main Display Window }
/// <summary> /// Constructs a ScrollPanelDemo for the specified program. /// </summary> /// <param name="program"></param> public ScrollPanelDemo(MySimpleWPFApplication program) : base(program) { // Create a stack panel for the title and scroll view. StackPanel panel = new StackPanel(Orientation.Vertical); // Create the text scroll view and set all of its properties. _viewer = new TextScrollViewer(Resources.GetString( Resources.StringResources.ScrollableText), MySimpleWPFApplication.NinaBFont, Color.Black); _viewer.Width = this.Width; // Make room for the title bar. _viewer.Height = this.Height - 25; _viewer.HScrollHeight = 10; _viewer.VScrollWidth = 10; _viewer.HorizontalAlignment = HorizontalAlignment.Left; _viewer.VerticalAlignment = VerticalAlignment.Top; // Create the title text Text title = new Text(MySimpleWPFApplication.NinaBFont, Resources.GetString(Resources.StringResources.ScrollableTextTitle)); title.ForeColor = Color.White; // Add the elements to the stack panel. panel.Children.Add(title); panel.Children.Add(_viewer); // Add the stack panel to this window. this.Child = panel; // Set the background color. this.Background = new SolidColorBrush(ColorUtility.ColorFromRGB(64, 64, 255)); }
/// <summary> /// Creates all WPF controls of the window /// </summary> private void InitializeComponents() { this.Width = SystemMetrics.ScreenWidth; this.Height = SystemMetrics.ScreenHeight; this.Background = new SolidColorBrush(Colors.Black); #region Caption Text caption = new Text(Resources.GetString(Resources.StringResources.HighScore)); caption.Font = Resources.GetFont(Resources.FontResources.Consolas23); caption.ForeColor = Colors.Red; caption.SetMargin(0, 10, 0, 15); caption.TextAlignment = TextAlignment.Center; #endregion #region Score ListBox scoreListBox = new ListBox(); scoreListBox.Background = this.Background; scoreListBox.HorizontalAlignment = HorizontalAlignment.Center; foreach (ScoreRecord scoreRecord in parentApp.HighScore.Table) { ScoreItem scoreItem = new ScoreItem(scoreRecord.Name, scoreRecord.Score); scoreItem.Background = scoreListBox.Background; scoreListBox.Items.Add(scoreItem); } #endregion #region HintLabel hintTextFlow = new TextFlow(); hintTextFlow.SetMargin(0, 15, 0, 0); hintTextFlow.TextAlignment = TextAlignment.Center; UpdateHint(); #endregion StackPanel mainStack = new StackPanel(Orientation.Vertical); mainStack.HorizontalAlignment = HorizontalAlignment.Center; mainStack.Children.Add(caption); mainStack.Children.Add(scoreListBox); mainStack.Children.Add(hintTextFlow); this.Child = mainStack; this.Visibility = Visibility.Visible; Buttons.Focus(this); }
/// <summary> /// Creates all WPF controls of the window /// </summary> private void InitializeComponents() { this.Width = SystemMetrics.ScreenWidth; this.Height = SystemMetrics.ScreenHeight; this.Background = new SolidColorBrush(Colors.Black); Image logoImage = new Image(Resources.GetBitmap(Resources.BitmapResources.Logo)); #region ListBox event handler Color selectedItemColor = Colors.White; Color unselectedItemColor = ColorUtility.ColorFromRGB(206, 206, 206); Brush selectedBackground = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 148, 255)); menuListBox = new ListBox(); menuListBox.Background = this.Background; menuListBox.HorizontalAlignment = HorizontalAlignment.Center; // Event handler for menu items menuListBox.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e) { int previousSelectedIndex = e.PreviousSelectedIndex; if (previousSelectedIndex != -1) { // Change previously-selected listbox item color to unselected color ((Text)menuListBox.Items[previousSelectedIndex].Child).ForeColor = unselectedItemColor; menuListBox.Items[previousSelectedIndex].Background = menuListBox.Background; } // Change newly-selected listbox item color to selected color and background ((Text)menuListBox.Items[e.SelectedIndex].Child).ForeColor = selectedItemColor; menuListBox.Items[e.SelectedIndex].Background = selectedBackground; }; #endregion #region Menu Items // Menu items from resources string[] menuItems = new string[4] { Resources.GetString(Resources.StringResources.RookieLevel), Resources.GetString(Resources.StringResources.AdvancedLevel), Resources.GetString(Resources.StringResources.ExtremeLevel), Resources.GetString(Resources.StringResources.ViewHighScore)}; // Add items into listbox foreach(string item in menuItems) { Text itemText = new Text(Resources.GetFont(Resources.FontResources.NinaB), item); itemText.Width = this.Width - 40; itemText.ForeColor = unselectedItemColor; itemText.TextAlignment = TextAlignment.Center; itemText.SetMargin(5); ListBoxItem listBoxItem = new ListBoxItem(); listBoxItem.Background = menuListBox.Background; listBoxItem.Child = itemText; menuListBox.Items.Add(listBoxItem); } menuListBox.SelectedIndex = 0; #endregion // Add all controls to stack panel StackPanel mainStackPanel = new StackPanel(Orientation.Vertical); mainStackPanel.Children.Add(logoImage); mainStackPanel.Children.Add(menuListBox); this.Child = mainStackPanel; this.Visibility = Visibility.Visible; Buttons.Focus(menuListBox); }
public QuaziMessageBox(Font font, int width, string message, MessageBoxButton buttons, Bitmap buttonBackground, Color buttonTextColor, Color textColor, EventHandler Closed) { Width = width; Visibility = Visibility.Hidden; this.buttons = buttons; onClose = Closed; Orientation = Orientation.Vertical; HorizontalAlignment = HorizontalAlignment.Center; VerticalAlignment = VerticalAlignment.Center; txtMessage = new Text(font, message); txtMessage.ForeColor = Color.Black; txtMessage.HorizontalAlignment = HorizontalAlignment.Center; txtMessage.TextAlignment = TextAlignment.Center; txtMessage.TextWrap = true; txtMessage.SetMargin(3); Children.Add(txtMessage); StackPanel pnlButtons = new StackPanel(Orientation.Horizontal); pnlButtons.HorizontalAlignment = HorizontalAlignment.Center; pnlButtons.VerticalAlignment = VerticalAlignment.Bottom; Children.Add(pnlButtons); btn1 = new Button(font, "", null, buttonTextColor); btn1.Background = buttonBackground; btn1.ImageSize = 16; btn1.HorizontalAlignment = HorizontalAlignment.Center; btn1.SetMargin(3); btn1.Clicked += new EventHandler(btn1_Clicked); pnlButtons.Children.Add(btn1); btn2 = new Button(font, "", null, buttonTextColor); btn2.Background = buttonBackground; btn2.ImageSize = 16; btn2.HorizontalAlignment = HorizontalAlignment.Center; btn2.SetMargin(3); btn2.Clicked += new EventHandler(btn2_Clicked); pnlButtons.Children.Add(btn2); btn3 = new Button(font, "", null, buttonTextColor); btn3.Background = buttonBackground; btn3.ImageSize = 16; btn3.HorizontalAlignment = HorizontalAlignment.Center; btn3.SetMargin(3); btn3.Clicked += new EventHandler(btn3_Clicked); pnlButtons.Children.Add(btn3); switch (buttons) { case MessageBoxButton.OK: btn1.Text = "OK"; btn2.Visibility = btn3.Visibility = Visibility.Collapsed; break; case MessageBoxButton.OKCancel: btn1.Text = "OK"; btn2.Text = "Отмена"; btn3.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNo: btn1.Text = "Да"; btn2.Text = "Нет"; btn3.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNoCancel: btn1.Text = "Да"; btn2.Text = "Нет"; btn3.Text = "Отмена"; break; } }
/// <summary> /// Creates the main window. /// </summary> /// <returns>The main window.</returns> public Window CreateWindow() { // Create a window object and set its size to the size of the // display. mainWindow = new Window(); mainWindow.Width = SystemMetrics.ScreenWidth; mainWindow.Height = SystemMetrics.ScreenHeight; // Detect landscape or portrait so the program can adjust its // layout. bool portrait = SystemMetrics.ScreenWidth < SystemMetrics.ScreenHeight; // Create the main stack panel. StackPanel stack = new StackPanel(portrait ? Orientation.Vertical : Orientation.Horizontal); // Create stack panels for the current temperature and target // temperature. StackPanel stack1 = new StackPanel(Orientation.Vertical); StackPanel stack2 = new StackPanel(Orientation.Vertical); // Create border panels for the current temperature and target // temperature. BorderPanel panel1; BorderPanel panel2; // Detect portrait or landscape orientation. if (portrait) { // If in portrait mode, set the width to the screen width and // height to 1/4 and 3/4. panel1 = new BorderPanel(SystemMetrics.ScreenWidth, (int)(SystemMetrics.ScreenHeight * .25)); panel2 = new BorderPanel(SystemMetrics.ScreenWidth, (int)(SystemMetrics.ScreenHeight * .75)); } else { // Otherwise, set the width and height to 1/2 and 1/2, // respectively. panel1 = new BorderPanel(SystemMetrics.ScreenWidth / 2, SystemMetrics.ScreenHeight); panel2 = new BorderPanel(SystemMetrics.ScreenWidth / 2, SystemMetrics.ScreenHeight); } // Add the border panels to the panels containing the current // temperature and target temperature. panel1.Children.Add(stack1); panel2.Children.Add(stack2); // Add the stack panels to the border panels. stack.Children.Add(panel1); stack.Children.Add(panel2); // Create text controls for the current temperature. _textCurrentTemp = new Text(); _textCurrentTemp.Font = Resources.GetFont(Resources.FontResources.nina48); _textCurrentTemp.TextContent = Resources.GetString(Resources.StringResources.InitialTemp); _textCurrentTemp.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center; _textCurrentTemp.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center; Text currentLabel = new Text(); currentLabel.Font = Resources.GetFont(Resources.FontResources.nina14); currentLabel.TextContent = Resources.GetString(Resources.StringResources.CurrentTemp); currentLabel.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center; currentLabel.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center; // Add the text controls to the current temperature stack panel. stack1.Children.Add(currentLabel); stack1.Children.Add(_textCurrentTemp); // Create controls for the target temperature. _textTargetTemp = new Text(); _textTargetTemp.Font = Resources.GetFont(Resources.FontResources.nina48); _textTargetTemp.TextContent = Resources.GetString(Resources.StringResources.InitialTemp); _textTargetTemp.HorizontalAlignment = HorizontalAlignment.Center; _textTargetTemp.VerticalAlignment = VerticalAlignment.Center; Text targetLabel = new Text(); targetLabel.Font = Resources.GetFont(Resources.FontResources.nina14); targetLabel.TextContent = Resources.GetString(Resources.StringResources.TargetTemp); targetLabel.HorizontalAlignment = HorizontalAlignment.Center; targetLabel.VerticalAlignment = VerticalAlignment.Center; // Create the air conditioner or heater status indicator. _statusIndicator = new StatusIndicator(); // Add the controls to the target temperature stack panel. stack2.Children.Add(targetLabel); stack2.Children.Add(_textTargetTemp); stack2.Children.Add(_statusIndicator); // Add instructions to the target temperature stack panel. TextFlow instructions = new TextFlow(); instructions.HorizontalAlignment = HorizontalAlignment.Center; instructions.VerticalAlignment = VerticalAlignment.Center; instructions.TextAlignment = TextAlignment.Center; instructions.TextRuns.Add(new TextRun("Up Button to Increase", Resources.GetFont(Resources.FontResources.nina14), Color.Black)); instructions.TextRuns.Add(TextRun.EndOfLine); instructions.TextRuns.Add(new TextRun("Down Button to Decrease", Resources.GetFont(Resources.FontResources.nina14), Color.Black)); instructions.TextRuns.Add(TextRun.EndOfLine); instructions.TextRuns.Add(new TextRun( "Select Button to Toggle Celsius / Fahrenheit", Resources.GetFont(Resources.FontResources.nina14), Color.Black)); stack2.Children.Add(instructions); // Set the main window child to the main horizontal stack panel. mainWindow.Child = stack; // 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; // Attach the button focus to the window. Buttons.Focus(mainWindow); // Create the timer that will check the current temperature. _timer = new DispatcherTimer(mainWindow.Dispatcher); _timer.Interval = new TimeSpan(0, 0, 0, 0, 50); _timer.Tick += new EventHandler(OnTimer); _timer.Start(); return mainWindow; }
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); }
///// <summary> ///// Assigns the provided TouchEventHander to the settings button ///// </summary> ///// <param name="handler"></param> //public void AttachButtonTouchHandler(TouchEventHandler handler) //{ // backButton.TouchDown += handler; //} /// <summary> /// Creates the UI elements /// </summary> public void SetupUI() { #region Title Bar AddTitleBar(Resources.GetString(Resources.StringResources.settingsTitle), Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black); #endregion // Title Bar #region Main Display Window StackPanel mainPanel = new StackPanel(Orientation.Horizontal); mainPanel.SetMargin(4); SetpointChangeButtons = new Controls.UpDownButton(Resources.GetString(Resources.StringResources.setpointLabel), theModel.TemperatureSetPoint + theModel.TemperatureDegreeSymbol); UnitsChangeButtons = new Controls.UpDownButton(Resources.GetString(Resources.StringResources.unitsLabel), theModel.TemperatureDegreeSymbol); ModeChangeButtons = new Controls.UpDownButton(Resources.GetString(Resources.StringResources.currentModeLabel), theModel.ControllerModeStringTable[(int)theModel.ControllerMode]); mainPanel.Children.Add(SetpointChangeButtons); mainPanel.Children.Add(UnitsChangeButtons); mainPanel.Children.Add(ModeChangeButtons); this.AddChild(mainPanel, 0); #region Back Button //C:\Users\user\Documents\Visual Studio 2010\Projects\TempControlV2\TempControlV2\View\Resources\ backButton = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueBackGlassSmall)); //backImage.TouchDown += new TouchEventHandler(backButton_Click); backButton.SetMargin(5, 3, 0, 0); #endregion #region Ale Button Image aleImage = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueGlassAleSmall)); aleImage.TouchDown += new TouchEventHandler(aleImage_TouchDown); aleImage.SetMargin(5, 3, 0, 0); #endregion #region Lager Button Image lagerImage = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueGlassLagerSmall)); lagerImage.TouchDown += new TouchEventHandler(lagerImage_TouchDown); lagerImage.SetMargin(5, 3, 0, 0); #endregion this.AddChild(backButton, displayHeight - 45, 0); this.AddChild(aleImage, displayHeight - 45, 150); this.AddChild(lagerImage, displayHeight - 45, 230); #endregion // Main Display Window #region Assign Handlers SetpointChangeButtons.UpButtonTouchDown += new TouchEventHandler(SetpointChangeButtons_UpButtonTouchDown); SetpointChangeButtons.DownButtonTouchDown += new TouchEventHandler(SetpointChangeButtons_DownButtonTouchDown); UnitsChangeButtons.UpButtonTouchDown += new TouchEventHandler(UnitsChangeButtons_ButtonTouchDown); UnitsChangeButtons.DownButtonTouchDown += new TouchEventHandler(UnitsChangeButtons_ButtonTouchDown); ModeChangeButtons.UpButtonTouchDown += new TouchEventHandler(ModeChangeButtons_UpButtonTouchDown); ModeChangeButtons.DownButtonTouchDown += new TouchEventHandler(ModeChangeButtons_DownButtonTouchDown); #endregion // Assign Handlers }