WPF公章制作之2
原文:WPF公章制作之2
早前,我曾写过一篇:“在WPF中制作正圆形公章”(http://blog.csdn.net/johnsuna/archive/2007/10/12/1821531.aspx)。
有空再次研究,使用C#将此WPF程序写了出来。
运行效果图:
关键C#代码:
// OfficialSeal.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using brawdrawSharp = BrawDraw.Com.Utility.PublicClasses.Shape;
namespace BrawDraw.Com.WPF.PublicControls.Demo
{
public class OfficialSeal : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new OfficialSeal());
}
public OfficialSeal()
{
string officialSealText = "BRAWDRAW图文印章示例";
Title = officialSealText;
Canvas canv = new Canvas();
Content = canv;
Ellipse ellipse = new Ellipse();
ellipse.Width = 400;
ellipse.Height = 400;
ellipse.Stroke = new SolidColorBrush(Colors.Red);
ellipse.StrokeThickness = 2;
Canvas.SetLeft(ellipse, 10);
canv.Children.Add(ellipse);
double angleAdd = 236.00 / officialSealText.Length;
int i = 0;
for (double angle = -112; angle < 123; angle += angleAdd)
{
TextBlock txtblk = new TextBlock();
txtblk.FontFamily = new FontFamily("方正大标宋简体,黑体,宋体");
txtblk.FontSize = 56;
txtblk.Foreground = new SolidColorBrush(Colors.Red);
txtblk.Text = officialSealText[i].ToString();
txtblk.RenderTransformOrigin = new Point(0.5, 0);
TransformGroup tg = new TransformGroup();
ScaleTransform st = new ScaleTransform(0.66, 1);
TranslateTransform tt = new TranslateTransform(0, -188);
tg.Children.Add(st);
tg.Children.Add(tt);
tg.Children.Add(new RotateTransform(angle));
txtblk.RenderTransform = tg;
canv.Children.Add(txtblk);
Canvas.SetLeft(txtblk, 180);
Canvas.SetTop(txtblk, 200);
i++;
}
Path myPath = new Path();
myPath.Stroke = Brushes.Red;
myPath.StrokeThickness = 1;
// 正五角星
StreamGeometry theGeometry = BuildPentagonalStars(new Point(180, 168), 80, 80);
theGeometry.FillRule = FillRule.EvenOdd;
theGeometry.Freeze();
myPath.Data = theGeometry;
myPath.Fill = Brushes.Red;
canv.Children.Add(myPath);
}
StreamGeometry BuildPentagonalStars(Point location, int width, int height)
{
Point[] pointsPentagonalStars = brawdrawSharp.RegularPolygon.GetStarPoints(location, width, height);
StreamGeometry geometry = new StreamGeometry();
using (StreamGeometryContext ctx = geometry.Open())
{
ctx.BeginFigure(new Point(pointsPentagonalStars[0].X, pointsPentagonalStars[0].Y), true, true);
for (int i = 0; i < pointsPentagonalStars.Length; i++)
{
ctx.LineTo(pointsPentagonalStars[i], true, false);
}
}
return geometry;
}
}
}
关于StreamGeometry相关文章参考:
如何:使用 StreamGeometry 创建形状 http://msdn2.microsoft.com/zh-cn/library/ms742199.aspx
WPF中图形表示语法详解(Path之Data属性语法)http://blog.csdn.net/johnsuna/archive/2007/11/14/1885597.aspx
WPF公章制作之2的更多相关文章
- 在WPF中制作正圆形公章
原文:在WPF中制作正圆形公章 之前,我利用C#与GDI+程序制作过正圆形公章(利用C#制作公章 ,C#制作公章[续])并将它集成到一个小软件中(个性印章及公章的画法及实现),今天我们来探讨一下WPF ...
- 在WPF中使用依赖注入的方式创建视图
在WPF中使用依赖注入的方式创建视图 0x00 问题的产生 互联网时代桌面开发真是越来越少了,很多应用都转到了浏览器端和移动智能终端,相应的软件开发上的新技术应用到桌面开发的文章也很少.我之前主要做W ...
- MVVM框架从WPF移植到UWP遇到的问题和解决方法
MVVM框架从WPF移植到UWP遇到的问题和解决方法 0x00 起因 这几天开始学习UWP了,之前有WPF经验,所以总体感觉还可以,看了一些基础概念和主题,写了几个测试程序,突然想起来了前一段时间在W ...
- MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息
MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二 ...
- MVVM模式解析和在WPF中的实现(五)View和ViewModel的通信
MVVM模式解析和在WPF中的实现(五) View和ViewModel的通信 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 M ...
- MVVM设计模式和WPF中的实现(四)事件绑定
MVVM设计模式和在WPF中的实现(四) 事件绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- MVVM模式解析和在WPF中的实现(三)命令绑定
MVVM模式解析和在WPF中的实现(三) 命令绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- MVVM模式和在WPF中的实现(二)数据绑定
MVVM模式解析和在WPF中的实现(二) 数据绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- MVVM模式和在WPF中的实现(一)MVVM模式简介
MVVM模式解析和在WPF中的实现(一) MVVM模式简介 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在 ...
随机推荐
- [TypeScript] Sharing Class Behavior with Inheritance in TypeScript
Typescript classes make inheritance much easier to write and understand. In this lesson we look into ...
- js进阶课程 12-9 jquery的事件对象event的方法有哪些?
js进阶课程 12-9 jquery的事件对象event的方法有哪些? 一.总结 一句话总结:三组六个,阻止默认事件一组,阻止冒泡一组,阻止冒泡和剩余事件一组. 1.事件的默认动作指什么? 比如点a标 ...
- POJ 2642 The Brick Stops Here 0-1背包
poj: http://poj.org/problem?id=2642 大意: 给出n(n<=200)块黄铜合金,还有它们的浓度和价钱.给出若干个个询问使它们在n块中取 M 块 使得这M块合金的 ...
- 16、NOR FLASH驱动框架
mtdram.c是内核自带用内存模拟nor flash程序 physmap.c是内核自带nor flash驱动程序最底层硬件相关层代码 其关键代码是:1.分配一个map_info结构体 2.设置 ...
- MySQL之SQL mode——检查官
原文:MySQL之SQL mode--检查官 MySQL升级后代码出bug? 前段时间,测试的MySQL服务器进行了一次升级,从MySQL5.6升级到了MySQL5.7.以为是简单的升级,不会影响到代 ...
- 【Nutch2.2.1基础教程之3】Nutch2.2.1配置文件 分类: H3_NUTCH 2014-08-18 16:33 1376人阅读 评论(0) 收藏
nutch-site.xml 在nutch2.2.1中,有两份配置文件:nutch-default.xml与nutch-site.xml. 其中前者是nutch自带的默认属性,一般情况下不要修改. 如 ...
- ENVI显示GDAL创建GeoTiff文件的一个问题及其思考
作者:朱金灿 来源:http://blog.csdn.net/clever101 使用gdal创建一个100*100的红色的geotiff图像,代码如下: #include <assert.h& ...
- ExtJS中store.findExact
var ds = myGrid.apf_ds; var store = myGrid.getStore(); forEach(data, function (item) { if (store.fin ...
- 在RedHa上安装MRTG监控网卡流量
http://os.51cto.com/art/201103/252149.htm 2011-03-30 15:05 张微波 phpchina 字号:T | T 在RedHa上安装MRTG监控网卡流量 ...
- [Docker] Prune Old Unused Docker Containers and Images
In this lesson, we will look at docker container prune to remove old docker containers. We can also ...