public void DropDownInElementHostShouldHaveCorrectInitialValue() { var dropDown = new DropDown(); dropDown.DataStore = new [] { "Item 1", "Item 2", "Item 3" }; var content = TableLayout.AutoSized(dropDown); // forces template to be applied to WPF controls var native = content.ToNative(false); native.Measure(new System.Windows.Size(double.PositiveInfinity, double.PositiveInfinity)); // now set selected index now that template has applied dropDown.SelectedIndex = 1; // check that the index is correct when it is shown int?dropDownIndex = null; var dlg = new Dialog(); dlg.ClientSize = new Drawing.Size(200, 200); dlg.Content = content; dlg.Shown += (sender, e) => { dropDownIndex = dropDown.SelectedIndex; dlg.Close(); }; dlg.ShowModal(Application.Instance.MainForm); Assert.AreEqual(1, dropDownIndex); }
Control ColorPickerControl() { var control = new ColorPicker(); LogEvents(control); return(TableLayout.AutoSized(control, centered: true)); }
public void ControlShouldFireShownEventWhenVisibleChanged(IControlTypeInfo <Control> controlType) { int shownCount = 0; int?initialShownCount = null; Form(form => { var ctl = controlType.CreateControl(); ctl.Shown += (sender2, e2) => { shownCount++; Application.Instance.AsyncInvoke(() => { if (form.Loaded) { form.Close(); } }); }; ctl.Visible = false; Assert.AreEqual(0, shownCount); form.Content = TableLayout.AutoSized(ctl); Assert.AreEqual(0, shownCount); form.Shown += (sender, e) => Application.Instance.AsyncInvoke(() => { initialShownCount = shownCount; ctl.Visible = true; }); }); Assert.AreEqual(0, initialShownCount, "#1"); // should not be initially called Assert.AreEqual(1, shownCount, "#2"); }
public CheckBoxListSection() { var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddRow(new Label { Text = "Default" }, Default(), null); layout.AddRow(new Label { Text = "With Items" }, TableLayout.AutoSized(Items())); layout.AddRow(new Label { Text = "Disabled" }, TableLayout.AutoSized(Disabled())); layout.AddRow(new Label { Text = "Set Initial Value" }, TableLayout.AutoSized(SetInitialValue())); layout.AddRow(new Label { Text = "EnumCheckBoxList<TestEnum>" }, TableLayout.AutoSized(EnumCombo())); layout.AddRow(new Label { Text = "Vertical" }, TableLayout.AutoSized(Items(Orientation.Vertical))); layout.Add(null, null, true); Content = layout; }
public SystemColorSection() { var layout = new StackLayout { Spacing = 10, HorizontalContentAlignment = HorizontalAlignment.Stretch }; var type = typeof(SystemColors); var properties = type.GetRuntimeProperties(); var skip = new List <PropertyInfo>(); var colorProperties = properties.Where(r => r.PropertyType == typeof(Color)).OrderBy(r => r.Name).ToList(); foreach (var property in colorProperties) { if (skip.Contains(property)) { continue; } var color = (Color)property.GetValue(null); var label = new Label { Text = property.Name }; var panel = new Panel { Content = label, Padding = new Padding(10), }; bool isTextColor = property.Name.EndsWith("Text"); if (isTextColor) { label.TextColor = color; } else { panel.BackgroundColor = color; var textProp = colorProperties.FirstOrDefault(r => r.Name == property.Name + "Text"); if (textProp != null) { label.TextColor = (Color)textProp.GetValue(null); label.Text += " && " + textProp.Name; skip.Add(textProp); } else if (color.ToHSB().B < 0.5) { label.TextColor = Colors.White; } } layout.Items.Add(panel); } Content = new Scrollable { Content = TableLayout.AutoSized(layout, centered: true) }; }
public RadioButtonListSection() { var layout = new DynamicLayout(); layout.AddRow(new Label { Text = "Default" }, Default(), null); layout.AddRow(new Label { Text = "With Items" }, TableLayout.AutoSized(Items())); layout.AddRow(new Label { Text = "Disabled" }, TableLayout.AutoSized(Disabled())); layout.AddRow(new Label { Text = "Set Initial Value" }, TableLayout.AutoSized(SetInitialValue())); layout.AddRow(new Label { Text = "EnumRadioButtonList<TestEnum>" }, TableLayout.AutoSized(EnumCombo())); layout.AddRow(new Label { Text = "Vertical" }, TableLayout.AutoSized(Items(RadioButtonListOrientation.Vertical))); layout.Add(null, null, true); Content = layout; }
/// <summary> /// Initializes a new instance of the <see cref="T:WarCollege.Dialogs.Preferences"/> class. /// </summary> public Preferences() { Title = Resources.Strings.HelloWorld; MinimumSize = new Size(300, 0); Resizable = false; var button = new Button { Text = Resources.Strings.CloseButton }; button.Click += (sender, e) => Close(); Content = new TableLayout { Padding = new Padding(10), Spacing = new Size(5, 5), Rows = { new Label { Text = Resources.Strings.HelloWorld }, TableLayout.AutoSized(button, centered: true) } }; AbortButton = DefaultButton = button; }
Control PageRange() { var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddRow(new Label { Text = "Print Selection" }, TableLayout.AutoSized(PrintSelection())); layout.BeginHorizontal(); layout.Add(new Label { Text = "Selected Start" }); layout.AddSeparateRow().Add(SelectedStart(), new Label { Text = "to" }, SelectedEnd()); layout.EndHorizontal(); layout.Add(null); return(new GroupBox { Text = "Page Range", Content = layout }); }
public BitmapSection() { var layout = new DynamicLayout(); layout.AddRow(new Label { Text = "Load from Stream" }, LoadFromStream()); layout.AddRow( new Label { Text = "Custom 32-bit" }, CreateCustom32(), new Label { Text = "Custom 32-bit alpha" }, CreateCustom32Alpha(), null ); layout.AddRow( new Label { Text = "Clone" }, Cloning(), new Label { Text = "Clone rectangle" }, TableLayout.AutoSized(CloningRectangle(), centered: true), null); layout.AddRow( new Label { Text = "Clone using tiles" }, TableLayout.AutoSized(CloneTiles(), centered: true), new Label { Text = "Draw to a rect" }, TableLayout.AutoSized(DrawImageToRect(), centered: true), null); layout.Add(null); Content = layout; }
void pSubShapeRef_UI(TableLayout tl) { TableRow tr = new TableRow(); tl.Rows.Add(tr); lbl_subShapeRef = new Label { Text = "Subshape Reference", ToolTip = "Which subshape to use for placement with respect to the world origin" }; tr.Cells.Add(new TableCell() { Control = lbl_subShapeRef }); comboBox_subShapeRef = new DropDown { DataContext = DataContext, SelectedIndex = 0, ToolTip = "Which subshape to use for placement with respect to the world origin" }; comboBox_subShapeRef.BindDataContext(c => c.DataStore, (UIStringLists m) => m.subShapeList); tr.Cells.Add(new TableCell() { Control = TableLayout.AutoSized(comboBox_subShapeRef) }); tr.Cells.Add(new TableCell() { Control = null }); }
Control Settings() { var layout = new DynamicLayout(); layout.AddRow(new Label { Text = "Orientation" }, TableLayout.AutoSized(PageOrientation())); layout.BeginHorizontal(); layout.Add(new Label { Text = "Copies" }); layout.AddSeparateRow(Padding.Empty).Add(TableLayout.AutoSized(Copies()), TableLayout.AutoSized(Collate())); layout.EndHorizontal(); layout.BeginHorizontal(); layout.Add(new Label { Text = "Maximum Pages" }); layout.AddSeparateRow(Padding.Empty).Add(MaximumStart(), new Label { Text = "to" }, MaximumEnd()); layout.EndHorizontal(); layout.AddRow(null, Reverse()); return(new GroupBox { Text = "Settings", Content = layout }); }
public void ExpandedColumnShouldAutoSize(int columnToExpand, int secondColumn) { ManualForm("First Column should be expanded, and change size with the Grid", form => { var grid = new T(); SetDataStore(grid, CreateDataStore()); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property((GridTestItem m) => m.Text) } }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell(0) }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell(1) }); var expandColumn = grid.Columns[columnToExpand]; expandColumn.HeaderText = "Expanded"; expandColumn.Expand = true; if (secondColumn != -1) { var expandColumn2 = grid.Columns[secondColumn]; expandColumn2.HeaderText = "Expanded2"; expandColumn2.Expand = true; } return(TableLayout.AutoSized(grid)); }); }
Control EditorControls() { var layout = new DynamicLayout(); layout.DefaultSpacing = new Size(10, 10); layout.DefaultPadding = Padding.Empty; layout.AddRow(new MyLabel { Text = "Title" }, TitleTextBox()); layout.AddRow(new MyLabel { Text = "Group" }, GroupTextBox()); layout.AddRow(new MyLabel { Text = "Author" }, AuthorTextBox()); layout.AddRow(new MyLabel { Text = "Date Created" }, DateBox()); layout.AddRow(new MyLabel { Text = "Data Type" }, TableLayout.AutoSized(TypeComboBox())); layout.AddRow(new MyLabel { Text = "Notes" }, CommentTextArea()); return(layout); }
public BitmapSection() { var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddRow( "Load from Stream", LoadFromStream(), "Custom 24-bit", CreateCustom24(), null ); layout.AddRow( "Custom 32-bit", CreateCustom32(), "Custom 32-bit alpha", CreateCustom32Alpha(), null ); layout.AddRow( "Clone", Cloning(), "Clone rectangle", TableLayout.AutoSized(CloneRectangle(), centered: true), null); layout.AddRow( "Draw to a rect", TableLayout.AutoSized(DrawImageToRect(), centered: true) ); layout.Add(null); Content = layout; }
public ComboBoxSection() { var layout = new DynamicLayout(this); layout.AddRow(new Label { Text = "Default" }, Default(), null); layout.AddRow(new Label { Text = "With Items" }, TableLayout.AutoSized(Items())); layout.AddRow(new Label { Text = "Disabled" }, TableLayout.AutoSized(Disabled())); layout.AddRow(new Label { Text = "Set Initial Value" }, TableLayout.AutoSized(SetInitialValue())); layout.AddRow(new Label { Text = "EnumComboBox<Key>" }, TableLayout.AutoSized(EnumCombo())); layout.Add(null, null, true); }
public TabPage GetAboutTab() { return(new TabPage { Text = "About", Content = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableRow( new TableCell(TableLayout.AutoSized(new ImageView { Image = _uiManager.SharedResources.TITAN_ICON, Size = new Size(128, 128) }, centered: true)) ), new TableRow( new TableCell(TableLayout.AutoSized(new Label { Text = "Titan", Font = new Font(SystemFont.Bold) }, centered: true)) ), new TableRow( new TableCell( TableLayout.AutoSized(new Label { Text = "Titan is an advanced Counter-Strike Global Offensive report and" + "commendation bot. Its goal is to maintain a clean Matchmaking system " + "by sending a target forcefully (by 11 reports) into Overwatch. It provides " + "a advanced set of features and high effiency when compared against other bots.", TextAlignment = TextAlignment.Center, Wrap = WrapMode.Word }, centered: true) ) ), new TableRow( new TableCell( TableLayout.AutoSized(new LinkButton { Text = "GitHub", Command = new Command((s, a) => Process.Start("https://github.com/Marc3842h/Titan")) }, centered: true) ) ) } } } } }); }
public About() { /* dialog attributes */ this.Title = "About BadaBing"; this.MinimumSize = new Size(300, 0); this.Resizable = false; /* dialog controls */ var imageView = new ImageView(); imageView.Image = Icon.FromResource("Icon.ico"); imageView.Size = new Size(128, 128); var labelTitle = new Label(); labelTitle.Text = "BadaBing"; labelTitle.Font = new Font(FontFamilies.Sans, 16); labelTitle.TextAlignment = TextAlignment.Center; var version = Assembly.GetExecutingAssembly().GetName().Version; var labelVersion = new Label(); labelVersion.Text = string.Format("Version {0}", version); labelVersion.TextAlignment = TextAlignment.Center; var labelDesc = new Label(); labelDesc.Text = "Daily Wallpaper from Bing"; labelDesc.TextAlignment = TextAlignment.Center; var labelCopyright = new Label(); labelCopyright.Text = "Copyright 2020 by Bruce Davidson"; labelCopyright.TextAlignment = TextAlignment.Center; var button = new Button(); button.Text = "Close"; button.Click += (sender, e) => Close(); /* dialog layout */ Content = new TableLayout { Padding = new Padding(10), Spacing = new Size(5, 5), Rows = { imageView, labelTitle, labelDesc, labelVersion, labelCopyright, TableLayout.AutoSized(button, centered: true) } }; AbortButton = DefaultButton = button; }
public NotificationSection() { var entryId = new TextBox(); entryId.TextBinding.BindDataContext((Notification n) => n.ID); var entryTitle = new TextBox(); entryTitle.TextBinding.BindDataContext((Notification n) => n.Title); var entryMessage = new TextBox(); entryMessage.TextBinding.BindDataContext((Notification n) => n.Message); var entryUserData = new TextArea(); entryUserData.TextBinding.BindDataContext((Notification n) => n.UserData); var showNotificationButton = new Button(); showNotificationButton.Text = "Show Notification"; showNotificationButton.Click += ShowNotificationButton_Click; var includeImageCheck = new CheckBox { Text = "Include Image", Checked = true }; includeImageCheck.CheckedBinding.Bind(this, t => t.IncludeImage); Content = new TableLayout { Spacing = new Size(5, 5), Padding = 10, Rows = { null, new TableRow(new Label { Text = "ID:", VerticalAlignment = VerticalAlignment.Center }, entryId), new TableRow(new Label { Text = "Title:", VerticalAlignment = VerticalAlignment.Center }, entryTitle), new TableRow(new Label { Text = "Message:", VerticalAlignment = VerticalAlignment.Center }, entryMessage), new TableRow(new Label { Text = "UserData:", VerticalAlignment = VerticalAlignment.Center }, entryUserData), new TableRow(new TableCell(),includeImageCheck), new TableRow(new TableCell(),TableLayout.AutoSized(showNotificationButton)), null } }; CreateNotification(); }
void DisplayImage(Bitmap image) { ManualForm("Inspect image", form => { form.WindowState = WindowState.Maximized; return(TableLayout.AutoSized(new ImageView { Image = image }, centered: true)); }); }
public TabPage GetCreditsTab() { return(new TabPage { Text = "Credits", Content = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableRow( new TableCell( TableLayout.AutoSized(new Label { Text = "Marc3842h", TextAlignment = TextAlignment.Center, Font = new Font(SystemFont.Bold) }, centered: true) ) ), new TableRow( new TableCell( TableLayout.AutoSized(new Label { Text = "Lead developer and project maintainer", TextAlignment = TextAlignment.Center }, centered: true) ) ), new TableRow( new TableCell( TableLayout.AutoSized(new Label { Text = "*****@*****.**", TextAlignment = TextAlignment.Center }, centered: true) ) ), new TableRow(new Label()), new TableRow( TableLayout.AutoSized(new Label { Text = "Thanks to all contributors.", TextAlignment = TextAlignment.Center }, centered: true) ), new TableRow { ScaleHeight = true } } } }); }
Control Orientation(RadioButtonList list) { var control = new EnumComboBox <RadioButtonListOrientation>(); control.SelectedValue = list.Orientation; control.SelectedValueChanged += delegate { list.Orientation = control.SelectedValue; }; return(TableLayout.AutoSized(control, centered: true)); }
static Control TestDynamic() { var control = new Button { Text = "Dynamic splitter creation" }; control.Click += (sender, e) => { var tabcontrol = new TabControl(); tabcontrol.Pages.Add(new TabPage { Text = "Index" }); var addTabButton = new Button { Text = "Add Tab With Splitter" }; addTabButton.Click += (ss, ee) => { using (Context) { var splitter = new Splitter { Panel1 = new TreeGridView { Size = new Size(100, 100) }, Panel2 = new GridView(), Orientation = Orientation.Horizontal, FixedPanel = SplitterFixedPanel.Panel1, Position = 100, }; LogEvents(splitter); var newTabpage = new TabPage { Text = "test", Content = splitter }; tabcontrol.Pages.Add(newTabpage); tabcontrol.SelectedPage = newTabpage; } }; var form = new Form { Padding = new Padding(5), Content = new TableLayout( TableLayout.AutoSized(addTabButton, centered: true), tabcontrol ) }; form.Size = new Size(600, 400); form.Show(); }; return(control); }
Control OrientationDropDown(CheckBoxList list) { var control = new EnumDropDown <Orientation>(); control.SelectedValue = list.Orientation; control.SelectedValueChanged += delegate { list.Orientation = control.SelectedValue; }; return(TableLayout.AutoSized(control, centered: true)); }
/// <summary> /// Initializes a new instance of the <see cref="T:WarCollege.Dialogs.About"/> class. /// </summary> public About() { Title = Resources.Strings.AboutMenuText; MinimumSize = new Size(300, 0); Resizable = false; //var imageView = new ImageView() //{ // Image = Icon.FromResource(""), // Size = new Size(128, 128) //}; var labelTitle = new Label { Text = Resources.Strings.AppTitle, Font = new Font(FontFamilies.Sans, 16), TextAlignment = TextAlignment.Center }; var version = Assembly.GetExecutingAssembly().GetName().Version; var labelVersion = new Label { Text = string.Format(Resources.Strings.VersionText, version), TextAlignment = TextAlignment.Center }; var labelCopyright = new Label { Text = string.Format(Resources.Strings.CopyriteText, DateTime.Now.Year), TextAlignment = TextAlignment.Center }; var button = new Button { Text = Resources.Strings.CloseButton }; button.Click += (sender, e) => Close(); Content = new TableLayout { Padding = new Padding(10), Spacing = new Size(5, 5), Rows = { labelTitle, labelVersion, labelCopyright, TableLayout.AutoSized(button, centered: true) } }; AbortButton = DefaultButton = button; }
public About() { /* dialog attributes */ this.Title = "About Notedown"; this.MinimumSize = new Size(300, 0); this.Resizable = false; /* dialog controls */ var imageView = new ImageView(); imageView.Image = Icon.FromResource("Icon.ico"); imageView.Size = new Size(128, 128); var labelTitle = new Label(); labelTitle.Text = "Notedown"; labelTitle.Font = new Font(FontFamilies.Sans, 16); labelTitle.HorizontalAlign = HorizontalAlign.Center; var version = Assembly.GetExecutingAssembly().GetName().Version; var labelVersion = new Label(); labelVersion.Text = string.Format("Version {0}", version); labelVersion.HorizontalAlign = HorizontalAlign.Center; var labelCopyright = new Label(); labelCopyright.Text = "Copyright by Andre Straubmeier"; labelCopyright.HorizontalAlign = HorizontalAlign.Center; var button = new Button(); button.Text = "Close"; button.Click += (sender, e) => Close(); /* dialog layout */ Content = new TableLayout { Padding = new Padding(10), Spacing = new Size(5, 5), Rows = { imageView, labelTitle, labelVersion, labelCopyright, TableLayout.AutoSized(button, centered: true) } }; AbortButton = DefaultButton = button; }
Control Default() { var control = new ComboBox(); LogEvents(control); var layout = new DynamicLayout(); layout.Add(TableLayout.AutoSized(control)); layout.AddSeparateRow(null, AddRowsButton(control), RemoveRowsButton(control), ClearButton(control), SetSelected(control), ClearSelected(control), null); layout.AddSeparateRow(null, GetEnabled(control), GetReadOnly(control), AutoComplete(control), ShowComboText(control), SetComboText(control), null); return(layout); }
private void oneDTabSetup() { // 1D tab tab_1DCalc_table = new TableLayout(); tab_1DCalc.Content = new Scrollable { Content = TableLayout.AutoSized(tab_1DCalc_table, centered: true) }; tab_1DCalc_table.Rows.Add(new TableRow()); lbl_1D_Guidance = new Label { Text = "All inputs should be 3-sigma values", Width = oneDGuidanceWidth }; tab_1DCalc_table.Rows[^ 1].Cells.Add(new TableCell {
Control Default() { var control = new RadioButtonList(); LogEvents(control); var layout = new DynamicLayout(); layout.Add(TableLayout.AutoSized(control)); layout.BeginVertical(); layout.AddRow(null, AddRowsButton(control), RemoveRowsButton(control), ClearButton(control), Orientation(control), null); layout.EndVertical(); return(layout); }
// Helper private void AddToTableWithLabel(TableLayout parent, Control me, string label) { me.Width = 200; parent.Rows.Add(new TableRow { Cells = { TableLayout.AutoSized(new Label { Text = label, TextAlignment = TextAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Width = 130 }), new TableCell(me) } }); }
Control Default() { var control = new ComboBox(); LogEvents(control); var layout = new DynamicLayout(new Panel()); layout.Add(TableLayout.AutoSized(control)); layout.BeginVertical(); layout.AddRow(null, AddRowsButton(control), RemoveRowsButton(control), ClearButton(control), null); layout.EndVertical(); return(layout.Container); }