当前位置: 首页 > news >正文

各种类型网站建设牛推网

各种类型网站建设,牛推网,商城分销模式,珠海做企业网站WPF 并没有内置FontDialog和ColorDialog,但可以通过引用 Windows Forms 的控件来实现字体和颜色选择对话框功能。FontDialog 允许用户选择字体、样式、大小等设置。 添加 Windows Forms的引用 项目工程:右键“引用”》“添加引用”》勾选System.Window…

WPF 并没有内置FontDialog和ColorDialog,但可以通过引用 Windows Forms 的控件来实现字体和颜色选择对话框功能。FontDialog 允许用户选择字体、样式、大小等设置。

添加 Windows Forms的引用

  1. 项目工程:右键“引用”=》“添加引用”=》勾选System.Windows.Forms
    在这里插入图片描述
  2. 浏览选择System.Windows.Forms.dll动态库文件
    默认路径:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework
    在这里插入图片描述
    3.添加成功
    在这里插入图片描述
  • 在C# WPF应用程序中,不能直接使用System.Drawing.Font,因为System.Drawing.Font是Windows Forms的一部分,而不是WPF。WPF使用System.Windows.Media.FontFamily来表示字体。需要做相应的转换才可以使用;
  • WinForm中的Color( System.Drawing.Color)与Wpf中Color(System.Windows.Media.Color)也需要要相互转换才能使用;

代码示例

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;namespace WpfColorFontDialog
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}private void btnSetFont_Click(object sender, RoutedEventArgs e){System.Windows.Forms.FontDialog fontDialog = new System.Windows.Forms.FontDialog();if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK){// System.Drawing.Font DFont = new System.Drawing.Font("宋体", 10, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);System.Drawing.Font drawingFont = fontDialog.Font;FontFamily fontFamily = new FontFamily(drawingFont.Name);double fontSize = drawingFont.Size;FontWeight fontWeight = FontWeights.Bold;if (drawingFont.Bold){fontWeight = FontWeights.Bold;}else {fontWeight = FontWeights.Normal;}FontStyle fontStyle = (drawingFont.Style & System.Drawing.FontStyle.Italic) != 0 ? FontStyles.Italic : FontStyles.Normal;txtBlock.FontFamily = fontFamily;txtBlock.FontSize = fontSize;txtBlock.FontStyle = fontStyle;txtBlock.FontWeight = fontWeight;}}private void btnSetColor_Click(object sender, RoutedEventArgs e){System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK){System.Windows.Media.Color MColor = new System.Windows.Media.Color();MColor = System.Windows.Media.Color.FromArgb(colorDialog.Color.A, colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B);System.Windows.Media.Brush BColor = new SolidColorBrush(MColor);txtBlock.Background = BColor;}}}
}

在这里插入图片描述
在这里插入图片描述

http://www.dinnco.com/news/980.html

相关文章:

  • 罗湖高端网站设计收录优美图片找不到了
  • 模仿别人网站侵权成人短期培训能学什么
  • 精品网站要建设需要多少钱软件排名优化
  • 济南做网站个人网站推广多少钱一年
  • 在哪些网站上申请做广告可以在百度引擎能收到关键字网络培训心得体会5篇
  • 江门市专业做网站公司互联网营销方式
  • 网站标题和关键词一样百度网站名称和网址
  • 电商网站开发论文程序员培训机构排名前十
  • 电子商务网站设计与实现昆明seo关键字推广
  • 怎么把个人做的网站发布到网上网站seo优化总结
  • 网站写手怎么做北京推广服务
  • 网页是网站吗做一个电商平台大概需要多少钱
  • 网页制作与网站建设完全学习手册光盘上海优质网站seo有哪些
  • 淘宝联盟推广网站怎么做网站seo优化运营
  • 4网站免费建站济南百度推广代理商
  • 展示类网站建设免费手机优化大师下载安装
  • 设计素材网站图片东莞网络营销信息推荐
  • 重庆网站制作哪家好app注册推广任务平台
  • 做海外批发有什么好的网站好嘉兴网站建设制作
  • 网站开发心路历程品牌运营公司
  • 合肥高新城创建设投资有限公司网站seo工资待遇怎么样
  • 广州哪个区有疫情苏州优化seo
  • 做神马网站优化百度网络营销app
  • 做一钓鱼网站国外网站制作
  • 一个域名可以做多少个二级网站b站2023年免费入口
  • 枣阳网站建设等服务淘宝关键词优化
  • 在线做数据图的网站有哪些问题怎样做好销售和客户交流
  • 一个网站交互怎么做的汕头网站关键词推广
  • 特色个人网站sem竞价托管代运营
  • 谢家华做网站榜单优化