Example #1
0
        /// <summary>
        /// Shows available objects.
        /// </summary>
        private void ShowObjects()
        {
            // create table columns
            List <DataGridViewColumn> columns = new ColumnBuilder(configBase).CreateColumns(typeof(Obj)).ToList();

            columns.ForEach(column => column.ReadOnly = true);
            columns.Insert(0, new DataGridViewCheckBoxColumn
            {
                Name             = "Selected",
                HeaderText       = AppPhrases.SelectedColumn,
                DataPropertyName = "Selected",
                SortMode         = DataGridViewColumnSortMode.Automatic
            });

            // prepare table data
            HashSet <int> objNumSet = ObjNums == null ?
                                      new HashSet <int>() :
                                      new HashSet <int>(ObjNums);

            objects = new List <SelectableObject>();

            foreach (Obj obj in configBase.ObjTable.Items.Values)
            {
                objects.Add(new SelectableObject(obj)
                {
                    Selected = objNumSet.Contains(obj.ObjNum)
                });
            }

            // display data
            if (ScadaUtils.IsRunningOnMono)
            {
                bindingSource.DataSource = objects;
                dataGridView.Columns.AddRange(columns.ToArray());
            }
            else
            {
                dataGridView.Columns.AddRange(columns.ToArray());
                bindingSource.DataSource = objects;
            }

            dataGridView.AutoSizeColumns();
        }