wpf 路径与几何图形

nnsrf1az  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(90)

只是想知道什么是更轻的,我将有一个控件,绘制280 * 4我的SegmentControl,这是四分之一个圆圈,我只是想知道什么是最少的内存的方式来绘制所说的部分。
几何图形:

<Image>
    <Image.Source>
        <DrawingImage>
            <DrawingImage.Drawing>
                <GeometryDrawing Brush="LightBlue"
                                 Geometry="M24.612317,0.14044853 C24.612317,0.14044853 33.499971,-0.60608719 41,7.0179795 48.37642,14.516393 47.877537,23.404541 47.877537,23.404541 L24.60978,23.401991 z" />
            </DrawingImage.Drawing>
        </DrawingImage>
    </Image.Source>
</Image>

字符串
或路径:

<Path Fill="LightBlue"
              Stretch="Fill"
              Stroke="#FF0DA17D"
              Data="M24.612317,0.14044853 C24.612317,0.14044853 33.499971,-0.60608719 41,7.0179795 48.37642,14.516393 47.877537,23.404541 47.877537,23.404541 L24.60978,23.401991 z" />


如果你知道更好的方法,我会很感激的。
谢谢你,谢谢

ecr0jaav

ecr0jaav1#

如果你想要一个更好的性能,你可以看看“绘图视觉”。它更复杂,但性能也更高。
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/using-drawingvisual-objects?view=netframeworkdesktop-4.8
但是,您需要了解如何绘制每个所需的形状。
样品:

// Create a DrawingVisual that contains a rectangle.
private DrawingVisual CreateDrawingVisualRectangle()
{
    DrawingVisual drawingVisual = new DrawingVisual();

    // Retrieve the DrawingContext in order to create new drawing content.
    DrawingContext drawingContext = drawingVisual.RenderOpen();

    // Create a rectangle and draw it in the DrawingContext.
    Rect rect = new Rect(new System.Windows.Point(160, 100), new System.Windows.Size(320, 80));
    drawingContext.DrawRectangle(System.Windows.Media.Brushes.LightBlue, (System.Windows.Media.Pen)null, rect);

    // Persist the drawing content.
    drawingContext.Close();

    return drawingVisual;
}

字符串

相关问题