aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-04-22 09:33:28 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-04-22 09:33:28 +0300
commit13887d7b53fec7e2d357fd377a6a1fbd0e875e65 (patch)
treef400c960cc086a6615de95d155b5da19044e37b6 /Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
parent26ede873b194b0df70979b6f1b62e0c91ca19341 (diff)
downloadTango-13887d7b53fec7e2d357fd377a6a1fbd0e875e65.tar.gz
Tango-13887d7b53fec7e2d357fd377a6a1fbd0e875e65.zip
Working on PPC optimizations...
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs28
1 files changed, 22 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
index 5b2808ab1..141fa6e27 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
@@ -9,6 +9,7 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
+using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
@@ -16,14 +17,24 @@ using System.Windows.Shapes;
namespace Tango.SharedUI.Controls
{
-
+ [ContentProperty(nameof(Text))]
public class FastTextBlock : Control
{
private FormattedText _formattedText;
static FastTextBlock()
{
-
+
+ }
+
+ public FastTextBlock()
+ {
+ Loaded += FastTextBlock_Loaded;
+ }
+
+ private void FastTextBlock_Loaded(object sender, RoutedEventArgs e)
+ {
+ Init();
}
public static readonly DependencyProperty TextProperty =
@@ -31,19 +42,24 @@ namespace Tango.SharedUI.Controls
"Text",
typeof(string),
typeof(FastTextBlock),
- new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure,
+ new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender,
(o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue)));
private void TextPropertyChanged(string text)
{
- if (text != null)
+ Init();
+ }
+
+ private void Init()
+ {
+ if (Text != null)
{
var typeface = new Typeface(
FontFamily,
- FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
+ FontStyle, FontWeight, FontStretch);
_formattedText = new FormattedText(
- text, CultureInfo.CurrentCulture,
+ Text, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, typeface, FontSize, Foreground);
}
}