private void mouseMove(object sender, MouseEventArgs e) { if (_control.IsDragging()) { Hide?.Invoke(); return; } _control.GetTabIndex(e.Location, out int hoveredIndex, out bool hoveredClose); var model = new TooltipModel { Id = "tab", Control = _control, Text = "Add tab: Ctrl+T or click '+' button\r\n" + "Remove tab: Ctrl + F4 or click 'x' button or Middle mouse click\r\n" + "Select next tab: Ctrl + Tab\r\n\r\n" + "Drag tab headers to reorder tabs.\r\n\r\n" + "Move the tab to another window by dragging it to another window title.\r\n\r\n" + "Drag the card here to select or create another tab where you want to drop the card." }; if ((hoveredIndex < 0 || hoveredIndex >= _control.Count) && hoveredIndex != _control.AddButtonIndex) { model.ObjectBounds = new Rectangle(default, _control.Size);
private void UC_Action_Hide(object sender, RoutedEventArgs e) { if (Hide != null) { Hide?.Invoke(sender, e); } }
private void UnClicked() { if (!_active) { return; } Hide.Invoke(); _active = false; }
private void mouseMove(object sender, MouseEventArgs e) { if (_view.IsSelectingText()) { Hide?.Invoke(); } else { showFieldTooltip(Cursor.Position); } }
public void OnShowOrHide(bool item) { if (item) { Show?.Invoke(); } else { Hide?.Invoke(); } }
public void hide() { try { if (Hide != null) { Hide.Invoke(this, EventArgs.Empty); } } catch (Exception exc) { ToolMobile.setRuntimeMsg(exc.ToString()); } }
private void BRD_Action_Tapped(object sender, TappedRoutedEventArgs e) { IsSelected = !IsSelected; SetImage(); if (IsSelected) { if (Show != null) { Show?.Invoke(this, e); } } else { if (Hide != null) { Hide?.Invoke(this, e); } } }
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 }); } } }
private void mouseLeave(object sender, EventArgs e) { Hide?.Invoke(); }
private void FadeStep() { switch (state) { case FadingState.Show: if (!visible) { visible = true; Show?.Invoke(); opacity = 0; ChangeOpacity?.Invoke(this, opacity); } else if (opacity < ShownMinus) { opacity += StepIn; ChangeOpacity?.Invoke(this, opacity); } else if (opacity != Shown) { opacity = Shown; ChangeOpacity?.Invoke(this, Shown); StartStopTimer(FadingState.Idle); } break; case FadingState.ShowTransparent: if (!visible) { visible = true; Show?.Invoke(); opacity = 0; ChangeOpacity?.Invoke(this, opacity); } else if (opacity < TransparentMinus) { opacity += StepIn; ChangeOpacity?.Invoke(this, opacity); } else if (opacity > TransparentPlus) { opacity -= StepOut; ChangeOpacity?.Invoke(this, opacity); } else if (opacity != Transparent) { ChangeOpacity?.Invoke(this, Transparent); StartStopTimer(FadingState.Idle); } break; case FadingState.Hide: if (opacity > StepOut) { opacity -= StepOut; ChangeOpacity?.Invoke(this, opacity); } else if (visible) { opacity = 0; ChangeOpacity?.Invoke(this, opacity); visible = false; Hide?.Invoke(); StartStopTimer(FadingState.Idle); } break; case FadingState.Idle: default: StartStopTimer(FadingState.Idle); break; } }
public void OnHide() { Hide?.Invoke(); }
private void LoginClicked(object sender, RoutedEventArgs e) { Hide?.Invoke(this, EventArgs.Empty); }
private void mouseMove(object sender, MouseEventArgs e) { var command = _control.GetCommand(e.Location, MouseButtons.None); if (!command.HasValue) { Hide?.Invoke(); return; } var property = _control.Properties[command.Value.ButtonIndex]; if (string.IsNullOrEmpty(property)) { Hide?.Invoke(); return; } var bounds = _control.GetPaintingRectangle(command.Value.ButtonIndex, command.Value.ClickedState); var model = new TooltipModel { Id = "qf." + property, Control = _control, ObjectBounds = bounds, Cursor = bounds.Center(), Text = property, PositionPreference = getPositionPreference }; Show?.Invoke(model); Func <ExtremumFinder <TooltipPosition>, ExtremumFinder <TooltipPosition> > getPositionPreference(Rectangle target) { Func <TooltipPosition, int> verticalDistanceFrom(Rectangle t) => c => { int dy = c.Bounds.CenterY() - t.CenterY(); return(PreferTooltipFromTop ? Math.Abs((-dy).MultiplyIfNegative(1.5f)) : Math.Abs(dy.MultiplyIfNegative(1.5f))); }; Func <TooltipPosition, int> horizontalDistanceFrom(Rectangle t) => c => { int dx = c.Bounds.CenterX() - t.CenterX(); return(PreferTooltipFromLeft ? Math.Abs((-dx).MultiplyIfNegative(1.5f)) : Math.Abs(dx.MultiplyIfNegative(1.5f))); }; if (PreferHorizontalShift) { return(_ => _ .ThenAtMin(verticalDistanceFrom(target)) .ThenAtMin(c => PreferTooltipFromLeft ? c.Bounds.X : -c.Bounds.X)); } else { return(_ => _ .ThenAtMin(horizontalDistanceFrom(target)) .ThenAtMin(c => PreferTooltipFromTop ? c.Bounds.Y : -c.Bounds.Y)); } } }
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(); } }
private void showFieldTooltip(Point position) { var cursorPosition = _view.PointToClient(position); var hitInfo = _view.CalcHitInfo(cursorPosition); var dataSource = _view.FindRow(hitInfo.RowHandle); if (!hitInfo.AlignButtonDirection.HasValue && (dataSource == null || !hitInfo.FieldBounds.HasValue)) { Hide?.Invoke(); return; } 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) { throw new NotSupportedException(); } if (hitInfo.CustomButtonIndex >= 0) { var tooltip = new TooltipModel { Id = $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.", ObjectBounds = hitInfo.ButtonBounds, Control = _view, Clickable = false }; if (hitInfo.CustomButtonIndex == DeckListLayout.CustomButtonAdd) { tooltip.Id += "add"; tooltip.Text = "Save this deck"; } else if (hitInfo.CustomButtonIndex == DeckListLayout.CustomButtonRemove) { tooltip.Id += "remove"; tooltip.Title = "Remove this deck"; tooltip.Text = "Removes this deck from the list.\r\n" + "NOTE: be careful, you cannot undo this."; } else if (hitInfo.CustomButtonIndex == DeckListLayout.CustomButtonRename) { tooltip.Id += "rename"; tooltip.Text = "Rename this deck"; } else if (hitInfo.CustomButtonIndex == DeckListLayout.CustomButtonOpen) { tooltip.Id += "open"; tooltip.Title = "Open this deck"; tooltip.Text = "Relaces currently opened deck with this one"; } else { throw new NotSupportedException(); } Show?.Invoke(tooltip); } else 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 (hitInfo.FieldName != null) { Show?.Invoke(new TooltipModel { Id = $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}", ObjectBounds = hitInfo.FieldBounds.Value, Control = _view, Title = hitInfo.FieldName, Text = _view.GetText(hitInfo.RowHandle, hitInfo.FieldName), HighlightRanges = _view.GetHighlihgtTextRanges(hitInfo.RowHandle, hitInfo.FieldName), HighlightOptions = _view.ProbeCard.HighlightOptions, Clickable = true }); } } }
private void showFieldTooltip(Point position) { var cursorPosition = _view.PointToClient(position); var hitInfo = _view.CalcHitInfo(cursorPosition); var dataSource = _view.FindRow(hitInfo.RowHandle); if (!hitInfo.AlignButtonDirection.HasValue && (dataSource == null || !hitInfo.FieldBounds.HasValue)) { Hide?.Invoke(); return; } 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) { _log.Error("Search button tooltip is not supported in DeckList layout view"); return; } if (hitInfo.CustomButtonIndex >= 0) { var tooltip = new TooltipModel { Id = $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}.", ObjectBounds = hitInfo.ButtonBounds, Control = _view, Clickable = false }; if (hitInfo.IsAddButton()) { tooltip.Id += "add"; tooltip.Text = "Save this deck"; } else if (hitInfo.IsRemoveButton()) { tooltip.Id += "remove"; tooltip.Title = "Remove this deck"; tooltip.Text = "Removes this deck from the list.\r\n" + "NOTE: be careful, you cannot undo this."; } else if (hitInfo.IsRenameButton()) { tooltip.Id += "rename"; tooltip.Text = "Rename this deck"; } else if (hitInfo.IsOpenButton()) { tooltip.Id += "open"; tooltip.Title = "Open deck"; tooltip.Text = "Open the deck in it's original form as it was edited and saved.\r\n\r\n" + "Left-click to open in this tab, currently opened deck will be replaced.\r\n" + "Middle-click to open in new tab.\r\n\r\n"; } else if (hitInfo.IsOpenTransformedButton()) { tooltip.Id += "open_transformed"; tooltip.Title = "Open transformed deck"; tooltip.Text = "Transformed deck uses cards from your collection and cards with known price whenever possible.\r\n\r\n" + "Left-click to open in this tab, currently opened deck will be replaced.\r\n" + "Middle-click to open in new tab.\r\n\r\n"; } else { return; } Show?.Invoke(tooltip); } else 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 (hitInfo.FieldName != null) { Show?.Invoke(new TooltipModel { Id = $"{_view.Name}.{hitInfo.RowHandle}.{hitInfo.FieldName}", ObjectBounds = hitInfo.FieldBounds.Value, Control = _view, Title = hitInfo.FieldName, Text = _view.GetText(hitInfo.RowHandle, hitInfo.FieldName), HighlightRanges = _view.GetHighlightTextRanges(hitInfo.RowHandle, hitInfo.FieldName), HighlightOptions = _view.HighlightOptions, Clickable = true }); } } }