Example #1
0
        private void materialFlatButton1_Click(object sender, EventArgs e)
        {
            var model = new VirtualHost();
            //listVirtualHostForm.Add(newItem);var dialog = new VirtualHostManager.Forms.VirtualHostDetail();
            var dialog = new VirtualHostManager.Forms.VirtualHostDetail();

            dialog.formType     = VirtualHostDetailType.Edit;
            dialog.Url          = "";
            dialog.Directory    = "";
            dialog.CreateAt     = "";
            dialog.Description  = "";
            dialog.Context      = dataStorageService.VirualHostTemplateRead(AppConst.VirtualHostTemplate);
            dialog.Status       = true;
            dialog.saveCallback = () =>
            {
                model.Url         = dialog.Url;
                model.Directory   = dialog.Directory;
                model.CreateAt    = DateTime.Now.ToString();
                model.UpdateAt    = DateTime.Now.ToString();
                model.Description = dialog.Description;
                model.Context     = dialog.Context;
                model.Status      = dialog.Status;
                model.Author      = dialog.Author;
                context.data.Add(model);
                //Rebind the Datagridview with the data.
                RebindGridForPageChange();
                setItems();
            };
            using (Panel p = this.blurPanel())
            {
                dialog.ShowDialog();
            }
        }
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
        }