Esempio n. 1
0
        public static BitmapSource StringToBitmapSource(this string str, int fontSize, System.Windows.Media.Color foreground,
                                                        System.Windows.Media.Color background, Media.FontFamily fontFamily, FontWeight fontWeight, FontStyle fontStyle, Thickness padding)
        {
            TextBlock tbX = new TextBlock();

            tbX.FontFamily    = fontFamily;
            tbX.Foreground    = new System.Windows.Media.SolidColorBrush(foreground);
            tbX.Background    = new System.Windows.Media.SolidColorBrush(background);
            tbX.TextAlignment = TextAlignment.Center;
            tbX.FontSize      = fontSize;
            tbX.FontStretch   = FontStretches.Normal;
            tbX.FontWeight    = fontWeight;
            tbX.FontStyle     = fontStyle;
            tbX.Padding       = padding;
            tbX.Text          = str;
            var size = tbX.MeasureString();

            tbX.Width  = size.Width;
            tbX.Height = size.Height;
            tbX.Measure(new Size(size.Width, size.Height));
            tbX.Arrange(new Rect(new Size(size.Width, size.Height)));
            return(tbX.ToBitmapSource());
        }
        public PositionsPaneWpf()
        {
            PositionsLabMain.InitPositionsLab();
            lightBlueBrush = new System.Windows.Media.SolidColorBrush();
            var lightBlue = new System.Windows.Media.Color();
            lightBlue.R = 190;
            lightBlue.G = 230;
            lightBlue.B = 253;
            lightBlue.A = 255;
            lightBlueBrush.Color = lightBlue;

            darkBlueBrush = new System.Windows.Media.SolidColorBrush();
            var darkBlue = new System.Windows.Media.Color();
            darkBlue.R = 60;
            darkBlue.G = 127;
            darkBlue.B = 177;
            darkBlue.A = 255;
            darkBlueBrush.Color = darkBlue;

            InitializeComponent();
            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(10);
            Focusable = true;
        }
Esempio n. 3
0
 public static BitmapSource StringToBitmapSource(this string str, int fontSize, System.Windows.Media.Color foreground,
                                                 System.Windows.Media.Color background, Media.FontFamily fontFamily, FontWeight fontWeight)
 {
     return(StringToBitmapSource(str, fontSize, foreground, background,
                                 fontFamily, fontWeight, FontStyles.Normal, new Thickness(0)));
 }
Esempio n. 4
0
 public static BitmapSource StringToBitmapSource(this string str, int fontSize, System.Windows.Media.Color foreground,
                                                 System.Windows.Media.Color background)
 {
     return(StringToBitmapSource(str, fontSize, foreground, background,
                                 new System.Windows.Media.FontFamily("Arial")));
 }