ColorDialogSection(bool showCreateDialog) { var layout = new DynamicLayout { Spacing = new Size(20, 20), DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; var btnCreateDialog = new Button { Text = "Use in Dialog" }; btnCreateDialog.Click += BtnCreateDialog_Click; layout.BeginCentered(); layout.Add(CreateAllowAlphaCheckBox()); layout.Add(PickColor()); layout.Add(PickColorWithStartingColor()); if (showCreateDialog) { layout.Add(btnCreateDialog); } layout.EndCentered(); layout.AddCentered(new ColorPicker()); layout.AddCentered(new TextBox()); layout.AddSpace(); Content = layout; }
public LoadingForm() { var layout = new DynamicLayout(); Icon = Resources.GetProgramIcon(); Title = "Loading - arcdps Log Manager"; ClientSize = new Size(200, 80); Resizable = false; Content = layout; layout.BeginCentered(spacing: new Size(5, 5)); { layout.Add(null, yscale: true); layout.AddCentered("Loading the cache"); layout.AddCentered(new ProgressBar { Indeterminate = true }); layout.Add(null, yscale: true); } layout.EndCentered(); if (!Settings.LogRootPaths.Any()) { LoadComplete += (sender, args) => Task.Run(ShowInitialConfiguration); } else { LoadComplete += (sender, args) => Task.Run(LoadManager); } }
public ScreenSection() { var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; screens = Screen.Screens.ToArray(); layout.BeginCentered(); layout.Add($"Display Bounds: {displayBounds}"); layout.BeginVertical(Padding.Empty); var num = 0; foreach (var screen in screens) { layout.Add($"Screen {num++}, BitsPerPixel: {screen.BitsPerPixel}, IsPrimary: {screen.IsPrimary}"); layout.BeginVertical(new Padding(10, 0)); layout.Add($"Bounds: {screen.Bounds}"); layout.Add($"WorkingArea: {screen.WorkingArea}"); layout.Add($"DPI: {screen.DPI}, Scale: {screen.Scale}, LogicalPixelSize: {screen.LogicalPixelSize}"); layout.EndVertical(); } layout.EndVertical(); layout.Add(windowPositionLabel = new Label()); layout.EndCentered(); layout.Add(ScreenLayout()); Content = layout; }
ContextMenuSection(bool inDialog) { Styles.Add <Label>(null, l => l.VerticalAlignment = VerticalAlignment.Center); var relativeToLabelCheckBox = new CheckBox { Text = "Relative to label" }; relativeToLabelCheckBox.CheckedBinding.Bind(this, c => c.RelativeToLabel); var useLocationCheckBox = new CheckBox { Text = "Use Location" }; useLocationCheckBox.CheckedBinding.Bind(this, c => c.UseLocation); var locationInput = PointControl(() => location, p => location = p); var contextMenuLabel = CreateContextMenuLabel(); var showInDialog = new Button { Text = "Show in Dialog" }; showInDialog.Click += (sender, e) => { var dlg = new Dialog { Content = new ContextMenuSection(true) }; dlg.ShowModal(this); }; // layout var layout = new DynamicLayout(); layout.BeginCentered(); layout.AddAutoSized(relativeToLabelCheckBox); layout.AddSeparateRow(useLocationCheckBox, locationInput); if (!inDialog) { layout.AddAutoSized(showInDialog); } layout.EndCentered(); layout.AddCentered(contextMenuLabel, yscale: true); Content = layout; }
public CursorSection() { var layout = new DynamicLayout(); layout.BeginCentered(spacing: new Size(10, 10), yscale: true); var drawable = new CursorDrawable(); var rect = new Rectangle(0, 0, 100, 50); layout.Add("Label"); layout.BeginVertical(spacing: new Size(5, 5)); layout.BeginHorizontal(); int count = 0; foreach (var type in GetCursors()) { var cursor = type.cursor; var text = type.name; drawable.Rects.Add(new CursorRect { Rectangle = rect, Cursor = cursor, Text = text }); rect.X += rect.Width + 5; var label = new Label { Size = new Size(100, 50), Text = text, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center, BackgroundColor = Colors.Silver }; if (cursor == null) { label.Cursor = null; } else { label.Cursor = cursor; } layout.Add(label); if (count++ > 3) { count = 0; rect.X = 0; rect.Y += rect.Height + 5; layout.EndBeginHorizontal(); } } layout.EndHorizontal(); layout.EndVertical(); layout.Add("Drawable with MouseMove"); layout.Add(drawable); layout.EndCentered(); drawable.Size = new Size(340, rect.Y + rect.Height + 20); Content = layout; }
public FormattedTextSection() { var font = SystemFonts.Default(); var color = Colors.White; var formattedText = new FormattedText { Text = Utility.LoremText, MaximumSize = new SizeF(200, 100), Wrap = FormattedTextWrapMode.Word, Trimming = FormattedTextTrimming.CharacterEllipsis, ForegroundBrush = Brushes.White, //ForegroundBrush = new LinearGradientBrush(Colors.White, Colors.Blue, new PointF(0, 0), new PointF(200, 200)), Font = font }; var control = new Drawable { Size = new Size(400, 500), BackgroundColor = Colors.Black }; control.Paint += (sender, e) => { var g = e.Graphics; var location = new Point(10, 10); g.DrawText(font, color, location, "Single Line Text That Will Not Wrap 漢字"); location.Y += 40; var rect = new RectangleF(location, new SizeF(300, 20)); g.DrawRectangle(Colors.Blue, rect); g.DrawText(font, new SolidBrush(color), rect, "Should Be Right Aligned", FormattedTextWrapMode.None, FormattedTextAlignment.Right, FormattedTextTrimming.None); location.Y += 40; g.DrawRectangle(Colors.Blue, new RectangleF(location, formattedText.MaximumSize)); var size = formattedText.Measure(); g.DrawText(formattedText, location); g.DrawRectangle(Colors.Silver, new RectangleF(location, size)); }; var wrapMode = new EnumDropDown <FormattedTextWrapMode>(); wrapMode.SelectedValueBinding.Bind(formattedText, f => f.Wrap); wrapMode.SelectedValueChanged += (sender, e) => control.Invalidate(); var trimming = new EnumDropDown <FormattedTextTrimming>(); trimming.SelectedValueBinding.Bind(formattedText, f => f.Trimming); trimming.SelectedValueChanged += (sender, e) => control.Invalidate(); var alignment = new EnumDropDown <FormattedTextAlignment>(); alignment.SelectedValueBinding.Bind(formattedText, f => f.Alignment); alignment.SelectedValueChanged += (sender, e) => control.Invalidate(); var fontSelection = new FontPicker(); fontSelection.ValueBinding.Bind(formattedText, f => f.Font); fontSelection.ValueChanged += (sender, e) => control.Invalidate(); var maxSizeEntry = new SizeFEntry(); maxSizeEntry.ValueBinding.Bind(formattedText, f => f.MaximumSize); maxSizeEntry.ValueChanged += (sender, e) => control.Invalidate(); var layout = new DynamicLayout(); layout.BeginCentered(); layout.AddSeparateRow("Wrap:", wrapMode, null); layout.AddSeparateRow("Trimming:", trimming, null); layout.AddSeparateRow("Alignment:", alignment, null); layout.AddSeparateRow("Font:", fontSelection, null); layout.AddSeparateRow("MaximumSize:", maxSizeEntry, null); layout.EndCentered(); layout.Add(control); Content = layout; }
public DragDropSection() { // drag data object showDragOverEvents = new CheckBox { Text = "Show DragOver Events" }; var includeImageCheck = new CheckBox { Text = "Include Image" }; descriptionTextBox = new TextBox { PlaceholderText = "Format", ToolTip = "Add {0} to insert inner text into the description, e.g. 'Move to {0}'" }; innerTextBox = new TextBox { PlaceholderText = "Inner", ToolTip = "Highlighted text to insert into description" }; var textBox = new TextBox { Text = "Some text" }; allowedEffectDropDown = new EnumDropDown <DragEffects> { SelectedValue = DragEffects.All }; dragEnterEffect = new EnumDropDown <DragEffects?> { SelectedValue = DragEffects.Copy }; dragOverEffect = new EnumDropDown <DragEffects?> { SelectedValue = null }; writeDataCheckBox = new CheckBox { Text = "Write data to log" }; useDragImage = new CheckBox { Text = "Use custom drag image" }; imageOffset = new PointEntry { Value = new Point(80, 80) }; imageOffset.Bind(c => c.Enabled, useDragImage, c => c.Checked); var htmlTextArea = new TextArea { Height = 24 }; var selectFilesButton = new Button { Text = "Select Files" }; Uri[] fileUris = null; selectFilesButton.Click += (sender, e) => { var ofd = new OpenFileDialog(); ofd.MultiSelect = true; ofd.ShowDialog(this); fileUris = ofd.Filenames.Select(r => new Uri(r)).ToArray(); if (fileUris.Length == 0) { fileUris = null; } }; var urlTextBox = new TextBox(); DataObject CreateDataObject() { var data = new DataObject(); if (!string.IsNullOrEmpty(textBox.Text)) { data.Text = textBox.Text; } var uris = new List <Uri>(); if (fileUris != null) { uris.AddRange(fileUris); } if (Uri.TryCreate(urlTextBox.Text, UriKind.Absolute, out var uri)) { uris.Add(uri); } if (uris.Count > 0) { data.Uris = uris.ToArray(); } if (!string.IsNullOrEmpty(htmlTextArea.Text)) { data.Html = htmlTextArea.Text; } if (includeImageCheck.Checked == true) { data.Image = TestIcons.Logo; } return(data); } // sources var buttonSource = new Button { Text = "Source" }; buttonSource.MouseDown += (sender, e) => { if (e.Buttons != MouseButtons.None) { DoDragDrop(buttonSource, CreateDataObject()); e.Handled = true; } }; var panelSource = new Panel { BackgroundColor = Colors.Red, Size = new Size(50, 50) }; panelSource.MouseMove += (sender, e) => { if (e.Buttons != MouseButtons.None) { DoDragDrop(panelSource, CreateDataObject()); e.Handled = true; } }; var treeSource = new TreeGridView { Size = new Size(200, 200) }; treeSource.SelectedItemsChanged += (sender, e) => Log.Write(treeSource, $"TreeGridView.SelectedItemsChanged (source) Rows: {string.Join(", ", treeSource.SelectedRows.Select(r => r.ToString()))}"); treeSource.DataStore = CreateTreeData(); SetupTreeColumns(treeSource); treeSource.MouseMove += (sender, e) => { if (e.Buttons == MouseButtons.Primary && !treeSource.IsEditing) { var cell = treeSource.GetCellAt(e.Location); if (cell.Item == null || cell.ColumnIndex == -1) { return; } var data = CreateDataObject(); var selected = treeSource.SelectedItems.OfType <TreeGridItem>().Select(r => (string)r.Values[0]); data.SetString(string.Join(";", selected), "my.tree.data"); DoDragDrop(treeSource, data); e.Handled = true; } }; var gridSource = new GridView { }; gridSource.SelectedRowsChanged += (sender, e) => Log.Write(gridSource, $"GridView.SelectedItemsChanged (source): {string.Join(", ", gridSource.SelectedRows.Select(r => r.ToString()))}"); SetupGridColumns(gridSource); gridSource.DataStore = CreateGridData(); gridSource.MouseMove += (sender, e) => { if (e.Buttons == MouseButtons.Primary && !gridSource.IsEditing) { var cell = gridSource.GetCellAt(e.Location); if (cell.RowIndex == -1 || cell.ColumnIndex == -1) { return; } var data = CreateDataObject(); var selected = gridSource.SelectedItems.OfType <GridItem>().Select(r => (string)r.Values[0]); data.SetString(string.Join(";", selected), "my.grid.data"); DoDragDrop(gridSource, data); e.Handled = true; } }; // destinations var buttonDestination = new Button { Text = "Drop here!", AllowDrop = true }; buttonDestination.DragEnter += (sender, e) => buttonDestination.Text = "Now, drop it!"; buttonDestination.DragLeave += (sender, e) => buttonDestination.Text = "Drop here!"; LogEvents(buttonDestination); var drawableDest = new Drawable { BackgroundColor = Colors.Blue, AllowDrop = true, Size = new Size(50, 50) }; LogEvents(drawableDest); drawableDest.DragEnter += (sender, e) => { if (e.Effects != DragEffects.None) { drawableDest.BackgroundColor = Colors.Green; } }; drawableDest.DragLeave += (sender, e) => { if (e.Effects != DragEffects.None) { drawableDest.BackgroundColor = Colors.Blue; } }; drawableDest.DragDrop += (sender, e) => { if (e.Effects != DragEffects.None) { drawableDest.BackgroundColor = Colors.Blue; } }; var dragMode = new RadioButtonList { Orientation = Orientation.Vertical, Items = { new ListItem { Text = "No Restriction", Key = "" }, new ListItem { Text = "RestrictToOver", Key = "over" }, new ListItem { Text = "RestrictToInsert", Key = "insert" }, new ListItem { Text = "RestrictToNode", Key = "node" }, new ListItem { Text = "No Node", Key = "none" } }, SelectedIndex = 0 }; var treeDest = new TreeGridView { AllowDrop = true, Size = new Size(200, 200) }; var treeDestData = CreateTreeData(); treeDest.DataStore = treeDestData; treeDest.DragOver += (sender, e) => { var info = treeDest.GetDragInfo(e); if (info == null) { return; // not supported } switch (dragMode.SelectedKey) { case "over": info.RestrictToOver(); break; case "insert": info.RestrictToInsert(); break; case "node": info.RestrictToNode(treeDestData[2]); break; case "none": info.Item = info.Parent = null; break; } }; SetupTreeColumns(treeDest); LogEvents(treeDest); var gridDest = new GridView { AllowDrop = true }; var gridDestData = CreateGridData(); gridDest.DataStore = gridDestData; gridDest.DragOver += (sender, e) => { var info = gridDest.GetDragInfo(e); if (info == null) { return; // not supported } switch (dragMode.SelectedKey) { case "over": info.RestrictToOver(); break; case "insert": info.RestrictToInsert(); break; case "node": info.Index = 2; info.Position = GridDragPosition.Over; break; case "none": info.Index = -1; break; } }; SetupGridColumns(gridDest); LogEvents(gridDest); // layout var layout = new DynamicLayout { Padding = 10, DefaultSpacing = new Size(4, 4) }; layout.BeginHorizontal(); layout.BeginScrollable(BorderType.None); layout.BeginCentered(); layout.AddSeparateRow(showDragOverEvents); layout.AddSeparateRow("AllowedEffect", allowedEffectDropDown, null); layout.BeginVertical(); layout.AddRow("DropDescription", descriptionTextBox); layout.AddRow(new Panel(), innerTextBox); layout.EndVertical(); layout.AddSeparateRow("DragEnter Effect", dragEnterEffect, null); layout.AddSeparateRow("DragOver Effect", dragOverEffect, null); layout.AddSeparateRow(useDragImage); layout.AddSeparateRow("Image offset:", imageOffset); layout.AddSeparateRow(writeDataCheckBox); layout.BeginGroup("DataObject", 10); layout.AddRow("Text", textBox); layout.AddRow("Html", htmlTextArea); layout.AddRow("Url", urlTextBox); layout.BeginHorizontal(); layout.AddSpace(); layout.BeginVertical(); layout.AddCentered(includeImageCheck); layout.AddCentered(selectFilesButton); layout.EndVertical(); layout.EndGroup(); layout.Add(dragMode); layout.AddSpace(); layout.EndCentered(); layout.EndScrollable(); layout.BeginVertical(xscale: true); layout.AddRange("Drag sources:", buttonSource, panelSource); layout.Add(treeSource, yscale: true); layout.Add(gridSource, yscale: true); layout.EndVertical(); layout.BeginVertical(xscale: true); layout.AddRange("Drag destinations:", buttonDestination, drawableDest); layout.Add(treeDest, yscale: true); layout.Add(gridDest, yscale: true); layout.EndVertical(); layout.EndHorizontal(); Content = layout; }
public DragDropSection() { // drag data object showDragOverEvents = new CheckBox { Text = "Show DragOver Events" }; var includeImageCheck = new CheckBox { Text = "Include Image" }; var textBox = new TextBox { Text = "Some text" }; var allowedEffectDropDown = new EnumDropDown <DragEffects> { SelectedValue = DragEffects.All }; dragOverEffect = new EnumDropDown <DragEffects> { SelectedValue = DragEffects.Copy }; var htmlTextArea = new TextArea(); var selectFilesButton = new Button { Text = "Select Files" }; Uri[] uris = null; selectFilesButton.Click += (sender, e) => { var ofd = new OpenFileDialog(); ofd.MultiSelect = true; ofd.ShowDialog(this); uris = ofd.Filenames.Select(r => new Uri(r)).ToArray(); if (uris.Length == 0) { uris = null; } }; Func <DataObject> createDataObject = () => { var data = new DataObject(); if (!string.IsNullOrEmpty(textBox.Text)) { data.Text = textBox.Text; } if (uris != null) { data.Uris = uris; } if (!string.IsNullOrEmpty(htmlTextArea.Text)) { data.Html = htmlTextArea.Text; } if (includeImageCheck.Checked == true) { data.Image = TestIcons.Logo; } return(data); }; // sources var buttonSource = new Button { Text = "Source" }; buttonSource.MouseDown += (sender, e) => { buttonSource.DoDragDrop(createDataObject(), allowedEffectDropDown.SelectedValue); e.Handled = true; }; var panelSource = new Panel { BackgroundColor = Colors.Red, Size = new Size(50, 50) }; panelSource.MouseDown += (sender, e) => { panelSource.DoDragDrop(createDataObject(), allowedEffectDropDown.SelectedValue); e.Handled = true; }; var treeSource = new TreeGridView { Size = new Size(200, 200) }; treeSource.DataStore = CreateTreeData(); SetupTreeColumns(treeSource); treeSource.MouseMove += (sender, e) => { if (e.Buttons == MouseButtons.Primary) { var cell = treeSource.GetCellAt(e.Location); if (cell.Item == null || cell.ColumnIndex == -1) { return; } var data = createDataObject(); var selected = treeSource.SelectedItems.OfType <TreeGridItem>().Select(r => (string)r.Values[0]); data.SetString(string.Join(";", selected), "my-tree-data"); treeSource.DoDragDrop(data, allowedEffectDropDown.SelectedValue); e.Handled = true; } }; var gridSource = new GridView { }; SetupGridColumns(gridSource); gridSource.DataStore = CreateGridData(); gridSource.MouseMove += (sender, e) => { if (e.Buttons == MouseButtons.Primary) { var data = createDataObject(); var selected = gridSource.SelectedItems.OfType <GridItem>().Select(r => (string)r.Values[0]); data.SetString(string.Join(";", selected), "my-grid-data"); gridSource.DoDragDrop(data, allowedEffectDropDown.SelectedValue); e.Handled = true; } }; // destinations var buttonDestination = new Button { Text = "Drop here!", AllowDrop = true }; buttonDestination.DragEnter += (sender, e) => buttonDestination.Text = "Now, drop it!"; buttonDestination.DragLeave += (sender, e) => buttonDestination.Text = "Drop here!"; LogEvents(buttonDestination); var drawableDest = new Drawable { BackgroundColor = Colors.Blue, AllowDrop = true, Size = new Size(50, 50) }; LogEvents(drawableDest); drawableDest.DragEnter += (sender, e) => { if (e.Effects != DragEffects.None) { drawableDest.BackgroundColor = Colors.Green; } }; drawableDest.DragLeave += (sender, e) => { if (e.Effects != DragEffects.None) { drawableDest.BackgroundColor = Colors.Blue; } }; drawableDest.DragDrop += (sender, e) => { if (e.Effects != DragEffects.None) { drawableDest.BackgroundColor = Colors.Blue; } }; var dragMode = new RadioButtonList { Orientation = Orientation.Vertical, Items = { new ListItem { Text = "No Restriction", Key = "" }, new ListItem { Text = "RestrictToOver", Key = "over" }, new ListItem { Text = "RestrictToInsert", Key = "insert" }, new ListItem { Text = "RestrictToNode", Key = "node" }, new ListItem { Text = "No Node", Key = "none" } }, SelectedIndex = 0 }; var treeDest = new TreeGridView { AllowDrop = true, Size = new Size(200, 200) }; var treeDestData = CreateTreeData(); treeDest.DataStore = treeDestData; treeDest.DragOver += (sender, e) => { var info = treeDest.GetDragInfo(e); if (info == null) { return; // not supported } switch (dragMode.SelectedKey) { case "over": info.RestrictToOver(); break; case "insert": info.RestrictToInsert(); break; case "node": info.RestrictToNode(treeDestData[2]); break; case "none": info.Item = info.Parent = null; break; } }; SetupTreeColumns(treeDest); LogEvents(treeDest); var gridDest = new GridView { AllowDrop = true }; var gridDestData = CreateGridData(); gridDest.DataStore = gridDestData; gridDest.DragOver += (sender, e) => { var info = gridDest.GetDragInfo(e); if (info == null) { return; // not supported } switch (dragMode.SelectedKey) { case "over": info.RestrictToOver(); break; case "insert": info.RestrictToInsert(); break; case "node": info.Index = 2; info.Position = GridDragPosition.Over; break; case "none": info.Index = -1; break; } }; SetupGridColumns(gridDest); LogEvents(gridDest); // layout var layout = new DynamicLayout { Padding = 10, DefaultSpacing = new Size(4, 4) }; layout.BeginHorizontal(); layout.BeginCentered(); layout.AddSeparateRow(showDragOverEvents); layout.AddSeparateRow("AllowedEffect", allowedEffectDropDown, null); layout.AddSeparateRow("DragOver Effect", dragOverEffect, null); layout.BeginGroup("DataObject", 10); layout.AddRow("Text", textBox); layout.AddRow("Html", htmlTextArea); layout.BeginHorizontal(); layout.AddSpace(); layout.BeginVertical(); layout.AddCentered(includeImageCheck); layout.AddCentered(selectFilesButton); layout.EndVertical(); layout.EndGroup(); layout.Add(dragMode); layout.AddSpace(); layout.EndCentered(); layout.BeginVertical(xscale: true); layout.AddRange("Drag sources:", buttonSource, panelSource); layout.Add(treeSource, yscale: true); layout.Add(gridSource, yscale: true); layout.EndVertical(); layout.BeginVertical(xscale: true); layout.AddRange("Drag destinations:", buttonDestination, drawableDest); layout.Add(treeDest, yscale: true); layout.Add(gridDest, yscale: true); layout.EndVertical(); layout.EndHorizontal(); Content = layout; }
private void ShowTestDialog() { int count = 0; var toolBar = new ToolBar(); var dlg = new Dialog { ClientSize = new Size(400, 300), Resizable = true, ToolBar = toolBar }; dlg.Styles.Add <Label>(null, l => l.VerticalAlignment = VerticalAlignment.Center); var indexStepper = new NumericStepper { MinValue = -1, MaxValue = -1, Value = -1 }; var typeDropDown = new DropDown { Items = { "Button", "Radio", "Check", "Separator:Divider", "Separator:Space", "Separator:FlexableSpace" }, SelectedIndex = 0 }; var withImageCheck = new CheckBox { Text = "With Image", Checked = true }; Image GetImage() { if (withImageCheck.Checked == true) { return(TestIcons.TestIcon); } return(null); } void SetStepperLimit() { if (toolBar.Items.Count == 0) { indexStepper.MinValue = indexStepper.MaxValue = -1; } else { indexStepper.MinValue = 0; indexStepper.MaxValue = toolBar.Items.Count - 1; } } ToolItem CreateItem() { switch (typeDropDown.SelectedKey?.ToLowerInvariant()) { default: case "button": return(new ButtonToolItem { Text = $"Button{++count}", Image = GetImage() }); case "radio": return(new RadioToolItem { Text = $"Radio{++count}", Image = GetImage() }); case "check": return(new CheckToolItem { Text = $"Check{++count}", Image = GetImage() }); case "separator:divider": return(new SeparatorToolItem { Type = SeparatorToolItemType.Divider }); case "separator:space": return(new SeparatorToolItem { Type = SeparatorToolItemType.Space }); case "separator:flexablespace": return(new SeparatorToolItem { Type = SeparatorToolItemType.FlexibleSpace }); } } var addButton = new Button { Text = "Add" }; addButton.Click += (sender, e) => { toolBar.Items.Add(CreateItem()); SetStepperLimit(); }; var removeButton = new Button { Text = "Remove" }; removeButton.Click += (sender, e) => { var index = (int)indexStepper.Value; if (index >= 0) { toolBar.Items.RemoveAt(index); } SetStepperLimit(); }; var insertButton = new Button { Text = "Insert" }; insertButton.Click += (sender, e) => { var index = (int)indexStepper.Value; if (index >= 0) { toolBar.Items.Insert(index, CreateItem()); } SetStepperLimit(); }; var clearButton = new Button { Text = "Clear" }; clearButton.Click += (sender, e) => { toolBar.Items.Clear(); SetStepperLimit(); }; var layout = new DynamicLayout(); layout.BeginCentered(yscale: true); layout.AddSeparateRow(null, "Type:", typeDropDown, withImageCheck, null); layout.AddSeparateRow(null, addButton, insertButton, removeButton, "Index:", indexStepper, null); layout.AddSeparateRow(null, clearButton, null); layout.EndCentered(); dlg.Content = layout; dlg.ShowModal(); }
public TabIndexSection() { var stack = new StackLayout { TabIndex = 2 }; stack.Items.Add(new TextBox { Text = "3", TabIndex = 3 }); stack.Items.Add(new TextBox { Text = "2", TabIndex = 2 }); stack.Items.Add(new TextBox { Text = "4", TabIndex = 4 }); stack.Items.Add(new TextBox { Text = "5", TabIndex = 5 }); stack.Items.Add(new TextBox { Text = "1", TabIndex = 1 }); var table = new TableLayout { TabIndex = 1 }; table.Rows.Add(new TextBox { Text = "3", TabIndex = 3 }); table.Rows.Add(new TextBox { Text = "2", TabIndex = 2 }); table.Rows.Add(new TextBox { Text = "4", TabIndex = 4 }); table.Rows.Add(new TextBox { Text = "5", TabIndex = 5 }); table.Rows.Add(new TextBox { Text = "1", TabIndex = 1 }); var pixel = new PixelLayout(); pixel.Add(new TextBox { Text = "3", TabIndex = 3 }, 0, 0); pixel.Add(new TextBox { Text = "2", TabIndex = 2 }, 25, 25); pixel.Add(new TextBox { Text = "4", TabIndex = 4 }, 50, 50); pixel.Add(new TextBox { Text = "5", TabIndex = 5 }, 75, 75); pixel.Add(new TextBox { Text = "1", TabIndex = 1 }, 100, 100); var dynamic = new DynamicLayout { TabIndex = 3 }; dynamic.BeginCentered(); dynamic.Add(new TextBox { Text = "3", TabIndex = 3 }); dynamic.EndCentered(); dynamic.BeginVertical(); dynamic.Add(new TextBox { Text = "2", TabIndex = 2 }); dynamic.Add(new TextBox { Text = "4", TabIndex = 4 }); dynamic.EndVertical(); dynamic.BeginVertical(); dynamic.BeginHorizontal(); dynamic.Add(new TextBox { Text = "5", TabIndex = 5 }); dynamic.Add(new TextBox { Text = "1", TabIndex = 1 }); dynamic.EndHorizontal(); dynamic.EndVertical(); Content = new TableLayout( new TableRow("StackLayout-2", stack), new TableRow("TableLayout-1", table), new TableRow("PixelLayout", pixel), new TableRow("DynamicLayout-3", dynamic), null); }
public void WindowShouldAutoSize(bool useForm) { void DoTest(Window window) { window.AutoSize = true; window.MinimumSize = Size.Empty; var bottomPanel = new StackLayout(); var rightPanel = new StackLayout { Orientation = Orientation.Horizontal }; var autoSize = new CheckBox { Text = "AutoSize", Checked = window.AutoSize }; autoSize.CheckedChanged += (sender, e) => { window.AutoSize = autoSize.Checked == true; }; var addBottomButton = new Button { Text = "Add bottom control" }; addBottomButton.Click += (sender, e) => { bottomPanel.Items.Add(new Panel { Size = new Size(20, 20) }); autoSize.Checked = window.AutoSize; }; var addRightButton = new Button { Text = "Add right control" }; addRightButton.Click += (sender, e) => { rightPanel.Items.Add(new Panel { Size = new Size(20, 20) }); autoSize.Checked = window.AutoSize; }; var resetButton = new Button { Text = "Reset" }; resetButton.Click += (sender, e) => { window.SuspendLayout(); bottomPanel.Items.Clear(); rightPanel.Items.Clear(); window.ResumeLayout(); autoSize.Checked = window.AutoSize; }; window.SizeChanged += (sender, e) => autoSize.Checked = window.AutoSize; var layout = new DynamicLayout(); layout.BeginHorizontal(); layout.BeginCentered(); layout.Add(addRightButton); layout.Add(addBottomButton); layout.Add(resetButton); layout.Add(autoSize); layout.EndCentered(); layout.Add(rightPanel); layout.EndHorizontal(); layout.Add(bottomPanel); window.Content = layout; } if (useForm) { Form(DoTest, -1); } else { Dialog(DoTest, -1); } }
// Creates and places all of the UI elements. This is particularly // nasty looking. There is probably a better way to do this, but idk. // https://github.com/picoe/Eto/wiki/DynamicLayout public void createUI() { layout.Padding = new Padding(10, 0, 10, 10); grid.Size = new Size(1000, 1000); layout.DefaultSpacing = new Size(5, 5); SelectSort.DataStore = SortStore; layout.BeginHorizontal(); layout.BeginVertical(); layout.BeginHorizontal(); layout.BeginGroup("User Info", new Padding(10, 10, 10, 10)); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(user); layout.EndVertical(); layout.AddAutoSized(userlogin); layout.EndHorizontal(); layout.BeginVertical(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "User Name:" }); layout.AddAutoSized(usernameBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Yelping Since:" }); layout.AddAutoSized(dateBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Stars:" }); layout.AddAutoSized(starsBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Number of Fans:" }); layout.AddAutoSized(fansBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Funny:" }); layout.AddAutoSized(funnyBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Cool:" }); layout.AddAutoSized(coolBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Useful:" }); layout.AddAutoSized(usefulBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Number of Tips:" }); layout.AddAutoSized(tipcountBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Number of Likes:" }); layout.AddAutoSized(totallikesBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Latitude:" }); layout.AddAutoSized(latitudeBox); layout.EndHorizontal(); layout.BeginHorizontal(); layout.AddAutoSized(new Label { Text = "Longitude:" }); layout.AddAutoSized(longitudeBox); layout.EndHorizontal(); layout.AddAutoSized(updateLocation); layout.EndVertical(); layout.EndGroup(); layout.EndHorizontal(); layout.BeginGroup("Location", new Padding(10, 10, 10, 10)); layout.BeginHorizontal(); //layout.BeginVertical(padding: new Padding(0, 10, 0, 10)); layout.AddAutoSized(new Label { Text = "State" }); layout.AddAutoSized(stateList); //layout.EndVertical(); layout.EndHorizontal(); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "City" }); layout.AddAutoSized(cityList); layout.EndVertical(); layout.EndHorizontal(); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Zip Code" }); layout.AddAutoSized(zipList); layout.AddAutoSized(new Label { Text = "Businesses in State:" }); layout.AddAutoSized(stnum); layout.AddAutoSized(new Label { Text = "Businesses in City:" }); layout.AddAutoSized(ctnum); layout.EndVertical(); layout.EndHorizontal(); layout.EndGroup(); layout.BeginGroup("Sort By", new Padding(10, 10, 10, 10)); layout.AddAutoSized(SelectSort); layout.EndGroup(); layout.EndVertical(); layout.BeginVertical(new Padding(10, 0, 0, 0)); layout.BeginGroup("Search Results"); layout.BeginCentered(); layout.AddAutoSized(grid); layout.EndCentered(); layout.EndGroup(); layout.EndVertical(); layout.BeginVertical(); layout.BeginGroup("Categories", new Padding(10, 10, 10, 10)); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Category" }); layout.AddAutoSized(catList); layout.EndVertical(); layout.EndHorizontal(); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Selected Categories" }); layout.AddAutoSized(selectedCats); layout.BeginHorizontal(); layout.AddAutoSized(add_cat); layout.AddAutoSized(remove_cat); layout.EndHorizontal(); layout.EndVertical(); layout.EndHorizontal(); layout.EndGroup(); layout.BeginGroup("Filters", new Padding(10, 10, 10, 10)); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Price" }); layout.AddAutoSized(priceFilters); layout.EndVertical(); layout.EndHorizontal(); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Attributes" }); layout.AddAutoSized(attributeFilters); layout.EndVertical(); layout.EndHorizontal(); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Meal" }); layout.AddAutoSized(mealFilters); layout.BeginHorizontal(); layout.AddAutoSized(add_att); layout.AddAutoSized(remove_att); layout.EndHorizontal(); layout.EndVertical(); layout.EndHorizontal(); layout.BeginHorizontal(); layout.BeginVertical(padding: new Padding(0, 0, 0, 10)); layout.AddAutoSized(new Label { Text = "Selected Attributes" }); layout.AddAutoSized(selectedAtts); layout.EndVertical(); layout.EndHorizontal(); layout.EndGroup(); layout.BeginCentered(); layout.AddAutoSized(search); layout.EndCentered(); layout.EndVertical(); layout.EndHorizontal(); }