StringFormat sf = StringFormatAlignment(this.TextAlign);
Rectangle rect = new Rectangle(0, 0, 100, 100);
g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), rect, sf);
...全文
23424打赏收藏
高分示绘图算法问题。100分求代码
有正确代码立刻结贴 前提:在onpaint事件中要将一个字符串打印到一个方框内。如果字符串过长超出界外则只显示方框内的。 要求:在方框内可以换行,直至文本将方框全部填充。 最重要的一点:该字符串一分为二,分二批打印。但看起来像直接打印该字符串一样。 我意思是假如第一段字符串打印完,恰好打印了一行半;所以下一段字符要打印出来必须接上上一段字符串。 下面的代码实现直接将该字符打印出来: StringFormat sf = StringFormatAlignment(this.TextAlign);
[code=C#]
using System;
using System.IO;//用于文件存取
using System.Data;//用于数据访问
using System.Drawing;//提供画GDI+图形的基本功能
using System.Drawing.Text;//提供画GDI+图形的高级功能
using System.Drawing.Drawing2D;//提供画高级二维,矢量图形功能
using System.Drawing.Imaging;//提供画GDI+图形的高级功能
namespace Drawpicture
{
/// <summary>
/// BarChart 的摘要说明。
/// </summary>
public class BarChart
{
private int Pic_Width = 410;
private int Pic_Height = 320;
public static bool hasNeg = false;
private const string FontWord = "Arial";
private const int FontSize = 9;
public int SIDE_WIDTH = 400;
public int SIDE_HEIGHT = 400;
private const int CHART_TOP = 60;
private int CHART_HEIGHT = 300;
private const int CHART_LEFT = 60;
private const int CHART_WIDTH = 300;
public void Render(string[] word,int[] data, out string fileName)
{