创建Wind Dirction控件 - .Net Framework 2.0 [英] Create Wind Dirction Control - .Net Framework 2.0

查看:143
本文介绍了创建Wind Dirction控件 - .Net Framework 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有什么方法可以绘制并创建风向控制 - 箭头围绕圆圈旋转,如参考图像


请帮助我如何开始和创建相同的参考  image



解决方案

您好,


您使用哪种技术来实现此目的?


这个论坛正在谈论Windows Forms,所以我用WinForm做了一个简单的演示,请参考下面的内容:

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

private void Form1_Paint(object sender,PaintEventArgs e)
{
DrawCircle();
}

private void button1_Click(object sender,EventArgs e)
{
using(Graphics g1 = this.CreateGraphics())
{
g1.Clear(this.BackColor);
}
DrawCircle();

Graphics g = this.CreateGraphics();
double angle = Convert.ToDouble(textBox1.Text);
倍X,Y;
int x,y;
int i =计算(角度,出X,出Y);
x = Convert.ToInt32(Math.Round(X));
y = Convert.ToInt32(Math.Round(Y));
Point point1 = new Point(0,0);
point1.X = x + 55;
point1.Y = y + 55;
g.FillEllipse(Brushes.Black,point1.X,point1.Y,10,10);
}

public void DrawCircle()
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Blue,2);
g.DrawEllipse(p,10,10,100,100);
}

public int计算(双角,双X,双Y)
{
X = 50 * Math.Cos(ConvertDegreesToRadians(angle)) ;
Y = 50 * Math.Sin(ConvertDegreesToRadians(angle));
返回0;
}

//将度数转换为弧度
public static double ConvertDegreesToRadians(double degrees)
{
double radians =(Math.PI / 180) *度;
return(弧度);
}
}


希望这会有所帮助!


最好的问候,


Stanly


Hello,

Is there any way I can draw and create Wind Directional control - Arrow rotating around circle based on value like the reference image

Please help how can I start and create the same as per the reference  image

解决方案

Hi,

So which technology do you use to achieve this purpose?

This forum is talking about Windows Forms, so I make a simple demo with WinForm, please refer to it as below:

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

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            DrawCircle();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            using (Graphics g1 = this.CreateGraphics())
            {
                g1.Clear(this.BackColor);
            }
            DrawCircle();

            Graphics g = this.CreateGraphics();            
            double angle = Convert.ToDouble(textBox1.Text);
            double X, Y;
            int x, y;
            int i = Calculate(angle, out X, out Y);
            x = Convert.ToInt32(Math.Round(X));
            y = Convert.ToInt32(Math.Round(Y));
            Point point1 = new Point(0, 0);
            point1.X = x + 55;
            point1.Y = y + 55;
            g.FillEllipse(Brushes.Black, point1.X, point1.Y, 10, 10);
        }

        public void DrawCircle()
        {
            Graphics g = this.CreateGraphics();
            Pen p = new Pen(Color.Blue, 2);
            g.DrawEllipse(p, 10, 10, 100, 100);
        }
                
        public int Calculate(double angle, out double X, out double Y)
        {
            X = 50 * Math.Cos(ConvertDegreesToRadians(angle));
            Y = 50 * Math.Sin(ConvertDegreesToRadians(angle));
            return 0;
        }

        //Convert Degrees To Radians
        public static double ConvertDegreesToRadians(double degrees)
        {
            double radians = (Math.PI / 180) * degrees;
            return (radians);
        }
    }

Hope this helps!

Best Regards,

Stanly


这篇关于创建Wind Dirction控件 - .Net Framework 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆