亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

C#動態數據繪圖graphic的案例

發布時間:2020-10-24 16:43:31 來源:億速云 閱讀:228 作者:小新 欄目:編程語言

這篇文章將為大家詳細講解有關C#動態數據繪圖graphic的案例,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

具體如下:

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;
using System.Drawing.Drawing2D;
namespace Drawing
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private int WidthAdded = 0;
    private int HeightAdded = 0;
    private int Added_Value = 15;
    private int Incremented = 3;
    private double Width_Max = 0.0f;
    private double Height_Max = 0f;
    private string hstrlink;
    private string vstrlink;
    private const int hor_kedu=17;
    private const int ver_kedu = 13;
    private double HelpRdm = 0;
    private void Form1_Load(object sender, EventArgs e)
    {
      Width_Max=Convert.ToDouble(panel.ClientSize.Width);
      Height_Max = Convert.ToDouble(panel.ClientSize.Height);
      BtnStatusInfoForb();
    }
    private void button1_Click(object sender, EventArgs e)
    {
      Graphics myGraphics_framwork;
      Pen myPen = new Pen(Color.Blue, 0.25f);
      myGraphics_framwork = panel.CreateGraphics();
      for (int Increment = 0; Increment < panel.Height; Increment += Incremented)
      {
        myGraphics_framwork.DrawLine(myPen, 0, HeightAdded, panel.ClientSize.Width, HeightAdded);
        HeightAdded = HeightAdded + Added_Value;
      }
      for (int Increment = 0; Increment < panel.Height; Increment += Incremented)
      {
        myGraphics_framwork.DrawLine(myPen, WidthAdded, 0, WidthAdded, panel.ClientSize.Height);
        WidthAdded = WidthAdded + Added_Value;
      }
      myGraphics_framwork.Dispose();
      for (int hstart = 0; hstart < Width_Max; hstart += hor_kedu)
      {
        hstrlink = hstrlink + hstart.ToString() + "-";
      }
      label2.Text = hstrlink;
      for (int start = (int)Height_Max; start > 0; start -= ver_kedu)
      {
        vstrlink = vstrlink + start.ToString() + "-" + "\n";
      }
      label3.Text = vstrlink + "0-";
      BtnStatusInfoActi();
      button1.Enabled = false;
    }
    private void BtnStatusInfoForb()
    {
      button2.Enabled = false;
      button3.Enabled = false;
      button4.Enabled = false;
      trackBar1.Enabled = false;
      Rec_NumBox.Enabled = false;
    }
    private void BtnStatusInfoActi()
    {
      button2.Enabled = true;
      button3.Enabled = true;
      button4.Enabled = true;
      trackBar1.Enabled = true;
      Rec_NumBox.Enabled = true;
    }
    private void myfun()
    {
      Graphics myGraphics = panel.CreateGraphics();
      Font myFont = new Font("Times New Roman", 72, FontStyle.Italic);
      Point startPoint = new Point(0, 0);
      Point endPoint = new Point(30, 30);
      LinearGradientBrush myBrush = new LinearGradientBrush(startPoint, endPoint, Color.Black, Color.Yellow);
      myBrush.WrapMode = WrapMode.TileFlipXY;
      myGraphics.DrawString("String", myFont, myBrush, 0, 0);
    }
    private void button2_Click(object sender, EventArgs e)
    {
      if (ParaBox1.Text == null)
      {
        MessageBox.Show("請輸入矩形的高度");
      }
      else
      {
        try
        {
          Graphics myGraphics_Rectangle = panel.CreateGraphics();
          Pen myPen_Rec = new Pen(Color.Red, 3);
          Rectangle rect = new Rectangle();
          rect.X = 20; rect.Y = panel.ClientSize.Height - Convert.ToInt32(ParaBox1.Text);
          rect.Width = 20; rect.Height = panel.ClientSize.Height;
          myGraphics_Rectangle = panel.CreateGraphics();
          myGraphics_Rectangle.DrawRectangle(myPen_Rec, rect);
          SolidBrush MyRectBrush = new SolidBrush(Color.Purple);
          myGraphics_Rectangle.FillRectangle(MyRectBrush, rect);
          myGraphics_Rectangle.Dispose();
        }
        catch (Exception Excp)
        {
          MessageBox.Show(Excp.Message);
        }
      }
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button3_Click(object sender, EventArgs e)
    {
      Graphics myGraphics_Rectangle = panel.CreateGraphics();
      if (Rec_NumBox == null)
      {
        MessageBox.Show("請輸入你要繪制的矩形數量");
      }
      else
      {
        double count = Convert.ToInt32(Rec_NumBox.Text);
        double TableSpace = (1 * Width_Max) / (4 * count);
        double TableWidth = (3 * Width_Max) / (4 * count);
        double RecOffset = TableWidth + TableSpace;//
        Pen myPen_Rec = new Pen(Color.Red, 3);
        for (long RectNum = 0; RectNum < count; RectNum++)
        {
          Random Radom = new Random();
          System.Threading.Thread.Sleep(20);
          double RandomHegiht =Radom.Next(0, Convert.ToInt32(Height_Max));
          Rectangle rect = new Rectangle();
          rect.X =Convert.ToInt32(RectNum*RecOffset);
          rect.Y = Convert.ToInt32(panel.ClientSize.Height - RandomHegiht);
          rect.Width = Convert.ToInt32(TableWidth);
          rect.Height = panel.ClientSize.Height;
          myGraphics_Rectangle = panel.CreateGraphics();
          myGraphics_Rectangle.DrawRectangle(myPen_Rec, rect);
          SolidBrush MyRectBrush = new SolidBrush(Color.Green);
          myGraphics_Rectangle.FillRectangle(MyRectBrush, rect);
        }
      myGraphics_Rectangle.Dispose();
      }
      Rec_NumBox.Text = Added_Value.ToString();
      Added_Value = Added_Value+50;
    }
    private void button4_Click(object sender, EventArgs e)
    {
      StringFormat sf=new StringFormat();
      sf.Alignment = StringAlignment.Near;
      Graphics myGraphics = panel.CreateGraphics();
      RectangleF REf = new RectangleF(12, 30, 8, 38);
      Font myFont = new Font("Times New Roman", 62, FontStyle.Italic);
      Point startPoint = new Point(0, 0);
      Point endPoint = new Point(30, 30);
      LinearGradientBrush myBrush = new LinearGradientBrush(startPoint, endPoint, Color.Green, Color.Blue);
      SolidBrush MyRectBrush = new SolidBrush(Color.Purple);
      myBrush.WrapMode = WrapMode.TileFlipXY;
      myGraphics.DrawString("b2spirit", myFont, myBrush, 0, 0);
      Random r=new Random();
      int temp=r.Next(10,300);
      myGraphics.DrawString(temp.ToString(), myFont, MyRectBrush, REf, sf);
    }
    private void trackBar1_Scroll(object sender, EventArgs e)
    {
      TrackBar myTB=new TrackBar();
      myTB=(TrackBar)sender;
      Rec_NumBox.Text = myTB.Value.ToString();
    }
  }
}

截圖

C#動態數據繪圖graphic的案例

C#動態數據繪圖graphic的案例

關于C#動態數據繪圖graphic的案例就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

宣武区| 成都市| 兰西县| 濉溪县| 平阳县| 佳木斯市| 泰州市| 五原县| 固安县| 宜宾市| 横峰县| 玉门市| 虎林市| 阳山县| 湘西| 庆元县| 治县。| 神农架林区| 柳江县| 卓资县| 西乌珠穆沁旗| 子洲县| 秦皇岛市| 沙洋县| 衡阳县| 扶沟县| 东山县| 长兴县| 新巴尔虎左旗| 巩义市| 沁阳市| 绥芬河市| 梨树县| 芦溪县| 和顺县| 礼泉县| 滕州市| 乌什县| 襄城县| 湾仔区| 广德县|