private static Rectangle getFieldBounds(FieldControl field, LayoutControl card) { var fieldBounds = field.Bounds; fieldBounds.Offset(card.Location); return(fieldBounds); }
private Bitmap getIcon(FieldControl field) { if (field.IsSortHotTracked) { switch (field.SortOrder) { case SortDirection.No: return(Icon); case SortDirection.Asc: return(AscIcon); case SortDirection.Desc: return(DescIcon); default: throw new ArgumentOutOfRangeException(); } } switch (field.SortOrder) { case SortDirection.No: return(IconTransp); case SortDirection.Asc: return(AscIconTransp); case SortDirection.Desc: return(DescIconTransp); default: throw new ArgumentOutOfRangeException(); } }
public override IEnumerable <ButtonLayout> GetCustomButtons(FieldControl field) { var deckModel = (DeckModel)DataSource; var baseResult = base.GetCustomButtons(field); if (field != _fieldName) { return(baseResult); } var list = baseResult.ToList(); if (deckModel.IsCurrent) { //foreach (var btn in list) // btn.Margin = new Size(24, 0); list[CustomButtonRemove].Size = Size.Empty; list[CustomButtonOpen].Size = Size.Empty; } else { list[CustomButtonAdd].Size = Size.Empty; } return(list); }
public bool IsButtonVisible(FieldControl field) { var fieldOptions = field.SearchOptions.Button; var generalOptions = Button; return(Allow && field.SearchOptions.Allow && ( field.IsHotTracked || !(fieldOptions.ShowOnlyWhenHotTracked ?? generalOptions.ShowOnlyWhenHotTracked ?? true))); }
private void updateSort(FieldControl field) { if (field.FieldName != null && _sortIndexByField.TryGetValue(field.FieldName, out int sortIndex)) { field.SortOrder = _sortInfos[sortIndex].SortOrder; } else { field.SortOrder = SortOrder.None; } }
public ButtonLayout GetButtonLayout(FieldControl field) { if (!field.AllowSort || !field.IsSortVisible) { return(new ButtonLayout(type: ButtonType.Sort)); } var icon = getIcon(field); return(new ButtonLayout(icon, ButtonMargin, ButtonAlignment, breaksLayout: false, type: ButtonType.Sort)); }
public void CopyFrom(FieldControl other) { Location = other.Location; Size = other.Size; Font = other.Font; BackColor = other.BackColor; ForeColor = other.ForeColor; HorizontalAlignment = other.HorizontalAlignment; IconRecognizer = other.IconRecognizer; SearchOptions = other.SearchOptions.Clone(); CustomButtons = other.CustomButtons.Select(_ => _.Clone()).ToList(); }
internal void SetField(FieldControl field, bool isSortButton, bool isSearchButton, int customButtonIndex, Rectangle?buttonBounds) { if (field != null && Card == null) { throw new InvalidOperationException($"{nameof(Card)} must be set first"); } Field = field; FieldBounds = field?.Bounds.Plus(Card.Bounds.Location); FieldName = field?.FieldName; IsSortButton = isSortButton; IsSearchButton = isSearchButton; CustomButtonIndex = customButtonIndex; ButtonBounds = buttonBounds ?? Rectangle.Empty; }
private void paintFieldBg(PaintEventArgs e, FieldControl field, Rectangle fieldArea, SolidBrush hotTrackBgBrush, Pen hotTrackBgPen) { var rect = new Rectangle(fieldArea.Location, new Size(fieldArea.Width - 1, fieldArea.Height - 1)); if (field.IsHotTracked) { e.Graphics.FillRectangle(hotTrackBgBrush, rect); e.Graphics.DrawRectangle(hotTrackBgPen, rect); } else if (!field.BackColor.Equals(BackColor) && !field.BackColor.Equals(Color.Transparent)) { var bgBrush = new SolidBrush(field.BackColor); e.Graphics.FillRectangle(bgBrush, rect); } }
private void cardInvalidated(LayoutControl layoutControl, FieldControl fieldControl) { Rectangle rect; if (fieldControl != null) { rect = fieldControl.Bounds; rect.Offset(layoutControl.Location); } else { rect = layoutControl.Bounds; } Invalidate(rect); }
private void paintButtons(PaintEventArgs e, FieldControl field, LayoutControl card) { var fieldBounds = getFieldBounds(field, card); var buttons = card.GetFieldButtons(field, SearchOptions, SortOptions).ToList(); buttons.LayOutIn(fieldBounds); foreach (var button in buttons) { if (button.Size == Size.Empty || button.Icon == null) { continue; } e.Graphics.DrawImage(button.Icon, button.Location); } }
public virtual IEnumerable <ButtonLayout> GetCustomButtons(FieldControl field) { for (int i = 0; i < field.CustomButtons.Count; i++) { var button = field.CustomButtons[i]; if (!field.IsHotTracked && (button.ShowOnlyWhenHotTracked ?? true)) { continue; } var icon = field.HotTrackedCustomButtonIndex == i ? button.Icon : button.IconTransp; yield return(new ButtonLayout(icon, button.Margin, button.Alignment, button.BreaksLayout)); } }
public IEnumerable <ButtonLayout> GetFieldButtons(FieldControl field, SearchOptions searchOptions, SortOptions sortOptions) { // usually the visual order will be reversed because default alignment is top-right if (field.IsSortVisible) { yield return(sortOptions.GetButtonLayout(field)); } if (field.IsSearchVisible) { yield return(searchOptions.GetButtonLayout(field)); } foreach (var buttonLayout in GetCustomButtons(field)) { yield return(buttonLayout); } }
public ButtonLayout GetButtonLayout(FieldControl field) { if (!field.SearchOptions.Allow || !field.IsSearchVisible) { return(new ButtonLayout(type: ButtonType.Search)); } var fieldOptions = field.SearchOptions.Button; var generalOptions = Button; var icon = field.IsSearchHotTracked ? fieldOptions.Icon ?? generalOptions.Icon : fieldOptions.IconTransp ?? generalOptions.IconTransp; var buttonAlignment = fieldOptions.Alignment ?? generalOptions.Alignment; var buttonMargin = fieldOptions.Margin ?? generalOptions.Margin; var breaksLayout = fieldOptions.BreaksLayout ?? generalOptions.BreaksLayout; return(new ButtonLayout(icon, buttonMargin, buttonAlignment, breaksLayout, ButtonType.Search)); }
private void paintFieldData(PaintEventArgs e, LayoutControl card, FieldControl field, Rectangle fieldArea, int rowHandle) { if (CustomDrawField != null) { var customFieldArgs = new CustomDrawArgs { RowHandle = rowHandle, Graphics = e.Graphics, Bounds = fieldArea, FieldName = field.FieldName, Handled = false, Font = field.Font, ForeColor = field.ForeColor, DisplayText = field.DataText, HAlignment = field.HorizontalAlignment, Selection = _selection }; CustomDrawField.Invoke(this, customFieldArgs); if (!customFieldArgs.Handled) { field.PaintSelf( e.Graphics, card.Location, card.HighlightOptions, _selection, SelectionOptions); } } else { field.PaintSelf( e.Graphics, card.Location, card.HighlightOptions, _selection, SelectionOptions); } }
public override IEnumerable <ButtonLayout> GetCustomButtons(FieldControl field) => DeckListLayoutCustomButtons.GetCustomButtons( base.GetCustomButtons(field), field, (DeckModel)DataSource);
public virtual bool ShowSortButton(FieldControl field) => IsHotTracked && field.AllowSort && (field.IsHotTracked || field.SortOrder != SortOrder.None);
private void fieldInvalidated(FieldControl field) => Invalid?.Invoke(this, field);
private void invalidateField(FieldControl field, LayoutControl card) { Invalidate(new Rectangle(field.Location.Plus(card.Location), field.Size)); }
public bool IsButtonVisible(FieldControl field) { return(Allow && field.AllowSort && (field.IsHotTracked || field.SortOrder != SortOrder.None)); }
public static IEnumerable <ButtonLayout> GetCustomButtons(IEnumerable <ButtonLayout> baseResult, FieldControl field, DeckModel deckModel) { if (!Str.Equals(field.FieldName, nameof(DeckModel.Saved))) { return(baseResult); } var list = baseResult.ToList(); if (deckModel.IsCurrent) { list[CustomButtonRemove].Size = Size.Empty; list[CustomButtonOpen].Size = Size.Empty; list[CustomButtonOpenTransformed].Size = Size.Empty; } else { list[CustomButtonAdd].Size = Size.Empty; } return(list); }
public bool IsButtonVisible(LayoutControl card, FieldControl field) => Allow && card.ShowSortButton(field);