0626-自动获取焦点 Canvas XY轴 贝塞尔曲线-BezierSegment Dispatcher.BeginInvoke

Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Keyboard.Focus(pwdBox); }));  自动获取焦点,光标正常显示

Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() => pwdBox.Focus()));  进行定位但光标不闪烁

https://blog.csdn.net/fwj380891124/article/details/8177125

<EllipseGeometry RadiusX="10" RadiusY="10"></EllipseGeometry>//圆

                Line l = new Line();
                l.StrokeThickness = 1;//线宽度
                l.Stroke =new SolidColorBrush(Colors.Red) ;//外宽颜色,自定义颜色
                l.X1 = 0;//X1、Y1 两个属性可以设置它的起点坐标
                l.Y1 = 0;//X1、Y1 两个属性可以设置它的起点坐标
                l.X2 = 580;//X2、Y2俩个属性则用来设置其终点坐标
                l.Y2 = 0;//X2、Y2俩个属性则用来设置其终点坐标

控制起点/终点坐标就可以实现平行、交错等效果。Stroke(笔触)属性的数据类型是Brush(画刷),凡是Brush的派生类均可用于给这个属性赋值。因为WPF提供了多种渐变色画刷,所以画直线也可以画出渐变效果。同时,Line的一些属性还帮助我们画出虚线以及控制线段终点的形状。

Line:直线段,可以设置其笔触(Stroke)。

Rectangle:矩形,既有笔触,又有填充(Fill)。

Ellipse:椭圆,长宽相等的椭圆即为正圆,既有笔触又有填充。

Polygon:多边形,由多条直线线段围成的闭合区域,既有笔触又有填充。

PolyLine:折线(不闭合),由多条首尾相接的直线组成。

Path:路径(闭合区域),基本图形中功能最强的一个,可由若干直线,圆弧,被塞尔曲线组成。
 

https://blog.csdn.net/xpj8888/article/details/82738224

https://blog.csdn.net/u012846041/article/details/81180803

BezierSegment(三次方贝塞尔曲线)由4个点决定:

(1)起点:即前一个线段的终点或PathFigure的StartPoint。

(2)终点:Point3属性,即曲线的终点位置。

(3)两个控制点:Point1和Point2属性。

初略的说,三次方贝塞尔曲线就是由起点出发走向Point1方向,再走向Point2方向,最后到达终点的平滑曲线,具体的算法请查阅维基百科“被塞尔曲线”词条。

<Window x:Class="WpfApplication1.Window51"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window51" Height="300" Width="300">
    <Grid>
        <Path Stroke="Black" StrokeThickness="2">
            <Path.Data>
                <PathGeometry>
                    <PathFigure StartPoint="0,0">
                        <BezierSegment Point1="250,0" Point2="50,200" Point3="300,200">
                            
                        </BezierSegment>
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
        </Path>
    </Grid>
</Window>


QuadraticBezierSegment(二次方贝塞尔曲线)与BezierSegment类似,只是控制点由两个变为了一个。也就是说QuadraticBezierSegment由3个点决定:

(1)起点:即前一个线段的终点或PathFigure的StartPoint。

(2)终点:Point2属性,即曲线的终止位置。

(3)控制点:Point1属性。

如下的代码就表示的是二次方贝塞尔曲线:
<Window x:Class="WpfApplication1.Window52"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window52" Height="339" Width="325">
    <Grid>
        <Path Stroke="Blue" StrokeThickness="2">
            <Path.Data>
                <PathGeometry>
                    <PathFigure StartPoint="0,300">
                        <QuadraticBezierSegment Point1="150,-150" Point2="300,300">
                            
                        </QuadraticBezierSegment>
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
        </Path>
    </Grid>
</Window>

至此,简单的路径就介绍完了。如果想绘制出复杂的图形来,我们要做的仅仅是在PathFigure把Segment一段段的加上去。

GeometryGroup也是Geometry的一个派生类,它最大的特点是可以将一组PathGeometry组合在一起,如下面的例子:

<Window x:Class="WpfApplication1.Window53"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window53" Height="300" Width="300">
    <Grid>
        <Path Stroke="Black" Fill="LightBlue" StrokeThickness="1">
            <Path.Data>
                <GeometryGroup>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="250,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="230,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="210,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="190,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="170,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="150,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <BezierSegment Point1="130,0" Point2="50,200" Point3="300,200"></BezierSegment>
                        </PathFigure>
                    </PathGeometry>
                </GeometryGroup>
            </Path.Data>
        </Path>
    </Grid>
</Window>

https://www.cnblogs.com/guogangj/archive/2013/02/27/2934733.html   打印和打印预览界面

https://www.cnblogs.com/guogangj/archive/2013/01/22/2870590.html   Dispatcher.BeginInvoke

猜你喜欢

转载自blog.csdn.net/qq_30807313/article/details/93733627