本文介绍了在执行多个单击事件时调用OpenGL绘画事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行以下操作的Windows窗体应用程序:
-6个按钮可增加或减少X,Y,Z值
-单击按钮时,程序将根据此值计算机械手配置
-程序在几个文本框中显示值和配置

我还创建了一个OpenGL绘制事件来绘制配置.
现在,每次单击6中的1时,我需要重绘配置文件. (换句话说,当一个动作调用另一个事件时(如单击按钮)如何调用一个事件)

I have a windows forms application that does the following:
- 6 buttons to increment or decrement X, Y, Z values
- when a button is clicked, the program calculates a robot configuration to this values
- the program displays the values and configuration in several text boxes

I have also created a OpenGL paint event which draws the configuration.
Now, I need to redraw the configuatrion every time 1 of the 6 is clicked. (In other words, how can I call an event when another event is called by an action - like a button click)

推荐答案

int _x, _y, _z;

// Properties
public int X
{
    get { return _x; }
    set { _x = value; UpdateConfiguration(); }
}

public int Y
{
    get { return _y; }
    set { _y = value; UpdateConfiguration(); }
}

public int Z
{
    get { return _z; }
    set { _z = value; UpdateConfiguration(); }
}

// Methods
void UpdateConfiguration()
{
    // Update your text boxes here

    // Redraw whatever you need to redraw
    DrawConfiguration();
}

void DrawConfiguration()
{
    // Do your openGL stuff here
}

// Event handlers
void IncX_Click(...)
{
    X += 1;
}

void DecX_Click(...)
{
    X -= 1;
}


void IncY_Click(...)
{
    Y += 1;
}

void DecY_Click(...)
{
    Y -= 1;
}

void IncZ_Click(...)
{
    Z += 1;
}

void DecZ_Click(...)
{
    Z -= 1;
}

void OpenGL_PaintEvent(...)
{
    DrawConfiguration();
}



这篇关于在执行多个单击事件时调用OpenGL绘画事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:24
查看更多