高分救解,在C#中使用GDI+如果使一行文字沿一条曲线路径进行排列 比如曲线是椭圆,或者是个半圆,文字就沿曲线路径的下面进行有序的排列,就象印章文字沿圆形排列一样,如能提供现成的代码最好,有解决思路和参考资料也不错,谢谢各位高手和坛友了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void DrawSeal() { RetrieveAll(); if(this.SealType == SealType.OfficeSeal) { DrawOfficeSeal(); } else { DrawPersonalSeal(); } panelDisplayResultBitmap.AutoScroll = true; panelDisplayResultBitmap.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom)); panelDisplayResultBitmap.Invalidate(); }//得到相关参数: private void RetrieveAll() { int diameter = 220; try { diameter = int.Parse(this.txtBoxDiameter.Text); } catch(Exception exc) { MessageBox.Show("输入错误的公章直径!\n请确保是整数"); } if(diameter>1000 || diameter < 100 ) { MessageBox.Show("公章直径输入太大或太小了!"); diameter = 220; } this.OfficeSealDiameter = diameter; string fontName = this.FontlistBox.Text; if(fontName == string.Empty) { fontName = "Times New Roman"; } this.SelectedFontName = fontName; this.SelectedFontColorFromArgb = Color.FromArgb((int)this.FontColor_A.Value,(int)this.FontColor_R.Value, (int)this.FontColor_G.Value,(int)this.FontColor_B.Value); }// 画公章: private void DrawOfficeSeal() { try { OfficeSealMaker osm = new OfficeSealMaker(); osm.FamilyName = this.SelectedFontName; osm.IsBold = false; osm.IsEmbedNotice = false; //是否保留“勿作他用”的提示信息 osm.Diameter = this.OfficeSealDiameter; osm.Style = Style.PentagonalStars;//设置中间LOGO osm.OfficeName = this.txtBoxCompanyName.Text; osm.IsDrawInnerRect = false; osm.WordsColor = this.SelectedFontColorFromArgb; osm.BorderColor = this.SelectedFontColorFromArgb; //osm.TextVerHeight = (float)this.numericUpDownFontHeight.Value; osm.RatioX = (float)numericUpDownFontRatioX.Value / 100f; m_Bitmap = osm.Draw(); } catch(Exception exc) { MessageBox.Show(exc.Message,"发生错误"); } }//画私章: private void DrawPersonalSeal() { //int stampWidth = int.Parse(this.txtBoxDiameter.Text); PersonalSeal personalSeal = new PersonalSeal(); personalSeal.SealColor = this.SelectedFontColorFromArgb; bool isYinSeal = false; if(this.cmbBoxYinYang.SelectedItem != null && this.cmbBoxYinYang.SelectedItem.ToString() == "阴章") { isYinSeal = true; } personalSeal.IsYinSeal = isYinSeal; string sealWords = this.txtBoxPersonalSealWords.Text.Trim(); if(sealWords.Length != 4) { sealWords = "美中印章"; } personalSeal.SealWords = sealWords; personalSeal.FontFamilyName = this.SelectedFontName; personalSeal.IsDrawInnerBorder = false; personalSeal.BorderWidth = 10; personalSeal.Celling = 0; int personalSealWidth = 100; try { personalSealWidth = int.Parse(this.txtBoxWidth.Text); } catch(Exception exc) { MessageBox.Show("输入有误,请输入整数!"); } int personalSealHeight = 100; try { personalSealHeight = int.Parse(this.txtBoxHeight.Text); } catch(Exception exc) { MessageBox.Show("输入有误,请输入整数!"); } personalSeal.Width = personalSealWidth; personalSeal.Height = personalSealHeight; m_Bitmap = (Bitmap)personalSeal.Draw(); }//私人印章的画法:public System.Drawing.Image Draw() { Bitmap m_Bitmap; Color sealColor = Color.Red; int sealWidth = this.Width; int sealHeight = this.Height; int celling = this.Celling; int penWidth = this.BorderWidth; int cornerRadius = this.CornerRadius; Rectangle rect = new Rectangle(0, 0, sealWidth, sealHeight); Rectangle rectInner = new Rectangle(penWidth + celling, penWidth + celling, sealWidth - (penWidth + celling) * 2, sealHeight - (penWidth + celling) * 2); m_Bitmap = new Bitmap(sealWidth, sealHeight); Graphics g = Graphics.FromImage(m_Bitmap); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; //g.Clear(Color.White); Pen pen = new Pen(sealColor, penWidth); pen.Alignment = PenAlignment.Inset; //画个人印章的外部圆角矩形 RoundRectangeHelper.DrawRoundRectangle(g, pen, rect, cornerRadius); pen = new Pen(this.SealColor, this.InnerBorderWidth); if(this.IsDrawInnerBorder) { g.DrawRectangle(pen, rectInner); } //画字 Font font; try { font = new Font(this.FontFamilyName, 20f); } catch(Exception exc) { font = new Font("Times New Roman",20f); } Color fillColor; if(this.IsYinSeal) { fillColor = Color.White; g.FillRectangle(new SolidBrush(this.SealColor), rectInner); } else { fillColor = this.SealColor; } string word = this.SealWords; int[] orderSrc = {1,2,3,4}; int[] orderDest = {2,4,1,3}; char[] words = word.ToCharArray(); char[] wordsTmp = new char[words.Length]; words.CopyTo(wordsTmp, 0); for(int i = 0; i < orderSrc.Length; i++) { words[orderDest[i] - 1] = wordsTmp[orderSrc[i] - 1]; } Rectangle rect1 = new Rectangle(rectInner.X, rectInner.Y, rectInner.Width/2, rectInner.Height/2); Rectangle rect2 = new Rectangle(rectInner.X + rectInner.Width/2, rectInner.Y, rectInner.Width/2, rectInner.Height/2); Rectangle rect3 = new Rectangle(rectInner.X, rectInner.Y + rectInner.Height/2, rectInner.Width/2, rectInner.Height/2); Rectangle rect4 = new Rectangle(rectInner.X + rectInner.Width/2, rectInner.Y + rectInner.Height/2, rectInner.Width/2, rectInner.Height/2); Rectangle[] rects = new Rectangle[] { rect1, rect2, rect3, rect4 }; for(int i = 0; i < 4; i++) { DrawWordIntoRectangle(g, words[i].ToString(), font, fillColor, rects[i]); } pen.Dispose(); g.Dispose(); return m_Bitmap; } xml转化为json,谢谢 关于C#对象的问题 帮我解释一段代码 请大家出点主意。 关于数据库的问题 谢谢 *.ocx 控件重新封装后,如何在打包时不把原来的*.ocx控件打进去. Form2怎么才能取到Form1 的数据 200分想和大家讨论一个问题:为什么有些人会说搞数据库开发只是表面的东西,技术含量不高,真正的程序员要做底层开发。 在安装文件中如何做到复制文件? C#中,一个对象的属性在Vs2017环境里能看到有值,但是用代码读取就变成了null 求助:c# 通过消息监控光驱不起作用? 使用事务的Linq语句中多次提交出现错误
private void DrawSeal()
{
RetrieveAll();
if(this.SealType == SealType.OfficeSeal)
{
DrawOfficeSeal();
}
else
{
DrawPersonalSeal();
} panelDisplayResultBitmap.AutoScroll = true;
panelDisplayResultBitmap.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
panelDisplayResultBitmap.Invalidate();
}//得到相关参数:
private void RetrieveAll()
{
int diameter = 220;
try
{
diameter = int.Parse(this.txtBoxDiameter.Text);
}
catch(Exception exc)
{
MessageBox.Show("输入错误的公章直径!\n请确保是整数");
}
if(diameter>1000 || diameter < 100 )
{
MessageBox.Show("公章直径输入太大或太小了!");
diameter = 220;
}
this.OfficeSealDiameter = diameter; string fontName = this.FontlistBox.Text;
if(fontName == string.Empty)
{
fontName = "Times New Roman";
}
this.SelectedFontName = fontName;
this.SelectedFontColorFromArgb = Color.FromArgb((int)this.FontColor_A.Value,(int)this.FontColor_R.Value,
(int)this.FontColor_G.Value,(int)this.FontColor_B.Value);
}// 画公章: private void DrawOfficeSeal()
{
try
{
OfficeSealMaker osm = new OfficeSealMaker();
osm.FamilyName = this.SelectedFontName;
osm.IsBold = false;
osm.IsEmbedNotice = false; //是否保留“勿作他用”的提示信息
osm.Diameter = this.OfficeSealDiameter;
osm.Style = Style.PentagonalStars;//设置中间LOGO
osm.OfficeName = this.txtBoxCompanyName.Text;
osm.IsDrawInnerRect = false;
osm.WordsColor = this.SelectedFontColorFromArgb;
osm.BorderColor = this.SelectedFontColorFromArgb;
//osm.TextVerHeight = (float)this.numericUpDownFontHeight.Value;
osm.RatioX = (float)numericUpDownFontRatioX.Value / 100f;
m_Bitmap = osm.Draw();
}
catch(Exception exc)
{
MessageBox.Show(exc.Message,"发生错误");
}
}//画私章: private void DrawPersonalSeal()
{
//int stampWidth = int.Parse(this.txtBoxDiameter.Text);
PersonalSeal personalSeal = new PersonalSeal();
personalSeal.SealColor = this.SelectedFontColorFromArgb;
bool isYinSeal = false;
if(this.cmbBoxYinYang.SelectedItem != null && this.cmbBoxYinYang.SelectedItem.ToString() == "阴章")
{
isYinSeal = true;
}
personalSeal.IsYinSeal = isYinSeal;
string sealWords = this.txtBoxPersonalSealWords.Text.Trim();
if(sealWords.Length != 4)
{
sealWords = "美中印章";
}
personalSeal.SealWords = sealWords;
personalSeal.FontFamilyName = this.SelectedFontName;
personalSeal.IsDrawInnerBorder = false;
personalSeal.BorderWidth = 10;
personalSeal.Celling = 0; int personalSealWidth = 100;
try
{
personalSealWidth = int.Parse(this.txtBoxWidth.Text);
}
catch(Exception exc)
{
MessageBox.Show("输入有误,请输入整数!");
} int personalSealHeight = 100;
try
{
personalSealHeight = int.Parse(this.txtBoxHeight.Text);
}
catch(Exception exc)
{
MessageBox.Show("输入有误,请输入整数!");
} personalSeal.Width = personalSealWidth;
personalSeal.Height = personalSealHeight; m_Bitmap = (Bitmap)personalSeal.Draw();
}//私人印章的画法:
public System.Drawing.Image Draw()
{
Bitmap m_Bitmap;
Color sealColor = Color.Red;
int sealWidth = this.Width;
int sealHeight = this.Height;
int celling = this.Celling;
int penWidth = this.BorderWidth;
int cornerRadius = this.CornerRadius;
Rectangle rect = new Rectangle(0, 0, sealWidth, sealHeight);
Rectangle rectInner = new Rectangle(penWidth + celling, penWidth + celling, sealWidth - (penWidth + celling) * 2, sealHeight - (penWidth + celling) * 2);
m_Bitmap = new Bitmap(sealWidth, sealHeight);
Graphics g = Graphics.FromImage(m_Bitmap);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
//g.Clear(Color.White); Pen pen = new Pen(sealColor, penWidth);
pen.Alignment = PenAlignment.Inset; //画个人印章的外部圆角矩形
RoundRectangeHelper.DrawRoundRectangle(g, pen, rect, cornerRadius); pen = new Pen(this.SealColor, this.InnerBorderWidth);
if(this.IsDrawInnerBorder)
{
g.DrawRectangle(pen, rectInner);
} //画字
Font font;
try
{
font = new Font(this.FontFamilyName, 20f);
}
catch(Exception exc)
{
font = new Font("Times New Roman",20f);
}
Color fillColor;
if(this.IsYinSeal)
{
fillColor = Color.White;
g.FillRectangle(new SolidBrush(this.SealColor), rectInner);
}
else
{
fillColor = this.SealColor;
} string word = this.SealWords;
int[] orderSrc = {1,2,3,4};
int[] orderDest = {2,4,1,3};
char[] words = word.ToCharArray();
char[] wordsTmp = new char[words.Length];
words.CopyTo(wordsTmp, 0);
for(int i = 0; i < orderSrc.Length; i++)
{
words[orderDest[i] - 1] = wordsTmp[orderSrc[i] - 1];
} Rectangle rect1 = new Rectangle(rectInner.X, rectInner.Y, rectInner.Width/2, rectInner.Height/2);
Rectangle rect2 = new Rectangle(rectInner.X + rectInner.Width/2, rectInner.Y, rectInner.Width/2, rectInner.Height/2);
Rectangle rect3 = new Rectangle(rectInner.X, rectInner.Y + rectInner.Height/2, rectInner.Width/2, rectInner.Height/2);
Rectangle rect4 = new Rectangle(rectInner.X + rectInner.Width/2, rectInner.Y + rectInner.Height/2, rectInner.Width/2, rectInner.Height/2);
Rectangle[] rects = new Rectangle[]
{
rect1, rect2, rect3, rect4
}; for(int i = 0; i < 4; i++)
{
DrawWordIntoRectangle(g, words[i].ToString(), font, fillColor, rects[i]);
} pen.Dispose();
g.Dispose(); return m_Bitmap;
}