public DialogResult ShowDialog(List<HeaderAttrabute> currentHeaders) { List<HeaderAttrabute> displayHeaders = new List<HeaderAttrabute>(); foreach (HeaderAttrabute header in currentHeaders) { if (header.IsShow) { HeaderAttrabute displayHeader = new HeaderAttrabute(); displayHeader.Assign(header); displayHeaders.Add(displayHeader); } } BindDisplayHeaders(displayHeaders); if (ShowDialog() == DialogResult.OK) { foreach (HeaderAttrabute header in currentHeaders) { header.IsShow = displayHeaders.Contains(header); if (!header.IsShow) { displayHeaders.Add(header); } } currentHeaders.Clear(); currentHeaders.AddRange(displayHeaders); } return this.DialogResult; }
public void Assign(HeaderAttrabute another) { this.Name = another.Name; this.Text = another.Text; this.Width = another.Width; this.IsShow = another.IsShow; }
private void FormSetHeader_Load(object sender, EventArgs e) { PropertyInfo[] properties = typeof(ListCardTotal).GetProperties(); List<HeaderAttrabute> totalHeaders = new List<HeaderAttrabute>(); foreach (PropertyInfo property in properties) { object[] attributes = property.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Length > 0) { DescriptionAttribute description = (DescriptionAttribute)attributes[0]; if (description != null) { HeaderAttrabute header = new HeaderAttrabute(); header.Name = property.Name; header.Text = description.Description; header.Width = 80; header.IsShow = true; totalHeaders.Add(header); } } } BindTotalHeaders(totalHeaders); }
private void MoveItemPosition(bool isMoveUp) { if (lbxDisplayField.SelectedIndices.Count > 0) { int selectedIndex = lbxDisplayField.SelectedIndex; bool canWork = isMoveUp ? selectedIndex > 0 : selectedIndex < lbxDisplayField.Items.Count - 1; if (canWork) { HeaderAttrabute temp = new HeaderAttrabute(); temp.Assign(lbxDisplayField.SelectedItem as HeaderAttrabute); List<HeaderAttrabute> source = lbxDisplayField.DataSource as List<HeaderAttrabute>; source.RemoveAt(selectedIndex); if (isMoveUp) selectedIndex--; else selectedIndex++; source.Insert(selectedIndex, temp); lbxDisplayField.DataSource = null; BindDisplayHeaders(source); lbxDisplayField.SelectedIndex = selectedIndex; } } }
private void lbxTotalField_MouseDown(object sender, MouseEventArgs e) { if (e.Clicks == 1 && e.Button == MouseButtons.Left && lbxTotalField.SelectedIndices.Count > 0) { HeaderAttrabute header = new HeaderAttrabute(); header.Name = lbxTotalField.SelectedValue.ToString(); header.Text = lbxTotalField.Text; lbxTotalField.AllowDrop = false; lbxDisplayField.AllowDrop = true; lbxDisplayField.DoDragDrop(header, DragDropEffects.Copy); } }
public override void RestoreToDefault() { LibraryHeadersSetting.Clear(); DeckHeadersSetting.Clear(); PropertyInfo[] properties = typeof(ListCardTotal).GetProperties(); foreach (PropertyInfo property in properties) { object[] attributes = property.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Length > 0) { DescriptionAttribute description = (DescriptionAttribute)attributes[0]; if (description != null) { HeaderAttrabute header = new HeaderAttrabute(); header.Name = property.Name; header.Text = description.Description; header.Width = 80; header.IsShow = true; LibraryHeadersSetting.Add(header); DeckHeadersSetting.Add(header); } } } }