本文介绍了画一条线或圆...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

可能有什么帮助我...

我想编写一个程序,让我用鼠标画一条线或任何形状.然后给我几英寸或几英寸.不是这个,但是我需要它来测量任何形状的长度,就好像它是一条线一样.为了说明,我需要测量从一个特定点到另一点的圆的长度.

非常感谢,

Hi all,

May any help me with this...

I want to write a program to let me draw a line or any shape, with the mouse, for example. Then gives me how long is it with inches or whatsoever. Not this, but I need it to measure any shape''s length as though it is a line. To illustrate,I need to measure the length of the circle from one specific point to another one.

Thanks a lot,

推荐答案

Point startPoint = new Point(0, 0);
bool down = false;
private void panel1_MouseDown(object sender, MouseEventArgs e)
    {
    startPoint = e.Location;
    down = true;
    }

private void panel1_MouseMove(object sender, MouseEventArgs e)
    {
    if (down)
        {
        Point endPoint = e.Location;
        double length = Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2));
        label1.Text = length.ToString();
        }
    }

private void panel1_MouseUp(object sender, MouseEventArgs e)
    {
    down = false;
    }



这篇关于画一条线或圆...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 16:49
查看更多