Example #1
0
        private static (int CountDelta, bool IsDeck) getChange(HitInfo hitInfo, MouseEventArgs e)
        {
            int countDelta = DeckEditorButtons.GetCountDelta(hitInfo.CustomButtonIndex);

            if (countDelta != 0)
            {
                return(countDelta, DeckEditorButtons.IsDeck(hitInfo.CustomButtonIndex));
            }

            int deltaAbs = (Control.ModifierKeys & Keys.Control) > 0
                                ? 4
                                : 1;

            bool isDeck = (Control.ModifierKeys & Keys.Alt) == 0;

            if (e.Button == MouseButtons.Middle)
            {
                return(-deltaAbs, isDeck);
            }

            if (e.Button == MouseButtons.Right)
            {
                return(+deltaAbs, isDeck);
            }

            return(0, true);
        }
Example #2
0
 private static void scaleLayoutView(LayoutViewControl view)
 {
     view.ScaleDpi(
         bmp => bmp.HalfResizeDpi(),
         transformSearchIcon: bmp => bmp.HalfResizeDpi(), transformCustomButtonIcon: (bmp, field, i) =>
     {
         int delta   = DeckEditorButtons.GetCountDelta(i);
         bool isDeck = DeckEditorButtons.IsDeck(i);
         return(bmp.HalfResizeDpi(preventMoire: isDeck && Math.Abs(delta) == 1));
     });
 }
Example #3
0
        private void probeCardCreating(object view, LayoutControl probeCard)
        {
            probeCard.ScaleDpi();

            foreach (var field in probeCard.Fields)
            {
                field.SearchOptions.Button.Icon = field.SearchOptions.Button.Icon?.HalfResizeDpi();

                for (int i = 0; i < field.CustomButtons.Count; i++)
                {
                    var button = field.CustomButtons[i];

                    int  delta  = DeckEditorButtons.GetCountDelta(i);
                    bool isDeck = DeckEditorButtons.IsDeck(i);

                    button.Icon = button.Icon?.HalfResizeDpi(preventMoire: isDeck && Math.Abs(delta) == 1);
                }
            }

            ((CardLayoutControlBase)probeCard).Ui = _formRoot.UiModel;
        }
Example #4
0
        private void showFieldTooltip(Point position)
        {
            var cursorPosition = _layoutView.Control.PointToClient(position);
            var hitInfo        = _layoutView.CalcHitInfo(cursorPosition);

            var card = (Card)_layoutView.FindRow(hitInfo.RowHandle);

            if (!hitInfo.AlignButtonDirection.HasValue && (card == null || hitInfo.IsOverImage() || !hitInfo.FieldBounds.HasValue))
            {
                Hide?.Invoke();
                return;
            }

            if (hitInfo.IsSortButton)
            {
                Show?.Invoke(new TooltipModel
                {
                    Id           = $"{_layoutView.Control.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.sort",
                    ObjectBounds = hitInfo.ButtonBounds,
                    Control      = _layoutView.Control,
                    Title        = "Sort by " + hitInfo.FieldName,
                    Text         =
                        "Click to sort by this field.\r\n" +
                        "\r\n" +
                        "Shift+Click to ADD this field to sorting. Currently sorted fields will have higher sort priority.\r\n" +
                        "\r\n" +
                        "Ctrl+Click to REMOVE this field from sorting. Other fields sort order will remain unchanged.\r\n" +
                        "\r\n" +
                        "Repeated click on sort button cycles sort order between Ascending, Descending, None.\r\n" +
                        "\r\n" +
                        "Hold Alt key when hovering to prevent showing this button. Helps selecting text in small fields.",
                    Clickable = false
                });
            }
            else
            {
                if (hitInfo.IsSearchButton)
                {
                    string text;
                    string title;
                    string query = _cardSearchSubsystem.GetFieldValueQuery(hitInfo.FieldName, _layoutView.GetFieldText(hitInfo.RowHandle, hitInfo.FieldName));

                    if (hitInfo.FieldName == nameof(Card.Image))
                    {
                        title = "Search similar cards";
                        text  = "Click to search cards similar to this one.\r\n" +
                                "Similarity is determined by Text and GeneratedMana fields.\r\n" +
                                "\r\n" +
                                "Following term will be added to search text\r\n" +
                                query;
                    }
                    else
                    {
                        title = "Add to search";
                        text  = "Click to EXTEND search result by cards matching this value\r\n" +
                                "Shift+Click to NARROW DOWN search result by cards matching this value\r\n" +
                                "\r\n" +
                                "Following term will be added to search text\r\n" +
                                query + "\r\n" +
                                "\r\n" +
                                "Hold Alt key when hovering to prevent showing this button. Helps selecting text in small fields.";
                    }


                    Show?.Invoke(new TooltipModel
                    {
                        Id           = $"{_layoutView.Control.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.search",
                        ObjectBounds = hitInfo.ButtonBounds,
                        Control      = _layoutView.Control,
                        Title        = title,
                        Text         = text,
                        Clickable    = false
                    });
                }
                else if (hitInfo.CustomButtonIndex >= 0)
                {
                    bool isDeck   = DeckEditorButtons.IsDeck(hitInfo.CustomButtonIndex);
                    int  delta    = DeckEditorButtons.GetCountDelta(hitInfo.CustomButtonIndex);
                    int  absDelta = Math.Abs(delta);

                    Show?.Invoke(new TooltipModel
                    {
                        Id           = $"{_layoutView.Control.Name}.{hitInfo.RowHandle}.{hitInfo.CustomButtonIndex}",
                        ObjectBounds = hitInfo.ButtonBounds,
                        Control      = _layoutView.Control,
                        Title        = $"{(delta > 0 ? "Add" : "Remove")} {absDelta} card{(absDelta == 1 ? string.Empty : "s")} {(delta > 0 ? "to" : "from")} {(isDeck ? "Deck" : "Collection")}",
                        Text         = $"{(absDelta == 1 ? string.Empty : "Ctrl + ")}{(isDeck ? string.Empty : "Alt + ")}{(delta > 0 ? "Right" : "Middle")} " +
                                       "mouse click on card image does the same",
                        Clickable = false
                    });
                }
                else if (hitInfo.AlignButtonDirection.HasValue)
                {
                    Show?.Invoke(new TooltipModel
                    {
                        Id           = $"{_layoutView.Control.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.align",
                        ObjectBounds = _layoutView.GetAlignButtonBounds(hitInfo),
                        Control      = _layoutView.Control,
                        Title        = "Viewport alignment",
                        Text         = "Aligns viewport by this corner.\r\n" +
                                       "\r\n" +
                                       "If this corner would be truncated\r\n" +
                                       "viewport will shift to fit it into the screen.",
                        Clickable = false
                    });
                }
                else
                {
                    Show?.Invoke(new TooltipModel
                    {
                        Id               = $"{_layoutView.Control.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}",
                        ObjectBounds     = hitInfo.FieldBounds.Value,
                        Control          = _layoutView.Control,
                        Title            = hitInfo.FieldName,
                        Text             = _layoutView.GetFieldTooltipText(hitInfo.RowHandle, hitInfo.FieldName),
                        HighlightRanges  = _layoutView.GetHighlightRanges(hitInfo.RowHandle, hitInfo.FieldName),
                        HighlightOptions = _layoutView.GetHighlightSettings(),
                        Clickable        = true
                    });
                }
            }
        }
Example #5
0
        private void showFieldTooltip(Point position)
        {
            var cursorPosition = _view.PointToClient(position);
            var hitInfo        = _view.CalcHitInfo(cursorPosition);

            if (hitInfo.AlignButtonDirection.HasValue)
            {
                Show?.Invoke(new TooltipModel
                {
                    Id =
                        $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.align",
                    ObjectBounds = _view.GetAlignButtonBounds(hitInfo),
                    Control      = _view,
                    Title        = "Viewport alignment",
                    Text         = "Aligns viewport by this corner.\r\n" +
                                   "\r\n" +
                                   "If this corner would be truncated\r\n" +
                                   "viewport will shift to fit it into the screen.",
                    Clickable = false
                });
            }
            else if (_countInput.IsCountRectangle(hitInfo, cursorPosition, out var countRect))
            {
                Show?.Invoke(new TooltipModel
                {
                    Id           = $"{_view.Name}.{hitInfo.RowHandle}.edit_count",
                    ObjectBounds = countRect,
                    Control      = _view,
                    Title        = "Edit count",
                    Text         =
                        "Left click here: set count in deck\r\n" +
                        "Alt + Left click here: set count in collection\r\n" +
                        "When editing, Tab / Shift + Tab: switch to next / previous card\r\n\r\n" +
                        "Right click: add 1 to deck\r\n" +
                        "Middle click: remove 1 from deck\r\n" +
                        "Alt + Right click: add 1 to collection\r\n" +
                        "Alt + Middle click: remove 1 from collection\r\n" +
                        "Ctrl + any above shortcut: add/remove 4 cards instead of 1\r\n\r\n" +
                        "Note: clicks work anywhere inside card, not necessarily at the count label",
                    Clickable = false
                });
            }
            else if (hitInfo.IsSortButton)
            {
                Show?.Invoke(new TooltipModel
                {
                    Id           = $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.sort",
                    ObjectBounds = hitInfo.ButtonBounds,
                    Control      = _view,
                    Title        = "Sort by " + hitInfo.FieldName,
                    Text         =
                        "Click to sort by this field.\r\n" +
                        "\r\n" +
                        "Shift+Click to ADD this field to sorting. Currently sorted fields will have higher sort priority.\r\n" +
                        "\r\n" +
                        "Ctrl+Click to REMOVE this field from sorting. Other fields sort order will remain unchanged.\r\n" +
                        "\r\n" +
                        "Repeated click on sort button cycles sort order between Ascending, Descending, None.\r\n" +
                        "\r\n" +
                        "Hold Alt key when hovering to prevent showing this button. Helps selecting text in small fields.",
                    Clickable = false
                });
            }
            else if (hitInfo.IsSearchButton)
            {
                string text;
                string title;
                string query = _cardSearchSubsystem.GetFieldValueQuery(
                    hitInfo.FieldName,
                    _view.GetText(hitInfo.RowHandle, hitInfo.FieldName));

                if (hitInfo.FieldName == nameof(Card.Image))
                {
                    title = "Search similar cards";
                    text  = "Click to search cards similar to this one.\r\n" +
                            "Similarity is determined by Text and GeneratedMana fields.\r\n" +
                            "\r\n" +
                            "Following term will be added to search bar\r\n" +
                            query;
                }
                else
                {
                    title = "Add to search";
                    text  =
                        "Click to NARROW DOWN search result by cards matching this value\r\n\r\n" +
                        "Following term will be added to search bar\r\n" +
                        query + "\r\n\r\n" +
                        "Hold Alt key when hovering to prevent showing this button. Helps selecting text in small fields.";
                }

                Show?.Invoke(new TooltipModel
                {
                    Id =
                        $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.search",
                    ObjectBounds = hitInfo.ButtonBounds,
                    Control      = _view,
                    Title        = title,
                    Text         = text,
                    Clickable    = false
                });
            }
            else if (hitInfo.CustomButtonIndex >= 0)
            {
                bool isDeck   = DeckEditorButtons.IsDeck(hitInfo.CustomButtonIndex);
                int  delta    = DeckEditorButtons.GetCountDelta(hitInfo.CustomButtonIndex);
                int  absDelta = Math.Abs(delta);

                Show?.Invoke(new TooltipModel
                {
                    Id           = $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.CustomButtonIndex}",
                    ObjectBounds = hitInfo.ButtonBounds,
                    Control      = _view,
                    Title        = $"{(delta > 0 ? "Add" : "Remove")} {absDelta} card{(absDelta == 1 ? string.Empty : "s")} {(delta > 0 ? "to" : "from")} {(isDeck ? "Deck" : "Collection")}",
                    Text         =
                        $"{(absDelta == 1 ? string.Empty : "Ctrl + ")}{(isDeck ? string.Empty : "Alt + ")}{(delta > 0 ? "Right" : "Middle")} " +
                        "mouse click on card image does the same",
                    Clickable = false
                });
            }
            else if (
                hitInfo.RowDataSource != null &&
                hitInfo.FieldBounds.HasValue &&
                !Str.Equals(hitInfo.FieldName, nameof(Card.Image)))
            {
                Show?.Invoke(new TooltipModel
                {
                    Id =
                        $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}",
                    ObjectBounds     = hitInfo.FieldBounds.Value,
                    Control          = _view,
                    Title            = hitInfo.FieldName,
                    Text             = getFieldTooltipText(hitInfo.RowHandle, hitInfo.FieldName),
                    HighlightRanges  = _view.GetHighlightTextRanges(hitInfo.RowHandle, hitInfo.FieldName),
                    HighlightOptions = _view.HighlightOptions,
                    Clickable        = true
                });
            }
            else
            {
                Hide?.Invoke();
            }
        }