using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AcknexWrapper;
namespace ButtonExample
{
class Program
{
private static BMAP button1On;
private static BMAP button1Off;
private static BMAP button1Over;
private static PANEL mainPanel;
private static IEnumerable<ScheduleMethod> buttonClick(double p)
{
Console.Write("button clicked");
yield break;
}
private static IEnumerable<ScheduleMethod> buttonLeave(double p)
{
Console.WriteLine("mouse left button");
yield break;
}
private static IEnumerable<ScheduleMethod> buttonOver(double p)
{
Console.WriteLine("mouse is over the button");
yield break;
}
private static void CreatePushButton()
{
// create BMAPS for button (and change their color)
Program.button1On =
BMAP.bmap_createblack(200, 200, 32);
Program.button1Off =
BMAP.bmap_createblack(200, 200, 32);
Program.button1Over =
BMAP.bmap_createblack(200, 200, 32);
Program.button1On.bmap_fill(new Color(200, 0, 0), 100);
Program.button1Off.bmap_fill(new Color(100, 0, 0), 100);
Program.button1Over.bmap_fill(new Color(150, 0, 0), 100);
// create a button in the panel
Program.mainPanel.pan_setbutton(
0,
1,
50,
50,
Program.button1On,
Program.button1Off,
Program.button1Over,
Program.button1On,
Program.buttonClick,
Program.buttonLeave,
Program.buttonOver);
}
//the main method, called by the scheduler
private static IEnumerable<ScheduleMethod> myMainMethod()
{
// create the main panel and make it visible
Program.mainPanel =
PANEL.pan_create(null, 1);
Program.mainPanel.SHOW = true;
Program.mainPanel.size_x = EngVar.screen_size.x;
Program.mainPanel.size_y = EngVar.screen_size.y;
// Shows how to create a simple push button and assign functions to it
Program.CreatePushButton();
// use mouse !!
EngVar.mouse_mode = 4;
yield break;
}
static void Main(string[] args)
{
//open the engine
EngFun.engine_open(null, null);
//start the scheduler
Scheduler.StartScheduler(myMainMethod);
}
}
}