drawingcontext

When do adjustsFontSizeToFitWidth or boundingRectWithSize change the context.actualScaleFactor?

笑着哭i 提交于 2020-01-10 05:03:49
问题 When does the actualScaleFactor of an NSStringDrawingContext change? The documentation says: "If you specified a custom value in the minimumScaleFactor property, when drawing is complete, this property contains the actual scale factor value that was used to draw the string." My code: myButton.titleLabel!.font = UIFont(name: "AmericanTypewriter-Bold", size: 40) myButton.titleLabel?.adjustsFontSizeToFitWidth = true myButton.setTitle("\(textString)", forState: .Normal) let attributes =

Vertical alignment with DrawingContext.DrawText [duplicate]

二次信任 提交于 2019-12-20 03:27:16
问题 This question already has answers here : Set VerticalAlignment in DrawText (2 answers) Closed 5 years ago . I need to align my text vertically to either the top or bottom or center. There's the FormattedText.TextAlignment property for horizontal alignment, but nothing for vertical alignment. To make it clear what Google doesn't understand: I am not interested in rotating text to flow vertically. I know how to do that. I just want to have (possibly multi-line) text to align above or below the

WPF DrawGeometry does not draw stroke

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:41:53
问题 I hope this question was not asked before, I searched everywhere. My problem is that I'm drawing a set of coordinates on my wpf usercontrol with points, I managed to fill my polygon with background color but not with a stroke. Stoke for some reason is not drawing? Here is my code on the OnRender event using the DrawingContext System.Windows.Media.Pen penDrawing = new System.Windows.Media.Pen(System.Windows.Media.Brushes.OrangeRed, 2); drawingContext.DrawGeometry(System.Windows.Media.Brushes

Line is not displayed on startup but becomes visible on resize (WPF)

我是研究僧i 提交于 2019-12-11 21:18:12
问题 I have a WPF application where a line shape is only displayed when the application window is resized, as shown here: The red line is drawn on-the-fly, it is not defined in XAML. It displays fine. The blue line is defined in XAML, but its dimensions are changed within the OnRender() call. If its dimensions are not changed, or if only some of its dimensions are changed, the blue line is displayed on startup. But when all the dimensions of the blue line are changed, it is not displayed on

DrawingContext adorner - possible to draw stackpanel?

那年仲夏 提交于 2019-12-06 05:54:16
问题 Using the DrawingContext class I've been able to use the DrawRectangle() method to successfully add an adorner to my adornedElement. Is it possible to construct a stackpanel, with a textbox and image inside - and assign this as the adorner? I'm using visual studio 2010 by the way - not microsoft expression. Thanks a lot, Dan 回答1: No, this is not possible out of the box as the DrawingContext is only meant to draw Visuals and no FrameworkElements. What you can do is create your own Adorner

DrawingContext.DrawLine: Pen has no full opacity?

和自甴很熟 提交于 2019-12-04 10:09:48
when I draw something like that (just random drawings here): public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DrawingVisual visual = new DrawingVisual(); DrawingContext context = visual.RenderOpen(); Pen pen = new Pen(Brushes.Black, 1); context.DrawEllipse(Brushes.YellowGreen, pen, new Point(0,0), 40, 40); for (int i = 0; i <= 100 - 1; i++) context.DrawLine(new Pen(Brushes.Black, 1), new Point(0, i), new Point(i, i)); context.Close(); RenderTargetBitmap bmp = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Pbgra32); bmp.Render(visual); image1.Source

Vertical alignment with DrawingContext.DrawText [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-02 01:08:58
This question already has an answer here: Set VerticalAlignment in DrawText 2 answers I need to align my text vertically to either the top or bottom or center. There's the FormattedText.TextAlignment property for horizontal alignment, but nothing for vertical alignment. To make it clear what Google doesn't understand: I am not interested in rotating text to flow vertically. I know how to do that. I just want to have (possibly multi-line) text to align above or below the centre point or in the middle of it. Anybody knows how to do that? Roel van Westerop If you're using the DrawingContext

How to apply a drop shadow effect when drawing to a DrawingContext in WPF?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 13:01:57
I'm drawing into a DrawingContext , and I'd like to apply a drop shadow effect to part of the drawing. At the moment I create the relevant parts in a DrawingGroup and apply a BitmapEffect , but this has no effect: var layer = new DrawingGroup(); using (var lcontext = layer.Open()) { // draw stuff in lcontext } layer.BitmapEffect = new DropShadowBitmapEffect { Color = Colors.Black, ShadowDepth = 3, Opacity = 0.5 }; context.DrawDrawing(layer); This draws everything inside the layer correctly, but without the drop shadow effect. What am I doing wrong / how else might I apply a drop shadow to a

How to apply a drop shadow effect when drawing to a DrawingContext in WPF?

时间秒杀一切 提交于 2019-11-29 18:34:52
问题 I'm drawing into a DrawingContext , and I'd like to apply a drop shadow effect to part of the drawing. At the moment I create the relevant parts in a DrawingGroup and apply a BitmapEffect , but this has no effect: var layer = new DrawingGroup(); using (var lcontext = layer.Open()) { // draw stuff in lcontext } layer.BitmapEffect = new DropShadowBitmapEffect { Color = Colors.Black, ShadowDepth = 3, Opacity = 0.5 }; context.DrawDrawing(layer); This draws everything inside the layer correctly,

When do adjustsFontSizeToFitWidth or boundingRectWithSize change the context.actualScaleFactor?

拈花ヽ惹草 提交于 2019-11-29 13:52:48
When does the actualScaleFactor of an NSStringDrawingContext change? The documentation says: "If you specified a custom value in the minimumScaleFactor property, when drawing is complete, this property contains the actual scale factor value that was used to draw the string." My code: myButton.titleLabel!.font = UIFont(name: "AmericanTypewriter-Bold", size: 40) myButton.titleLabel?.adjustsFontSizeToFitWidth = true myButton.setTitle("\(textString)", forState: .Normal) let attributes = [NSFontAttributeName : myButton.titleLabel!.font] let attributedString = NSMutableAttributedString(string