/* Column Details */ private void HighlightSelectedColumn(ViewListColumn columnSettings) { try { foreach (Label columnLabel in pnlRow.Controls.OfType <Label>()) { ViewListColumn column = (ViewListColumn)columnLabel.Tag; if (column.Index == columnSettings.Index) { columnLabel.BackColor = Color.Yellow; } else { columnLabel.BackColor = pnlRow.BackColor; } } foreach (Label columnLabel in pnlGridHeader.Controls.OfType <Label>()) { ViewListColumn column = (ViewListColumn)columnLabel.Tag; if (column.Index == columnSettings.Index) { columnLabel.BackColor = Color.Yellow; } else { columnLabel.BackColor = pnlRow.BackColor; } } } catch (Exception ex) { ExceptionHandler("Error highlighting column", ex); } }
private void UpdateColumnDetails(ViewListColumn column) { column.Caption = txtCaption.Text.Trim(); column.DataMember = txtDataField.Text.Trim(); column.DataFullPath = txtDataPath.Text.Trim(); column.Format = txtFormat.Text.Trim(); SortType sort; if (Enum.TryParse <SortType>(cboSort.SelectedValue.ToString(), out sort)) { column.SortType = sort; } ContentAlignment alignment; if (Enum.TryParse <ContentAlignment>(cboAlignment.SelectedValue.ToString(), out alignment)) { column.Alignment = alignment; } int width = 0; if (Int32.TryParse(txtWidth.Text, out width)) { column.Width = width; } else { column.Width = null; } }
private Label GetColumnRowLabel(int index) { foreach (Label columnLabel in pnlRow.Controls.OfType <Label>()) { ViewListColumn column = (ViewListColumn)columnLabel.Tag; if (column.Index == index) { return(columnLabel); } } return(null); }
protected virtual Label GetCaptionLabel(ViewListColumn viewListColumn) { Label label = new Label(); label.Size = new Size( viewListColumn.Width.HasValue ? viewListColumn.Width.Value : 100, pnlFields.Height); label.Text = viewListColumn.Caption; label.Name = "lbl" + viewListColumn.DataMember + "Caption"; label.TextAlign = viewListColumn.Alignment; label.ForeColor = _labelForeColor; label.BackColor = _unselectedCaptionBackColor; label.BorderStyle = BorderStyle.None; label.Margin = new Padding(0, 0, 0, 0); label.Tag = viewListColumn; return(label); }
public static Label BuildColumnLabel(ViewListColumn column, bool isHeader = false) { var columnLabel = new Label() { Text = isHeader ? column.Caption : string.Empty, TextAlign = column.Alignment, AutoSize = false, BackColor = Color.FromKnownColor(KnownColor.Control), BorderStyle = BorderStyle.None, Tag = column }; if (column.Width.HasValue) { columnLabel.Size = new Size(column.Width.Value, columnLabel.Height); } return(columnLabel); }
protected virtual Label GetLabel(ViewListColumn viewListColumn) { Label label = new Label(); label.Text = FormatSampleValue( viewListColumn.ConvertedType, viewListColumn.Format, String.IsNullOrEmpty(viewListColumn.Sample) ? viewListColumn.Caption : viewListColumn.Sample); label.Size = new Size( viewListColumn.Width.HasValue ? viewListColumn.Width.Value : 100, pnlFields.Height); label.Name = "lbl" + viewListColumn.DataMember; label.TextAlign = viewListColumn.Alignment; label.ForeColor = _labelForeColor; label.BackColor = _unselectedFieldBackColor; label.BorderStyle = BorderStyle.FixedSingle; label.Margin = new Padding(0, 0, 0, 0); label.Tag = viewListColumn; label.ContextMenuStrip = ctxCaptionLabel; PictureBox pictureBox1 = new PictureBox(); pictureBox1.BackColor = Color.Transparent; pictureBox1.Size = new Size(10, 10); pictureBox1.Location = new Point(label.Width - pictureBox1.Width, label.Height - pictureBox1.Height); pictureBox1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; pictureBox1.Dock = DockStyle.Right; pictureBox1.Cursor = Cursors.SizeWE; pictureBox1.MouseDown += pictureBox1_MouseDown; pictureBox1.MouseMove += pictureBox1_MouseMove; pictureBox1.MouseUp += pictureBox1_MouseUp; label.Controls.Add(pictureBox1); pictureBox1.BringToFront(); ConfigureDragging(label); return(label); }
private void NewColumn() { using (var dialog = new InputDialog( "New Column", "Enter a caption for the new column", "<New Column>")) { if (dialog.ShowDialog(this) != DialogResult.Cancel) { ViewListColumn column = new ViewListColumn(); column.Caption = dialog.Value; column.Index = _selectedViewState.ListSettings.Columns.Count; _selectedViewState.ListSettings.Columns.Add(column); ReloadColumns(); } } }
private void cboViews_SelectedIndexChanged(object sender, EventArgs e) { try { if (_loading) { return; } if (_selectedViewState != null) { UpdateViewState(_selectedViewState); } ClearViewStateDetails(); _selectedViewState = (ViewState)cboViews.SelectedItem; var hasSelection = (_selectedViewState != null); btnNewView.Enabled = true; btnEditSave.Enabled = hasSelection; btnCopyView.Enabled = hasSelection; btnDeleteView.Enabled = hasSelection; _selectedColumn = null; if (_selectedViewState == null) { return; } DisplayViewState(_selectedViewState); } catch (Exception ex) { ExceptionHandler("Error selecting view", ex); } }
protected virtual Label GetCaptionLabel(ViewListColumn viewListColumn) { Label label = new Label(); label.Size = new Size( viewListColumn.Width.HasValue ? viewListColumn.Width.Value : 100, pnlFields.Height); label.Text = viewListColumn.Caption; label.Name = "lbl" + viewListColumn.DataMember + "Caption"; label.TextAlign = viewListColumn.Alignment; label.ForeColor = _labelForeColor; label.BackColor = _unselectedCaptionBackColor; label.BorderStyle = BorderStyle.FixedSingle; label.Margin = new Padding(0, 0, 0, 0); label.Tag = viewListColumn; label.ContextMenuStrip = ctxCaptionLabel; label.DoubleClick += (s, e) => { SetUIEditState(false, viewListColumn.Index); }; return(label); }
private void CopyColumn() { using (var dialog = new InputDialog( "Copy Column", "Enter a name for the new column", $"Copy of {_selectedColumn.Caption}")) { if (dialog.ShowDialog(this) != DialogResult.Cancel) { ViewListColumn column = new ViewListColumn(); column.Caption = dialog.Value; column.Index = _selectedViewState.ListSettings.Columns.Count; UpdateColumnDetails(column); _selectedViewState.ListSettings.Columns.Add(column); ReloadColumns(); } } }
private void ClearColumnDetails() { btnCopyColumn.Enabled = false; btnNewColumn.Enabled = false; btnDeleteColumn.Enabled = false; btnMoveLeft.Enabled = false; btnMoveRight.Enabled = false; ClearChildControls(pnlGridHeader); ClearChildControls(pnlRow); txtCaption.Clear(); txtDataField.Clear(); txtWidth.Clear(); txtFormat.Clear(); txtIndex.Clear(); txtDataPath.Clear(); cboAlignment.SelectedIndex = -1; cboSort.SelectedIndex = -1; _selectedColumn = null; }
protected virtual Label GetLabel(ViewListColumn viewListColumn) { Label label = new Label(); label.Text = FormatSampleValue( viewListColumn.ConvertedType, viewListColumn.Format, String.IsNullOrEmpty(viewListColumn.Sample) ? viewListColumn.Caption : viewListColumn.Sample); label.Size = new Size( viewListColumn.Width.HasValue ? viewListColumn.Width.Value : 100, pnlFields.Height); label.Name = "lbl" + viewListColumn.DataMember; label.TextAlign = viewListColumn.Alignment; label.ForeColor = _labelForeColor; label.BackColor = _unselectedFieldBackColor; label.BorderStyle = BorderStyle.None; label.Margin = new Padding(0, 0, 0, 0); label.Tag = viewListColumn; return(label); }
private void DisplayColumnDetails(ViewListColumn column) { if (_selectedColumn != null) { UpdateColumnDetails(_selectedColumn); } _selectedColumn = column; txtCaption.Text = column.Caption; txtDataField.Text = column.DataMember; txtDataPath.Text = column.DataFullPath; txtWidth.Text = column.Width.HasValue ? column.Width.Value.ToString() : String.Empty; txtFormat.Text = column.Format; cboAlignment.SelectedItem = column.Alignment; txtIndex.Text = column.Index.ToString(); cboSort.SelectedItem = column.SortType; btnCopyColumn.Enabled = true; btnNewColumn.Enabled = true; btnDeleteColumn.Enabled = true; btnMoveLeft.Enabled = true; btnMoveRight.Enabled = true; }
private void SelectColumn(ViewListColumn columnSettings) { HighlightSelectedColumn(columnSettings); DisplayColumnDetails(columnSettings); }