Esempio n. 1
0
        public List<RowEntity> GenReflectElements()
        {
            List<RowEntity> list = new List<RowEntity>();
            if (this.Entity == null)
            {
                this.Entity = System.Activator.CreateInstance<T>();
            }
            int index = 1;
            Type type = typeof(T);
            foreach (PropertyInfo pi in type.GetProperties())
            {
                if (this.ignoreFields.Contains(pi.Name))
                {
                    continue;
                }
                RowEntity row = new RowEntity();
                list.Add(row);
                object[] objs = pi.GetCustomAttributes(typeof(DescriptionAttribute), true);
                string descName = objs.Length > 0 ? ((DescriptionAttribute)objs[0]).Description : pi.Name;
                row.Key = pi.Name;
                row.Name = descName;
                row.Value = pi.GetValue(this.Entity, null) ?? string.Empty;
                row.Index = index++;
                row.Type = ControlType.TEXT_BOX;
                if (pi.PropertyType == typeof(DateTime))
                {
                    row.Type = ControlType.DATE_TIME;
                }
                row.DataType = pi.PropertyType;

            }
            return list;
        }
Esempio n. 2
0
        public void Form_Load(object sender, EventArgs e)
        {
            List <RowEntity> rowList = new List <RowEntity>();
            int   j = 0;
            float f = 100F / this.testCase.StepList.Count;

            this.tableLayoutPanel2.RowStyles[0].Height = f;
            this.Height = this.firstHeight + rowHeght * this.testCase.StepList.Count;
            this.tableLayoutPanel2.RowCount = this.testCase.StepList.Count;
            for (int i = 1; i < this.testCase.StepList.Count; i++)
            {
                this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, f));
            }
            int index = 1;

            foreach (var step in this.testCase.StepList)
            {
                RowEntity rowEntity = new RowEntity();
                rowEntity.DisplayMember = "Model";
                rowEntity.Name          = step.Name;
                List <object> stepDevList = this.deviceList.Where(s => s.AgentType.Equals(step.AgentType)).ToList <object>();
                UCRowComboBox row         = new UCRowComboBox(rowEntity, stepDevList);
                row.IsHideThirdRow = true;
                if (this.testCase.StepList.Count == index)
                {
                    row.ComBoxDockStyle = DockStyle.Top;
                }
                else
                {
                    row.ComBoxDockStyle = DockStyle.Bottom;
                }
                index++;
                this.tableLayoutPanel2.Controls.Add(row, 0, j++);
            }
        }
Esempio n. 3
0
        public UCProjectRowComboBox(RowEntity row, List <object> list)
        {
            InitializeComponent();
            this.row                  = row;
            this.Dock                 = DockStyle.Fill;
            this.label1.Text          = row.Name + ":";
            this.comboBox1.DataSource = list;
            if (row.Value != null)
            {
                this.comboBox1.Text = row.Value.ToString();
            }
            else if (list.Count > 0)
            {
                this.comboBox1.SelectedIndex = 0;
            }
            this.comboBox1.DisplayMember = row.DisplayMember;

            if (list.Count == 1)
            {
                this.comboBox1.Dock = DockStyle.Top;
                this.label1.Dock    = DockStyle.Top;
            }
            else
            {
                this.comboBox1.Dock = DockStyle.Bottom;
            }
        }
Esempio n. 4
0
 public UCProjectRowComboBox(RowEntity row)
 {
     InitializeComponent();
     this.row         = row;
     this.Dock        = DockStyle.Fill;
     this.label1.Text = row.Name + ":";
 }
Esempio n. 5
0
 private void GetStepDevice(Control control)
 {
     if (control is UCRowComboBox)
     {
         UCRowComboBox row    = control as UCRowComboBox;
         RowEntity     entity = row.GetRow();
         if (entity.Value != null)
         {
             Step step = this.testCase.StepList.Where(s => s.Name == entity.Name).FirstOrDefault();
             if (step != null)
             {
                 TestDevice testDevice = (TestDevice)entity.Value;
                 step.TestDeviceId    = testDevice.Id;
                 step.TestDeviceModel = testDevice.Model;
             }
         }
     }
     else if (control.HasChildren)
     {
         foreach (Control item in control.Controls)
         {
             GetStepDevice(item);
         }
     }
 }
Esempio n. 6
0
 public UCRowDateTime(RowEntity row)
 {
     InitializeComponent();
     this.Dock                 = DockStyle.Fill;
     this.label1.Text          = row.Name + ":";
     this.dateTimePicker1.Text = row.Value.ToString();
     this.row = row;
 }
Esempio n. 7
0
 public UCRowTextBox(RowEntity row)
 {
     InitializeComponent();
     this.Dock          = DockStyle.Fill;
     this.label1.Text   = row.Name + ":";
     this.textBox1.Text = row.Value.ToString();
     this.row           = row;
 }
Esempio n. 8
0
 public void DisplayDirectory(FileSystemNode node)
 {
     Blank();
     TryGetFiles(node.FullPath)?.ToList().ForEach(f => {
         var add = new RowEntity();
         add.TrySetMember(Column(0).BindName, f);
         AddRow(add);
     });
 }
Esempio n. 9
0
        private void FillTableList(List <List <object> > queryResult)
        {
            tableListOperator.Blank();
            queryResult.ForEach(row => {
                var addRow = new RowEntity();
                addRow.TrySetMember(@"TableName", row[0].ToString());
                tableListOperator.AddRow(addRow);
            });

            tableListOperator.Refresh();
        }
Esempio n. 10
0
 private void CellChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     try {
         DataGrid  senderObj = sender as DataGrid;
         RowEntity senderRow = senderObj.SelectedItem as RowEntity;
         object    path      = null;
         if (senderRow.TryGetMember(@"FileName", out path))
         {
             text.Text = path as string;
         }
     }
     catch (Exception ex) {
         Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
     }
 }
        public TableLayoutPanel AddOrRemoveRows(RowEntity entity)
        {
            int listSize = entity.List.Count;
            int rowCount = _layout.RowCount;

            if (entity.Operation == RowEnum.Add && listSize > rowCount)
            {
                AddRow(listSize - rowCount);
            }
            else if (entity.Operation == RowEnum.Delete && listSize < rowCount)
            {
                RemoveRows(rowCount - listSize);
            }
            _layout.AutoScroll = true;
            return(_layout);
        }
Esempio n. 12
0
            public void DisplayNode(NodeEntity arg)
            {
                Blank();
                foreach (AttributeEntity a in arg.GetAttrList())
                {
                    RowEntity add = new RowEntity();
                    add.TrySetMember(Column(0).GetBindName(), a.GetAttrName());
                    add.TrySetMember(Column(1).GetBindName(), a.GetAttrValue());
                    AddRow(add);
                }
                RowEntity nodeValue = new RowEntity();

                nodeValue.TrySetMember(Column(0).GetBindName(), @"Node Value");
                nodeValue.TrySetMember(Column(1).GetBindName(), arg.GetNodeValue());
                AddRow(nodeValue);
                Refresh();
            }
Esempio n. 13
0
            public void DisplayDirectory(FileSystemNode arg)
            {
                Blank();
                IEnumerable <string> files = TryGetFiles(arg.GetPath());

                if (files == null)
                {
                    return;
                }
                foreach (string item in files)
                {
                    RowEntity add = new RowEntity();
                    add.TrySetMember(Column(0).GetBindName(), item);
                    AddRow(add);
                }
                Refresh();
            }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            _list.Add("row " + _list.Count);
            RowEntity row = new RowEntity();

            row.List      = _list;
            row.Operation = RowEnum.Add;
            TableLayoutPanel   temp    = (TableLayoutPanel)pnlTableHolder.Controls[0];
            DynamicTableHelper control = new DynamicTableHelper(temp);

            temp = control.AddOrRemoveRows(row);
            pnlTableHolder.Controls.Remove(tblMain);
            pnlTableHolder.Controls.Add(temp);
            //we will get the no. of rows directly from  the table
            //to ascertain that rows have been added correctly
            lblRowCount.Text = "No. of rows " + temp.RowCount;
        }
 public void Show(SqliteAccessor accessor)
 {
     if (0 == accessor.QueryResultAttributes.Count || 0 == accessor.QueryResult.Count)
     {
         return;
     }
     accessor.QueryResultAttributes.ForEach(a => dataGridOperator.AddColumn(a.Item1, a.Item1));
     dataGridOperator.CreateColumns();
     accessor.QueryResult.ForEach(row => {
         var addRow = new RowEntity();
         for (var i = 0; accessor.QueryResultAttributes.Count > i; ++i)
         {
             addRow.TrySetMember(accessor.QueryResultAttributes[i].Item1,
                                 accessor.IsBlobColumn(accessor.QueryResultAttributes, i) ? @"[Blob data]" : row[i]);
         }
         dataGridOperator.AddRow(addRow);
     });
     dataGridOperator.Refresh();
 }
Esempio n. 16
0
        public override async Task <List <RowEntity> > GetEntityData(int count, int skip)
        {
            using var connection = _connectionFactory.Create();
            var sql = $"SELECT * FROM {Name}";

            SqlCommand command = new SqlCommand(
                sql,
                connection);

            connection.Open();

            using SqlDataReader reader = await command.ExecuteReaderAsync();

            var result = new List <RowEntity>();

            int fieldCount = reader.FieldCount;

            while (reader.HasRows)
            {
                // Console.WriteLine("\t{0}\t{1}", reader.GetName(0),
                //     reader.GetName(1));

                var rowResult = new RowEntity();
                result.Add(rowResult);

                while (reader.Read())
                {
                    for (int i = 0; i < fieldCount; i++)
                    {
                        rowResult.Columns.Add(new Field()
                        {
                            Name  = reader.GetName(i),
                            Value = reader.GetValue(i)?.ToString()
                        });
                    }
                }
                reader.NextResult();
            }

            return(result);
        }
Esempio n. 17
0
 public bool ReadUI()
 {
     List<RowEntity> list = new List<RowEntity>();
     if (this.Entity == null)
     {
         this.Entity = System.Activator.CreateInstance<T>();
     }
     foreach (Control control in this.tableLayoutPanel1.Controls)
     {
         if (control is UCRowTextBox)
         {
             UCRowTextBox uc = control as UCRowTextBox;
             RowEntity entity = uc.GetRow();
             if (entity == null)
             {
                 return false;
             }
             list.Add(entity);
         }
         else if (control is UCRowComboBox)
         {
             UCRowComboBox uc = control as UCRowComboBox;
             RowEntity entity = uc.GetRow();
             if (entity == null)
             {
                 return false;
             }
             list.Add(entity);
         }
         else if (control is UCRowDateTime)
         {
             UCRowDateTime uc = control as UCRowDateTime;
             RowEntity entity = uc.GetRow();
             if (entity == null)
             {
                 return false;
             }
             list.Add(entity);
         }
     }
     Type type = typeof(T);
     foreach (RowEntity inst in list)
     {
         foreach (PropertyInfo pi in type.GetProperties())
         {
             if (this.ignoreFields.Contains(pi.Name))
             {
                 continue;
             }
             if (inst.Key == pi.Name)
             {
                 if (inst.DataType.IsEnum)
                 {
                     Type t = inst.DataType;
                     pi.SetValue(this.Entity, (int)(Enum.Parse(t, inst.Value.ToString())), null);
                 }
                 else
                 {
                     pi.SetValue(this.Entity, inst.Value, null);
                 }
                 break;
             }
         }
     }
     return true;
 }
Esempio n. 18
0
 public void AddRow(RowEntity row)
 {
     rows.Add(row);
 }