ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

wpf 使用图形字体

2020-04-24 19:03:46  阅读:305  来源: 互联网

标签:files 映射 E5% 编辑 字体 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>

显示:

 

标签:files,映射,E5%,编辑,字体,wpf,图形
来源: https://www.cnblogs.com/lcawen/p/12769433.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有