我需要在运行从 textbox1 获得的字符串输入流程图时创建。表单大小为 700*450,并且允许滚动。每个字母之间(输入字符串中的字符)必须是(在输出中)一个箭头(显示在按钮上)*整个图表必须在按钮 * 例如,对于这个输入字符串:'ABZAZAZA' 每个字母都有一个合适的颜色,按钮的背景应该被着色。
程序应该是“打印”:A --> B --> Z --> A --> Z --> A --> Z --> A -->
箭头按钮尺寸:34*23 字母按钮尺寸:34*29
我的代码的问题,没有显示流程图
继承人的代码:
public void DrawingSystem(string st)
{
shura_acid = 12;
tur_acid = 185;
for (int i = 1; i <= st.Length; i++)
{
if ((i % 7) == 0)
{
OpenNewLine();
}
CreateAcid(st[i - 1], i);
shura_acid = shura_acid + 24 + 68;
}
}
public void OpenNewLine()
{
tur_acid = tur_acid + 29 + 12;//34 because the size of button,12 because space between lines
shura_acid = 12;
}
public void CreateAcid(char letter, int i)
{
//create acid
Button acid = new Button();
acid.Location = new System.Drawing.Point(shura_acid, tur_acid);
acid.Name = "acid" + i;
acid.Size = new System.Drawing.Size(34, 29);
acid.TabIndex = 100 + i;
acid.Text = Convert.ToString(letter);
switch (letter)
{
case 'A': acid.BackColor = System.Drawing.Color.Fuchsia; break;
case 'C': acid.BackColor = System.Drawing.Color.Pink; break;
case 'D': acid.BackColor = System.Drawing.Color.Gray; break;
case 'F': acid.BackColor = System.Drawing.Color.Azure; break;
case 'G': acid.BackColor = System.Drawing.Color.Red; break;
case 'H': acid.BackColor = System.Drawing.Color.Aqua; break;
case 'I': acid.BackColor = System.Drawing.Color.Lime; break;
case 'K': acid.BackColor = System.Drawing.Color.Yellow; break;
case 'L': acid.BackColor = System.Drawing.Color.Olive; break;
case 'M': acid.BackColor = System.Drawing.Color.Coral; break;
case 'N': acid.BackColor = System.Drawing.Color.SaddleBrown; break;
case 'P': acid.BackColor = System.Drawing.Color.Teal; break;
case 'Q': acid.BackColor = System.Drawing.Color.Blue; break;
case 'R': acid.BackColor = System.Drawing.Color.Orange; break;
case 'S': acid.BackColor = System.Drawing.Color.Green; break;
case 'T': acid.BackColor = System.Drawing.Color.SteelBlue; break;
case 'V': acid.BackColor = System.Drawing.Color.DarkViolet; break;
case 'W': acid.BackColor = System.Drawing.Color.Crimson; break;
case 'X': acid.BackColor = System.Drawing.Color.MediumAquamarine; break;
default: acid.BackColor = System.Drawing.Color.Gold; break;
}
//create arrow
Button arrow = new System.Windows.Forms.Button();
arrow.Location = new System.Drawing.Point(shura_acid + 34 + 12, tur_acid);
arrow.Name = "acid" + i;
arrow.Size = new System.Drawing.Size(34, 23);
arrow.TabIndex = 100 + i;
arrow.Text = "-->";
arrow.UseVisualStyleBackColor = false;
}