예제 #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, 1),
            };

            grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3));
            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     = "GroupBox is a control that displays a frame around a control with an optional caption. It has only one child, but you can used any components for macking rich user interfaces",
            };

            grid.AddContent(lb1, 0, 0, 2);

            targetPanel = new GroupBox()
            {
                Background = Color.DarkMagenta,
                Text       = "Header",
            };

            var contentPanel = new Panel
            {
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center,
            };

            contentPanel.AddContent(new Label("Content")
            {
                Background = Color.Magenta,
                Foreground = Color.White,
            });
            targetPanel.AddContent(contentPanel);
            grid.AddContent(targetPanel, 0, 1);

            descriptionLabel = new Label("Let's check how to work TextAlignment, BorderThickness, BorderColor and BorderChars properties")
            {
                Margin   = new Thickness(1, 0, 0, 0),
                WordWrap = true,
            };
            grid.AddContent(descriptionLabel, 1, 1);
        }
예제 #2
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, 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);
        }
예제 #3
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, 1),
            };

            grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3));
            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     = "Panel is a simple control using to group collections of controls. It has only one child, but you can used any components for macking rich user interfaces",
            };

            grid.AddContent(lb1, 0, 0, 2);

            targetPanel = new Panel()
            {
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Background = Color.DarkMagenta,
            };
            targetPanel.AddContent(new Label("Content")
            {
                Background = Color.Magenta,
                Foreground = Color.White,
            });
            grid.AddContent(targetPanel, 0, 1);

            descriptionLabel = new Label("Let's check how to work VerticalContentAlignment and HorizontalContentAlignment properties")
            {
                Margin   = new Thickness(1, 0, 0, 0),
                WordWrap = true,
            };
            grid.AddContent(descriptionLabel, 1, 1);
        }
예제 #4
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, 1),
            };

            grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3));
            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     = "TilePanel defines the char tiling element. It hasn't any child components, but you can tiling by char for macking specific user interfaces",
            };

            grid.AddContent(lb1, 0, 0, 2);

            targetPanel = new TilePanel('░')
            {
                Background = Color.DarkMagenta,
                Foreground = Color.Cyan,
            };

            grid.AddContent(targetPanel, 0, 1);

            descriptionLabel = new Label("Let's check how to work Tile property")
            {
                Margin   = new Thickness(1, 0, 0, 0),
                WordWrap = true,
            };
            grid.AddContent(descriptionLabel, 1, 1);
        }
예제 #5
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, 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     = "DockPanel defines an area where you can arrange child elements either horizontally or vertically, relative to each other",
            };

            grid.AddContent(lb1, 0, 0, 2);

            targetPanel = new DockPanel()
            {
                Background = Color.DarkMagenta,
            };

            grid.AddContent(targetPanel, 0, 1);

            descriptionLabel = new Label("Let's check how to arrange child elements and what is the LastChildFill property")
            {
                Margin   = new Thickness(1, 0, 0, 0),
                WordWrap = true,
            };
            grid.AddContent(descriptionLabel, 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  = 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, 55));
            grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 45));

            var lb1 = new Label
            {
                WordWrap = true,
                Text     = "CheckBoxGroup is a control to group of related but mutually exclusive checkbox buttons, requiring the user to select any of alternatives.",
            };

            grid.AddContent(lb1, 0, 0, 2);
            targetPanel = new CheckBoxGroup()
            {
                Text          = "CheckBoxGroup panel",
                TextAlignment = TextAlignment.Left,
                AutoSize      = false,
            };
            grid.AddContent(targetPanel, 0, 1);

            descriptionLabel = new Label("Let's check how to work Columns, Autosize and other properties. If press [Tab] you can focus item inside the control. [Space] - check focusabled item")
            {
                Margin   = new Thickness(1, 0, 0, 0),
                WordWrap = true,
            };
            grid.AddContent(descriptionLabel, 1, 1);
        }
예제 #7
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, 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);
        }
예제 #8
0
        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);
        }
예제 #9
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, 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);
        }
예제 #10
0
        /// <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);
        }
예제 #11
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);
        }
예제 #12
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, 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);
        }
예제 #13
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, 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);
        }
예제 #14
0
        /// <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  = 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, 60));
            grid.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 40));

            var lb1 = new Label
            {
                WordWrap = true,
                Text     = "A ProgressBar control visually indicates the progress of a lengthy operation",
            };

            grid.AddContent(lb1, 0, 0, 2);

            targetPanel = new Panel();
            var targetPanelContent = new Grid();

            targetPanelContent.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize));
            targetPanelContent.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize));
            targetPanelContent.RowDefinitions.Add(new RowDefinition(SizeType.AutoSize));
            targetPanelContent.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1));

            targetPanelContent.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 25));
            targetPanelContent.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 25));
            targetPanelContent.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 25));
            targetPanelContent.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Percent, 25));

            targetPanelContent.AddContent(
                new Label("Press [Tab] to select button below. Change some properties in main menu")
            {
                WordWrap = true,
                Margin   = new Thickness(0, 0, 0, 1),
            },
                0, 0, 4);

            targetProgressBar = new ProgressBar()
            {
                Minimum            = 0,
                Maximum            = 200,
                Value              = 50,
                SelectedBackground = Color.DarkBlue,
                Background         = Color.Gray,
            };

            targetPanelContent.AddContent(targetProgressBar, 0, 2, 4);

            foreach (var item in new []
예제 #15
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, 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);
        }
예제 #16
0
        /// <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);
        }
예제 #17
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, 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);
        }
예제 #18
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);
        }
예제 #19
0
        internal static void ShowHelp()
        {
            var wnd = new Window
            {
                Title       = "Help",
                WindowState = ControlState.Normal,
                Width       = 58,
                Background  = Application.SystemColors.DialogWindowBackground,
                Foreground  = Application.SystemColors.DialogWindowForeground,
            };

            var context = new Grid()
            {
                Padding = new Thickness(1),
            };

            context.ColumnDefinitions.Add(new ColumnDefinition(SizeType.Absolute, 15));
            context.ColumnDefinitions.Add(new ColumnDefinition());

            context.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1));
            context.AddContent(new Label("Alt+F1"), 0, 0);
            context.AddContent(new Label("Go to main menu"), 1, 0);

            context.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 2));
            context.AddContent(new Label("Ctrl+F4"), 0, 1);
            context.AddContent(new Label("Close current window. If current window is main - it close all application")
            {
                WordWrap = true,
            }, 1, 1);

            context.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 2));
            context.AddContent(new Label("Tab"), 0, 2);
            context.AddContent(new Label("Change focusable control to next. You can also change selected menu item")
            {
                WordWrap = true,
            }, 1, 2);

            context.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 1));
            context.AddContent(new Label("Shift+Tab"), 0, 3);
            context.AddContent(new Label("Change focusable control to previous"), 1, 3);

            context.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3));
            context.AddContent(new Label("Space(Enter)"), 0, 4);
            context.AddContent(new Label("Imitation of click on buttons, menu items, checkboxes and other focusable controls")
            {
                WordWrap = true,
            }, 1, 4);

            context.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 2));
            context.AddContent(new Label("Esc"), 0, 5);
            context.AddContent(new Label("Close popup menu items, exit from main menu. Close this help window")
            {
                WordWrap = true,
            }, 1, 5);

            wnd.AddContent(context);
            wnd.OnKeyPressed += WndKeyPressed;
            wnd.Show();
        }
예제 #20
0
        /// <summary>
        /// Initialize components of Window as buttons, panels, etc.
        /// </summary>
        private void InitializeComponent()
        {
            panel1 = new Panel
            {
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
            };

            var grid = new Grid
            {
                Parent = panel1,
                Width  = 70,
                Margin = new Thickness(0, 1),
            };

            grid.RowDefinitions.Add(new RowDefinition(SizeType.Absolute, 3));
            grid.RowDefinitions.AddRow();
            grid.RowDefinitions.AddRow();
            grid.RowDefinitions.AddRow();
            grid.RowDefinitions.AddRow();

            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 TextBox in your application. Press [Tab] to change control.",
            };

            grid.AddContent(lb1, 0, 0, 2);

            var tb1 = new TextBox()
            {
                CharacterCasing = CharacterCasing.Lower,
                Text            = "Character casing is Lower",
                Tag             = "CharacterCasing is modifies the case of characters as they are typed. Lower: converts all characters to lowercase",
            };

            tb1.OnEnter += ShowDescriptionByControlEnter;
            grid.AddContent(tb1, 0, 1);

            var tb2 = new TextBox()
            {
                CharacterCasing = CharacterCasing.Normal,
                Text            = "Character casing is Normal",
                Tag             = "CharacterCasing is modifies the case of characters as they are typed. Normal: converts all characters is left unchanged",
            };

            tb2.OnEnter += ShowDescriptionByControlEnter;
            grid.AddContent(tb2, 0, 2);

            var tb3 = new TextBox()
            {
                CharacterCasing = CharacterCasing.Upper,
                Text            = "Character casing is Upper",
                Tag             = "CharacterCasing is modifies the case of characters as they are typed. Upper: converts all characters to uppercase",
            };

            tb3.OnEnter += ShowDescriptionByControlEnter;
            grid.AddContent(tb3, 0, 3);

            var tb4 = new TextBox()
            {
                PasswordChar = '●',
                Text         = "Password char was set",
                Tag          = "PasswordChar has character used to mask characters of a password in the control. Original text is: 'Password char was set'",
            };

            tb4.OnEnter       += ShowDescriptionByControlEnter;
            tb4.OnTextChanged += TextChanged;
            grid.AddContent(tb4, 0, 4);

            descriptionCodeLabel = new Label
            {
                WordWrap = true,
                Text     = "Let's check how to work CharacterCasing and PasswordChar properties",
                Margin   = new Thickness(1, 0, 0, 0),
            };
            grid.AddContent(descriptionCodeLabel, 1, 1, 1, 4);
        }