# 怎么能给矩形分出层次来呢！！大家帮忙提供源码或者思路！！！

0

win的程序！！

wys0301mm | 初学一级 | 园豆：12

0

longmeimei | 园豆：292 (菜鸟二级) | 2012-08-28 16:47
0

C#使用GDI+的话，接收一个画矩形l的队列，重新封装画矩形的方法增加层次参数，层高的后画。坐标轴你可以先绘制在一个底图上，每次贴图，或是每次clear后重绘。

C# code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Paint
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int x1=10;
int max = 600;
public  void GrahpicsUpdate(Graphics graphics)
{
Pen mypen = new Pen(Color.Black);
Pen mypen1 = new Pen(Color.Red);
System.Drawing.Font font = new System.Drawing.Font("Arial", 8, FontStyle.Regular);
graphics.DrawLine(mypen, 0, 192, 700, 192);
String[] n = { "0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%" };
int xstart = 10;
for (int i = 0; i < 11; i++)
{
graphics.DrawString(n[i].ToString(), font, Brushes.DarkGray, xstart - 7, 192);//.Red
int Xmin = xstart;
for (int j = 0; j < 9; j++)
{
Xmin += 6;
if (j == 4) graphics.DrawLine(mypen, Xmin, 184, Xmin, 192);
else graphics.DrawLine(mypen, Xmin, 188, Xmin, 192);
}
graphics.DrawLine(mypen, xstart, 182, xstart, 192);
xstart = xstart + 60;
}
graphics.DrawLine(mypen1, x1, 180, x1, 200);
}

private void groupBox2_Paint(object sender, PaintEventArgs e)
{
GrahpicsUpdate(e.Graphics);
}

private void textBox5_TextChanged(object sender, EventArgs e)
{
double d = Convert.ToDouble(textBoxPresentVal.Text);
x1 = (int)(d / 100 * max)+10;
groupBox1.Invalidate(); //这里可以传入要更新的区域，不过我觉得没有必要，反而破坏了算法的简洁性，如果不是刻意地追求效率
}
}
}
acepro | 园豆：1218 (小虾三级) | 2012-08-28 17:10

您需要登录以后才能回答，未注册用户请先注册