public static void LoadFormState(Form frm, string title, ViewModelBase vm = null) { string profileName = (frm.GetType().FullName + "_" + title + (vm == null ? "" : vm.GetType().FullName)); FormState profile = LocalUserProfile.GetProfile <FormState>(ClientInfo.CurrentUser.UserName, profileName); if (profile != null) { frm.WindowState = profile.WindowState; if (frm.WindowState != FormWindowState.Maximized) { frm.StartPosition = FormStartPosition.Manual; frm.Location = profile.Location; frm.Size = profile.Size; } } }
private void AdvFilterForm_Load(object sender, EventArgs e) { #region 加载保存的过滤 #if !DEBUG try { #endif FilterProfile[] profile = LocalUserProfile.GetProfile <FilterProfile[]>(ClientInfo.CurrentUser.UserName, _listForm.GetType().FullName + "_AdvFilter"); if (profile != null) { flowLayoutPanel1.Controls.Clear(); foreach (FilterProfile p in profile) { AdvFilterBar bar = new AdvFilterBar { Name = "bf" + _filterCount++, DataSource = _dataSource, }; bar.Load += (object s, EventArgs ea) => { AdvFilterBar b = (AdvFilterBar)s; b.cmbField.SelectedValue = p.SelectedField; b.cNot.Checked = p.NotChecked; b.cmbOperator.SelectedValue = p.SelectedOperator; if (b.ValueEditor is DateTimePicker dtp) { dtp.Value = Convert.ToDateTime(p.ValueObject); } else if (b.ValueEditor is RadioButton r) { if (Convert.ToBoolean(p.ValueObject)) { r.Checked = true; } else { ((RadioButton)b.Controls[r.Name + 1]).Checked = true; } } else if (b.ValueEditor is NumericUpDown n) { n.Value = Convert.ToDecimal(p.ValueObject); } else if (b.ValueEditor is TextBox t) { t.Text = p.ValueObject.ToString(); } }; this.flowLayoutPanel1.Controls.Add(bar); } } #if !DEBUG } catch { } #endif #endregion }