zoukankan      html  css  js  c++  java
  • WPF 基础

    1. 绘画

    1.1 图形类型

    • Line
      X1、Y1、X2、Y2,Stroke,StrokeThickness
    • Rectangle 矩形
    • Ellipse 椭圆
    • Polygon 多边形(自动闭合)
    • Polyline 多变形(不自动闭合)
    • Path

    1.2 线段

    <Line X1="10" Y1="20" X2="260" Y2="20" Stroke="Red" StrokeThickness="3"/>
    

    效果:

    1.3 矩形及填充色

    • SolidColorBrush 单色画刷
    • LinearGradientBrush 线性渐画刷
    • RadialGradientBrush 径向渐变画刷
    • ImageBrush 图片
    • DrawingBrush 矢量图和位图做填充
    • VisualBrush 控件的
      举例:
    <WrapPanel>
        <WrapPanel.Resources>
            <Style TargetType="Rectangle">
                <Setter Property="Width" Value="150"/>
                <Setter Property="Height" Value="150"/>
                <Setter Property="Margin" Value="10"/>
                <Setter Property="Stroke" Value="Black"/>
            </Style>
            <LinearGradientBrush x:Key="DefaultColor">
                <GradientStop Color="#ff4b1f" Offset="0.1"/>
                <GradientStop Color="#1fddff" Offset="1"/>
            </LinearGradientBrush>                
        </WrapPanel.Resources>
        
        <Rectangle Fill="{StaticResource DefaultColor}"/>
        <Rectangle>
            <Rectangle.Fill>
                <LinearGradientBrush>
                    <GradientStop Color="#999999" Offset="0"/>
                    <GradientStop Color="#555555" Offset="0.5"/>
                    <GradientStop Color="#111111" Offset="1"/>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>
        
        <Rectangle>
            <Rectangle.Fill>
                <RadialGradientBrush>
                    <GradientStop Color="#999999" Offset="0"/>
                    <GradientStop Color="#555555" Offset="0.5"/>
                    <GradientStop Color="#111111" Offset="1"/>
                </RadialGradientBrush>
            </Rectangle.Fill>
        </Rectangle>
        
        <Rectangle>
            <Rectangle.Fill>
                <ImageBrush ImageSource="/Resources/Images/Cars/Audi.jpg"/>
            </Rectangle.Fill>
        </Rectangle>
    
        <!--使用 Drawing 绘制区域,可用形状、文本、视频、图像或其他绘制项填充,这里使用形状-->
        <Rectangle>
            <Rectangle.Fill>
                <DrawingBrush Viewport="0,0,0.2,0.2" TileMode="Tile">
                    <DrawingBrush.Drawing>
                        <GeometryDrawing Brush="{StaticResource DefaultColor}">                                
                            <GeometryDrawing.Geometry>
                                <EllipseGeometry RadiusX="10" RadiusY="10"/>
                            </GeometryDrawing.Geometry>
                        </GeometryDrawing>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </Rectangle.Fill>
        </Rectangle>
        
        <!--使用 Drawing 绘制区域,这里使用图像填充-->
        <Rectangle>
            <Rectangle.Fill>
                <DrawingBrush Viewport="0,0,0.5,0.5" TileMode="Tile">
                    <DrawingBrush.Drawing>
                        <ImageDrawing ImageSource="/Resources/Images/Cars/Cayenne.jpg" Rect="0,0 0.5,0.5"/>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </Rectangle.Fill>
        </Rectangle>
        
        <!--使用 System.Windows.Media.VisualBrush.Visual 绘制区域-->
        <Rectangle>
            <Rectangle.Fill>
                <VisualBrush>
                    <VisualBrush.Visual>
                        <Ellipse Fill="{StaticResource DefaultColor}" Opacity="0.6" Stretch="Fill" HorizontalAlignment="Stretch" 
                         VerticalAlignment="Stretch" Width="100" Height="100"></Ellipse>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
    </WrapPanel>
    

    效果:

    1.4 椭圆

    <Ellipse Width="100" Height="100" Stroke="#FFBBDDDD">        
        <Ellipse.Fill>
            <RadialGradientBrush GradientOrigin="0.2, 0.5" RadiusX="0.5" RadiusY="0.5">
                <RadialGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <RotateTransform CenterX="0" CenterY="0" Angle="30"/>
                    </TransformGroup>
                </RadialGradientBrush.RelativeTransform>
                <GradientStop Color="#FF225555" Offset="0"/>
                <GradientStop Color="#FF336666" Offset="0.2"/>
                <GradientStop Color="#FF558888" Offset="0.4"/>
                <GradientStop Color="#FF88AAAA" Offset="0.6"/>
                <GradientStop Color="#FFAACCCC" Offset="0.8"/>
                <GradientStop Color="#FFCCEEEE" Offset="1"/>
            </RadialGradientBrush>
        </Ellipse.Fill>
    </Ellipse>
    

    效果:

  • 相关阅读:
    python的select和epoll
    ibatis annotations 注解方式返回刚插入的自增长主键ID的值
    java web 项目中获取当前路径的几种方法
    Servlet的监听器
    mybatis-配置文件mybatis-config.xml
    数据库死锁
    JDBC控制事务
    server.xml 解析
    linux下Tomcat 安装后执行startup.sh,出现– Cannot find …bin/catalina.sh
    jni 类初始化失败(nested exception is java.lang.NoClassDefFoundError)
  • 原文地址:https://www.cnblogs.com/MichaelLoveSna/p/14452116.html
Copyright © 2011-2022 走看看