gpt4 book ai didi

c# - 如何使用图形方法传递参数?示例如下

转载 作者:太空宇宙 更新时间:2023-11-03 14:31:22 24 4
gpt4 key购买 nike

private static void getCorners(out float Wx, out float Wy, out float Vx, out float Vy)
{
// note-- I don't know how to flip the Y axis using this method...
// this is not a "graphics" method
// In other words, I should use something like:
// flipY(object sender, System.EventArgs e);
// but don't know the syntax or whatever

// I tried to do this:
//Graphics g = this.CreateGraphic
//Matrix myMatrix2 = new Matrix(1, 0, 0, -1, 0, 0); // flip Y axis
//g.Transform = myMatrix2;
//g.TranslateTransform(0, 480, MatrixOrder.Append);
// ...but I get the error:
// error CS0026: Keyword 'this' is not valid in a static property, static method, or
// static field initializer

Wx = 1.00F;
Wy = 1.00F; // make this 1.00 (not 3.00F) down from the TOP since cannot get Y flipped
Vx = ((Wx- WXmin)*((VXmax-VXmin)+VXmin)/(WXmax-WXmin));
Vy = ((Wy-WYmin)*(VYmax-VYmin)/(WYmax-WYmin)+VYmin);
}

最佳答案

您的代码的主要问题 - 它无法编译的原因 - 是您试图从静态方法调用实例方法(通过 this 关键字)。

getCorners 方法中删除 static 关键字应该可以让您继续。除此之外,我有点不清楚你在问什么。有关 Windows 窗体中图形编程的更多帮助,这里有一个简短的教程。

http://www.techotopia.com/index.php/Drawing_Graphics_in_C_Sharp

关于c# - 如何使用图形方法传递参数?示例如下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2488286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com