第一范文网 - 专业文章范例文档资料分享平台

编译原理经典算法的可视化实现 - 图文

来源:用户分享 时间:2025/5/29 7:50:55 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

编译原理经典算法的可视化实现 } //标识符 if (judge(str2) ==1) { int j; length = str1.Length ; for (j = 0; j< length;j++) { changecolor(); if (j == 0) draw(1); else draw(2);

autoEvent.WaitOne(); }

changecolor(); draw(3); i--;

inputListview(str1, str2,str3); }

if (judge(str2) == 2) {

int j;

length = str1.Length ; for (j= 0; j < length; j++) {

changecolor();

autoEvent.WaitOne(); }

changecolor(); i--;

inputListview(str1, str2,str3);

}

if(judge(str2)==3) {

changecolor();

autoEvent.WaitOne(); }

37

编译原理经典算法的可视化实现 } sr.Close(); } /*输入二元组*/ private void inputListview(string str1,string str2,string str3) { ListViewItem item = new ListViewItem(); item.Text = str1; item.SubItems.Add(str2); item.SubItems.Add(str3); listShow.Items.Add(item); listShow.Update(); } /*画图*/ private void paint() { Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Black, 2); int x = rtSource.Location.X + rtSource.Width + 50; int y = rtSource.Location.Y; int width = this.Width - x - 100; int heigh = this.Height - listShow.Height - 220; Rectangle rect = new Rectangle(x, y, width, heigh); g.DrawRectangle(p, rect); //画S Rectangle rect1 = new Rectangle(x + 30, y + 45, 50, 50); g.DrawEllipse(p, rect1); Brush brush = new SolidBrush(Color.LawnGreen); Font font = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font, brush, x + 40, y + 55); //画A Rectangle rect2 = new Rectangle(x + 120, y + 45, 50, 50); g.DrawEllipse(p, rect2); Brush brush1 = new SolidBrush(Color.LawnGreen); Brush bru = new SolidBrush(Color.IndianRed); Font font1 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font1, brush1, x + 130, y + 45); //画B Rectangle rect3 = new Rectangle(x + 200, y + 45, 50, 50); Rectangle rect31 = new Rectangle(x + 210, y + 55, 35, 35); g.DrawEllipse(p, rect3); 38

编译原理经典算法的可视化实现 g.DrawEllipse(p, rect31); Brush brush2 = new SolidBrush(Color.LawnGreen); Font font2 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font2, brush2, x + 210, y + 55); //画C Rectangle rect4 = new Rectangle(x + 120, y + 140, 50, 50); g.DrawEllipse(p, rect4); Brush brush3 = new SolidBrush(Color.LawnGreen); Font font3 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font3, brush1, x + 130, y + 150); //画D Rectangle rect5 = new Rectangle(x + 200, y + 140, 50, 50); Rectangle rect51 = new Rectangle(x + 210, y + 150, 35, 35); g.DrawEllipse(p, rect5); g.DrawEllipse(p, rect51); Brush brush5 = new SolidBrush(Color.LawnGreen); Font font5 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font5, brush5, x + 210, y + 150); //画线 Pen pline = new Pen(Color.Black, 5); pline.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; pline.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; //画s->A g.DrawLine(pline, x + 80, y + 70, x + 120, y + 70); g.DrawString(\, font, bru, x + 80, y + 35); //画s->c g.DrawLine(pline, x + 80, y + 70, x + 120, y + 155); g.DrawString(\, font, bru, x + 70, y + 90); //A->B g.DrawLine(pline, x + 170, y + 70, x + 200, y + 70); g.DrawString(\, font, bru, x + 170, y + 35); //C->D g.DrawLine(pline, x + 170, y + 165, x + 200, y + 165); g.DrawString(\, font, bru, x + 170, y + 130); //画A->A Point[] points = new Point[3]; points[0] = new Point(x + 124, y + 55); points[1] = new Point(x + 140, y + 25); points[2] = new Point(x + 165, y + 55); g.DrawString(\, font, bru, x + 100, y - 5); g.DrawCurve(pline, points); //画C->C Point[] point = new Point[3]; point[0] = new Point(x + 124, y + 150); 39

编译原理经典算法的可视化实现 point[1] = new Point(x + 140, y + 120); point[2] = new Point(x + 165, y + 150); g.DrawString(\, font, bru, x + 130, y + 90); g.DrawCurve(pline, point); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Pen p=new Pen(Color.Black ,2); int x = rtSource.Location.X + rtSource.Width + 50; int y=rtSource .Location .Y; int width = this.Width - x - 100; int heigh = this.Height - listShow.Height - 250; Rectangle rect = new Rectangle(x,y , width,heigh ); g.DrawRectangle(p, rect); //画S Rectangle rect1=new Rectangle (x+30,y+45,50,50); g.DrawEllipse(p, rect1); Brush brush = new SolidBrush(Color.LawnGreen); Font font = new Font(\楷体GB-2312\,25,FontStyle.Bold); g.DrawString(\, font, brush, x + 40, y + 55); //画A Rectangle rect2 = new Rectangle(x + 120, y + 45, 50, 50); g.DrawEllipse(p, rect2); Brush brush1 = new SolidBrush(Color.LawnGreen); Brush bru = new SolidBrush(Color.IndianRed); Font font1 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font1, brush1, x + 130, y + 45); //画B Rectangle rect3 = new Rectangle(x + 200, y + 45, 50, 50); Rectangle rect31 = new Rectangle(x + 210, y + 55, 35, 35); g.DrawEllipse(p, rect3); g.DrawEllipse(p, rect31); Brush brush2 = new SolidBrush(Color.LawnGreen); Font font2 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font2, brush2, x + 210, y +55); //画C Rectangle rect4 = new Rectangle(x + 120, y + 140, 50, 50); g.DrawEllipse(p, rect4); Brush brush3 = new SolidBrush(Color.LawnGreen); Font font3 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font3, brush1, x + 130, y + 150); //画D 40

编译原理经典算法的可视化实现 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3s3oq73jzx7u3cn9al3b_11.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top