本人正做一个电子图章生成软件,其中的环形文字不知如何现实?(附一段程序,帮忙改一下)

lg9706032921 2004-04-28 01:02:35
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication4
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();


//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.panel1.ForeColor = System.Drawing.Color.Red;
this.panel1.Location = new System.Drawing.Point(8, 8);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(376, 336);
this.panel1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(8, 360);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(376, 48);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(392, 429);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.panel1});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{





}

private void button1_Click(object sender, System.EventArgs e)
{
Graphics aa;


string centerstr="☆";
// Create font and brush.
int fontsize;
fontsize=20;
Font drawFont = new Font("Arial", fontsize);

SolidBrush drawBrush = new SolidBrush(Color.Red );


// Create point for upper-left corner of drawing.



// Set format of string.

StringFormat drawFormat = new StringFormat();

drawFormat.FormatFlags = StringFormatFlags.NoClip ;

aa=panel1.CreateGraphics();

string str="武冈市人民政府办公室";
int b;//字符长度
double x,y,CurrentX,CurrentY,CurrentZ;//坐标点
int c;//字符间长
int rw;//圆半径
rw=150;
c=50;
double lsx,l,l1;//初始长,弧长,
b=str.Length;
if (b%2==0)
{
lsx=Font.Size/2;
}
else
{

lsx=(c + Font.Size)/2;
}
Pen bb=new Pen(Color.Red ,5);
aa.DrawString(centerstr, drawFont, drawBrush, (panel1.Width-(int)(fontsize*1.85)-2)/2,(panel1.Height-(int)(fontsize*1.4)+1)/2, drawFormat);
aa.DrawEllipse(bb,(panel1.Width)/2-rw,(panel1.Height )/2-rw,2*rw,2*rw);
for(int j=0;j<str.Length;j++)
{
if (b >0)
{

l = lsx + (c +Font.Size ) * (int)(b / 2);
//MessageBox.Show(l.ToString() );
x = rw * Math.Sin(l / rw);
y = rw * Math.Cos(l / rw);
CurrentX = ((panel1.Width+Font.Size *2.5)/2 ) - x;
CurrentY = ((panel1.Height+Font.Height )/2 ) - y;
CurrentZ=(panel1.Width )/2 + x;
aa.DrawString(str.Substring (j,1), drawFont, drawBrush, (float)CurrentX,(float)CurrentY, drawFormat);
//MessageBox.Show(CurrentX.ToString() +str.Substring (j,1)+CurrentY.ToString() );
}
if (b<0)
{
//MessageBox.Show(b.ToString() );
l = lsx + (c + Font.Size) * (int)(Math.Abs(b) / 2);
l1= lsx + (c + Font.Size) * (int)(Math.Abs(b-2) / 2);
//MessageBox.Show("l:"+l.ToString() );
x =rw * System.Math.Sin(l /rw);
y = rw * System.Math.Cos(l1 / rw);
CurrentX = ((panel1.Width)/2 ) + x;
CurrentY = ((panel1.Height+Font.Height)/2 ) - y;
aa.DrawString(str.Substring (j,1), drawFont, drawBrush, (float)CurrentX,(float)CurrentY, drawFormat);
//MessageBox.Show(CurrentX.ToString() +str.Substring (j,1)+CurrentY.ToString() );
}
b = b - 2;
}


}
}
}
...全文
147 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lg9706032921 2004-04-28
  • 打赏
  • 举报
回复
帮个忙嘛

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧