• 大小: 0.07M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C#
  • 标签: 其他  

资源简介

C#GDI绘图_Pen的使用合集.rar

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

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

        //画图
        public void drawClock(int h int m int s)
        {
            Graphics g = this.CreateGraphics();

            //定义用来绘制小时的Pen定义用来绘制分钟的Pen定义用来绘制秒钟的Pen
            using (Pen hPen = new Pen(Color.Red 4) mPen = new Pen(Color.Green 2) sPen = new Pen(Color.Black 1))
            {
                try
                {
                    
                    g.Clear(Color.White);
                    //清除WinForm窗体上的物体
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    //设置绘制图形的质量
                    g.DrawEllipse(new Pen(Color.Tomato) this.Width / 2 - 90 this.Height / 2 - 90 180 180);
                    //绘制表盘
                    g.FillEllipse(Brushes.Red this.Width / 2 - 5 this.Height / 2 - 5 10 10);
                    //绘制中心点
                    g.DrawString(“3“ new Font(“隶书“ 12) Brushes.Red this.Width / 2 + 90 this.Height / 2 - 5);
                    g.DrawString(“6“ new Font(“隶书“ 12) Brushes.Red this.Width / 2 - 5 this.Height / 2 + 90);
                    g.DrawString(“9“ new Font(“隶书“ 12) Brushes.Red this.Width / 2 - 90 this.Height / 2 - 5);
                    g.DrawString(“12“ new Font(“隶书“ 12) Brushes.Red this.Width / 2 - 5 this.Height / 2 - 90);
                    //分别绘制3,6,9,12点
                    Point c = new Point(this.Width / 2 this.Height / 2);
                    //中心点c
                    double hd = Convert.ToDouble(30 * h * Math.PI / 180);
                    double md = Convert.ToDouble(6 * m * Math.PI / 180);
                    double sd = Convert.ToDouble(6 * s * Math.PI / 180);
                    Point hp = new Point((c.X + Convert.ToInt32((Math.Sin(hd)) * 30)) (c.Y - Convert.ToInt32((Math.Cos(hd)) * 30)));
                    //时钟的坐标点
                    Point mp = new Point((c.X + Convert.ToInt32((Math.Sin(md)) * 60)) (c.Y - Convert.ToInt32((Math.Cos(md)) * 60)));
                    //分钟的坐标点
                    Point sp = new Point((c.X + Convert.ToInt32((Math.Sin(sd)) * 90)) (c.Y - Convert.ToInt32((Math.Cos(sd)) * 90)));
                    //秒钟的坐标点
                    g.DrawLine(hPen c hp);
                    g.DrawLine(mPen c mp);
                    g.DrawLine(sPen c sp);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    g.Dispose();
                    hPen.Dispose();
                    mPen.Dispose();
                    sPen.Dispose();

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3403  2009-02-18 15:25  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Form1.cs

     文件       1823  2009-02-18 14:54  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Form1.Designer.cs

     文件       6008  2009-02-18 14:54  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Form1.resx

     文件       3221  2009-02-18 14:34  C#GDI绘图_Pen的使用合集\Backup\PenDemo\PenDemo.csproj

     文件        466  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Program.cs

     文件       1186  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Properties\AssemblyInfo.cs

     文件       2868  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Properties\Resources.Designer.cs

     文件       5612  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Properties\Resources.resx

     文件       1090  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Properties\Settings.Designer.cs

     文件        249  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo\Properties\Settings.settings

     文件        910  2009-02-18 13:29  C#GDI绘图_Pen的使用合集\Backup\PenDemo.sln

    ..A..H.     12288  2009-02-19 16:42  C#GDI绘图_Pen的使用合集\Backup\PenDemo.v12.suo

     文件      10752  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\bin\Debug\PenDemo.exe

     文件      30208  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\bin\Debug\PenDemo.pdb

     文件      22704  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\bin\Debug\PenDemo.vshost.exe

     文件        490  2013-03-18 17:00  C#GDI绘图_Pen的使用合集\PenDemo\bin\Debug\PenDemo.vshost.exe.manifest

     文件       3403  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\Form1.cs

     文件       2694  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\Form1.Designer.cs

     文件       6008  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\Form1.resx

     文件       7941  2019-11-12 13:39  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6218  2019-11-12 13:39  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        866  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.csproj.FileListAbsolute.txt

     文件        847  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.csproj.GenerateResource.Cache

     文件       7834  2019-11-12 13:39  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.csprojResolveAssemblyReference.cache

     文件      10752  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.exe

     文件        180  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.Form1.resources

     文件      30208  2019-11-12 13:40  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.pdb

     文件        180  2019-11-12 13:39  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\PenDemo.Properties.Resources.resources

     文件       4608  2019-11-12 13:39  C#GDI绘图_Pen的使用合集\PenDemo\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件        268  2009-02-19 11:39  C#GDI绘图_Pen的使用合集\PenDemo\obj\PenDemo.csproj.FileList.txt

............此处省略27个文件信息

评论

共有 条评论