Exemplo n.º 1
0
        public SimpleTableRow()
        {
            RowHeight = 16f;

            GroupItem  = false;
            Selectable = true;

            _cell    = new TextFieldCell();
            DataCell = new Dictionary <string, string>();
        }
        public List <ITreeTableRow> CreateTreeTableRows(List <string> columnIdentifiers)
        {
            var data = new List <ITreeTableRow>();

            var typeCellEnum = Enum.GetValues(typeof(TypeCell)).Cast <int>().ToList();

            var tableRow = new TreeTableRow();

            foreach (var columnIdentifier in columnIdentifiers)
            {
                var tf = new TextFieldCell();
                tf.Text = nameof(TextFieldCell);

                tableRow.Cells.Add(columnIdentifier, tf);
            }


            var children = new List <ITreeTableRow>();

            for (int i = 0; i < typeCellEnum.Count; i++)
            {
                var tr = new TreeTableRow();
                tr.RowHeight = 25;

                foreach (var columnIdentifier in columnIdentifiers)
                {
                    tr.Cells.Add(
                        columnIdentifier,
                        CreateCell(i));
                }
                children.Add(tr);
            }

            tableRow.Children = children;

            data.Add(tableRow);

            return(data);
        }
        private List <ITableRow> CreateDataForCellTable(string[] columnIdentifier, int countRows)
        {
            var list = new List <ITableRow>();

            var typeCellEnum = Enum.GetValues(typeof(TypeCell)).Cast <int>().ToList();
            var rand         = new Random();

            for (int i = 0; i < countRows; i++)
            {
                var tr = new TableRow();
                tr.RowHeight = 25;

                var wasCellTypes = new List <int>();
                foreach (var identifier in columnIdentifier)
                {
                    int cellType = -1;

                    while (true)
                    {
                        cellType = rand.Next(0, typeCellEnum.Count);

                        if (!wasCellTypes.Contains(cellType))
                        {
                            wasCellTypes.Add(cellType);
                            break;
                        }
                    }

                    ICell cell = null;
                    switch (cellType)
                    {
                    case 0:     //TextField
                        var tf = new TextFieldCell();
                        tf.Text = nameof(TextFieldCell);

                        cell = tf;
                        break;

                    case 1:     //TextView
                        var txtv = new TextViewCell();
                        txtv.Text = nameof(TextViewCell) + " change column size";

                        cell = txtv;
                        break;

                    case 2:     //Button
                        var btn = new ButtonCell();
                        btn.Text    = nameof(ButtonCell);
                        btn.Enabled = true;

                        btn.Activated = () => {
                            _alertWindow.ShowAlert(
                                nameof(ButtonCell),
                                "You activeted button",
                                "OK");
                        };

                        cell = btn;
                        break;

                    case 3:     //CheckBox
                        var ckb = new CheckboxCell();
                        ckb.Text            = nameof(CheckboxCell);
                        ckb.AllowMixedState = true;
                        ckb.Enabled         = true;

                        //also can use
                        //ckb.StateChanged += (state) => {};

                        ckb.Activated = () => {
                            var state = string.Empty;

                            if (ckb.State == null)
                            {
                                state = "mixed";
                            }
                            else
                            {
                                state = ckb.State.ToString();
                            }

                            _alertWindow.ShowAlert(
                                nameof(CheckboxCell),
                                "You activeted checkbox. State: " + state,
                                "OK");
                        };

                        cell = ckb;
                        break;

                    case 4:     //PopUp
                        var btnP = new PopUpButtonCell();
                        //popup.Text = nameof(PopUpButtonCell);
                        btnP.Enabled = true;

                        btnP.MenuTitles = new string[] {
                            "Title1", "Title2", "Title3"
                        };

                        //also can use
                        //btnP.SelectItem += (index) => {};

                        btnP.Activated = () => {
                            _alertWindow.ShowAlert(
                                nameof(CheckboxCell),
                                "You activeted checkbox. Selected title: " +
                                btnP.MenuTitles[btnP.IndexOfSelectedItem],
                                "OK");
                        };

                        cell = btnP;
                        break;
                    }

                    tr.Cells.Add(identifier, cell);
                }

                list.Add(tr);
            }

            return(list);
        }
        public ICell CreateCell(int cellType)
        {
            ICell cell = null;

            switch (cellType)
            {
            case 0:     //TextField
                var tf = new TextFieldCell();
                tf.Text = nameof(TextFieldCell);

                cell = tf;
                break;

            case 1:     //TextView
                var txtv = new TextViewCell();
                txtv.Text = nameof(TextViewCell) + " change column size";

                cell = txtv;
                break;

            case 2:     //Button
                var btn = new ButtonCell();
                btn.Text    = nameof(ButtonCell);
                btn.Enabled = true;

                btn.Activated = () => {
                    _alertWindow.ShowAlert(
                        nameof(ButtonCell),
                        "You activeted button",
                        "OK");
                };

                cell = btn;
                break;

            case 3:     //CheckBox
                var ckb = new CheckboxCell();
                ckb.Text            = nameof(CheckboxCell);
                ckb.AllowMixedState = true;
                ckb.Enabled         = true;

                //also can use
                //ckb.StateChanged += (state) => {};

                ckb.Activated = () => {
                    var state = string.Empty;

                    if (ckb.State == null)
                    {
                        state = "mixed";
                    }
                    else
                    {
                        state = ckb.State.ToString();
                    }

                    _alertWindow.ShowAlert(
                        nameof(CheckboxCell),
                        "You activeted checkbox. State: " + state,
                        "OK");
                };

                cell = ckb;
                break;

            case 4:     //PopUp
                var btnP = new PopUpButtonCell();
                //popup.Text = nameof(PopUpButtonCell);
                btnP.Enabled = true;

                btnP.MenuTitles = new string[] {
                    "Title1", "Title2", "Title3"
                };

                //also can use
                //btnP.SelectItem += (index) => {};

                btnP.Activated = () => {
                    _alertWindow.ShowAlert(
                        nameof(CheckboxCell),
                        "You activeted checkbox. Selected title: " +
                        btnP.MenuTitles[btnP.IndexOfSelectedItem],
                        "OK");
                };

                cell = btnP;
                break;
            }


            return(cell);
        }