public static void SaveFormState(Form frm, string title, ViewModelBase vm = null) { string profileName = (frm.GetType().FullName + "_" + title + (vm == null ? "" : vm.GetType().FullName)); FormState profile = new FormState { WindowState = frm.WindowState, Location = frm.Location, Size = frm.Size }; LocalUserProfile.Save(ClientInfo.CurrentUser.UserName, profileName, profile); }
private void bOK_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; var query = from bar in flowLayoutPanel1.Controls.OfType <AdvFilterBar>() let f = bar.GetFilter() where f.HasValue select f.Value; if (!query.Any()) { Result = null; return; } string filter = '(' + string.Join(") AND (", query.Select(f => f.Key).ToArray()) + ')'; var parms = query.Select(f => f.Value).ToArray(); Result = new KeyValuePair <string, SqlParameter[]>(filter, parms); #region 保存过滤 #if !DEBUG try { #endif var queryFilter = from bar in flowLayoutPanel1.Controls.OfType <AdvFilterBar>() where bar.GetFilter().HasValue select new FilterProfile { SelectedField = bar.cmbField.SelectedValue.ToString(), NotChecked = bar.cNot.Checked, SelectedOperator = bar.cmbOperator.SelectedValue.ToString(), ValueObject = bar.GetValueEditorValue(), }; LocalUserProfile.Save(ClientInfo.CurrentUser.UserName, _listForm.GetType().FullName + "_AdvFilter", queryFilter.ToArray()); #if !DEBUG } catch { } #endif #endregion }