zoukankan      html  css  js  c++  java
  • wpf 使用图形字体

    1.生成图形字体:

    使用工具字体编辑器工具Font Cteator Program 4.1(https://files.cnblogs.com/files/lcawen/%E5%AD%97%E4%BD%93%E7%BC%96%E8%BE%91%E5%99%A8.zip),编辑修改字体(xxx.ttf),以及编辑和查看字体的映射地址:

     2.在Wpf前端映射字体,在Content属性赋值【】即可

    如下,小例子:

    <UserControl
        x:Class="Lierda.Control.Pages.Pager" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Lcawen.Control.Pages">
        <FrameworkElement.Resources>
            <ResourceDictionary>
                <RoutedUICommand
                    x:Key="FirstPage" />
                <RoutedUICommand
                    x:Key="PreviewPage" />
                <RoutedUICommand
                    x:Key="NextPage" />
                <RoutedUICommand
                    x:Key="LastPage" />
                <RoutedUICommand
                    x:Key="RefreshData" />
                <RoutedUICommand
                    x:Key="JunpToPage" />
            </ResourceDictionary>
        </FrameworkElement.Resources>
        <UIElement.CommandBindings>
            <CommandBinding
                Command="{StaticResource JunpToPage}"
                CanExecute="CommandBinding_CanExecute_5"
                Executed="CommandBinding_Executed_5" />
            <CommandBinding
                Command="{StaticResource FirstPage}"
                CanExecute="CommandBinding_CanExecute"
                Executed="CommandBinding_Executed" />
            <CommandBinding
                Command="{StaticResource PreviewPage}"
                CanExecute="CommandBinding_CanExecute_1"
                Executed="CommandBinding_Executed_1" />
            <CommandBinding
                Command="{StaticResource NextPage}"
                CanExecute="CommandBinding_CanExecute_2"
                Executed="CommandBinding_Executed_2" />
            <CommandBinding
                Command="{StaticResource LastPage}"
                CanExecute="CommandBinding_CanExecute_3"
                Executed="CommandBinding_Executed_3" />
            <CommandBinding
                Command="{StaticResource RefreshData}"
                CanExecute="CommandBinding_CanExecute_4"
                Executed="CommandBinding_Executed_4" />
        </UIElement.CommandBindings>
        <Grid>
            <FrameworkElement.Resources>
                <ResourceDictionary>
                    <Style
                        TargetType="{x:Type TextBlock}"
                        x:Key="{x:Type TextBlock}">
                        <Setter
                            Property="Margin"
                            Value="5" />
                        <Setter
                            Property="TextBlock.Padding"
                            Value="5" />
                        <Setter
                            Property="VerticalAlignment"
                            Value="Center" />
                    </Style>
                    <Style
                        TargetType="{x:Type Button}"
                        x:Key="{x:Type Button}">
                        <Setter
                            Property="FontWeight"
                            Value="Bold" />
                        <Setter
                            Property="FontFamily"
                            Value="/Lierda.Control;component/Font/#iconfont" />
                        <Setter
                            Property="Margin"
                            Value="5" />
                        <Setter
                            Property="VerticalAlignment"
                            Value="Center" />
                        <Setter
                            Property="Padding"
                            Value="5" />
                    </Style>
                    <Style
                        TargetType="{x:Type TextBox}"
                        x:Key="{x:Type TextBox}">
                        <Setter
                            Property="Margin"
                            Value="5" />
                        <Setter
                            Property="VerticalAlignment"
                            Value="Center" />
                        <Setter
                            Property="Padding"
                            Value="5" />
                    </Style>
                </ResourceDictionary>
            </FrameworkElement.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition
                    Width="*" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
                <ColumnDefinition
                    Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock
                FontWeight="Bold"
                Foreground="#FFFF0000"
                Grid.Column="0"
                Text="{Binding Path=PageDisplayer}" />
            <TextBlock
                Text="显示数量"
                Grid.Column="1" />
            <TextBox
                Grid.Column="2"
                Width="70"
                Text="{Binding Path=DisplayCount, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True, BindsDirectlyToSource=True}" />
            <Button
                Grid.Column="3"
                ToolTip="第一页"
                Content="�"
                Command="{StaticResource FirstPage}"
                Foreground="#FFFF0000" />
            <Button
                Grid.Column="4"
                ToolTip="上一页"
                Content="�"
                Command="{StaticResource PreviewPage}" />
            <TextBox
                Grid.Column="5"
                Width="60"
                Text="{Binding Path=CurrentPage, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, NotifyOnTargetUpdated=True, NotifyOnSourceUpdated=True}" />
            <TextBlock
                Grid.Column="6"
                IsHitTestVisible="False">
                <Run>/</Run> <Run
                    Text="{Binding Path=TotalPage, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" /></TextBlock>
            <Button
                Grid.Column="7"
                ToolTip="下一页"
                Content="�"
                Command="{StaticResource NextPage}"
                Background="{x:Null}" />
            <Button
                Grid.Column="8"
                ToolTip="最后一页"
                Content="�"
                Command="{StaticResource LastPage}"
                Foreground="#FFFF0000" />
            <Button
                Grid.Column="9"
                Content="�"
                Command="{StaticResource RefreshData}"
                ToolTip="刷新当前页"
                Foreground="#FF1F757E" />
            <Button
                Grid.Column="10"
                ToolTip="跳转到指定页"
                Content="�"
                Command="{StaticResource JunpToPage}"
                Foreground="#FF00D1FF" />
        </Grid>
    </UserControl>

    显示:

  • 相关阅读:
    OO第二单元——多线程(电梯)
    OO前三次作业思考(第一次OO——Blog)
    P2016 战略游戏——树形DP大水题
    P1108 低价购买——最长下降子序列+方案数
    P1041 传染病控制——暴力遍历所有相同深度的节点
    P2502 [HAOI2006]旅行——暴力和并查集的完美结合
    2019.10.25字符串——zr
    P3719 [AHOI2017初中组]rexp——递归模拟
    树状数组优化最长上升子序列
    P1378 油滴扩展——搜索小记
  • 原文地址:https://www.cnblogs.com/lcawen/p/12769433.html
Copyright © 2011-2022 走看看