Пример #1
0
        Control WithIcons()
        {
            var control = new ListBox
            {
                Size = new Size(100, 150)
            };

            LogEvents(control);

            control.DataStore = new VirtualList();

            var useVariableImages = new CheckBox {
                Text = "Use Variable Image Sizes"
            };

            useVariableImages.CheckedChanged += (sender, e) =>
            {
                control.DataStore = new VirtualList {
                    UseVariableImages = useVariableImages.Checked ?? false
                };
            };

            return(new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    TableLayout.Horizontal(useVariableImages, null),
                    control
                }
            });
        }
Пример #2
0
 TableLayout CreateOptions(GridView grid, SelectableFilterCollection <MyGridItem> filtered)
 {
     return(new TableLayout
     {
         Padding = Padding.Empty,
         Rows =
         {
             TableLayout.Horizontal(
                 null,
                 EnabledCheckBox(grid),
                 EditableCheckBox(grid),
                 AllowMultiSelectCheckBox(grid),
                 ShowHeaderCheckBox(grid),
                 GridLinesDropDown(grid),
                 null
                 ),
             TableLayout.Horizontal(
                 null,
                 CreateScrollToRow(grid),
                 CreateBeginEditButton(grid),
                 null
                 ),
             CreateSearchBox(filtered)
         }
     });
 }
Пример #3
0
        private Control ConstructSensitivityEditor(string header, Action <string> setValue, Func <string> getValue, string unit = null)
        {
            var textbox = new TextBox();

            this.SettingsChanged += (settings) =>
            {
                textbox.TextBinding.Bind(getValue, setValue);
            };

            var layout = TableLayout.Horizontal(5, new TableCell(textbox, true));

            if (unit != null)
            {
                var unitControl = new Label
                {
                    Text = unit,
                    VerticalAlignment = VerticalAlignment.Center
                };
                layout.Rows[0].Cells.Add(unitControl);
            }

            return(new GroupBox
            {
                Text = header,
                Padding = App.GroupBoxPadding,
                Content = layout
            });
        }
Пример #4
0
        private void InitializeComponent()
        {
            SuspendLayout();

            txtSearchPattern = new TextBox();
            //txtSearchPattern.Width = 150;
            //txtSearchPattern.Height = 24;
            txtSearchPattern.TextChanged += SearchPattern_TextChanged;

            btnPrev        = new Button();
            btnPrev.Size   = new Size(26, 26);
            btnPrev.Click += FindPrev_Click;

            btnNext        = new Button();
            btnNext.Size   = new Size(26, 26);
            btnNext.Click += FindNext_Click;

            Content = TableLayout.Horizontal(10, new TableCell(txtSearchPattern, true), btnPrev, btnNext);

            KeyDown      += SearchPanel_KeyDown;
            Maximizable   = false;
            Minimizable   = false;
            Resizable     = false;
            ShowInTaskbar = false;
            Topmost       = true;

            UIHelper.SetPredefProperties(this, 210, 30);
            ResumeLayout();
        }
Пример #5
0
        private void InitializeComponent()
        {
            SuspendLayout();

            lblName      = new Label();
            lblName.Text = "lblName";

            edName = new TextBox();

            pageMembers      = new TabPage();
            pageMembers.Text = "pageMembers";

            pageNotes      = new TabPage();
            pageNotes.Text = "pageNotes";

            pageMultimedia      = new TabPage();
            pageMultimedia.Text = "pageMultimedia";

            tabsData = new TabControl();
            tabsData.Pages.Add(pageMembers);
            tabsData.Pages.Add(pageNotes);
            tabsData.Pages.Add(pageMultimedia);
            tabsData.Size = new Size(600, 260);

            btnAccept = new Button();
            btnAccept.ImagePosition = ButtonImagePosition.Left;
            btnAccept.Size          = new Size(130, 26);
            btnAccept.Text          = "btnAccept";
            btnAccept.Click        += btnAccept_Click;
            btnAccept.Image         = Bitmap.FromResource("Resources.btn_accept.gif");

            btnCancel = new Button();
            btnCancel.ImagePosition = ButtonImagePosition.Left;
            btnCancel.Size          = new Size(130, 26);
            btnCancel.Text          = "btnCancel";
            btnCancel.Click        += btnCancel_Click;
            btnCancel.Image         = Bitmap.FromResource("Resources.btn_cancel.gif");

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        Cells =  { TableLayout.Horizontal(10,lblName, edName) }
                    },
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { tabsData }
                    },
                    UIHelper.MakeDialogFooter(null, btnAccept, btnCancel)
                }
            };

            DefaultButton = btnAccept;
            AbortButton   = btnCancel;
            Title         = "GroupEditDlg";

            SetPredefProperties(580, 460);
            ResumeLayout();
        }
Пример #6
0
        public DrawableSection()
        {
            Content = new TableLayout
            {
                Padding = new Padding(10),
                Spacing = new Size(10, 10),
                Rows    =
                {
                    TableLayout.HorizontalScaled(
                        10,
                        new TableLayout(
                            "Default",
                            Default()
                            ),
                        new TableLayout(
                            "With Background",
                            WithBackground()
                            )
                        ),

                    new TableLayout(
                        "Large Canvas",
                        // use a separate containing panel to test calculations in those cases
                        new Panel {
                        Content = LargeCanvas()
                    }
                        ),

                    new TableRow(TableLayout.Horizontal(
                                     10,
                                     new TableLayout(
                                         "Nested",
                                         Nested()
                                         ),
                                     new TableLayout(
                                         "Transparent",
                                         Transparent()
                                         ),
                                     new TableLayout(
                                         "Tools",
                                         TableLayout.Horizontal(
                                             Tools(1), Tools(2), Tools(0)
                                             ),
                                         Tools(3),
                                         Tools(0)
                                         )
                                     )),

                    (Platform.SupportedFeatures & PlatformFeatureFlags.DrawableWithTransparentContent) == 0 ?
                    new TableRow(
                        "(Transparent content on drawable not supported on this platform)"
                        ) : null,

                    null
                }
            };
        }
Пример #7
0
        /// <summary>
        /// Let the user choose from a number of possibilities.
        /// Pre-selects first entry if only one is provided.
        /// </summary>
        /// <param name="possibleChoices">A list of choices</param>
        /// <param name="textRepresentation">A function that returns a text representation for each choice</param>
        /// <param name="callback">The method that is called with the chosen element as a parameter</param>
        /// <typeparam name="T">The type of element to chose from</typeparam>
        public void GetChoice <T>(List <T> possibleChoices,
                                  Func <T, string> textRepresentation,
                                  Action <T> callback)
        {
            Log.Debug("InputPanel: Get choice in {num}", possibleChoices.Count);

            var combo = new ComboBox {
                DataStore = possibleChoices.Select(textRepresentation)
            };

            if (possibleChoices.Count == 1)
            {
                combo.SelectedIndex = 0;                             // preselect if only one option
            }
            combo.KeyDown += (sender, args) =>
            {
                // todo on Gtk, this only triggers then the focus is on the little arrow on the combo box
                if (args.Key == Keys.Enter)
                {
                    RunCallback();
                }
            };

            // confirm btn
            var btn = new Button {
                Text = "Confirm"
            };

            btn.Click += (s, a) => RunCallback();

            // helper method for running callback
            void RunCallback()
            {
                // nothing chosen or user entered own text -> do not do it
                if (combo.SelectedIndex == -1)
                {
                    AppState.IO.Write(">> Choose an option from the dropdown below");
                    return; // return in helper method, not GetChoice
                }

                // remove choice box and run callback
                this.Content = null;
                callback(possibleChoices[combo.SelectedIndex]);
            }

            // set layout on UI
            this.Content = TableLayout.Horizontal(
                new TableCell {
                Control = combo, ScaleWidth = true
            },
                btn
                );

            // set focus to the combo box so you can easily choose with arrow keys, press tab and enter to confirm
            combo.Focus();
        }
Пример #8
0
        private void InitializeComponent()
        {
            SuspendLayout();

            lblName      = new Label();
            lblName.Text = "lblName";

            txtName = new TextBox();

            pageNotes      = new TabPage();
            pageNotes.Text = "pageNotes";

            tabsData = new TabControl();
            tabsData.Pages.Add(pageNotes);
            tabsData.Size = new Size(600, 260);

            //

            btnAddress        = new Button();
            btnAddress.Size   = new Size(130, 26);
            btnAddress.Text   = "btnAddress";
            btnAddress.Click += btnAddress_Click;

            btnAccept = new Button();
            btnAccept.ImagePosition = ButtonImagePosition.Left;
            btnAccept.Size          = new Size(130, 26);
            btnAccept.Text          = "btnAccept";
            btnAccept.Click        += btnAccept_Click;

            btnCancel = new Button();
            btnCancel.ImagePosition = ButtonImagePosition.Left;
            btnCancel.Size          = new Size(130, 26);
            btnCancel.Text          = "btnCancel";
            btnCancel.Click        += btnCancel_Click;

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        Cells =  { TableLayout.Horizontal(10,lblName, txtName) }
                    },
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { tabsData }
                    },
                    UIHelper.MakeDialogFooter(btnAddress, null, btnAccept, btnCancel)
                }
            };

            DefaultButton = btnAccept;
            AbortButton   = btnCancel;
            Title         = "RepositoryEditDlg";

            SetPredefProperties(580, 460);
            ResumeLayout();
        }
Пример #9
0
        Control WrapLabel()
        {
            const string text  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
            var          label = new Label
            {
                Text = text
            };

            var wrapDropDown = new EnumDropDown <WrapMode>();

            wrapDropDown.SelectedValueBinding.Bind(label, l => l.Wrap);

            var textAlignmentDropDown = new EnumDropDown <TextAlignment>();

            textAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.TextAlignment);

            var verticalAlignmentDropDown = new EnumDropDown <VerticalAlignment>();

            verticalAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.VerticalAlignment);

            var testVerticalAlignment = new CheckBox {
                Text = "Test VerticalAlignment"
            };

            testVerticalAlignment.CheckedChanged += (sender, e) => label.Size = new Size(-1, testVerticalAlignment.Checked == true ? 200 : -1);
            testVerticalAlignment.CheckedBinding.Bind(verticalAlignmentDropDown, c => c.Enabled, DualBindingMode.OneWayToSource);

            var fontSelector = new FontPicker();

            fontSelector.Bind(c => c.Value, label, l => l.Font);

            Func <Control> spacer = () => new Panel {
                BackgroundColor = Colors.DarkGray, Size = new Size(10, 10)
            };

            return(new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    TableLayout.Horizontal(5,    null,  "Wrap:",               wrapDropDown,              "Font:",          fontSelector,          null),
                    TableLayout.Horizontal(5,    null,  testVerticalAlignment, verticalAlignmentDropDown, "TextAlignment:", textAlignmentDropDown, null),
                    spacer(),
                    new TableLayout(
                        new TableRow(
                            spacer(),
                            new TableCell(label, true),
                            spacer()
                            )
                        ),
                    spacer()
                }
            });
        }
Пример #10
0
        public Input(string caption, string text)
        {
            /* dialog attributes */

            Title       = caption;
            MinimumSize = new Size(400, 0);
            Resizable   = false;

            /* dialog controls */

            var textBox = new TextBox();

            textBox.TextBinding.Bind(this, r => r.Data);

            var buttonOk = new Button {
                Text = "Ok"
            };

            buttonOk.Click += (sender, e) => Close(true);

            var buttonCancel = new Button {
                Text = "Cancel"
            };

            buttonCancel.Click += (sender, e) => Close(false);

            /* dialog layout */

            var groupBox = new GroupBox
            {
                Text    = text,
                Content = new TableLayout
                {
                    Padding = new Padding(10),
                    Rows    = { textBox }
                }
            };

            Content = new TableLayout
            {
                Padding = new Padding(10),
                Rows    =
                {
                    groupBox,
                    TableLayout.Horizontal(null,buttonCancel,  buttonOk, null).With(r => r.Spacing = new Size(5, 5))
                }
            };

            /* dialog accessors */

            DefaultButton = buttonOk;
            AbortButton   = buttonCancel;
        }
Пример #11
0
        Control WrapLabel()
        {
            var label = new Label
            {
                Text = Utility.LoremText
            };

            var wrapDropDown = new EnumDropDown <WrapMode>();

            wrapDropDown.SelectedValueBinding.Bind(label, l => l.Wrap);

            var textAlignmentDropDown = new EnumDropDown <TextAlignment>();

            textAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.TextAlignment);

            var verticalAlignmentDropDown = new EnumDropDown <VerticalAlignment>();

            verticalAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.VerticalAlignment);

            var testVerticalAlignment = new CheckBox {
                Text = "Test VerticalAlignment"
            };

            testVerticalAlignment.CheckedChanged += (sender, e) => label.Size = new Size(-1, testVerticalAlignment.Checked == true ? 200 : -1);
            testVerticalAlignment.CheckedBinding.Bind(verticalAlignmentDropDown, c => c.Enabled, DualBindingMode.OneWayToSource);

            var fontSelector = new FontPicker();

            fontSelector.Bind(c => c.Value, label, l => l.Font);

            Func <Control> spacer = () => new Panel {
                BackgroundColor = Colors.DarkGray, Size = new Size(10, 10)
            };

            return(new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    TableLayout.Horizontal(5,    null,  "Wrap:",               wrapDropDown,              "Font:",          fontSelector,          null),
                    TableLayout.Horizontal(5,    null,  testVerticalAlignment, verticalAlignmentDropDown, "TextAlignment:", textAlignmentDropDown, null),
                    spacer(),
                    new TableLayout(
                        new TableRow(
                            spacer(),
                            new TableCell(label, true),
                            spacer()
                            )
                        ),
                    spacer()
                }
            });
        }
Пример #12
0
        private void InitializeLayout()
        {
            var bounceTable = new TableLayout()
            {
                Spacing = new Eto.Drawing.Size(1, 5),
                Rows    =
                {
                    new TableRow(new TableCell(m_minimum,    true),                    new TableCell(m_maximum, true)),
                    new TableRow(m_maxbounce,                null),
                    new TableRow(m_maxdiffusebounce_lb,      m_maxdiffusebounce),
                    new TableRow(m_maxglossybounce_lb,       m_maxglossybounce),
                    new TableRow(m_maxtransmissionbounce_lb, m_maxtransmissionbounce),
                    new TableRow(m_maxvolumebounce_lb,       m_maxvolumebounce),
                }
            };

            StackLayout layout = new StackLayout()
            {
                // Padding around the table
                Padding = new Eto.Drawing.Padding(3, 5, 3, 0),
                // Spacing between table cells
                //Spacing = new Eto.Drawing.Size(15, 5),
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    TableLayout.Horizontal(10,
                                           new GroupBox()
                    {
                        Padding = new Eto.Drawing.Padding(10, 5, 5, 10),
                        Text    = Localization.LocalizeString("Seed", 4),
                        ToolTip = Localization.LocalizeString("Set the seed for the random number generator.",34),
                        Content = new TableLayout
                        {
                            Rows = { new TableRow(new TableCell(m_seed,true)) }
                        }
                    }),
                    //new TableRow(m_diffusesamples_lb, m_diffusesamples),
                    //new TableRow(m_glossysamples_lb, m_glossysamples),
                    //new TableRow(m_transmissionsamples_lb, m_transmissionsamples),
                    TableLayout.Horizontal(10,
                                           new GroupBox()
                    {
                        Padding = new Eto.Drawing.Padding(10, 5, 5, 10),
                        Text    = Localization.LocalizeString("Ray Bounces", 35),
                        ToolTip = Localization.LocalizeString("Settings controlling the bounce limits\nfor different types of rays.",36),
                        Content = bounceTable,
                    }
                                           ),
                }
            };

            Content = layout;
        }
Пример #13
0
        public static void ManualForm(string description, Func <Form, Label, Control> init)
        {
            Exception exception = null;

            Form(form =>
            {
                var label = new Label {
                    Text = description
                };
                var c = init(form, label);

                var failButton = new Button {
                    Text = "Fail"
                };
                failButton.Click += (sender, e) =>
                {
                    try
                    {
                        Assert.Fail(description);
                    }
                    catch (Exception ex)
                    {
                        exception = ex;
                    }
                    finally
                    {
                        form.Close();
                    }
                };

                var passButton = new Button {
                    Text = "Pass"
                };
                passButton.Click += (sender, e) => form.Close();

                form.Content = new StackLayout
                {
                    Padding = 10,
                    Spacing = 10,
                    Items   =
                    {
                        new StackLayoutItem(c,                        HorizontalAlignment.Stretch, true),
                        label,
                        new StackLayoutItem(TableLayout.Horizontal(2, failButton,                  passButton), HorizontalAlignment.Center)
                    }
                };
            }, timeout: -1);

            if (exception != null)
            {
                ExceptionDispatchInfo.Capture(exception).Throw();
            }
        }
Пример #14
0
 StackLayout CreateOptions(GridView grid, SelectableFilterCollection <MyGridItem> filtered)
 {
     return(new StackLayout
     {
         Spacing = 5,
         HorizontalContentAlignment = HorizontalAlignment.Stretch,
         Items =
         {
             TableLayout.Horizontal(
                 5,
                 null,
                 EnabledCheckBox(grid),
                 EditableCheckBox(grid),
                 AllowMultiSelectCheckBox(grid),
                 ShowHeaderCheckBox(grid),
                 GridLinesDropDown(grid),
                 null
                 ),
             TableLayout.Horizontal(
                 5,
                 null,
                 AddItemButton(filtered),
                 CreateScrollToRow(grid),
                 CreateBeginEditButton(grid),
                 "Border",
                 CreateBorderType(grid),
                 null
                 ),
             TableLayout.Horizontal(
                 5,
                 null,
                 ReloadDataButton(grid),
                 null
                 ),
             TableLayout.Horizontal(
                 5,
                 null,
                 "TextBoxCell:",
                 "TextAlignment",               TextAlignmentDropDown(grid),
                 "VerticalAlignment",           VerticalAlignmentDropDown(grid),
                 null
                 ),
             TableLayout.Horizontal(
                 5,
                 null,
                 "AutoSelectMode",              AutoSelectModeDropDown(grid),
                 null
                 ),
             CreateSearchBox(filtered)
         }
     });
 }
Пример #15
0
        Control SetInitialFolderCheckBox()
        {
            var control = new CheckBox {
                Text = "Set initial folder:"
            };

            control.CheckedBinding.Bind(this, c => c.SetInitialFolder);
            var folder = new TextBox();

            folder.TextBinding.Bind(this, c => c.InitialFolder);
            control.CheckedBinding.Bind(folder, f => f.Enabled, DualBindingMode.OneWayToSource);
            return(TableLayout.Horizontal(2, control, folder));
        }
Пример #16
0
 public ColorPickerSection()
 {
     Content = new StackLayout
     {
         Spacing = 5,
         Padding = 10,
         Items   =
         {
             CreateAllowAlpha(),
             TableLayout.Horizontal(5,"Default",        Default()),
             TableLayout.Horizontal(5,"Initial Value",  InitialValue())
         }
     };
 }
Пример #17
0
 public static Control TextAreaOptions3(TextArea text)
 {
     return(TableLayout.Horizontal
            (
                null,
                EnabledCheckBox(text),
                ReadOnlyCheckBox(text),
                AcceptsTabCheckBox(text),
                AcceptsReturnCheckBox(text),
                WrapCheckBox(text),
                SpellCheckCheckBox(text),
                null
            ).With(r => r.Padding = Padding.Empty));
 }
Пример #18
0
        private void InitializeComponent()
        {
            this.cmbDateType      = new ComboBox();
            this.txtDate1         = new GKUI.Components.GKDateBox();
            this.txtDate2         = new GKUI.Components.GKDateBox();
            this.cmbDate1Calendar = new ComboBox();
            this.cmbDate2Calendar = new ComboBox();
            this.chkBC2           = new CheckBox();
            this.chkBC1           = new CheckBox();

            this.SuspendLayout();

            this.cmbDateType.ReadOnly              = true;
            this.cmbDateType.SelectedIndexChanged += cmbDateType_SelectedIndexChanged;

            this.txtDate1.AllowDrop = true;
            this.txtDate1.DragOver += txtDateX_DragOver;
            this.txtDate1.DragDrop += txtDateX_DragDrop;

            this.txtDate2.AllowDrop = true;
            this.txtDate2.DragOver += txtDateX_DragOver;
            this.txtDate2.DragDrop += txtDateX_DragDrop;

            this.cmbDate1Calendar.ReadOnly = true;

            this.cmbDate2Calendar.ReadOnly = true;

            this.chkBC2.Text = "BC";

            this.chkBC1.Text = "BC";

            Content = new TableLayout {
                Padding = new Padding(0),
                Spacing = new Size(10, 10),
                Rows    =
                {
                    new TableRow {
                        Cells =  { cmbDateType,txtDate1, txtDate2 }
                    },
                    new TableRow {
                        Cells =  { null,
                                   TableLayout.Horizontal(10, cmbDate1Calendar, chkBC1),
                                   TableLayout.Horizontal(10, cmbDate2Calendar, chkBC2) }
                    },
                }
            };

            this.ResumeLayout();
        }
Пример #19
0
        Control Default()
        {
            var text = new TextArea {
                Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
            };

            LogEvents(text);

            return(new TableLayout
            {
                Rows =
                {
                    TableLayout.Horizontal(null, ShowSelectedText(text), SetSelectedText(text),  ReplaceSelected(text),    SelectAll(text),             null).With(r => r.Padding = Padding.Empty),
                    TableLayout.Horizontal(null, SetAlignment(text),     SetCaretButton(text),   ChangeColorButton(text),  null).With(r => r.Padding = Padding.Empty),
                    TableLayout.Horizontal(null, EnabledCheckBox(text),  ReadOnlyCheckBox(text), AcceptsTabCheckBox(text), AcceptsReturnCheckBox(text), WrapCheckBox(text), null).With(r => r.Padding= Padding.Empty),
                    text
                }
            });
        }
Пример #20
0
 public FileDialogSection()
 {
     Content = new TableLayout
     {
         Spacing = new Size(5, 5),
         Rows    =
         {
             TableLayout.Horizontal(null, new Label {
                 Text = "File Name"
             },                           GetFileName(), null),
             TableLayout.Horizontal(null, new Label {
                 Text = "Directory"
             },                           GetDirectory(), null),
             TableLayout.Horizontal(null, GetMultiSelect(), null),
             TableLayout.Horizontal(null, new Label {
                 Text = "Title"
             },                           GetTitle(), null),
             TableLayout.Horizontal(null, OpenFile(), OpenFileWithFilters(), null),
             TableLayout.Horizontal(null, SaveFile(), SaveFileWithFilters(), null),
             null
         }
     };
 }
Пример #21
0
        /// <summary>
        /// Get arbitrary text input
        /// </summary>
        /// <param name="action">The callback to be called with the entered text as a parameter</param>
        public void GetTextInput(Action <string> action)
        {
            var field = new TextBox();

            field.KeyDown += (sender, args) =>
            {
                // On enter press, run supplied action
                if (args.Key == Keys.Enter)
                {
                    RunAction();
                }
            };

            var btn = new Button {
                Text = "Enter"
            };

            // on button press, run supplied action
            btn.Click += (sender, args) => RunAction();

            void RunAction()
            {
                this.Content = null;
                action.Invoke(field.Text);
            }

            // set layout on UI
            this.Content = TableLayout.Horizontal(
                new TableCell {
                Control = field, ScaleWidth = true
            },
                btn
                );

            // set focus to text box so you can enter text without clicking it first
            field.Focus();
        }
Пример #22
0
        private Control ConstructSensitivityEditor(string header, IndirectBinding <float> dataContextBinding)
        {
            var textbox = new TextBox();

            ViewModel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(ViewModel.Settings))
                {
                    textbox.TextBinding.Convert(
                        s => float.TryParse(s, out var v) ? v : 0,
                        f => f.ToString())
                    .BindDataContext(dataContextBinding);
                }
            };

            return(new GroupBox
            {
                Text = header,
                Padding = App.GroupBoxPadding,
                Content = TableLayout.Horizontal(5, new TableCell(textbox, true), new Label {
                    Text = "mm/px", VerticalAlignment = VerticalAlignment.Center
                })
            });
        }
Пример #23
0
        private void InitializeComponent()
        {
            SuspendLayout();

            lblName      = new Label();
            lblName.Text = "lblName";

            lblType      = new Label();
            lblType.Text = "lblType";

            lblStoreType      = new Label();
            lblStoreType.Text = "lblStoreType";

            lblFile      = new Label();
            lblFile.Text = "lblFile";

            txtName              = new TextBox();
            txtName.TextChanged += edName_TextChanged;

            cmbMediaType          = new ComboBox();
            cmbMediaType.ReadOnly = true;

            cmbStoreType                       = new ComboBox();
            cmbStoreType.ReadOnly              = true;
            cmbStoreType.SelectedIndexChanged += cmbStoreType_SelectedIndexChanged;

            txtFile          = new TextBox();
            txtFile.ReadOnly = true;

            btnFileSelect = new Button();
            //btnFileSelect.Size = new Size(60, 26);
            btnFileSelect.Width  = 60;
            btnFileSelect.Text   = "...";
            btnFileSelect.Click += btnFileSelect_Click;

            pageCommon         = new TabPage();
            pageCommon.Text    = "pageCommon";
            pageCommon.Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        Cells =  { lblName,txtName }
                    },
                    new TableRow {
                        Cells =
                        {
                            lblFile,
                            TableLayout.Horizontal(10,new TableCell(txtFile,  true), btnFileSelect)
                        }
                    },
                    new TableRow {
                        Cells =
                        {
                            lblType,
                            TableLayout.Horizontal(10,cmbMediaType,  lblStoreType, cmbStoreType)
                        }
                    },
                    null
                }
            };

            pageNotes      = new TabPage();
            pageNotes.Text = "pageNotes";

            pageSources      = new TabPage();
            pageSources.Text = "pageSources";

            tabsData = new TabControl();
            tabsData.Pages.Add(pageCommon);
            tabsData.Pages.Add(pageNotes);
            tabsData.Pages.Add(pageSources);
            tabsData.Size = new Size(600, 260);

            //

            btnView        = new Button();
            btnView.Size   = new Size(130, 26);
            btnView.Text   = "btnView";
            btnView.Click += btnView_Click;

            btnAccept = new Button();
            btnAccept.ImagePosition = ButtonImagePosition.Left;
            btnAccept.Size          = new Size(130, 26);
            btnAccept.Text          = "btnAccept";
            btnAccept.Click        += btnAccept_Click;

            btnCancel = new Button();
            btnCancel.ImagePosition = ButtonImagePosition.Left;
            btnCancel.Size          = new Size(130, 26);
            btnCancel.Text          = "btnCancel";
            btnCancel.Click        += btnCancel_Click;

            //

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { tabsData }
                    },
                    UIHelper.MakeDialogFooter(btnView, null, btnAccept, btnCancel)
                }
            };

            DefaultButton = btnAccept;
            AbortButton   = btnCancel;
            Title         = "MediaEditDlg";

            SetPredefProperties(580, 460);
            ResumeLayout();
        }
Пример #24
0
        public AreaEditor(string unit, bool enableRotation = false)
        {
            this.DataContext = new AreaViewModel();
            this.ContextMenu = new ContextMenu();

            areaDisplay = new AreaDisplay(unit)
            {
                Padding = new Padding(5)
            };
            areaDisplay.Bind(c => c.ViewModel.Width, ViewModel, m => m.Width);
            areaDisplay.Bind(c => c.ViewModel.Height, ViewModel, m => m.Height);
            areaDisplay.Bind(c => c.ViewModel.X, ViewModel, m => m.X);
            areaDisplay.Bind(c => c.ViewModel.Y, ViewModel, m => m.Y);
            areaDisplay.Bind(c => c.ViewModel.Rotation, ViewModel, m => m.Rotation);
            areaDisplay.Bind(c => c.ViewModel.MaxWidth, ViewModel, m => m.MaxWidth);
            areaDisplay.Bind(c => c.ViewModel.MaxHeight, ViewModel, m => m.MaxHeight);

            widthBox = new TextBox();
            widthBox.TextBinding.Convert(
                s => float.TryParse(s, out var v) ? v : 0,
                f => f.ToString()).BindDataContext(
                Binding.Property(
                    (AreaViewModel d) => d.Width));

            heightBox = new TextBox();
            heightBox.TextBinding.Convert(
                s => float.TryParse(s, out var v) ? v : 0,
                f => f.ToString()).BindDataContext(
                Binding.Property(
                    (AreaViewModel d) => d.Height));

            xOffsetBox = new TextBox();
            xOffsetBox.TextBinding.Convert(
                s => float.TryParse(s, out var v) ? v : 0,
                f => f.ToString()).BindDataContext(
                Binding.Property(
                    (AreaViewModel d) => d.X));

            yOffsetBox = new TextBox();
            yOffsetBox.TextBinding.Convert(
                s => float.TryParse(s, out var v) ? v : 0,
                f => f.ToString()).BindDataContext(
                Binding.Property(
                    (AreaViewModel d) => d.Y));

            rotationBox = new TextBox();
            rotationBox.TextBinding.Convert(
                s => float.TryParse(s, out var v) ? v : 0,
                f => f.ToString()).BindDataContext(
                Binding.Property(
                    (AreaViewModel d) => d.Rotation));

            var stackLayout = new StackLayout
            {
                Orientation = Orientation.Vertical,
                Spacing     = 5,
                Items       =
                {
                    new GroupBox
                    {
                        Text    = "Width",
                        Content = AppendUnit(widthBox, unit)
                    },
                    new GroupBox
                    {
                        Text    = "Height",
                        Content = AppendUnit(heightBox, unit)
                    },
                    new GroupBox
                    {
                        Text    = "X Offset",
                        Content = AppendUnit(xOffsetBox, unit)
                    },
                    new GroupBox
                    {
                        Text    = "Y Offset",
                        Content = AppendUnit(yOffsetBox, unit)
                    },
                    new GroupBox
                    {
                        Text    = "Rotation",
                        Content = AppendUnit(rotationBox, "°"),
                        Visible = enableRotation
                    }
                }
            };

            foreach (var item in stackLayout.Items)
            {
                if (item.Control is GroupBox groupBox)
                {
                    groupBox.Padding = App.GroupBoxPadding;
                }
            }

            TableCell[] cells =
            {
                new TableCell(stackLayout),
                new TableCell(areaDisplay, true)
            };
            Content = TableLayout.Horizontal(5, cells);

            this.ContextMenu.Items.GetSubmenu("Align").Items.AddRange(
                new MenuItem[]
            {
                CreateMenuItem("Left", () => ViewModel.X   = ViewModel.Width / 2),
                CreateMenuItem("Right", () => ViewModel.X  = ViewModel.MaxWidth - (ViewModel.Width / 2)),
                CreateMenuItem("Top", () => ViewModel.Y    = ViewModel.Height / 2),
                CreateMenuItem("Bottom", () => ViewModel.Y = ViewModel.MaxHeight - (ViewModel.Height / 2)),
                CreateMenuItem("Center",
                               () =>
                {
                    ViewModel.X = ViewModel.MaxWidth / 2;
                    ViewModel.Y = ViewModel.MaxHeight / 2;
                }
                               )
            }
                );

            this.ContextMenu.Items.GetSubmenu("Resize").Items.AddRange(
                new MenuItem[]
            {
                CreateMenuItem(
                    "Full area",
                    () =>
                {
                    ViewModel.Height = ViewModel.MaxHeight;
                    ViewModel.Width  = ViewModel.MaxWidth;
                    ViewModel.Y      = ViewModel.MaxHeight / 2;
                    ViewModel.X      = ViewModel.MaxWidth / 2;
                }
                    ),
                CreateMenuItem(
                    "Quarter area",
                    () =>
                {
                    ViewModel.Height = ViewModel.MaxHeight / 2;
                    ViewModel.Width  = ViewModel.MaxWidth / 2;
                }
                    )
            }
                );

            AppendMenuItemSeparator();

            AppendCheckBoxMenuItem(
                "Lock to usable area",
                lockToMax =>
            {
                if (lockToMax)
                {
                    ViewModel.PropertyChanged += LimitArea;
                }
                else
                {
                    ViewModel.PropertyChanged -= LimitArea;
                }
            },
                defaultValue: true
                );

            this.MouseDown += (sender, e) =>
            {
                if (e.Buttons.HasFlag(MouseButtons.Alternate))
                {
                    this.ContextMenu.Show(this);
                }
            };
        }
Пример #25
0
        private void InitializeComponent()
        {
            SuspendLayout();

            lblHusband      = new Label();
            lblHusband.Text = "lblHusband";

            lblWife      = new Label();
            lblWife.Text = "lblWife";

            txtHusband         = new TextBox();
            txtHusband.Enabled = false;

            txtWife         = new TextBox();
            txtWife.Enabled = false;

            btnHusbandAdd         = new Button();
            btnHusbandAdd.Enabled = false;
            btnHusbandAdd.Size    = new Size(26, 26);
            btnHusbandAdd.Click  += btnHusbandAddClick;
            btnHusbandAdd.Image   = Bitmap.FromResource("Resources.btn_rec_new.gif");

            btnHusbandDelete         = new Button();
            btnHusbandDelete.Enabled = false;
            btnHusbandDelete.Size    = new Size(26, 26);
            btnHusbandDelete.Click  += btnHusbandDeleteClick;
            btnHusbandDelete.Image   = Bitmap.FromResource("Resources.btn_rec_delete.gif");

            btnHusbandSel        = new Button();
            btnHusbandSel.Size   = new Size(26, 26);
            btnHusbandSel.Click += btnHusbandSelClick;
            btnHusbandSel.Image  = Bitmap.FromResource("Resources.btn_jump.gif");

            btnWifeSel        = new Button();
            btnWifeSel.Size   = new Size(26, 26);
            btnWifeSel.Click += btnWifeSelClick;
            btnWifeSel.Image  = Bitmap.FromResource("Resources.btn_jump.gif");

            btnWifeDelete         = new Button();
            btnWifeDelete.Enabled = false;
            btnWifeDelete.Size    = new Size(26, 26);
            btnWifeDelete.Click  += btnWifeDeleteClick;
            btnWifeDelete.Image   = Bitmap.FromResource("Resources.btn_rec_delete.gif");

            btnWifeAdd         = new Button();
            btnWifeAdd.Enabled = false;
            btnWifeAdd.Size    = new Size(26, 26);
            btnWifeAdd.Click  += btnWifeAddClick;
            btnWifeAdd.Image   = Bitmap.FromResource("Resources.btn_rec_new.gif");

            lblStatus      = new Label();
            lblStatus.Text = "lblStatus";

            cmbMarriageStatus          = new ComboBox();
            cmbMarriageStatus.ReadOnly = true;

            GroupBox1         = new GroupBox();
            GroupBox1.Text    = "GroupBox1";
            GroupBox1.Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        Cells =
                        {
                            lblHusband,
                            TableLayout.Horizontal(10,new TableCell(txtHusband,  true), btnHusbandAdd, btnHusbandDelete, btnHusbandSel)
                        }
                    },
                    new TableRow {
                        Cells =
                        {
                            lblWife,
                            TableLayout.Horizontal(10,new TableCell(txtWife,  true), btnWifeAdd, btnWifeDelete, btnWifeSel)
                        }
                    },
                    new TableRow {
                        //ScaleHeight = true,
                        Cells =  { lblStatus,cmbMarriageStatus }
                    }
                }
            };

            //

            pageChilds      = new TabPage();
            pageChilds.Text = "pageChilds";

            pageEvents      = new TabPage();
            pageEvents.Text = "pageEvents";

            pageNotes      = new TabPage();
            pageNotes.Text = "pageNotes";

            pageMultimedia      = new TabPage();
            pageMultimedia.Text = "pageMultimedia";

            pageSources      = new TabPage();
            pageSources.Text = "pageSources";

            tabsData = new TabControl();
            tabsData.Pages.Add(pageChilds);
            tabsData.Pages.Add(pageEvents);
            tabsData.Pages.Add(pageNotes);
            tabsData.Pages.Add(pageMultimedia);
            tabsData.Pages.Add(pageSources);
            tabsData.Size = new Size(600, 260);

            lblRestriction      = new Label();
            lblRestriction.Text = "lblRestriction";

            cmbRestriction          = new ComboBox();
            cmbRestriction.ReadOnly = true;
            //cmbRestriction.Size = new Size(203, 25);
            cmbRestriction.SelectedIndexChanged += cbRestriction_SelectedIndexChanged;

            btnAccept = new Button();
            btnAccept.ImagePosition = ButtonImagePosition.Left;
            btnAccept.Size          = new Size(130, 26);
            btnAccept.Text          = "btnAccept";
            btnAccept.Click        += btnAccept_Click;
            btnAccept.Image         = Bitmap.FromResource("Resources.btn_accept.gif");

            btnCancel = new Button();
            btnCancel.ImagePosition = ButtonImagePosition.Left;
            btnCancel.Size          = new Size(130, 26);
            btnCancel.Text          = "btnCancel";
            btnCancel.Click        += btnCancel_Click;
            btnCancel.Image         = Bitmap.FromResource("Resources.btn_cancel.gif");

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        Cells =  { GroupBox1}
                    },
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { tabsData }
                    },
                    UIHelper.MakeDialogFooter(lblRestriction, cmbRestriction, null, btnAccept, btnCancel)
                }
            };

            DefaultButton = btnAccept;
            AbortButton   = btnCancel;
            Title         = "FamilyEditDlg";

            SetPredefProperties(700, 540);
            ResumeLayout();
        }
Пример #26
0
        public UnitTestSection()
        {
            startButton = new Button {
                Text = "Start Tests", Size = new Size(200, 80)
            };
            useTestPlatform = new CheckBox {
                Text = "Use Test Platform"
            };
            includeManualTests = new CheckBox {
                Text = "Manual Tests", Checked = true
            };
            var buttons = new StackLayout
            {
                Padding = new Padding(10),
                Spacing = 5,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Items =
                {
                    startButton,
                    TableLayout.Horizontal(useTestPlatform, includeManualTests)
                }
            };

            if (Platform.Supports <TreeGridView>())
            {
                search = new SearchBox();
                search.Focus();
                search.KeyDown += (sender, e) =>
                {
                    if (e.KeyData == Keys.Enter)
                    {
                        startButton.PerformClick();
                        e.Handled = true;
                    }
                };

                var timer = new UITimer();
                timer.Interval = 0.5;
                timer.Elapsed += (sender, e) =>
                {
                    timer.Stop();
                    var searchText = search.Text;
                    Task.Factory.StartNew(() => PopulateTree(searchText));
                };
                search.TextChanged += (sender, e) => {
                    if (timer.Started)
                    {
                        timer.Stop();
                    }
                    timer.Start();
                };

                tree = new TreeGridView {
                    ShowHeader = false
                };
                tree.Columns.Add(new GridColumn
                {
                    DataCell = new TextBoxCell {
                        Binding = Binding.Property((UnitTestItem m) => m.Text)
                    }
                });

                tree.Activated += (sender, e) =>
                {
                    var item = (TreeGridItem)tree.SelectedItem;
                    if (item != null)
                    {
                        RunTests(item.Tag as CategoryFilter);
                    }
                };

                Content = new StackLayout
                {
                    Spacing = 5,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    Items = { buttons, search, new StackLayoutItem(tree, expand: true) }
                };
            }
            else
            {
                Content = buttons;
            }

            startButton.Click += (s, e) => RunTests();
        }
Пример #27
0
        private void InitializeComponent()
        {
            SuspendLayout();

            Lab1      = new Label();
            Lab1.Text = "XXX1";

            Lab2      = new Label();
            Lab2.Text = "XXX2";

            Edit1          = new TextBox();
            Edit1.ReadOnly = true;
            Edit1.Width    = 350;

            Edit2          = new TextBox();
            Edit2.ReadOnly = true;
            Edit2.Width    = 350;

            btnRec1Select        = new Button();
            btnRec1Select.Size   = new Size(80, 26);
            btnRec1Select.Text   = "btnRec1Select";
            btnRec1Select.Click += btnRec1Select_Click;

            btnRec2Select        = new Button();
            btnRec2Select.Size   = new Size(80, 26);
            btnRec2Select.Text   = "btnRec2Select";
            btnRec2Select.Click += btnRec2Select_Click;

            btnMergeToLeft         = new Button();
            btnMergeToLeft.Enabled = false;
            btnMergeToLeft.Size    = new Size(80, 26);
            btnMergeToLeft.Text    = "<<<";
            btnMergeToLeft.Click  += btnMergeToLeft_Click;

            btnMergeToRight         = new Button();
            btnMergeToRight.Enabled = false;
            btnMergeToRight.Size    = new Size(80, 26);
            btnMergeToRight.Text    = ">>>";
            btnMergeToRight.Click  += btnMergeToRight_Click;

            fView1 = new HyperView();
            fView2 = new HyperView();

            var contPan = new DefTableLayout(2, 4);

            contPan.SetRowScale(0, false);
            contPan.SetRowScale(1, false);
            contPan.SetRowScale(2, true);
            contPan.SetRowScale(3, false);
            contPan.SetColumnScale(0, true);
            contPan.SetColumnScale(1, true);

            contPan.Add(Lab1, 0, 0);
            contPan.Add(Lab2, 1, 0);
            contPan.Add(TableLayout.Horizontal(Edit1, null, btnRec1Select), 0, 1);
            contPan.Add(TableLayout.Horizontal(Edit2, null, btnRec2Select), 1, 1);
            contPan.Add(fView1, 0, 2);
            contPan.Add(fView2, 1, 2);
            contPan.Add(TableLayout.Horizontal(null, btnMergeToLeft), 0, 3);
            contPan.Add(TableLayout.Horizontal(btnMergeToRight, null), 1, 3);

            Content = contPan;

            UIHelper.SetControlFont(this, UIHelper.GetDefaultFont());
            ResumeLayout();
        }
Пример #28
0
        private void InitializeComponent()
        {
            SuspendLayout();

            lblRelation      = new Label();
            lblRelation.Text = "lblRelation";

            lblPerson      = new Label();
            lblPerson.Text = "lblPerson";

            btnPersonAdd        = new Button();
            btnPersonAdd.Size   = new Size(26, 26);
            btnPersonAdd.Click += btnPersonAdd_Click;

            cmbRelation = new ComboBox();

            txtPerson          = new TextBox();
            txtPerson.ReadOnly = true;
            txtPerson.Width    = 280;

            var panelData = new TableLayout {
                Spacing = new Size(10, 10),
                Rows    =
                {
                    new TableRow {
                        Cells =  { lblRelation,cmbRelation   }
                    },
                    new TableRow {
                        Cells =  { lblPerson,  TableLayout.Horizontal(10, new TableCell(txtPerson, true), btnPersonAdd)}
                    },
                    null
                }
            };

            btnAccept = new Button();
            btnAccept.ImagePosition = ButtonImagePosition.Left;
            btnAccept.Size          = new Size(130, 26);
            btnAccept.Text          = "btnAccept";
            btnAccept.Click        += btnAccept_Click;

            btnCancel = new Button();
            btnCancel.ImagePosition = ButtonImagePosition.Left;
            btnCancel.Size          = new Size(130, 26);
            btnCancel.Text          = "btnCancel";
            btnCancel.Click        += btnCancel_Click;

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { panelData }
                    },
                    UIHelper.MakeDialogFooter(null, btnAccept, btnCancel)
                }
            };

            DefaultButton = btnAccept;
            AbortButton   = btnCancel;
            Title         = "AssociationEditDlg";

            SetPredefProperties(500, 180);
            ResumeLayout();
        }
Пример #29
0
        private void InitializeComponent()
        {
            SuspendLayout();

            btnLangEdit        = new Button();
            btnLangEdit.Size   = new Size(26, 26);
            btnLangEdit.Click += btnLangEdit_Click;

            lblName      = new Label();
            lblName.Text = "lblName";

            lblAddress      = new Label();
            lblAddress.Text = "lblAddress";

            lblLanguage      = new Label();
            lblLanguage.Text = "lblLanguage";

            lblTelephone      = new Label();
            lblTelephone.Text = "lblTelephone";

            txtName = new TextBox();

            txtLanguage          = new TextBox();
            txtLanguage.ReadOnly = true;

            txtTel = new TextBox();

            txtAddress = new TextArea();

            pageAuthor         = new TabPage();
            pageAuthor.Text    = "pageAuthor";
            pageAuthor.Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        Cells =  { lblName,      txtName    }
                    },
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { lblAddress, txtAddress }
                    },
                    new TableRow {
                        Cells =  { lblTelephone, txtTel     }
                    },
                    new TableRow {
                        Cells =
                        {
                            lblLanguage,
                            TableLayout.Horizontal(10,new TableCell(txtLanguage,  true), btnLangEdit)
                        }
                    }
                }
            };

            lvRecordStats = new GKListView();
            lvRecordStats.AddColumn("Records", 300);
            lvRecordStats.AddColumn("Count", 100 /*, HorizontalAlignment.Right*/);

            pageOther         = new TabPage();
            pageOther.Text    = "pageOther";
            pageOther.Content = lvRecordStats;

            tabsData = new TabControl();
            tabsData.Pages.Add(pageAuthor);
            tabsData.Pages.Add(pageOther);
            tabsData.Size = new Size(500, 340);

            btnAccept = new Button();
            btnAccept.ImagePosition = ButtonImagePosition.Left;
            btnAccept.Size          = new Size(130, 26);
            btnAccept.Text          = "btnAccept";
            btnAccept.Click        += btnAccept_Click;

            btnCancel = new Button();
            btnCancel.ImagePosition = ButtonImagePosition.Left;
            btnCancel.Size          = new Size(130, 26);
            btnCancel.Text          = "btnCancel";
            btnCancel.Click        += btnCancel_Click;

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { tabsData }
                    },
                    UIHelper.MakeDialogFooter(null, btnAccept, btnCancel)
                }
            };

            DefaultButton = btnAccept;
            AbortButton   = btnCancel;
            Title         = "FilePropertiesDlg";

            SetPredefProperties(580, 400);
            ResumeLayout();
        }
Пример #30
0
        public void BeginEditShoudWorkOnCustomCells()
        {
            ManualForm("The custom cell should go in edit mode when clicking the BeginEdit button", form =>
            {
                var grid                    = new T();
                grid.ShowHeader             = true;
                grid.AllowMultipleSelection = true;

                string CellInfo(GridViewCellEventArgs e) => $"Row: {e.Row}, Column: {e.Column}";
                string CellEditInfo(CellEventArgs e) => $"Row: {e.Row}";
                void AddLogging(CustomCell cell)
                {
                    cell.BeginEdit  += (sender, e) => Log.Write(sender, $"BeginEdit {CellEditInfo(e)}, Grid.IsEditing: {grid.IsEditing}");
                    cell.CommitEdit += (sender, e) => Log.Write(sender, $"CommitEdit {CellEditInfo(e)}, Grid.IsEditing: {grid.IsEditing}");
                    cell.CancelEdit += (sender, e) => Log.Write(sender, $"CancelEdit {CellEditInfo(e)}, Grid.IsEditing: {grid.IsEditing}");

                    if (!CustomCell.SupportsControlView)
                    {
                        cell.GetPreferredWidth = args => 100;
                        cell.Paint            += (sender, e) =>
                        {
                            e.Graphics.DrawText(SystemFonts.Default(), Brushes.Black, e.ClipRectangle, "Cell", alignment: FormattedTextAlignment.Center);
                        };
                    }
                }

                grid.CellEditing     += (sender, e) => Log.Write(sender, $"CellEditing {CellInfo(e)}, Grid.IsEditing: {grid.IsEditing}");
                grid.CellEdited      += (sender, e) => Log.Write(sender, $"CellEdited {CellInfo(e)}, Grid.IsEditing: {grid.IsEditing}");
                var customCell        = new CustomCell();
                customCell.CreateCell = args =>
                {
                    var textBox = new TextBox {
                        ShowBorder = false, BackgroundColor = Colors.Transparent
                    };

                    if (!Platform.Instance.IsMac)
                    {
                        textBox.GotFocus  += (sender, e) => textBox.BackgroundColor = SystemColors.ControlBackground;
                        textBox.LostFocus += (sender, e) => textBox.BackgroundColor = Colors.Transparent;

                        // ugly, there should be a better way to do this..
                        var colorBinding      = textBox.Bind(c => c.TextColor, args, Binding.Property((CellEventArgs a) => a.CellTextColor).Convert(c => args.IsEditing ? SystemColors.ControlText : c));
                        args.PropertyChanged += (sender, e) =>
                        {
                            if (e.PropertyName == nameof(CellEventArgs.IsEditing))
                            {
                                colorBinding.Update();
                            }
                        };
                    }
                    else
                    {
                        // macOS handles colors more automaticcally for a TextBox
                    }

                    textBox.TextBinding.BindDataContext((GridTestItem i) => i.Text);

                    return(textBox);
                };
                AddLogging(customCell);
                grid.Columns.Add(new GridColumn {
                    DataCell = customCell, Editable = true, HeaderText = "CustomTextBox"
                });

                var customCell2        = new CustomCell();
                customCell2.CreateCell = args =>
                {
                    var dropDown = new DropDown {
                        Items = { "Item 1", "Item 2", "Item 3" }
                    };

                    return(dropDown);
                };
                AddLogging(customCell2);
                grid.Columns.Add(new GridColumn {
                    DataCell = customCell2, Editable = true, HeaderText = "CustomDropDown"
                });

                var customCell3        = new CustomCell();
                customCell3.CreateCell = args =>
                {
                    var checkBox = new CheckBox();

                    return(checkBox);
                };
                AddLogging(customCell3);
                grid.Columns.Add(new GridColumn {
                    DataCell = customCell3, Editable = true, HeaderText = "CustomCheckBox"
                });

                grid.Columns.Add(new GridColumn {
                    DataCell = new TextBoxCell(nameof(GridTestItem.Text)), HeaderText = "TextBoxCell", Editable = true
                });

                var list = new TreeGridItemCollection();
                list.Add(new GridTestItem {
                    Text = "Item 1"
                });
                list.Add(new GridTestItem {
                    Text = "Item 2"
                });
                list.Add(new GridTestItem {
                    Text = "Item 3"
                });
                SetDataStore(grid, list);

                // using MouseDown so the buttons don't get focus
                var beginEditButton = new Button {
                    Text = "BeginEdit"
                };
                beginEditButton.MouseDown += (sender, e) =>
                {
                    grid.BeginEdit(1, 0);
                    e.Handled = true;
                };

                var commitEditButton = new Button {
                    Text = "CommitEdit"
                };
                commitEditButton.MouseDown += (sender, e) =>
                {
                    grid.CommitEdit();
                    e.Handled = true;
                };

                var cancelEditButton = new Button {
                    Text = "CancelEdit"
                };
                cancelEditButton.MouseDown += (sender, e) =>
                {
                    grid.CancelEdit();
                    e.Handled = true;
                };

                return(new TableLayout(
                           TableLayout.Horizontal(4, beginEditButton, commitEditButton, cancelEditButton, null),
                           grid
                           ));
            });
        }