Example #1
0
        private void setItems()
        {
            //flowLayoutPanel1.Controls.Clear();
            var items = context.data;

            listVirtualHostForm = new BindingList <VirtualHost>();
            items.ForEach(x =>
            {
                //flowLayoutPanel1.Controls.Add(newItem);
                listVirtualHostForm.Add(x);
            });
            dataGridView1.DataSource = items;
            PagesCount  = Convert.ToInt32(Math.Ceiling(items.Count * 1.0 / pageRows));
            CurrentPage = 1;
            RefreshPagination();
            RebindGridForPageChange();

            var columnConfig = dataStorageService.Read <VirtualHostDataGridViewColumns>(AppConst.VirtualHostColumns);

            if (columnConfig == null)
            {
                columnConfig = new VirtualHostDataGridViewColumns()
                {
                    Author      = true,
                    CreateAt    = true,
                    Description = true,
                    Directory   = true,
                    ErrorLogs   = true,
                    Status      = true,
                    UpdateAt    = true,
                    Url         = true,
                };
            }
            var list = columnConfig.GetType()
                       .GetProperties()
                       .Select(x => new { Name = x.Name, Value = (bool)x.GetValue(columnConfig) })
                       .ToList();

            list.ForEach(x =>
            {
                dataGridView1.Columns[x.Name + "DataGridViewTextBoxColumn"].Visible = x.Value;
            });
        }
Example #2
0
        public SettingForm()
        {
            InitializeComponent();

            dataStorageService = new DataStorageService();

            #region Init config column
            hostDataGridViewColumns = dataStorageService.Read <VirtualHostDataGridViewColumns>(AppConst.VirtualHostColumns);
            if (hostDataGridViewColumns == null)
            {
                hostDataGridViewColumns = new VirtualHostDataGridViewColumns()
                {
                    Author      = true,
                    CreateAt    = true,
                    Description = true,
                    Directory   = true,
                    ErrorLogs   = true,
                    Status      = true,
                    UpdateAt    = true,
                    Url         = true,
                };
            }

            var list = hostDataGridViewColumns.GetType()
                       .GetProperties()
                       .Select(x => new { Name = x.Name, Value = (bool)x.GetValue(hostDataGridViewColumns) })
                       .ToList();
            list.ForEach(x =>
            {
                checkedListBox1.Items.Add(x.Name);
                checkedListBox1.SetItemChecked(checkedListBox1.Items.Count - 1, x.Value);
            });
            #endregion

            #region Init virtual host template
            virtualHostTemplateTxt.Text = dataStorageService.VirualHostTemplateRead(AppConst.VirtualHostTemplate);
            #endregion
        }