zoukankan      html  css  js  c++  java
  • C#:画图坐标平移,重绘,及不消失的方法。

    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 RactangleDrawAndMatrix
    {
        public partial class Form1 : Form
        {
            float move = 50f;
            public Form1()
            {
                InitializeComponent();
              
            }
            private void panel1_Paint(object sender, PaintEventArgs e)
            {//这里画图是随着控件的刷新而刷新的,就是说只要控件不消失图就不消失。下面的则可能消失
                Graphics g = panel1.CreateGraphics();
                g.DrawRectangle(new Pen(Color.Black, 5), new Rectangle(50, 50, panel1.Width - 100, panel1.Height - 100));
            }
            private void button1_Click(object sender, EventArgs e)
            {
                Refresh();
                Graphics g = panel1.CreateGraphics();
                Pen blackPen = new Pen(Color.Black, 2);
                Point point1 = new Point(1, 1);
                Point point2 = new Point(100, 100);
                g.DrawRectangle(blackPen, 1, 1, 100, 200);
            }
            private void button2_Click(object sender, EventArgs e)
            {
                Refresh();//刷新,清除所有图形
                Graphics g = panel1.CreateGraphics();
                g.TranslateTransform(panel1.Width / 2, panel1.Height / 2);
                g.RotateTransform(90);//旋转90度
               // Pen blackPen = new Pen(Color.Black, 2);
                //Point point1 = new Point(1, 1);
               // Point point2 = new Point(100, 100);
               
              
                g.DrawRectangle(new Pen(Color.Blue, 2), new Rectangle(0, 0, 100, 200));
            }
           
        }
    }
    自动驱动未来
  • 相关阅读:
    PHP Framework
    PHP Framework
    PHP Framework
    PHP Framework
    Coursera:一流大学免费在线课程平台
    在线编译器Coding Ground
    朱子家训
    [转]3天搞定的小型B/S内部管理类软件定制开发项目【软件开发实战10步骤详解】
    [转]Android 如何监听返回键,弹出一个退出对话框
    [转]Android 完美退出 App (Exit)
  • 原文地址:https://www.cnblogs.com/rb-huang/p/hrb.html
Copyright © 2011-2022 走看看