예제 #1
0
        private static Rectangle getFieldBounds(FieldControl field, LayoutControl card)
        {
            var fieldBounds = field.Bounds;

            fieldBounds.Offset(card.Location);
            return(fieldBounds);
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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)));
        }
예제 #5
0
 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;
     }
 }
예제 #6
0
        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));
        }
예제 #7
0
 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();
 }
예제 #8
0
        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;
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        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));
            }
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        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));
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
 public override IEnumerable <ButtonLayout> GetCustomButtons(FieldControl field) =>
 DeckListLayoutCustomButtons.GetCustomButtons(
     base.GetCustomButtons(field),
     field,
     (DeckModel)DataSource);
예제 #17
0
 public virtual bool ShowSortButton(FieldControl field) =>
 IsHotTracked && field.AllowSort && (field.IsHotTracked || field.SortOrder != SortOrder.None);
예제 #18
0
 private void fieldInvalidated(FieldControl field) =>
 Invalid?.Invoke(this, field);
예제 #19
0
 private void invalidateField(FieldControl field, LayoutControl card)
 {
     Invalidate(new Rectangle(field.Location.Plus(card.Location), field.Size));
 }
예제 #20
0
 public bool IsButtonVisible(FieldControl field)
 {
     return(Allow && field.AllowSort && (field.IsHotTracked || field.SortOrder != SortOrder.None));
 }
예제 #21
0
        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);
        }
예제 #22
0
 public bool IsButtonVisible(LayoutControl card, FieldControl field) =>
 Allow && card.ShowSortButton(field);