// Assumes that the bitmapcontext is active
        private void drawHeaderForBox(WriteableBitmap bitmap, int x, int y, int width, String text)
        {
            const int BOX_HEIGHT = 40;
            const int BOX_WIDTH = 120;

            TranslateTransform transform = new TranslateTransform();
            transform.X = x + (width - BOX_WIDTH) / 2;
            transform.Y = y;

            Border border = new Border();
            border.Height = BOX_HEIGHT;
            border.Width = BOX_WIDTH;
            border.Background = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0));

            TextBlock textBlock = new TextBlock();
            textBlock.FontSize = 36;
            textBlock.TextAlignment = TextAlignment.Center;
            textBlock.Foreground = new SolidColorBrush(Colors.White);
            textBlock.Text = text;

            border.Child = textBlock;
            border.Arrange(new Rect(0.0, 0.0, border.Width, border.Height));
            border.UpdateLayout();

            bitmap.Render(border, transform);
        }
        public static FrameworkElement GetRendreable(IconVm iconVm, ImageSource sourceIcon, Color color)
        {
            var border = new Border()
            {
                Background = new SolidColorBrush(color),
                Width = iconVm.Width,
                Height = iconVm.Height
            };
            var image = new Image()
            {
                Stretch = Stretch.Uniform,
                Source = sourceIcon,
                Width = iconVm.ImageWidth,
                Height = iconVm.ImageHeight,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };


            border.Child = image;

            border.Measure(new Size(border.Width, border.Height));
            border.Arrange(new Rect(new Size(border.Width, border.Height)));
            border.UpdateLayout();
            return border;
        }
Exemple #3
0
		public void UpdateLayoutTest ()
		{
			Border b = new Border ();
			var path = new Path ();
			var canvas = new Canvas ();
			b.Child = path;
			canvas.Children.Add (b);
			RectangleGeometry r = new RectangleGeometry ();
			r.Rect = new Rect (10, 10, 80, 90);
			path.Data = r;
			
			path.Fill = new SolidColorBrush (Colors.Red);

			b.UpdateLayout ();
			path.UpdateLayout ();

			Assert.AreEqual (new Size (0,0), path.DesiredSize, "desired");
			Assert.AreEqual (new Size (0,0), path.RenderSize, "render");
			Assert.AreEqual (0, path.ActualWidth);
			Assert.AreEqual (0, path.ActualHeight);
		}