Making the tooltips have markdown and context help
This commit is contained in:
parent
15e83d6cbe
commit
15d39d297d
6 changed files with 57 additions and 42 deletions
|
|
@ -213,6 +213,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private static GuiWidget MatterControlToolTipWidget(string toolTipText)
|
||||
{
|
||||
var toolTipPopover = new ClickablePopover(ArrowDirection.Up, new BorderDouble(0, 0), 7, 0);
|
||||
|
||||
var markdownWidegt = new MarkdownWidget(Theme)
|
||||
{
|
||||
HAnchor = HAnchor.Absolute,
|
||||
|
|
@ -225,8 +227,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
markdownWidegt.Markdown = toolTipText;
|
||||
markdownWidegt.Width = 350;
|
||||
var firstParagraph = markdownWidegt.Descendants<ParagraphX>().First();
|
||||
markdownWidegt.Width = firstParagraph.MaxLineWidth + 30;
|
||||
var maxLineWidth = markdownWidegt.Descendants<ParagraphX>().Max(i => i.MaxLineWidth);
|
||||
markdownWidegt.Width = maxLineWidth + 30;
|
||||
|
||||
return markdownWidegt;
|
||||
}
|
||||
|
|
@ -825,7 +827,10 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
await sceneContext.Scene.AutoArrangeChildren(new Vector3(sceneContext.BedCenter)).ConfigureAwait(false);
|
||||
},
|
||||
IsEnabled = (sceneContext, widget) => sceneContext.EditableScene && sceneContext.Scene.VisibleMeshes().Any(),
|
||||
IsEnabled = (sceneContext, widget) =>
|
||||
{
|
||||
return sceneContext.EditableScene && sceneContext.Scene.VisibleMeshes().Any();
|
||||
},
|
||||
Icon = (invertIcon) => AggContext.StaticData.LoadIcon("arrange_all.png", 16, 16, invertIcon).SetPreMultiply(),
|
||||
},
|
||||
new SceneSelectionOperation()
|
||||
|
|
@ -848,12 +853,14 @@ namespace MatterHackers.MatterControl
|
|||
},
|
||||
IsEnabled = (sceneContext, widget) =>
|
||||
{
|
||||
var enabled = sceneContext.Scene.SelectedItem != null;
|
||||
|
||||
if (widget != null)
|
||||
{
|
||||
widget.ToolTipText = widget.Enabled ? "Lay Flat\nSelect Object to Enable" : "Lay Flat";
|
||||
widget.ToolTipText = enabled ? "Lay Flat".Localize() : "Lay Flat\n\n*At least 1 part must be selected*".Localize();
|
||||
}
|
||||
|
||||
return sceneContext.Scene.SelectedItem != null;
|
||||
return enabled;
|
||||
},
|
||||
Icon = (invertIcon) => AggContext.StaticData.LoadIcon("lay_flat.png", 16, 16, invertIcon).SetPreMultiply(),
|
||||
},
|
||||
|
|
@ -869,7 +876,17 @@ namespace MatterHackers.MatterControl
|
|||
align.AddSelectionAsChildren(scene, selectedItem);
|
||||
},
|
||||
Icon = (invertIcon) => AggContext.StaticData.LoadIcon("align_left_dark.png", 16, 16, invertIcon).SetPreMultiply(),
|
||||
IsEnabled = (sceneContext, widget) => sceneContext.Scene.SelectedItem is SelectionGroupObject3D,
|
||||
IsEnabled = (sceneContext, widget) =>
|
||||
{
|
||||
var enabled = sceneContext.Scene.SelectedItem is SelectionGroupObject3D;
|
||||
|
||||
if (widget != null)
|
||||
{
|
||||
widget.ToolTipText = enabled ? "Align".Localize() : "Arrange All Parts\n\n*At least 2 parts must be selected*".Localize();
|
||||
}
|
||||
|
||||
return enabled;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -2048,8 +2065,7 @@ namespace MatterHackers.MatterControl
|
|||
"Printer Hardware Error".Localize(),
|
||||
StyledMessageBox.MessageType.YES_NO,
|
||||
"Resume".Localize(),
|
||||
"OK".Localize())
|
||||
);
|
||||
"OK".Localize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2080,8 +2096,8 @@ namespace MatterHackers.MatterControl
|
|||
progressStatus.Status = string.Format(
|
||||
"{0} {1:0}m {2:0}s",
|
||||
"Automatic Heater Shutdown in".Localize(),
|
||||
(int)(printerConnection.SecondsToHoldTemperature) / 60,
|
||||
(int)(printerConnection.SecondsToHoldTemperature) % 60);
|
||||
(int)printerConnection.SecondsToHoldTemperature / 60,
|
||||
(int)printerConnection.SecondsToHoldTemperature % 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2099,7 +2115,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
|
||||
taskActions: new RunningTaskOptions()
|
||||
{
|
||||
PauseAction = () => UiThread.RunOnIdle(() =>
|
||||
|
|
@ -2244,7 +2259,7 @@ namespace MatterHackers.MatterControl
|
|||
/// </summary>
|
||||
/// <param name="collector">The custom collector function to load the content</param>
|
||||
/// <returns></returns>
|
||||
public async static Task<T> LoadCacheableAsync<T>(string cacheKey, string cacheScope, Func<Task<T>> collector, string staticDataFallbackPath = null) where T : class
|
||||
public static async Task<T> LoadCacheableAsync<T>(string cacheKey, string cacheScope, Func<Task<T>> collector, string staticDataFallbackPath = null) where T : class
|
||||
{
|
||||
string cachePath = CacheablePath(cacheScope, cacheKey);
|
||||
|
||||
|
|
@ -2975,7 +2990,6 @@ namespace MatterHackers.MatterControl
|
|||
AggContext.DefaultFontBoldItalic = LiberationSansBoldFont.Instance;
|
||||
}
|
||||
|
||||
|
||||
string translationFilePath = Path.Combine("Translations", twoLetterIsoLanguageName, "Translation.txt");
|
||||
|
||||
if (twoLetterIsoLanguageName == "en")
|
||||
|
|
@ -3257,7 +3271,7 @@ namespace MatterHackers.MatterControl
|
|||
var printAreaButton = new RadioIconButton(AggContext.StaticData.LoadIcon("print_area.png", theme.InvertIcons), theme)
|
||||
{
|
||||
Name = "Bed Button",
|
||||
ToolTipText = (buildHeightValid()) ? "Show Print Area".Localize() : "Define printer build height to enable",
|
||||
ToolTipText = buildHeightValid() ? "Show Print Area".Localize() : "Define printer build height to enable",
|
||||
Checked = sceneContext.RendererOptions.RenderBuildVolume,
|
||||
Margin = theme.ButtonSpacing,
|
||||
VAnchor = VAnchor.Absolute,
|
||||
|
|
|
|||
|
|
@ -32,16 +32,18 @@ using MatterHackers.Agg.UI;
|
|||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow
|
||||
{
|
||||
public class SliceSettingsPopover : Popover
|
||||
public class ClickablePopover : Popover, IOverrideAutoClose
|
||||
{
|
||||
public SliceSettingsPopover(ArrowDirection arrowDirection, BorderDouble padding, int notchSize, int p2, bool autoBorderColor = true)
|
||||
: base(arrowDirection, padding, notchSize, p2, autoBorderColor)
|
||||
private bool allowAutoClose = true;
|
||||
|
||||
public ClickablePopover(ArrowDirection arrowDirection, BorderDouble padding, int notchSize, int arrowOffset, bool autoBorderColor = true)
|
||||
: base(arrowDirection, padding, notchSize, arrowOffset, autoBorderColor)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseEnterBounds(MouseEventArgs mouseEvent)
|
||||
{
|
||||
this.AllowAutoClose = false;
|
||||
this.allowAutoClose = false;
|
||||
base.OnMouseEnterBounds(mouseEvent);
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +53,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
base.OnMouseLeaveBounds(mouseEvent);
|
||||
}
|
||||
|
||||
public bool AllowAutoClose { get; set; } = true;
|
||||
public bool AllowAutoClose => allowAutoClose;
|
||||
}
|
||||
}
|
||||
|
|
@ -85,19 +85,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public RectangleDouble Offset { get; set; }
|
||||
}
|
||||
|
||||
public interface IOverrideAutoClose
|
||||
{
|
||||
bool AllowAutoClose { get; }
|
||||
}
|
||||
|
||||
public static class SystemWindowExtension
|
||||
{
|
||||
public static void ShowPopover(this SystemWindow systemWindow, MatePoint anchor, MatePoint popup, RectangleDouble altBounds = default(RectangleDouble), double secondsToClose = 0)
|
||||
{
|
||||
var settingsRow = anchor.Widget as SettingsRow;
|
||||
var sliceSettingsPopover = popup.Widget as SliceSettingsPopover;
|
||||
var sliceSettingsPopover = popup.Widget as ClickablePopover;
|
||||
|
||||
var hookedWidgets = new HashSet<GuiWidget>();
|
||||
|
||||
void anchor_Closed(object sender, EventArgs e)
|
||||
void Anchor_Closed(object sender, EventArgs e)
|
||||
{
|
||||
if (popup.Widget is SliceSettingsPopover popover
|
||||
&& !popover.AllowAutoClose)
|
||||
if (popup.Widget is IOverrideAutoClose overideAutoClose
|
||||
&& !overideAutoClose.AllowAutoClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -107,7 +112,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
foreach (var widget in hookedWidgets)
|
||||
{
|
||||
widget.Closed -= anchor_Closed;
|
||||
widget.Closed -= Anchor_Closed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,13 +175,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
popup.Widget.Closed += anchor_Closed;
|
||||
anchor.Widget.Closed += anchor_Closed;
|
||||
popup.Widget.Closed += Anchor_Closed;
|
||||
anchor.Widget.Closed += Anchor_Closed;
|
||||
hookedWidgets.Add(anchor.Widget);
|
||||
|
||||
foreach (var widget in anchor.Widget.Parents<GuiWidget>())
|
||||
{
|
||||
widget.Closed += anchor_Closed;
|
||||
widget.Closed += Anchor_Closed;
|
||||
hookedWidgets.Add(widget);
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +198,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
if (secondsToClose > 0)
|
||||
{
|
||||
UiThread.RunOnIdle(() => anchor_Closed(null, null), secondsToClose);
|
||||
UiThread.RunOnIdle(() => Anchor_Closed(null, null), secondsToClose);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
base.OnMouseLeaveBounds(mouseEvent);
|
||||
}
|
||||
|
||||
protected virtual void ExtendPopover(SliceSettingsPopover popover)
|
||||
protected virtual void ExtendPopover(ClickablePopover popover)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
int arrowOffset = (int)(settingsRow.Height / 2);
|
||||
|
||||
var popover = new SliceSettingsPopover(this.ArrowDirection, new BorderDouble(15, 10), 7, arrowOffset)
|
||||
var popover = new ClickablePopover(this.ArrowDirection, new BorderDouble(15, 10), 7, arrowOffset)
|
||||
{
|
||||
HAnchor = HAnchor.Fit,
|
||||
VAnchor = VAnchor.Fit,
|
||||
|
|
@ -291,10 +291,10 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
HAnchor = HAnchor.Fit,
|
||||
});
|
||||
|
||||
bool alignLeft = (this.ArrowDirection == ArrowDirection.Right);
|
||||
bool alignLeft = this.ArrowDirection == ArrowDirection.Right;
|
||||
|
||||
// after a certain amount of time make the popover close (just like a tool tip)
|
||||
double closeSeconds = Math.Max(1, (settingsRow.HelpText.Length / 50.0)) * 5;
|
||||
double closeSeconds = Math.Max(1, settingsRow.HelpText.Length / 50.0) * 5;
|
||||
|
||||
this.ExtendPopover(popover);
|
||||
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
public UIField UIField { get; internal set; }
|
||||
|
||||
protected override void ExtendPopover(SliceSettingsPopover popover)
|
||||
protected override void ExtendPopover(ClickablePopover popover)
|
||||
{
|
||||
string mapsTo = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -52,13 +52,7 @@ namespace Markdig.Agg
|
|||
this.BaseUri = baseUri;
|
||||
}
|
||||
|
||||
private string matchingText;
|
||||
|
||||
public string MatchingText
|
||||
{
|
||||
get => matchingText;
|
||||
set => matchingText = value;
|
||||
}
|
||||
public string MatchingText { get; set; }
|
||||
|
||||
public Uri BaseUri { get; set; } = new Uri("https://www.matterhackers.com/");
|
||||
|
||||
|
|
@ -112,10 +106,10 @@ namespace Markdig.Agg
|
|||
{
|
||||
MarkdownPipeline pipeline;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(matchingText))
|
||||
if (!string.IsNullOrWhiteSpace(MatchingText))
|
||||
{
|
||||
var builder = new MarkdownPipelineBuilder().UseSupportedExtensions();
|
||||
builder.InlineParsers.Add(new MatchingTextParser(matchingText));
|
||||
builder.InlineParsers.Add(new MatchingTextParser(MatchingText));
|
||||
|
||||
pipeline = builder.Build();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue