aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-04-20 21:48:32 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-04-20 21:48:32 +0300
commit26ede873b194b0df70979b6f1b62e0c91ca19341 (patch)
tree5b473cf20793ef1c89325fa8e04183843aefac7e /Software/Visual_Studio/Tango.SharedUI/Controls
parent09eabd45ecf65d6f900b9d53428e7576bdc4d825 (diff)
downloadTango-26ede873b194b0df70979b6f1b62e0c91ca19341.tar.gz
Tango-26ede873b194b0df70979b6f1b62e0c91ca19341.zip
Working on PPC performance...
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
new file mode 100644
index 000000000..5b2808ab1
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/FastTextBlock.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.SharedUI.Controls
+{
+
+ public class FastTextBlock : Control
+ {
+ private FormattedText _formattedText;
+
+ static FastTextBlock()
+ {
+
+ }
+
+ public static readonly DependencyProperty TextProperty =
+ DependencyProperty.Register(
+ "Text",
+ typeof(string),
+ typeof(FastTextBlock),
+ new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsMeasure,
+ (o, e) => ((FastTextBlock)o).TextPropertyChanged((string)e.NewValue)));
+
+ private void TextPropertyChanged(string text)
+ {
+ if (text != null)
+ {
+ var typeface = new Typeface(
+ FontFamily,
+ FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
+
+ _formattedText = new FormattedText(
+ text, CultureInfo.CurrentCulture,
+ FlowDirection.LeftToRight, typeface, FontSize, Foreground);
+ }
+ }
+
+
+ public string Text
+ {
+ get { return (string)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ if (_formattedText != null)
+ {
+ drawingContext.DrawText(_formattedText, new Point());
+ }
+ }
+
+ protected override Size MeasureOverride(Size constraint)
+ {
+ return _formattedText != null
+ ? new Size(_formattedText.Width, _formattedText.Height)
+ : new Size();
+ }
+ }
+} \ No newline at end of file