Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: OpenGL C#3.5
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)
 
Posted 6-Oct-11 10:33am
Tiemer128
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Put your opengl painting code in a function, and call it from the button click events and the opengl paint event.
 
Here's some rough pseudo code:
 
 
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();
}
 
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

using (Font myFont = new Font("Arial", 14)) { e.Graphics.DrawString("Hello .NET Guide!", myFont, Brushes.Green, new Point(2, 2)); }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 10 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100