Merge pull request #3461 from jlewin/design_tools
Use theme text colors in Markdown text controls
This commit is contained in:
commit
cbdcd62187
5 changed files with 64 additions and 16 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit b22228763c87cb90dab2055a1f0a42b9f1597fc5
|
||||
Subproject commit f38d68ae2c71343c909b43c7a497ed8bf1a7d23a
|
||||
|
|
@ -10,16 +10,15 @@ using Markdig.Renderers.Agg;
|
|||
using Markdig.Renderers.Agg.Inlines;
|
||||
using Markdig.Syntax;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl;
|
||||
|
||||
namespace Markdig.Renderers
|
||||
{
|
||||
public class TextWordX : TextWidget
|
||||
{
|
||||
public TextWordX()
|
||||
: base("", pointSize: 10, textColor: Color.Black)
|
||||
: base("", pointSize: 10, textColor: ApplicationController.Instance.Theme.Colors.PrimaryTextColor)
|
||||
{
|
||||
this.AutoExpandBoundsToText = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,36 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
{
|
||||
public class EmphasisInlineX : FlowLayoutWidget
|
||||
{
|
||||
public EmphasisInlineX()
|
||||
private char delimiter;
|
||||
|
||||
public EmphasisInlineX(char delimiter)
|
||||
{
|
||||
HAnchor = HAnchor.Fit;
|
||||
VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Fit;
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
|
||||
this.delimiter = delimiter;
|
||||
}
|
||||
|
||||
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
|
||||
{
|
||||
if (childToAdd is TextWidget textWidget)
|
||||
{
|
||||
textWidget.Bold = true;
|
||||
|
||||
switch (delimiter)
|
||||
{
|
||||
case '~':
|
||||
textWidget.StrikeThrough = true;
|
||||
break;
|
||||
case '*':
|
||||
default:
|
||||
textWidget.Bold = true;
|
||||
break;
|
||||
|
||||
// case '_': Italic();
|
||||
// case '^': Styles.SuperscriptStyleKey
|
||||
// case '+': Styles.InsertedStyleKey
|
||||
// case '=': Styles.MarkedStyleKey
|
||||
}
|
||||
}
|
||||
|
||||
base.AddChild(childToAdd, indexInChildrenList);
|
||||
|
|
@ -63,7 +82,7 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
|
||||
if (true) //span != null)
|
||||
{
|
||||
renderer.Push(new EmphasisInlineX());
|
||||
renderer.Push(new EmphasisInlineX(obj.DelimiterChar));
|
||||
renderer.WriteChildren(obj);
|
||||
renderer.Pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,43 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
{
|
||||
public class TextLinkX : FlowLayoutWidget
|
||||
{
|
||||
public TextLinkX()
|
||||
private LinkInline linkInline;
|
||||
|
||||
public TextLinkX(LinkInline linkInline)
|
||||
{
|
||||
HAnchor = HAnchor.Fit;
|
||||
VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Fit;
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
this.Cursor = Cursors.Hand;
|
||||
this.linkInline = linkInline;
|
||||
|
||||
}
|
||||
|
||||
public override void OnClick(MouseEventArgs mouseEvent)
|
||||
{
|
||||
if (linkInline.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ApplicationController.Instance.LaunchBrowser(linkInline.Url);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Inline link?
|
||||
Debugger.Break();
|
||||
}
|
||||
|
||||
base.OnClick(mouseEvent);
|
||||
}
|
||||
|
||||
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
|
||||
{
|
||||
if (childToAdd is TextWidget textWidget)
|
||||
{
|
||||
// Mark with underline if any character data exists
|
||||
textWidget.Underline = textWidget.Text.Trim().Length > 0;
|
||||
}
|
||||
|
||||
// Allow link parent to own mouse events
|
||||
childToAdd.Selectable = false;
|
||||
|
||||
base.AddChild(childToAdd, indexInChildrenList);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,8 +65,9 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
|
||||
public ImageLinkSimpleX(string url)
|
||||
{
|
||||
HAnchor = HAnchor.Fit;
|
||||
VAnchor = VAnchor.Fit;
|
||||
this.HAnchor = HAnchor.Fit;
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
this.Selectable = false;
|
||||
|
||||
var imageBuffer = new ImageBuffer(icon);
|
||||
var imageWidget = new ImageWidget(imageBuffer);
|
||||
|
|
@ -154,7 +184,7 @@ namespace Markdig.Renderers.Agg.Inlines
|
|||
}
|
||||
else
|
||||
{
|
||||
renderer.Push(new TextLinkX()); // hyperlink);
|
||||
renderer.Push(new TextLinkX(link)); // hyperlink);
|
||||
renderer.WriteChildren(link);
|
||||
renderer.Pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace Markdig.Agg
|
|||
: this(baseUri, scrollContent)
|
||||
{
|
||||
var webClient = new WebClient();
|
||||
this.Markdown = webClient.DownloadString(contentUri);
|
||||
this.Markdown = "~~Strike-through test text~~ \r\n" + webClient.DownloadString(contentUri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue