本文介绍了更改方向的光标箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我需要从屏幕中心(Winform)到鼠标移动点画一条线.

我已经使用此逻辑来更改光标箭头图像.这是四个方向的.我要如何在8个方向上进行操作(东北,西北,东南,西南)

Hi all
i need to draw a line from the center of the screen(Winform) to the point where the mouse is moved.

i have used this logic to change the cursor arrow image. this is for the 4 directions. how can i do it for 8 directions(NorthEast,Northwest,SouthEast,SouthWest)

if (System.Math.Abs(x_axis - p.X) > System.Math.Abs(y_axis - p.Y))
{
    // change in x is greater, now find left or right
    if ((x_axis - p.X) < 0)
    {
        //Right
        //Cursor.DrawStretched;
        Cursor.Current = Cursors.PanEast;
    }
    else
    {
        //return "left";
        Cursor.Current = Cursors.PanWest;
        //Cursors.p
    }
}
else
{
    // change in y is greater, now find up or down
    if ((y_axis - p.Y) < 0)
    {
        //return "up";
        Cursor.Current = Cursors.PanSouth;
    }
    else
    {
        //return "down";
        Cursor.Current = Cursors.PanNorth;
    }
}



[edit]添加了代码块,将我的内容作为纯文本..."选项已禁用-OriginalGriff [/edit]



[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]

推荐答案


这篇关于更改方向的光标箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 02:10