Example #1
0
        private ComboBoxCell CreateDatabindingComboBoxCell(ComboBoxCell comboBoxCell)
        {
            CategoriesResult result         = null;
            CategorySearch   categorySearch = new CategorySearch();

            categorySearch.CompanyId    = CompanyId;
            categorySearch.CategoryType = 4;

            var task = ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CategoryMasterClient>();

                result = await service.GetItemsAsync(SessionKey, categorySearch);
            });

            ProgressDialog.Start(ParentForm, task, false, SessionKey);

            if (result.ProcessResult.Result)
            {
                CategoryList = result.Categories;

                comboBoxCell.DataSource    = new BindingSource(CategoryList, null);
                comboBoxCell.DisplayMember = nameof(Category.Name);
                comboBoxCell.ValueMember   = nameof(Category.Id);
            }

            return(comboBoxCell);
        }
        private Cell ErrorLogDestinationComboCell(ComboBoxCell errorlogdestinationcomboBoxCell)
        {
            errorlogdestinationcomboBoxCell.DataSource    = new BindingSource(GetErrorLogSource(), null);
            errorlogdestinationcomboBoxCell.DisplayMember = "Value";
            errorlogdestinationcomboBoxCell.ValueMember   = "Key";

            return(errorlogdestinationcomboBoxCell);
        }
        public ComboBoxCell GetComboBoxCell(MultiRowContentAlignment align = MultiRowContentAlignment.MiddleLeft)
        {
            var cell = new ComboBoxCell();

            cell.FlatStyle     = FlatStyle.Flat;
            cell.DropDownStyle = MultiRowComboBoxStyle.DropDownList;
            cell.Style         = GetDefaultCellStyle(align);
            return(cell);
        }
Example #4
0
        /// <summary>ComboBoxCell For CapturePattern</summary>
        /// <param name="cell">ComboBoxCell</param>
        /// <returns>Binded ComboBoxCell</returns>
        private ComboBoxCell GetMasterBoundComboBox(ComboBoxCell cell)
        {
            var fileSettings = GetUseableEBFileSettings().ToDictionary(x => x.Id, x => x.Name);

            if (!fileSettings.Any())
            {
                return(cell);
            }
            cell.DataSource    = new BindingSource(fileSettings, null);
            cell.DisplayMember = "Value";
            cell.ValueMember   = "Key";
            return(cell);
        }
Example #5
0
        public void AddComboColumn(string caption, int width, bool autoSize, object[] items)
        {
            var cell = new ComboBoxCell(Columns.Count);

            cell.DataStore = items;

            GridColumn column = new GridColumn();

            column.HeaderText = caption;
            column.DataCell   = cell;
            column.AutoSize   = autoSize;
            column.Width      = width;
            column.Editable   = true;
            Columns.Add(column);
        }
        private Cell ImportModeComboBoxCell(ComboBoxCell importmodecomboBoxCell)
        {
            var importMode = new Dictionary <string, string>
            {
                { "0", "上書" },
                { "1", "追加" },
                { "2", "更新" },
            };

            importmodecomboBoxCell.DataSource    = new BindingSource(importMode, null);
            importmodecomboBoxCell.DisplayMember = "Value";
            importmodecomboBoxCell.ValueMember   = "Key";

            return(importmodecomboBoxCell);
        }
Example #7
0
        public static GridColumn AddDropDownColumn <T>(this GridView view, Func <T, object> value, IEnumerable <object> dataStore, IIndirectBinding <string> textBinding, string header, bool editable = false)
        {
            var  internalBinding = Binding.Delegate(value);
            Cell cell;

            // hack for eto/gtk not supporting ItemTextBinding on ComboBoxCells
            if (Platform.Instance.IsGtk)
            {
                const char zws = '\u200B'; // This is a zero width (ZWS) space Unicode character.

                var lDataStore = dataStore.ToList();

                var tDataStore = lDataStore.Select(i =>
                                                   string.Empty.PadLeft(lDataStore.IndexOf(i) + 1, zws) // Pad with index+1 ZWS chars to be able to check later. If no ZWS is there, this did not work.
                                                   + textBinding.GetValue(i))
                                 .ToList();
                var hasNonUnique = tDataStore.Distinct().Count() != tDataStore.Count; // Check if textBinding produced the same string for more than one data item.

                var binding = Binding.Delegate <T, string>(
                    (T s) => textBinding.GetValue(internalBinding.GetValue(s)),
                    (T t, string s) =>
                {
                    int idx = s.Split(zws).Length - 2;
                    if (idx == -1)
                    {
                        idx = tDataStore.IndexOf(s);     // Fallback if ZWS is not supported.
                        if (hasNonUnique)
                        {
                            throw new Exception("ComboBoxCell ComboTextBinding Polyfill: Duplicate text entry encountered and Zero-Width-Space Hack not supported by platform!");
                        }
                    }

                    internalBinding.SetValue(t, lDataStore[idx]);
                }).Cast <object>();

                cell = new ComboBoxCell {
                    Binding = binding, DataStore = tDataStore
                };
            }
            else
            {
                cell = new ComboBoxCell {
                    Binding = internalBinding, DataStore = dataStore, ComboTextBinding = textBinding
                }
            };

            return(view.AddColumn(cell, header, editable));
        }
Example #8
0
            public MyGridItem(Random rand, int row, ComboBoxCell dropDown)
            {
                // initialize to random values
                this.Row = row;
                var val = rand.Next(3);

                check = val == 0 ? (bool?)false : val == 1 ? (bool?)true : null;

                val   = rand.Next(3);
                Image = val == 0 ? (Image)image1 : val == 1 ? (Image)image2 : null;

                text = string.Format("Col 1 Row {0}", row);

                val         = rand.Next(dropDown.DataStore.Count + 1);
                dropDownKey = val == 0 ? null : dropDown.DataStore [val - 1].Key;
            }
Example #9
0
        ComboBoxCell MyDropDown(string bindingProperty)
        {
            var combo = new ComboBoxCell(bindingProperty);
            var items = new ListItemCollection();

            items.Add(new ListItem {
                Text = "Item 1"
            });
            items.Add(new ListItem {
                Text = "Item 2"
            });
            items.Add(new ListItem {
                Text = "Item 3"
            });
            items.Add(new ListItem {
                Text = "Item 4"
            });
            combo.DataStore = items;
            return(combo);
        }
Example #10
0
        ComboBoxCell MyDropDown(string bindingProperty)
        {
            var combo = new ComboBoxCell(bindingProperty);

            combo.DataStore = new ListItemCollection
            {
                new ListItem {
                    Text = "Item 1"
                },
                new ListItem {
                    Text = "Item 2"
                },
                new ListItem {
                    Text = "Item 3"
                },
                new ListItem {
                    Text = "Item 4"
                }
            };
            return(combo);
        }
Example #11
0
        private void InitGrid()
        {
            // "00/00/0000"

            var clmCell = new ComboBoxCell();

            clmCell.DataStore = fFields;
            clmCell.Binding   = Binding.Property <FilterConditionRow, object>(r => r.ColumnText);

            Columns.Add(new GridColumn {
                DataCell   = clmCell,
                HeaderText = LangMan.LS(LSID.LSID_Field),
                Width      = 200,
                Editable   = true
            });

            var condCell = new ComboBoxCell();

            condCell.DataStore = GKData.CondSigns;
            condCell.Binding   = Binding.Property <FilterConditionRow, object>(r => r.ConditionText);

            Columns.Add(new GridColumn {
                DataCell   = condCell,
                HeaderText = LangMan.LS(LSID.LSID_Condition),
                Width      = 150,
                Editable   = true
            });

            Columns.Add(new GridColumn {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <FilterConditionRow, string>(r => r.ValueText)
                },
                HeaderText = LangMan.LS(LSID.LSID_Value),
                Width      = 300,
                Editable   = true
            });
        }
        private async Task SetDataGridViewAsync()
        {
            if (string.IsNullOrEmpty(txtPatternNumber.Text))
            {
                return;
            }
            if (code == "")
            {
                code = txtPatternNumber.Text;
            }
            var comboYear         = new List <Setting>();
            var comboToroku       = new List <Setting>();
            var comboExternalCode = new List <Setting>();

            ImporterSettingDetailsResult result = null;
            await ServiceProxyFactory.DoAsync <ImporterSettingServiceClient>(async client
                                                                             => result = await client.GetDetailByCodeAsync(SessionKey, CompanyId, FormatId, code));

            Action <ComboBoxCell, List <Setting> > comboboxCellSetter = (cmb, items) =>
            {
                if (items.Count > 0)
                {
                    cmb.DataSource    = items.Select(x => new { x.ItemKey, x.ItemValue }).ToArray();
                    cmb.DisplayMember = nameof(Setting.ItemValue);
                    cmb.ValueMember   = nameof(Setting.ItemKey);
                }
            };
            await ServiceProxyFactory.DoAsync <SettingMasterClient>(async client =>
            {
                var settingListResult = await client.GetItemsAsync(SessionKey, new string[] { "ATTR1", "ATTR3", "ATTR6" });
                comboYear             = settingListResult.Settings.Where(x => x.ItemId == "ATTR1").ToList();
                comboToroku           = settingListResult.Settings.Where(x => x.ItemId == "ATTR3").ToList();
                comboExternalCode     = settingListResult.Settings.Where(x => x.ItemId == "ATTR6").ToList();
            });

            code = "";
            if (result.ImporterSettingDetails.Count == 0)
            {
                return;
            }
            var detailCurrencyCode = result.ImporterSettingDetails.FirstOrDefault(d => d.Sequence == (int)Fields.CurrencyCode);

            grid.CellEditedFormattedValueChanged -= grid_CellEditedFormattedValueChanged;
            grid.CellValueChanged -= grid_CellValueChanged;
            Invoke(new System.Action(() =>
            {
                ComboBoxCell comboAttribute = null;
                grid.RowCount = result.ImporterSettingDetails.Count;
                for (int i = 0; i < result.ImporterSettingDetails.Count; i++)
                {
                    var detail = result.ImporterSettingDetails[i];
                    var field  = (Fields)detail.Sequence;
                    var row    = grid.Rows[i];
                    row.Cells[CellIndexRowHeader].Value      = i + 1;
                    row.Cells[CellIndexFieldName].Value      = detail.FieldName;
                    row.Cells[CellIndexImportDivision].Value = detail.ImportDivision;
                    row.Cells[CellIndexCaption].Value        = detail.Caption;
                    row.Cells[CellIndexSequence].Value       = detail.Sequence;

                    row.Cells[CellIndexImportDivision].Enabled = IsImportDivisionEnabled(field);
                    comboAttribute        = (ComboBoxCell)row.Cells[CellIndexAttribute];
                    var fieldIndexEnabled = IsFieldIndexEnabled(detail);
                    row.Cells[CellIndexFieldIndex].Enabled = fieldIndexEnabled;
                    row.Cells[CellIndexCaption].Enabled    = fieldIndexEnabled;
                    if (fieldIndexEnabled && detail.FieldIndex > 0)
                    {
                        row.Cells[CellIndexFieldIndex].Value = detail.FieldIndex;
                    }

                    var priorityEnabled = IsItemPriorityEnabled(detail);
                    row.Cells[CellIndexPriority].Enabled       = priorityEnabled;
                    row.Cells[CellIndexAssendingOrder].Enabled = priorityEnabled;
                    if (priorityEnabled && detail.FieldIndex > 0)
                    {
                        row.Cells[CellIndexPriority].Value       = detail.FieldIndex;
                        row.Cells[CellIndexAssendingOrder].Value = detail.ItemPriority;
                    }
                    row.Cells[CellIndexAttribute].Enabled = IsAttributeEnabled(detail);
                    if (IsDateAttribute(field))
                    {
                        comboboxCellSetter(comboAttribute, comboYear);
                        comboAttribute.Value = detail.AttributeDivision;
                    }
                    if (IsStringAttribute(field))
                    {
                        comboboxCellSetter(comboAttribute, comboToroku);
                        comboAttribute.Value = detail.AttributeDivision;
                    }
                    if (IsExternalCodeAttribute(field))
                    {
                        comboboxCellSetter(comboAttribute, comboExternalCode);
                        comboAttribute.Value = detail.AttributeDivision;
                    }
                }

                if (UseForeignCurrency)
                {
                    var rowIndex = GetGridRowIndex(Fields.CurrencyCode);
                    if (rowIndex != -1)
                    {
                        grid.Rows[rowIndex].Cells[CellIndexImportDivision].Value   = true;
                        grid.Rows[rowIndex].Cells[CellIndexImportDivision].Enabled = false;
                        grid.Rows[rowIndex].Cells[CellIndexFieldIndex].Enabled     = true;
                        if (detailCurrencyCode.FieldIndex == 0)
                        {
                            grid.Rows[rowIndex].Cells[CellIndexFieldIndex].Value = null;
                        }
                        else
                        {
                            grid.Rows[rowIndex].Cells[CellIndexFieldIndex].Value = detailCurrencyCode.FieldIndex;
                        }
                        grid.Rows[rowIndex].Cells[CellIndexCaption].Value          = detailCurrencyCode.Caption;
                        grid.Rows[rowIndex].Cells[CellIndexCaption].Enabled        = true;
                        grid.Rows[rowIndex].Cells[CellIndexPriority].Enabled       = false;
                        grid.Rows[rowIndex].Cells[CellIndexAssendingOrder].Enabled = false;
                        grid.Rows[rowIndex].Cells[CellIndexAttribute].Enabled      = false;
                    }
                }
            }));
            grid.CellEditedFormattedValueChanged += grid_CellEditedFormattedValueChanged;
            grid.CellValueChanged += grid_CellValueChanged;

            ColumnNameSettingsResult colResult = null;
            await ServiceProxyFactory.DoAsync <ColumnNameSettingMasterClient>(async client
                                                                              => colResult = await client.GetItemsAsync(Login.SessionKey, Login.CompanyId));

            if (colResult.ProcessResult.Result)
            {
                var names = colResult.ColumnNames.Where(x => x.TableName == nameof(Billing)).ToList();
                if (names.Count > 0)
                {
                    foreach (var setting in names)
                    {
                        var rowIndex = -1;
                        switch (setting.ColumnName)
                        {
                        case nameof(Billing.Note1): rowIndex = GetGridRowIndex(Fields.Note1); break;

                        case nameof(Billing.Note2): rowIndex = GetGridRowIndex(Fields.Note2); break;

                        case nameof(Billing.Note3): rowIndex = GetGridRowIndex(Fields.Note3); break;

                        case nameof(Billing.Note4): rowIndex = GetGridRowIndex(Fields.Note4); break;

                        case nameof(Billing.Note5): rowIndex = GetGridRowIndex(Fields.Note5); break;

                        case nameof(Billing.Note6): rowIndex = GetGridRowIndex(Fields.Note6); break;

                        case nameof(Billing.Note7): rowIndex = GetGridRowIndex(Fields.Note7); break;

                        case nameof(Billing.Note8): rowIndex = GetGridRowIndex(Fields.Note8); break;

                        default: continue;
                        }
                        if (rowIndex != -1)
                        {
                            grid.Rows[rowIndex].Cells[CellIndexFieldName].Value
                                = setting.DisplayColumnName;
                        }
                    }
                }
            }
        }