private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 2)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); var lb1 = new Label { WordWrap = true, Text = "StackPanel arranges child elements into a single line that can be oriented horizontally or vertically", }; grid.AddContent(lb1, 0, 0, 2); targetPanel = new StackPanel(Orientation.Horizontal) { Background = Color.DarkMagenta, AutoSize = false, }; targetPanel.AddContent(new Label("Content1") { Background = Color.Magenta, Foreground = Color.White, Margin = new Thickness(1), }); targetPanel.AddContent(new Label("Content2") { Background = Color.Magenta, Foreground = Color.White, Margin = new Thickness(1), }); grid.AddContent(targetPanel, 0, 1); descriptionLabel = new Label("Let's check how to work Orientation property") { Margin = new Thickness(1, 0, 0, 0), WordWrap = true, }; grid.AddContent(descriptionLabel, 1, 1); }
private void InitializeComponent() { Title = "Open a file"; WindowState = ControlState.Normal; Width = 40; OnActivated += OpenFileWindowActivated; stackPanel1 = new StackPanel(Orientation.Vertical) { Margin = new Thickness(1, 1, 1, 0), }; label1 = new Label("Select a file for open"); stackPanel1.AddContent(label1); listBox1 = new ListBox <string>() { Height = 9, }; listBox1.OnSelectedIndexChanged += ListBoxSelectedIndexChanged; stackPanel1.AddContent(listBox1); tilePanel1 = new TilePanel { Tile = '─', Background = this.Background, Foreground = this.Foreground, Height = 1, }; stackPanel1.AddContent(tilePanel1); dockPanel1 = new DockPanel() { Margin = new Thickness(2, 0), AutoSize = true, }; stackPanel1.AddContent(dockPanel1); button2 = new Button("Cancel") { Margin = new Thickness(1, 0, 0, 0), DialogResult = DialogResult.Cancel, }; dockPanel1.AddContent(button2, Dock.Right); button1 = new Button("Open") { DialogResult = DialogResult.OK, Width = 10, TabIndex = 1, IsDisabled = true, }; dockPanel1.AddContent(button1, Dock.Right); AddContent(stackPanel1); }
private void InitializeComponent() { panel1 = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; stackPanel1 = new StackPanel(Orientation.Vertical) { Parent = panel1, Width = 60, }; var gb = new GroupBox() { BorderThickness = new Thickness(1), BorderColor = Color.Cyan, Margin = new Thickness(0, 0, 0, 1), }; gb.AddContent(new Label("Welcome to command-line interface forms!!!") { Foreground = Color.Cyan, TextAlignment = TextAlignment.Center, }); stackPanel1.AddContent(gb); stackPanel1.AddContent(new Label("This App show you how to use properties and events of components in the list below:") { TextAlignment = TextAlignment.Center, WordWrap = true, }); foreach (var item in new [] { "Window", "StatusBar", "MainMenu", "TextBox", }) { stackPanel1.AddContent(new Label(item) { TextAlignment = TextAlignment.Center, Foreground = Color.Green, }); } stackPanel1.AddContent(new Label("If you want to continue press [space bar]. For close this window and exit from app press [Ctrl+F4]") { TextAlignment = TextAlignment.Center, WordWrap = true, }); }
private void InitializeComponent() { Title = Consts.SavingHeader; WindowState = ControlState.Normal; Width = 40; OnActivated += SaveFileWindowActivated; stackPanel1 = new StackPanel(Orientation.Vertical) { Margin = new Thickness(1, 1, 1, 0), }; label1 = new Label("Previously saved files"); stackPanel1.AddContent(label1); listBox1 = new ListBox <string>() { Height = 6, }; listBox1.OnSelectedItemClick += ListBoxSelectedItemClick; stackPanel1.AddContent(listBox1); label2 = new Label("Target file name") { Margin = new Thickness(0, 1, 0, 0) }; stackPanel1.AddContent(label2); textBox1 = new TextBox(); textBox1.OnTextChanged += TextBox1Changed; stackPanel1.AddContent(textBox1); tilePanel1 = new TilePanel { Tile = '─', Background = this.Background, Foreground = this.Foreground, Height = 1, }; stackPanel1.AddContent(tilePanel1); dockPanel1 = new DockPanel() { Margin = new Thickness(2, 0), AutoSize = true, }; stackPanel1.AddContent(dockPanel1); button2 = new Button("Cancel") { Margin = new Thickness(1, 0, 0, 0), DialogResult = DialogResult.Cancel, }; dockPanel1.AddContent(button2, Dock.Right); button1 = new Button("Save") { DialogResult = DialogResult.OK, Width = 10, TabIndex = 1, IsDisabled = true, }; dockPanel1.AddContent(button1, Dock.Right); AddContent(stackPanel1); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); var lb1 = new Label { WordWrap = true, Text = "Button is a common button control. It inherited from ButtonBase and has Background as Application.SystemColors.ButtonFace and Foreground as Application.SystemColors.ButtonText", }; grid.AddContent(lb1, 0, 0, 2); var targetPanel = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var stackPanel = new StackPanel(Orientation.Vertical) { AutoSize = true, Padding = new Thickness(1), }; for (int i = 1; i <= 4; i++) { var btn = new Button($"Button{i}") { Margin = new Thickness(0, 0, 0, i < 4 ? 1 : 0), IsDisabled = i == 2, }; btn.OnClick += BtnClick; stackPanel.AddContent(btn); } targetPanel.AddContent(stackPanel); grid.AddContent(targetPanel, 0, 1); var descriptionLabel = new Label("Use [Tab]\\[Shift+Tab] for change focused button. [Space] or [Enter] to clik. If you want to disable button selection, set the IsDisabled property. DialogResult gets or sets a value that is returned to the parent form when the button is clicked") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }; grid.AddContent(descriptionLabel, 1, 1); }
private void InitializeComponent() { Title = "Select maze dimension"; Width = 45; OnKeyPressed += KeyPressed; stackPanel1 = new StackPanel(Orientation.Vertical); AddContent(stackPanel1); stackPanel2 = new StackPanel(Orientation.Vertical) { Padding = new Thickness(2, 1), }; stackPanel1.AddContent(stackPanel2); label1 = new Label("Select the dimension of the created maze map from the list below") { Margin = new Thickness(0, 0, 0, 1), WordWrap = true, }; stackPanel2.AddContent(label1); radioButton1 = new RadioButton("45 x 15") { Checked = true, Margin = new Thickness(5, 0, 0, 0), Tag = new Size(45, 15), }; stackPanel2.AddContent(radioButton1); radioButton2 = new RadioButton("59 x 21") { Margin = new Thickness(5, 0, 0, 0), Tag = new Size(59, 21), }; stackPanel2.AddContent(radioButton2); radioButton3 = new RadioButton("119 x 27") { Margin = new Thickness(5, 0, 0, 0), Tag = new Size(119, 27), }; stackPanel2.AddContent(radioButton3); tilePanel1 = new TilePanel { Tile = '─', Background = this.Background, Foreground = this.Foreground, Height = 1, }; stackPanel1.AddContent(tilePanel1); dockPanel1 = new DockPanel() { Margin = new Thickness(2, 0), AutoSize = true, }; stackPanel1.AddContent(dockPanel1); button2 = new Button("Cancel") { Margin = new Thickness(1, 0, 0, 0), DialogResult = DialogResult.Cancel, }; dockPanel1.AddContent(button2, Dock.Right); button1 = new Button("OK") { DialogResult = DialogResult.OK, Width = 10, TabIndex = 1, }; dockPanel1.AddContent(button1, Dock.Right); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1, 0, 0), }; grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 20)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 80)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 4)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 4)); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); var lb1 = new Label { WordWrap = true, Text = "MessageBox displays a message window, also known as a dialog box, which presents a message to the user. It is a modal window, blocking other actions in the application until the user closes it.", }; grid.AddContent(lb1, 0, 0, 2); grid.AddContent(new Label("Caption") { Foreground = Color.DarkMagenta }, 0, 1); grid.AddContent(new Label("The text to display in the title bar of the message box") { WordWrap = true }, 1, 1); grid.AddContent(new Label("Message") { Foreground = Color.DarkMagenta }, 0, 2); grid.AddContent(new Label("The text to display in the message box") { WordWrap = true }, 1, 2); grid.AddContent(new Label("MessageIcon") { Foreground = Color.DarkMagenta }, 0, 3); grid.AddContent(new Label("One of the values that specifies which icon to display in the message box [None, Error, Question, Warning, Information]") { WordWrap = true }, 1, 3); grid.AddContent(new Label("Buttons") { Foreground = Color.DarkMagenta }, 0, 4); grid.AddContent(new Label("One of the values that specifies which buttons to display in the message box [OK, OKCancel, AbortRetryIgnore, YesNoCancel, YesNo, RetryCancel]") { WordWrap = true }, 1, 4); var buttonsPanel = new Panel() { HorizontalContentAlignment = HorizontalAlignment.Center, }; var stackPanel = new StackPanel(Orientation.Horizontal); var btn1 = new Button("Simple") { Margin = new Thickness(0, 0, 1, 0) }; btn1.OnClick += SimpleClick; stackPanel.AddContent(btn1); var btn2 = new Button("With caption") { Margin = new Thickness(0, 0, 1, 0) }; btn2.OnClick += CaptionClick; stackPanel.AddContent(btn2); var btn3 = new Button("Caption & icon") { Margin = new Thickness(0, 0, 1, 0) }; btn3.OnClick += CaptionIconClick; stackPanel.AddContent(btn3); var btn4 = new Button("Full variant") { Margin = new Thickness(0, 0, 1, 0) }; btn4.OnClick += FullClick; stackPanel.AddContent(btn4); buttonsPanel.AddContent(stackPanel); grid.AddContent(buttonsPanel, 0, 5, 2); }
private void InitializeComponent() { panel1 = new Panel() { HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, AutoSize = false, }; stackPanel1 = new StackPanel(Orientation.Vertical) { Width = 40, }; groupBox1 = new GroupBox() { Background = Color.Green, BorderColor = Color.DarkGreen, }; stackPanel2 = new StackPanel(Orientation.Vertical) { Margin = new Thickness(5, 0), }; label1 = new Label("Congratulations!!!") { Foreground = Color.DarkGreen, TextAlignment = TextAlignment.Center, }; stackPanel2.AddContent(label1); labelMapName = new Label() { Foreground = Color.DarkGreen, TextAlignment = TextAlignment.Center, WordWrap = true, }; stackPanel2.AddContent(labelMapName); groupBox1.AddContent(stackPanel2); groupBox2 = new GroupBox() { Background = Color.Gray, BorderColor = Color.DarkGray, Margin = new Thickness(0, 1, 0, 0), }; stackPanel3 = new StackPanel(Orientation.Vertical); stackPanel3.AddContent(new Label("Your achievements:") { TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 0, 0, 1), }); grid1 = new Grid(); grid1.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Absolute, 20)); grid1.ColumnDefinitions.Add(new ColumnDefinition()); grid1.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid1.AddContent(new Label("Steps taken"), 0, 0); labelSteps = new Label(); grid1.AddContent(labelSteps, 1, 0); grid1.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid1.AddContent(new Label("Coins collected"), 0, 1); labelCoins = new Label(); grid1.AddContent(labelCoins, 1, 1); stackPanel3.AddContent(grid1); groupBox2.AddContent(stackPanel3); stackPanel1.AddContent(groupBox1); stackPanel1.AddContent(groupBox2); panel1.AddContent(stackPanel1); AddContent(panel1); }
private void InitializeComponent() { panel1 = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Absolute, 2)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); var lb1 = new Label { WordWrap = true, Text = "ListBox represents a Windows control to display a list of items. You can use [ListBox] with object items or [ListBox<T>] with items of specified [T] type", }; grid.AddContent(lb1, 0, 0, 3); targetListBox = new ListBox <ItemTest>(); grid.AddContent(targetListBox, 0, 1); targetListBox.OnSelectedIndexChanged += ListBoxSelectedIndexChanged; Action <GlyphLabel> glyphStyle = x => { x.Foreground = Color.Cyan; x.GlyphForeground = Color.Black; }; var stackPanel = new StackPanel(Orientation.Vertical); countLabel = new GlyphLabel("Items count: ", "0"); countLabel.SetStyle(glyphStyle); stackPanel.AddContent(countLabel); selectedIndexLabel = new GlyphLabel("Selected index: ", "-1"); selectedIndexLabel.SetStyle(glyphStyle); stackPanel.AddContent(selectedIndexLabel); formatStringLabel = new GlyphLabel("Format string: ", " {0} "); formatStringLabel.SetStyle(glyphStyle); stackPanel.AddContent(formatStringLabel); addButton = new Button("Add item") { Margin = new Thickness(0, 1, 0, 0), }; addButton.OnClick += AddButtonClick; stackPanel.AddContent(addButton); removeButton = new Button("Remove item") { IsDisabled = true, Margin = new Thickness(0, 1, 0, 0), }; removeButton.OnClick += RemoveButtonClick; stackPanel.AddContent(removeButton); grid.AddContent(stackPanel, 2, 1); }
/// <summary> /// Initialize components of Window as buttons, panels, etc. /// </summary> private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 76, }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Percent, 100)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); targetListView = new ListView <CountryInfo>() { ShowGridLine = true, ShowSummary = true, BorderColor = Color.Black, SummaryText = "Use [Tab], [↓] or [↑]", Text = "Counties", TextAlignment = TextAlignment.Center, AutoSelect = true, }; targetListView.Items.AddRange(MainWindow.CountryInfos); targetListView.OnSelectedIndexChanged += ListViewSelectedIndexChanged; grid.AddContent(targetListView, 0, 0, 1, 2); var stackPanel = new StackPanel(Orientation.Vertical) { Margin = new Thickness(1, 0, 0, 0), }; descriptionLabel = new Label("Let's check how to work Items, ShowGridLine and ShowSummary properties") { WordWrap = true, }; stackPanel.AddContent(descriptionLabel); codeLabel = new Label(new[] { "targetListView = new ListView<CountryInfo>()", "{", " ShowGridLine = true,", " ShowSummary = true,", " BorderColor = Color.Black,", " SummaryText = …,", " Text = \"Counties\",", " TextAlignment = …,", "};" }) { WordWrap = true, Foreground = Color.Yellow, }; stackPanel.AddContent(codeLabel); grid.AddContent(stackPanel, 1, 0); }
private void InitializeComponent() { panel1 = new Panel { HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, }; mainMenu1 = new MainMenu(); var paramItem = new MenuItem("Window"); var maxParamItem = new MenuItem("Maximized"); maxParamItem.Tag = ControlState.Maximized; maxParamItem.OnClick += WindowStateChangedClick; paramItem.Items.Add(maxParamItem); var mormParamItem = new MenuItem("Normal"); mormParamItem.Tag = ControlState.Normal; mormParamItem.OnClick += WindowStateChangedClick; paramItem.Items.Add(mormParamItem); paramItem.Items.Add(new SeparatorMenuItem()); hideMenuItem = new MenuItem("Hide title"); hideMenuItem.OnClick += HideMenuItemClick; paramItem.Items.Add(hideMenuItem); paramItem.Items.Add(new SeparatorMenuItem()); var exitItem = new MenuItem("Exit"); exitItem.OnClick += ExitClick; paramItem.Items.Add(exitItem); mainMenu1.Items.Add(paramItem); var commonParam = new MenuItem("Common"); var bgItem = new MenuItem("Background"); var fgItem = new MenuItem("Foreground"); foreach (var value in Enum.GetValues(typeof(Color)) .Cast <Color>() .Where(x => x != Color.NotSet) .OrderBy(x => x.ToString())) { if (value.ToString().StartsWith("Dark")) { var bgClItem = new MenuItem(value.ToString()); bgClItem.Tag = value; bgClItem.OnClick += BackgroundItemClick; bgItem.Items.Add(bgClItem); } else { var fgClItem = new MenuItem(value.ToString()); fgClItem.Tag = value; fgClItem.OnClick += ForegroundClick; fgItem.Items.Add(fgClItem); } } commonParam.Items.Add(bgItem); commonParam.Items.Add(fgItem); mainMenu1.Items.Add(commonParam); var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 4)); grid.RowDefinitions.AddRow(); grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 50)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 50)); var lb1 = new Label { WordWrap = true, Foreground = Color.NotSet, Background = Color.NotSet, Text = "Now look at an example how to use MainMenu in your application. Look at the top of the window. There are panel with items. Press [Alt+F1] for go to the first main menu item.", }; grid.AddContent(lb1, 0, 0, 2); codeStackPanel = new StackPanel(Orientation.Vertical) { Background = Application.SystemColors.WindowBackground, }; codeStackPanel.AddContent(new Label { Foreground = Color.Blue, Text = "var mMenu = new MainMenu();", }); codeStackPanel.AddContent(new Label { Foreground = Color.DarkBlue, Text = "var fItem = new MenuItem(\"File\");", }); codeStackPanel.AddContent(new Label { Foreground = Color.DarkBlue, Text = "var nItem = new MenuItem(\"&New\");", }); codeStackPanel.AddContent(new Label { Foreground = Color.DarkBlue, Text = "nItem.OnClick += itemClick;", }); codeStackPanel.AddContent(new Label { Foreground = Color.DarkBlue, Text = "fItem.Items.Add(nItem);", }); codeStackPanel.AddContent(new Label { Foreground = Color.Blue, Text = "mMenu.Items.Add(fItem);", }); codeStackPanel.AddContent(new Label { Foreground = Color.Blue, Text = "this.MainMenu = mMenu;", }); grid.AddContent(codeStackPanel, 0, 1); descriptionCodeLabel = new Label { WordWrap = true, Text = "First you should to create new instance of MainMenu. Then create some menu items for your business logic. Finally set \"MainMenu\" property of main window.", }; grid.AddContent(descriptionCodeLabel, 1, 1); grid.AddContent( new Label { Text = "Press [space bar] button for next controls", Margin = new Thickness(0, 0, 0, 0), }, 0, 2, 2); AddContent(panel1); }
private void InitializeComponent() { panel1 = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 20)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); var lb1 = new Label { WordWrap = true, Text = "Look at the example how to move some items between two listboxes. Manipulation only [Items] property by add and remove methods", }; grid.AddContent(lb1, 0, 0, 3); leftListBox = new ListBox <string>(); leftListBox.OnSelectedIndexChanged += ListBoxSelectedIndexChanged; grid.AddContent(leftListBox, 0, 1); stackPanel = new StackPanel(Orientation.Vertical) { Padding = new Thickness(1, 0), AutoSize = false, }; leftToRightButton = new Button(">") { IsDisabled = true, }; leftToRightButton.OnClick += LeftToRightButtonClick; stackPanel.AddContent(leftToRightButton); leftAllToRightButton = new Button(">>") { Margin = new Thickness(0, 1), IsDisabled = true, }; leftAllToRightButton.OnClick += LeftAllToRightButtonClick; stackPanel.AddContent(leftAllToRightButton); rightToLeftButton = new Button("<") { IsDisabled = true, }; rightToLeftButton.OnClick += RightToLeftButtonClick; stackPanel.AddContent(rightToLeftButton); rightAllToLeftButton = new Button("<<") { Margin = new Thickness(0, 1, 0, 0), IsDisabled = true, }; rightAllToLeftButton.OnClick += RightAllToLeftButtonClick; stackPanel.AddContent(rightAllToLeftButton); grid.AddContent(stackPanel, 1, 1); rightListBox = new ListBox <string>(); rightListBox.OnSelectedIndexChanged += ListBoxSelectedIndexChanged; grid.AddContent(rightListBox, 2, 1); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); var lb1 = new Label { WordWrap = true, Text = "CheckBox represents a control to give the user an option, such as true/false or yes/no. CheckBox controls let the user pick a combination of options", }; grid.AddContent(lb1, 0, 0, 2); var targetPanel = new Panel() { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var stackPanel = new StackPanel(Orientation.Vertical) { AutoSize = true, Padding = new Thickness(1), }; var cb1 = new CheckBox("CheckBox1") { Margin = new Thickness(0, 0, 0, 1), }; cb1.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb1); var cb2 = new CheckBox("CheckBox2") { Checked = true, Margin = new Thickness(0, 0, 0, 1), }; cb2.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb2); var cb3 = new CheckBox("CheckBox3") { IsDisabled = true, Margin = new Thickness(0, 0, 0, 1), }; cb3.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb3); var cb4 = new CheckBox("CheckBox4") { IsDisabled = true, Checked = true, Margin = new Thickness(0, 0, 0, 1), }; cb4.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb4); var cb5 = new CheckBox("CheckBox5") { ThreeState = true, }; cb5.OnCheckedChanged += CheckedChanged; stackPanel.AddContent(cb5); targetPanel.AddContent(stackPanel); grid.AddContent(targetPanel, 0, 1); var propertyPanel = new StackPanel(Orientation.Vertical); propertyPanel.AddContent( new Label( "Use [Tab]\\[Shift+Tab] for change focused checkbox. [Space] or [Enter] to change the state. The ThreeState property determines whether the control supports two or three states") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }); propertyChangedLabel = new Label("Click on any available checkbox…") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }; propertyPanel.AddContent(propertyChangedLabel); grid.AddContent(propertyPanel, 1, 1); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 1), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 2)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); var lb1 = new Label { WordWrap = true, Text = "RadioButton enables the user to select a single option from a group of choices when paired with other RadioButton controls", }; grid.AddContent(lb1, 0, 0, 2); var stackPanel = new StackPanel(Orientation.Vertical) { AutoSize = true, Padding = new Thickness(1), }; var grBox1 = new GroupBox() { Text = "Group1", Margin = new Thickness(0, 0, 0, 1), Padding = new Thickness(2, 0), }; var grStackPanel1 = new StackPanel(Orientation.Vertical); for (int i = 1; i <= 3; i++) { var rButton = new RadioButton($"RadioButton{i}"); rButton.OnCheckedChanged += CheckedChanged; grStackPanel1.AddContent(rButton); } grBox1.AddContent(grStackPanel1); stackPanel.AddContent(grBox1); var grBox2 = new GroupBox() { Text = "Group2", Padding = new Thickness(2, 0), }; var grStackPanel2 = new StackPanel(Orientation.Vertical); for (int i = 1; i <= 3; i++) { var rButton = new RadioButton($"RadioButton{i}"); rButton.OnCheckedChanged += CheckedChanged; grStackPanel2.AddContent(rButton); } grBox2.AddContent(grStackPanel2); stackPanel.AddContent(grBox2); grid.AddContent(stackPanel, 0, 1); var propertyPanel = new StackPanel(Orientation.Vertical); propertyPanel.AddContent( new Label( "Use [Tab]\\[Shift+Tab] for change focused radiobutton. [Space] or [Enter] to clik. When the user selects one option button (also known as a radio button) within a group, the others clear automatically. All RadioButton controls in a given container, such as a Window, constitute a group") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }); propertyChangedLabel = new Label("Click on any radiobutton…") { Margin = new Thickness(1, 1, 0, 0), WordWrap = true, }; propertyPanel.AddContent(propertyChangedLabel); grid.AddContent(propertyPanel, 1, 1); }
/// <summary> /// Initialize components of Window as buttons, panels, etc. /// </summary> private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 76, }; grid.RowDefinitions.Add(new RowDefinition(SizeType.Percent, 100)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 60)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40)); targetListView = new ListView <CountryInfo>() { ShowGridLine = true, ShowSummary = true, BorderColor = Color.Black, SummaryText = "Use [Tab], [↓] or [↑]", Text = "Counties", TextAlignment = TextAlignment.Center, AutoSelect = true, HeaderForeground = Color.Cyan, }; targetListView.Items.AddRange(MainWindow.CountryInfos); targetListView.ColumnHeaders.Add("Country", x => x.Country); targetListView.ColumnHeaders.Add("Gdp", x => x.Gdp.ToString(), 6, TextAlignment.Right); targetListView.ColumnHeaders.Add("Ppl", x => x.Population.ToString(), 9, TextAlignment.Right); targetListView.OnItemDraw += TargetListViewItemDraw; grid.AddContent(targetListView, 0, 0, 1, 2); var stackPanel = new StackPanel(Orientation.Vertical) { Margin = new Thickness(1, 0, 0, 0), }; descriptionLabel = new Label("Let's check how to work with ColumnHeaders") { WordWrap = true, }; stackPanel.AddContent(descriptionLabel); codeLabel = new Label(new[] { "targetListView.HeaderForeground = Color.Cyan;", "…", "targetListView.ColumnHeaders", ".Add(\"Country\",", " x => x.Population,", " 9,", " TextAlignment.Right", ");", }) { WordWrap = true, Foreground = Color.Yellow, }; stackPanel.AddContent(codeLabel); grid.AddContent(stackPanel, 1, 0); }
private void InitializeComponent() { panel1 = new Panel { VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Center, }; var grid = new Grid { Parent = panel1, Width = 70, Margin = new Thickness(0, 2), }; grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 50)); grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 50)); var lb1 = new Label { WordWrap = true, Text = "let's see an example how to use StatusBar in your application. Look at the bottom of the window. There are panel with button and label.", Margin = new Thickness(0, 0, 0, 1), }; grid.AddContent(lb1, 0, 0, 2); var sp = new StackPanel(Orientation.Vertical); sp.AddContent(new Label { Foreground = Color.DarkBlue, Text = "var statusBar1 = new StatusBar();", }); sp.AddContent(new Label { Foreground = Color.DarkBlue, Text = "statusBar1.AddHelpButton();", }); sp.AddContent(new Label { Foreground = Color.DarkBlue, Text = "this.StatusBar = statusBar1;", }); grid.AddContent(sp, 0, 1); var lb2 = new Label { WordWrap = true, Text = "First you should to create new instance of StatusBar. Then call \"AddHelpButton\" method for append help button to StatusBar. Finally set \"StatusBar\" property of main window.", }; grid.AddContent(lb2, 1, 1); var lb3 = new Label { WordWrap = true, Text = "Let's see now what we prepared for you next. Press [space bar] button for continue", Margin = new Thickness(0, 1, 0, 1), }; grid.AddContent(lb3, 0, 2, 2); AddContent(panel1); }