Show Study_Project.cs syntax highlighted
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Tao.Platform.Windows;
using Tao.OpenGl;
namespace New_Study_Project
{
public class WorkSpace : System.Windows.Forms.Form
{
/* Definitions of the Program */
private int NUM_USERS;
/* Create InterfaceGrid - Stuff and other things */
private Tao.Platform.Windows.SimpleOpenGlControl OpenGLWorkSpace;
private System.Windows.Forms.Timer DoingNothing;
private System.ComponentModel.IContainer components;
private InterfaceGrid interfaceMain;
private int[] IconTextures;
/* Create Moving Object and Spline Stuff */
private Spline[] MOVINGSpline;
private InterfaceObject[] MOVINGInterfaceObject;
private IOSelectObject[] MOVINGIOSelectObject;
private static float INITIAL_STORAGE_WIDTH = 120.0f;
private bool MouseDOWN;
private bool MouseMOVE;
private bool MouseUP;
private ulong[] doubleClick;
private bool[] switchISDragging;
private Point[] switchLastCoordinates;
private int globalObjectCounter;
/* drawing stuff */
private ArrayList animateInterfaceObjectList;
private ArrayList animateIOSelectObjectList;
private int GLListMousePoint;
private int SELRGBCount;
private ArrayList SELColorNum;
private Point[] posCursor;
/* for selecting */
private bool[] SELSelecting;
private Point[] SELBoxUpLeft, SELBoxRightDown;
private bool[] drawIObjects;
private bool[] drawObjects;
private bool drawNonMoveObject;
private bool drawGridInterface;
private LogFile logfile;
/* for startup screen */
private StartupScreen startupScreen;
/* for MultiUser - Mod */
//private SBSDKEXWRAPPERLib.SbSdkBase sbsdk;
/* End of Definitions of the Program */
public WorkSpace(StartupScreen setScreen)
{
/* Initialize all Variables */
this.startupScreen = setScreen;
this.NUM_USERS = 2;
this.animateInterfaceObjectList = new ArrayList();
this.animateIOSelectObjectList = new ArrayList();
this.MouseDOWN = false;
this.MouseMOVE = false;
this.MouseUP = false;
this.drawNonMoveObject = false;
this.drawGridInterface = false;
this.logfile = new LogFile(startupScreen.GroupID, startupScreen.TrialNum, startupScreen.Storage, startupScreen.Material, startupScreen.Display);
this.globalObjectCounter = 0;
this.components = null;
this.InitializeComponent();
this.OpenGLWorkSpace.InitializeContexts();
// this.sbsdk = new SBSDKEXWRAPPERLib.SbSdkBaseClass();
// this.sbsdk.SetTool(1, SBSDKEXWRAPPERLib.ESBSDK_TOOL_TYPE.ESB_PEN , 1, 0xcccccc, 1, 0.0f, 0.0f);
// this.sbsdk.XYDown += new SBSDKEXWRAPPERLib._ISbSdkBaseEvents_XYDownEventHandler(this.OnXYDown);
// this.sbsdk.XYMove +=new SBSDKEXWRAPPERLib._ISbSdkBaseEvents_XYMoveEventHandler(this.OnXYMove);
// this.sbsdk.XYUp +=new SBSDKEXWRAPPERLib._ISbSdkBaseEvents_XYUpEventHandler(this.OnXYUp);
this.MOVINGInterfaceObject = new InterfaceObject[this.NUM_USERS];
this.MOVINGIOSelectObject = new IOSelectObject[this.NUM_USERS];
this.MOVINGSpline = new Spline[this.NUM_USERS];
this.SELSelecting = new bool[this.NUM_USERS];
this.SELBoxUpLeft = new Point[this.NUM_USERS];
this.SELBoxRightDown = new Point[this.NUM_USERS];
this.posCursor = new Point[this.NUM_USERS];
this.drawIObjects = new bool[this.NUM_USERS];
this.drawObjects = new bool[this.NUM_USERS];
this.drawObjects = new bool[this.NUM_USERS];
this.doubleClick = new ulong[this.NUM_USERS];
this.switchISDragging = new bool[this.NUM_USERS];
this.switchLastCoordinates = new Point[this.NUM_USERS];
for (int MU=0; MU<this.NUM_USERS; MU++)
{
this.MOVINGInterfaceObject[MU] = null;
this.MOVINGIOSelectObject[MU] = null;
this.MOVINGSpline[MU] = null;
this.SELSelecting[MU] = false;
this.SELBoxUpLeft[MU] = new Point(0, 0);
this.SELBoxRightDown[MU] = new Point(0, 0);
this.posCursor[MU] = new Point(0, 0);
this.drawIObjects[MU] = false;
this.drawObjects[MU] = false;
this.doubleClick[MU] = 0;
this.switchISDragging[MU] = false;
this.switchLastCoordinates[MU] = new Point(0, 0);
}
this.loadIconTextures();
this.SELRGBCount = 3;
this.SELColorNum = new ArrayList();
/* Initialize the OpenGLWorkSpace */
Gl.glViewport(0, 0, this.ClientSize.Width, this.ClientSize.Height);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluOrtho2D(0.0, (double) this.ClientSize.Width, this.ClientSize.Height, 0.0);
this.createMousePointList();
this.OpenGLWorkSpace.Focus();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
this.OpenGLWorkSpace.DestroyContexts();
components.Dispose();
}
}
base.Dispose( disposing );
}
private void loadIconTextures()
{
this.IconTextures = new int[10];
Gl.glGenTextures(10, this.IconTextures);
/* load ControlPoint Mask and Icon */
Bitmap image = new Bitmap(System.Environment.CurrentDirectory + "\\ControlPoint_mask.bmp");
Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
System.Drawing.Imaging.BitmapData bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[0]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\ControlPoint_pic.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[1]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\areaMove_mask.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[2]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\areaMove_pic.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[3]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\areaResize_mask.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[4]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\areaResize_pic.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[5]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\ControlPointMove_mask.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[6]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\ControlPointMove_pic.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[7]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\resize4_mask.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[8]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
image = new Bitmap(System.Environment.CurrentDirectory + "\\resize4_pic.bmp");
rect = new Rectangle(0, 0, image.Width, image.Height);
bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[9]);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, image.Width, image.Height,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
image.UnlockBits(bitmapdata);
image.Dispose();
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(WorkSpace));
this.OpenGLWorkSpace = new Tao.Platform.Windows.SimpleOpenGlControl();
this.DoingNothing = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// OpenGLWorkSpace
//
this.OpenGLWorkSpace.AccumBits = ((System.Byte)(0));
this.OpenGLWorkSpace.AutoCheckErrors = true;
this.OpenGLWorkSpace.AutoFinish = true;
this.OpenGLWorkSpace.AutoMakeCurrent = true;
this.OpenGLWorkSpace.AutoSwapBuffers = true;
this.OpenGLWorkSpace.BackColor = System.Drawing.Color.Black;
this.OpenGLWorkSpace.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("OpenGLWorkSpace.BackgroundImage")));
this.OpenGLWorkSpace.ColorBits = ((System.Byte)(32));
this.OpenGLWorkSpace.DepthBits = ((System.Byte)(16));
this.OpenGLWorkSpace.Location = new System.Drawing.Point(0, 0);
this.OpenGLWorkSpace.Name = "OpenGLWorkSpace";
this.OpenGLWorkSpace.Size = new System.Drawing.Size(1024, 2048);
this.OpenGLWorkSpace.StencilBits = ((System.Byte)(0));
this.OpenGLWorkSpace.TabIndex = 0;
this.OpenGLWorkSpace.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.OpenGLWorkSpace_KeyPressed);
this.OpenGLWorkSpace.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OpenGLWorkSpace_MouseUp);
this.OpenGLWorkSpace.Paint += new System.Windows.Forms.PaintEventHandler(this.OpenGLWorkSpace_Paint);
this.OpenGLWorkSpace.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OpenGLWorkSpace_MouseMove);
this.OpenGLWorkSpace.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OpenGLWorkSpace_MouseDown);
//
// DoingNothing
//
this.DoingNothing.Enabled = true;
this.DoingNothing.Interval = 10;
this.DoingNothing.Tick += new System.EventHandler(this.DoingNothing_Tick);
//
// WorkSpace
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.ClientSize = new System.Drawing.Size(1024, 1116);
this.Controls.Add(this.OpenGLWorkSpace);
this.Cursor = System.Windows.Forms.Cursors.Cross;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "WorkSpace";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Study - Project";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.WorkSpace_Load);
this.ResumeLayout(false);
}
private void initializeDesktop()
{
PointF[] pointStore;
DirectoryInfo theFolder;
PointF center;
float objX, objY;
float radius;
for (int MU=0; MU<this.NUM_USERS; MU++)
{
this.posCursor[MU] = new Point((int) (this.ClientSize.Width/2), (int) (this.ClientSize.Height/2));
}
switch (this.startupScreen.Storage)
{
case (StartupScreen.StorageType.Fixed):
this.interfaceMain.addWholeMoveSpline(new NonMoveAbleSpline(new PointF(0.0f, 0.0f), new PointF(this.ClientSize.Width, 0.0f), new PointF(this.ClientSize.Width, this.ClientSize.Height), new PointF(0.0f, this.ClientSize.Height), this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures, INITIAL_STORAGE_WIDTH));
this.globalObjectCounter++;
break;
case (StartupScreen.StorageType.Mobile):
float xPos;
float yPos;
xPos = 140;
yPos = 140;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(25.0f, 25.0f);
pointStore[1] = new PointF(200.0f, 7.0f);
pointStore[2] = new PointF(360.0f, 15.0f);
pointStore[3] = new PointF(330.0f, 90.0f);
pointStore[4] = new PointF(220.0f, 200.0f);
pointStore[5] = new PointF(110.0f, 310.0f);
pointStore[6] = new PointF(15.0f, 360.0f);
pointStore[7] = new PointF(7.0f, 200.0f);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
xPos = this.OpenGLWorkSpace.Width-140;
yPos = 140;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore[0] = new PointF(this.OpenGLWorkSpace.Width-25.0f, 25.0f);
pointStore[1] = new PointF(this.OpenGLWorkSpace.Width-7.0f, 200.0f);
pointStore[2] = new PointF(this.OpenGLWorkSpace.Width-15.0f, 360.0f);
pointStore[3] = new PointF(this.OpenGLWorkSpace.Width-110.0f, 310.0f);
pointStore[4] = new PointF(this.OpenGLWorkSpace.Width-220.0f, 200.0f);
pointStore[5] = new PointF(this.OpenGLWorkSpace.Width-330.0f, 90.0f);
pointStore[6] = new PointF(this.OpenGLWorkSpace.Width-360.0f, 15.0f);
pointStore[7] = new PointF(this.OpenGLWorkSpace.Width-200.0f, 7.0f);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
xPos = 140;
yPos = this.OpenGLWorkSpace.Height-140;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(25.0f, this.OpenGLWorkSpace.Height-25.0f);
pointStore[1] = new PointF(7.0f, this.OpenGLWorkSpace.Height-200.0f);
pointStore[2] = new PointF(15.0f, this.OpenGLWorkSpace.Height-360.0f);
pointStore[3] = new PointF(110.0f, this.OpenGLWorkSpace.Height-310.0f);
pointStore[4] = new PointF(220.0f, this.OpenGLWorkSpace.Height-200.0f);
pointStore[5] = new PointF(330.0f, this.OpenGLWorkSpace.Height-90.0f);
pointStore[6] = new PointF(360.0f, this.OpenGLWorkSpace.Height-15.0f);
pointStore[7] = new PointF(200.0f, this.OpenGLWorkSpace.Height-7.0f);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
xPos = this.OpenGLWorkSpace.Width-140;
yPos = this.OpenGLWorkSpace.Height-140;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore[0] = new PointF(this.OpenGLWorkSpace.Width-25.0f, this.OpenGLWorkSpace.Height-25.0f);
pointStore[1] = new PointF(this.OpenGLWorkSpace.Width-200.0f, this.OpenGLWorkSpace.Height-7.0f);
pointStore[2] = new PointF(this.OpenGLWorkSpace.Width-360.0f, this.OpenGLWorkSpace.Height-15.0f);
pointStore[3] = new PointF(this.OpenGLWorkSpace.Width-330.0f, this.OpenGLWorkSpace.Height-90.0f);
pointStore[4] = new PointF(this.OpenGLWorkSpace.Width-220.0f, this.OpenGLWorkSpace.Height-200.0f);
pointStore[5] = new PointF(this.OpenGLWorkSpace.Width-110.0f, this.OpenGLWorkSpace.Height-310.0f);
pointStore[6] = new PointF(this.OpenGLWorkSpace.Width-15.0f, this.OpenGLWorkSpace.Height-360.0f);
pointStore[7] = new PointF(this.OpenGLWorkSpace.Width-7.0f, this.OpenGLWorkSpace.Height-200.0f);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
radius = 110;
xPos = 905.0f;
yPos = 1581.0f;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(center.X, center.Y - radius-25);
pointStore[1] = new PointF(center.X + radius, center.Y - radius);
pointStore[2] = new PointF(center.X + radius+25, center.Y);
pointStore[3] = new PointF(center.X + radius, center.Y + radius );
pointStore[4] = new PointF(center.X, center.Y + radius+25);
pointStore[5] = new PointF(center.X - radius, center.Y + radius);
pointStore[6] = new PointF(center.X - radius-25, center.Y);
pointStore[7] = new PointF(center.X - radius, center.Y - radius);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
radius = 110;
xPos = 843.0f;
yPos = 1421.0f;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(center.X, center.Y - radius-25);
pointStore[1] = new PointF(center.X + radius, center.Y - radius);
pointStore[2] = new PointF(center.X + radius+25, center.Y);
pointStore[3] = new PointF(center.X + radius, center.Y + radius );
pointStore[4] = new PointF(center.X, center.Y + radius+25);
pointStore[5] = new PointF(center.X - radius, center.Y + radius);
pointStore[6] = new PointF(center.X - radius-25, center.Y);
pointStore[7] = new PointF(center.X - radius, center.Y - radius);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
radius = 110;
xPos = 668.0f;
yPos = 1275.0f;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(center.X, center.Y - radius-25);
pointStore[1] = new PointF(center.X + radius, center.Y - radius);
pointStore[2] = new PointF(center.X + radius+25, center.Y);
pointStore[3] = new PointF(center.X + radius, center.Y + radius );
pointStore[4] = new PointF(center.X, center.Y + radius+25);
pointStore[5] = new PointF(center.X - radius, center.Y + radius);
pointStore[6] = new PointF(center.X - radius-25, center.Y);
pointStore[7] = new PointF(center.X - radius, center.Y - radius);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
radius = 110;
xPos = 648.0f;
yPos = 1036.0f;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(center.X, center.Y - radius-25);
pointStore[1] = new PointF(center.X + radius, center.Y - radius);
pointStore[2] = new PointF(center.X + radius+25, center.Y);
pointStore[3] = new PointF(center.X + radius, center.Y + radius );
pointStore[4] = new PointF(center.X, center.Y + radius+25);
pointStore[5] = new PointF(center.X - radius, center.Y + radius);
pointStore[6] = new PointF(center.X - radius-25, center.Y);
pointStore[7] = new PointF(center.X - radius, center.Y - radius);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
radius = 110;
xPos = 718.0f;
yPos = 796.0f;
center = new PointF(xPos, yPos);
// Make an oval along the top of the workspace
pointStore = new PointF[8];
pointStore[0] = new PointF(center.X, center.Y - radius-25);
pointStore[1] = new PointF(center.X + radius, center.Y - radius);
pointStore[2] = new PointF(center.X + radius+25, center.Y);
pointStore[3] = new PointF(center.X + radius, center.Y + radius );
pointStore[4] = new PointF(center.X, center.Y + radius+25);
pointStore[5] = new PointF(center.X - radius, center.Y + radius);
pointStore[6] = new PointF(center.X - radius-25, center.Y);
pointStore[7] = new PointF(center.X - radius, center.Y - radius);
this.interfaceMain.addWholeMoveSpline(new MoveAbleSpline(center, pointStore, this.interfaceMain, this.globalObjectCounter, this.logfile, this.IconTextures));
this.globalObjectCounter++;
break;
} // switch (this.startupScreen.Storage)
switch (this.startupScreen.Material)
{
case (StartupScreen.MaterialType.Practice1):
theFolder = new DirectoryInfo(System.Environment.CurrentDirectory+"\\Practice1\\");
break;
case (StartupScreen.MaterialType.Practice2):
theFolder = new DirectoryInfo(System.Environment.CurrentDirectory+"\\Practice2\\");
break;
case (StartupScreen.MaterialType.Friends):
theFolder = new DirectoryInfo(System.Environment.CurrentDirectory+"\\Friends\\");
break;
case (StartupScreen.MaterialType.LOTR):
theFolder = new DirectoryInfo(System.Environment.CurrentDirectory+"\\LOTR\\");
break;
default:
theFolder = new DirectoryInfo(System.Environment.CurrentDirectory+"\\Practice1\\");
break;
} // switch (this.startupScreen.Material)
if (theFolder.Exists)
{
Random randX = new Random(System.DateTime.Now.Millisecond);
Random randY = new Random(System.DateTime.Now.Second + System.DateTime.Now.Millisecond);
int maxX = (int)Math.Ceiling((double)this.ClientSize.Width/2.0);
int maxY = (int)Math.Ceiling((double)this.ClientSize.Height/2.0);
foreach(FileInfo NextFile in theFolder.GetFiles())
{
if (NextFile.Extension.Equals(".bmp") || NextFile.Extension.Equals(".BMP"))
{
objX = this.Location.X + maxX/2 + randX.Next(maxX);
objY = this.Location.Y + maxY/2 + randY.Next(maxY);
this.interfaceMain.addObject(new InterfaceObject(new PointF(objX, objY), NextFile.FullName, this.interfaceMain, (float) (randX.Next(360)), this.globalObjectCounter, this.logfile, NextFile.Name, this.animateInterfaceObjectList, this.IconTextures));
this.globalObjectCounter++;
}
}
}
}
/*******************************************************************/
/* End of the head of the program - now the user code stuff begins */
/*******************************************************************/
private void selectMouseDown(Point selMouseDOWN, int inputID)
{
this.SELBoxUpLeft[inputID] = selMouseDOWN;
this.SELBoxRightDown[inputID] = selMouseDOWN;
this.SELSelecting[inputID] = true;
}
private void selectMouseMove(Point selMouseMOVE, int inputID)
{
if (this.SELSelecting[inputID] == true)
{
this.SELBoxRightDown[inputID] = selMouseMOVE;
}
}
private void selectMouseUp(Point selMouseUp, int inputID)
{
this.SELBoxRightDown[inputID] = selMouseUp;
this.SELSelecting[inputID] = false;
this.findInterfaceObjectInSelectBox(this.SELBoxUpLeft[inputID], this.SELBoxRightDown[inputID], inputID);
}
private bool isDoubleClick(int inputID)
{
if (this.doubleClick[inputID] > 2 && this.doubleClick[inputID] < 30)
{
this.doubleClick[inputID] = 30;
return true;
}
else
{
this.doubleClick[inputID] = 0;
return false;
}
}
private ArrayList getAllInterfaceObject()
{
ArrayList allIO;
allIO = new ArrayList();
foreach(InterfaceObject IObj in this.interfaceMain.getAllGridObjects())
{
allIO.Add(IObj);
}
foreach(IOSelectObject IOSELObj in this.interfaceMain.getAllGridIOSelectObjects())
{
foreach(InterfaceObject IObj in IOSELObj.getIOSelectObjectList())
{
allIO.Add(IObj);
}
}
return allIO;
}
private void findInterfaceObjectInSelectBox(Point boxUpLeft, Point boxDownRight, int inputID)
{
float rc;
float gc;
float bc;
float angle_dif;
float grad45;
bool selected;
IOSelectObject IOSelectOBJ;
ArrayList allInterfaceObject;
IOSelectOBJ = null;
allInterfaceObject = this.getAllInterfaceObject();
foreach(InterfaceObject IObj in allInterfaceObject)
{
if (((IObj.CentrePoint.X >= boxUpLeft.X && IObj.CentrePoint.X <= boxDownRight.X) || (IObj.CentrePoint.X >= boxDownRight.X && IObj.CentrePoint.X <= boxUpLeft.X)) && ((IObj.CentrePoint.Y >= boxUpLeft.Y && IObj.CentrePoint.Y <= boxDownRight.Y) || (IObj.CentrePoint.Y >= boxDownRight.Y && IObj.CentrePoint.Y <= boxUpLeft.Y)))
{
if (IOSelectOBJ == null)
{
IOSelectOBJ = new IOSelectObject(this.interfaceMain, this.globalObjectCounter, this.logfile, this.animateIOSelectObjectList);
this.globalObjectCounter++;
}
IOSelectOBJ.addInterfaceObject(IObj, inputID);
}
}
if (IOSelectOBJ != null)
{
rc = 0.0f;
gc = 0.0f;
bc = 0.0f;
angle_dif = (float) ((2*Math.PI)/5);
grad45 = (float) (Math.PI/4.0);
selected = false;
while (selected == false)
{
rc = (float) (0.5*Math.Cos(this.SELRGBCount*angle_dif));
gc = (float) (0.5*Math.Sin(this.SELRGBCount*angle_dif));
bc = (float) (-gc*Math.Sin(grad45));
gc = (float) (gc*Math.Cos(grad45));
rc = (float) (rc*Math.Cos(grad45)-bc*Math.Sin(grad45));
bc = (float) (rc*Math.Sin(grad45)+bc*Math.Cos(grad45));
rc = rc+0.5f;
gc = gc+0.5f;
bc = bc+0.5f;
if (this.SELColorNum.Contains(this.SELRGBCount) == true && this.SELColorNum.Count < 5)
{
this.SELRGBCount++;
if (this.SELRGBCount>=5) this.SELRGBCount = 0;
}
else
{
this.SELColorNum.Add(this.SELRGBCount);
this.SELRGBCount++;
if (this.SELRGBCount>=5) this.SELRGBCount = 0;
selected = true;
}
}
foreach(IOSelectObject IOSELObj in this.interfaceMain.getAllGridIOSelectObjects())
{
IOSELObj.update(inputID);
}
IOSelectOBJ.initializeIOSelectObject(rc, gc, bc, this.SELRGBCount, this.SELColorNum, boxUpLeft, boxDownRight, inputID);
}
}
private void removeIOSelectObject(Point pos, int inputID)
{
int objectID;
IOSelectObject removeIOSELObj = this.interfaceMain.getTopIOSelectObject(pos);
InterfaceObject IObjToBG = this.interfaceMain.getTopObject(pos);
//ControlPoint c_point = this.interfaceMain.getControlPoint(pos);
if (IObjToBG != null && removeIOSELObj != null)
{
objectID = choiceTopObject(IObjToBG, removeIOSELObj);
if (objectID == 10) removeIOSELObj = null;
else if (objectID == 1050) IObjToBG = null;
}
if (removeIOSELObj != null) removeIOSELObj.endSelection(pos, inputID);
else if (IObjToBG != null)
{
this.interfaceMain.addObjectToBG(IObjToBG);
IObjToBG.logMoveToBG(pos, inputID);
}
/*
else if (c_point != null)
{
ArrayList InterfaceObjectList = ((ArrayList) this.interfaceMain.getAllGridObjects().Clone());
foreach(InterfaceObject IObject in InterfaceObjectList)
{
IObject.isIObjectInsideWorkspace();
}
}
*/
}
private int choiceTopObject(InterfaceObject IObj, IOSelectObject IOSELObj)
{
Object drawObj;
bool found = false;
int objectID = -1;
ArrayList drawnObjectList = this.interfaceMain.getDrawnObjects();
int io=(drawnObjectList.Count-1);
while(io>=0 && found == false)
{
drawObj = drawnObjectList[io];
if (drawObj is InterfaceObject)
{
if (((InterfaceObject) drawObj) == IObj)
{
found = true;
objectID = 10;
}
}
else if (drawObj is IOSelectObject )
{
if (((IOSelectObject) drawObj) == IOSELObj)
{
found = true;
objectID = 1050;
}
}
io--;
}
return objectID;
}
private InterfaceObject catchInterfaceObject(Point hitPoint)
{
int hits = 0;
int[] pickmod = new int[200];
int[] viewport = new int[4];
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix (hitPoint.X, viewport[3]-hitPoint.Y, 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
for (int names=0; names < this.animateInterfaceObjectList.Count; names++)
{
Gl.glPushName(names);
((InterfaceObject) this.animateInterfaceObjectList[names]).drawInterfaceShadow();
Gl.glPopName();
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0) return ((InterfaceObject) this.animateInterfaceObjectList[pickmod[(hits-1)*4+3]]);
else return null;
}
private IOSelectObject catchIOSelectObject(Point hitPoint)
{
int hits = 0;
int[] pickmod = new int[200];
int[] viewport = new int[4];
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix (hitPoint.X, viewport[3]-hitPoint.Y, 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
for (int names=0; names < this.animateIOSelectObjectList.Count; names++)
{
Gl.glPushName(names);
((IOSelectObject) this.animateIOSelectObjectList[names]).drawIOSelectObjectShadow();
Gl.glPopName();
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0) return ((IOSelectObject) this.animateIOSelectObjectList[pickmod[(hits-1)*4+3]]);
else return null;
}
private MoveAbleSpline getMoveAbleSpline(Point e)
{
int hits = 0;
int[] pickmod = new int[200];
int[] viewport = new int[4];
Spline MASpline = null;
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix (e.X, viewport[3]-e.Y, 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
ArrayList MoveSplineList = this.interfaceMain.getAllGridMoveSplines();
for (int names=0; names < MoveSplineList.Count; names++)
{
MASpline = ((Spline) MoveSplineList[names]);
if (MASpline is MoveAbleSpline)
{
Gl.glPushName(names);
MASpline.drawBackGround(false);
Gl.glPopName();
}
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0) return (MoveAbleSpline) MoveSplineList[pickmod[(hits-1)*5+3]];
else return null;
}
/*******************************************************************/
/* Here are the mouse events for the OpenGLWorkSpace */
/*******************************************************************/
private void OpenGLWorkSpace_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
OnXYDown(e.X, e.Y, 0, 0);
}
private void OpenGLWorkSpace_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
OnXYMove(e.X, e.Y, 0, 0);
}
private void OpenGLWorkSpace_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
OnXYUp(e.X, e.Y, 0, 0);
}
/* Mouse Events for MultiUser - Mod */
private int getInputID(int iPointerID)
{
if (iPointerID == 2) return 0;
else if (iPointerID == 258) return 1;
else return iPointerID;
}
private void OnXYDown(int x, int y, int z, int iPointerID)
{
int objectID;
//////////////////////////////////////
//this.DoingNothing.Enabled = false;//
//////////////////////////////////////
this.MouseDOWN = true;
Point e = new Point(x, y);
int inputID = this.getInputID(iPointerID);
//Console.WriteLine("MouseDown: "+inputID);
this.switchISDragging[inputID] = true;
this.switchLastCoordinates[inputID] = new Point(e.X, e.Y);
if (this.isDoubleClick(inputID) == true) this.removeIOSelectObject(new Point(e.X, e.Y), inputID);
else
{
ControlPoint c_point = this.interfaceMain.getControlPoint(new Point(e.X, e.Y));
ObjectButton objButton = this.interfaceMain.getAssociatedObjectButton(new Point(e.X, e.Y));
InterfaceObject IObj = this.interfaceMain.getTopObject(new Point(e.X, e.Y));
IOSelectObject IOSELObj = this.interfaceMain.getTopIOSelectObject(new Point(e.X, e.Y));
InterfaceObject catchIObj = this.catchInterfaceObject(new Point(e.X, e.Y));
IOSelectObject catchISELObj = this.catchIOSelectObject(new Point(e.X, e.Y));
MoveAbleSpline splineMove = this.getMoveAbleSpline(new Point(e.X, e.Y));
if (IObj != null && IOSELObj != null)
{
objectID = choiceTopObject(IObj, IOSELObj);
if (objectID == 10) IOSELObj = null;
else if (objectID == 1050) IObj = null;
}
this.posCursor[inputID].X = e.X;
this.posCursor[inputID].Y = e.Y;
if (catchIObj != null)
{
this.MOVINGInterfaceObject[inputID] = catchIObj;
this.MOVINGInterfaceObject[inputID].catchIT(new Point(e.X, e.Y), inputID);
}
else if (catchISELObj != null)
{
this.MOVINGIOSelectObject[inputID] = catchISELObj;
this.MOVINGIOSelectObject[inputID].catchIT(new Point(e.X, e.Y), inputID);
}
else if (IObj != null)
{
this.MOVINGInterfaceObject[inputID] = IObj;
this.MOVINGInterfaceObject[inputID].mouseDOWN(new Point(e.X, e.Y), inputID);
}
else if (IOSELObj != null)
{
this.MOVINGIOSelectObject[inputID] = IOSELObj;
this.MOVINGIOSelectObject[inputID].mouseDOWN(new Point(e.X, e.Y), inputID);
}
else if (objButton != null)
{
if(objButton.getState.Equals(ObjectButton.State.StoreMove) || objButton.getState.Equals(ObjectButton.State.StoreReshape) || objButton.getState.Equals(ObjectButton.State.StoreResize))
{
this.MOVINGSpline[inputID] = objButton.storage_area;
this.MOVINGSpline[inputID].clickedStorageButton(new Point(e.X, e.Y), objButton, inputID);
}
}
else if (c_point != null)
{
this.MOVINGSpline[inputID] = c_point.getSpline;
this.MOVINGSpline[inputID].mouseDOWN(c_point, inputID);
}
else if (splineMove != null)
{
this.MOVINGSpline[inputID] = splineMove;
((MoveAbleSpline) (this.MOVINGSpline[inputID])).mouseDOWNSplineMove(new Point(e.X, e.Y));
}
else this.selectMouseDown(new Point(e.X, e.Y), inputID);
}
/////////////////////////////////
//this.OpenGLWorkSpace.Refresh();//
/////////////////////////////////
this.MouseDOWN = false;
}
private void OnXYMove(int x, int y, int z, int iPointerID)
{
Point e = new Point(x, y);
int inputID = this.getInputID(iPointerID);
//Console.WriteLine("MouseMove: "+inputID);
if (this.testSwitching(this.switchLastCoordinates[inputID], e) == true) e = this.switchLastCoordinates[inputID];
else this.switchLastCoordinates[inputID] = e;
int hits = 0;
int[] pickmod = new int[200];
int[] viewport = new int[4];
this.MouseMOVE = true;
this.posCursor[inputID].X = e.X;
this.posCursor[inputID].Y = e.Y;
if (this.MOVINGInterfaceObject[inputID] != null)
{
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix (e.X, viewport[3]-e.Y, 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
ArrayList MoveSplineList = this.interfaceMain.getAllGridMoveSplines();
for (int names=0; names < MoveSplineList.Count; names++)
{
Gl.glPushName(names);
((Spline) MoveSplineList[names]).drawBackGround(false);
Gl.glPopName();
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0) this.MOVINGInterfaceObject[inputID].mouseMOVE(new Point(e.X, e.Y), true, (Spline) MoveSplineList[pickmod[(hits-1)*5+3]], pickmod[(hits-1)*5+4]);
else this.MOVINGInterfaceObject[inputID].mouseMOVE(new Point(e.X, e.Y), false, null, 0);
}
else if (this.MOVINGIOSelectObject[inputID] != null)
{
Gl.glGetIntegerv(Gl.GL_VIEWPORT,viewport);
Gl.glSelectBuffer(200, pickmod);
Gl.glRenderMode(Gl.GL_SELECT);
Gl.glInitNames();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
Glu.gluPickMatrix (e.X, viewport[3]-e.Y, 1.0, 1.0,viewport);
Glu.gluOrtho2D(0,(double) viewport[2], (double) viewport[3] , 0);
Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
ArrayList MoveSplineList = this.interfaceMain.getAllGridMoveSplines();
for (int names=0; names < MoveSplineList.Count; names++)
{
Gl.glPushName(names);
((Spline) MoveSplineList[names]).drawBackGround(false);
Gl.glPopName();
}
Gl.glPopMatrix();
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
Gl.glFlush();
hits = Gl.glRenderMode(Gl.GL_RENDER);
if (hits > 0) this.MOVINGIOSelectObject[inputID].mouseMOVE(new Point(e.X, e.Y), true, (Spline) MoveSplineList[pickmod[(hits-1)*5+3]], pickmod[(hits-1)*5+4]);
else this.MOVINGIOSelectObject[inputID].mouseMOVE(new Point(e.X, e.Y), false, null, 0);
}
else if (this.MOVINGSpline[inputID] != null) this.MOVINGSpline[inputID].mouseMOVE(new Point(e.X, e.Y));
else if (this.SELSelecting[inputID] == true) this.selectMouseMove(new Point(e.X, e.Y), inputID);
///////////////////////////////////
//this.OpenGLWorkSpace.Refresh();//
///////////////////////////////////
this.MouseMOVE = false;
}
private void OnXYUp(int x, int y, int z, int iPointerID)
{
Point e = new Point(x, y);
int inputID = this.getInputID(iPointerID);
//Console.WriteLine("MouseUp: "+inputID);
this.MouseUP = true;
this.posCursor[inputID].X = e.X;
this.posCursor[inputID].Y = e.Y;
if (this.MOVINGInterfaceObject[inputID] != null)
{
this.MOVINGInterfaceObject[inputID].mouseUP(new Point(e.X, e.Y));
this.MOVINGInterfaceObject[inputID] = null;
}
else if (this.MOVINGIOSelectObject[inputID] != null)
{
this.MOVINGIOSelectObject[inputID].mouseUP(new Point(e.X, e.Y));
this.MOVINGIOSelectObject[inputID] = null;
}
else if (this.MOVINGSpline[inputID] != null)
{
this.MOVINGSpline[inputID].mouseUP(new Point(e.X, e.Y));
this.MOVINGSpline[inputID] = null;
}
else if (this.SELSelecting[inputID] == true) this.selectMouseUp(new Point(e.X, e.Y), inputID);
///////////////////////////////////
//this.OpenGLWorkSpace.Refresh();////
//this.DoingNothing.Enabled = true;
///////////////////////////////////
this.switchISDragging[inputID] = false;
this.MouseUP = false;
}
private bool testSwitching(Point swPointDown, Point swPointUp)
{
//int maxdist;
//if (this.switchISDragging[0] == true && this.switchISDragging[1] == true) maxdist = (int) (Math.Pow((this.switchLastCoordinates[0].X-this.switchLastCoordinates[1].X),2)+ Math.Pow((this.switchLastCoordinates[0].Y-this.switchLastCoordinates[1].Y),2)-1.0); else maxdist = 15625;
if ((Math.Pow((swPointUp.X-swPointDown.X),2)+ Math.Pow((swPointUp.Y-swPointDown.Y),2)) > 22500) return true;
else return false;
}
/*******************************************************************/
/* This are the drawing Functions which draw all OpenGL stuff */
/*******************************************************************/
private void createMousePointList()
{
this.GLListMousePoint = Gl.glGenLists(1);
Gl.glNewList(this.GLListMousePoint, Gl.GL_COMPILE);
Gl.glScalef(5.0f, 5.0f, 1.0f);
Gl.glBegin(Gl.GL_TRIANGLE_FAN);
Gl.glColor4f(0.2f, 1.0f, 1.0f, 1.0f);
Gl.glVertex2d(0.0, 0.0);
for(float run=0.0f; run<=2*Math.PI; run+=0.06282f)
{
Gl.glColor4f(0.0f, 0.0f, 1.0f, 0.0f);
Gl.glVertex2d(Math.Sin(run), Math.Cos(run));
}
Gl.glEnd();
Gl.glEndList();
}
private void DrawSpline()
{
ArrayList SplineList = this.interfaceMain.getAllGridMoveSplines();
foreach(Spline splines in SplineList)
{
splines.drawSpline(false);
//splines.drawBackGround(false);
}
}
private void animateInterfaceObject()
{
ArrayList InterfaceObjectList = this.interfaceMain.getAllGridObjects();
foreach(InterfaceObject IObject in InterfaceObjectList)
{
IObject.computeAnimations();
}
}
private void animateIOSelectObject()
{
ArrayList IOSelectObjectList = this.interfaceMain.getAllGridIOSelectObjects();
foreach(IOSelectObject IOSELObject in IOSelectObjectList)
{
IOSELObject.computeAnimations();
}
}
private void drawKindObject()
{
ArrayList drawnObjectList = this.interfaceMain.getDrawnObjects();
foreach(Object drawObj in drawnObjectList)
{
if (drawObj is InterfaceObject) ((InterfaceObject) drawObj).drawInterfaceObject(false);
else if (drawObj is IOSelectObject ) ((IOSelectObject) drawObj).drawIOSelectObject(false);
}
}
private void OpenGLWorkSpace_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Gl.glEnable(Gl.GL_BLEND);
Gl.glEnable(Gl.GL_LINE_SMOOTH);
Gl.glDisable(Gl.GL_DEPTH_TEST);
Gl.glShadeModel(Gl.GL_SMOOTH); // Enables Smooth Color Shading
Gl.glHint(Gl.GL_LINE_SMOOTH_HINT, Gl.GL_DONT_CARE);
Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
if (this.drawGridInterface == true) this.interfaceMain.drawGrid();
this.DrawSpline();
this.drawNonMoveObject = true;
this.drawKindObject();
this.drawNonMoveObject = false;
for (int MU=0; MU<this.NUM_USERS; MU++)
{
if (this.MOVINGInterfaceObject[MU] != null)
{
this.drawObjects[MU] = true;
this.MOVINGInterfaceObject[MU].drawInterfaceObject(true);
this.drawObjects[MU] = false;
}
if (this.MOVINGIOSelectObject[MU] != null)
{
this.drawIObjects[MU] = true;
this.MOVINGIOSelectObject[MU].drawIOSelectObject(true);
this.drawIObjects[MU] = false;
}
if (this.MOVINGSpline[MU] != null) this.MOVINGSpline[MU].drawSpline(true);
//if (this.MOVINGSpline[MU] != null) this.MOVINGSpline[MU].drawBackGround(true);
if (this.SELSelecting[MU] == true)
{
Gl.glPushMatrix();
Gl.glBegin(Gl.GL_QUADS);
Gl.glColor4f(0.3f, 0.6f, 0.9f, 0.40f);
Gl.glVertex2f(this.SELBoxUpLeft[MU].X, this.SELBoxUpLeft[MU].Y);
Gl.glVertex2f(this.SELBoxRightDown[MU].X, this.SELBoxUpLeft[MU].Y);
Gl.glVertex2f(this.SELBoxRightDown[MU].X, this.SELBoxRightDown[MU].Y);
Gl.glVertex2f(this.SELBoxUpLeft[MU].X, this.SELBoxRightDown[MU].Y);
Gl.glEnd();
Gl.glPopMatrix();
Gl.glPushMatrix();
Gl.glLineWidth(1.0f);
Gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.SELBoxUpLeft[MU].X, this.SELBoxUpLeft[MU].Y);
Gl.glVertex2f(this.SELBoxRightDown[MU].X, this.SELBoxUpLeft[MU].Y);
Gl.glVertex2f(this.SELBoxRightDown[MU].X, this.SELBoxRightDown[MU].Y);
Gl.glVertex2f(this.SELBoxUpLeft[MU].X, this.SELBoxRightDown[MU].Y);
Gl.glEnd();
Gl.glPopMatrix();
}
Gl.glPushMatrix();
Gl.glTranslatef(this.posCursor[MU].X, this.posCursor[MU].Y, 0.0f);
Gl.glCallList(this.GLListMousePoint);
Gl.glPopMatrix();
}
} // end of MultiUser - Mod - for while
/*******************************************************************/
/* Other stuff which was needed for this running programm */
/*******************************************************************/
private void DoingNothing_Tick(object sender, System.EventArgs e)
{
if (this.MouseDOWN == false && this.MouseMOVE == false && this.MouseUP == false)
{
for (int MU=0; MU<this.NUM_USERS; MU++)
{
if (this.MOVINGInterfaceObject[MU] != null && this.drawObjects[MU] == false) this.MOVINGInterfaceObject[MU].continueCalculateRNTObject();
if (this.MOVINGIOSelectObject[MU] != null && this.drawIObjects[MU] == false) this.MOVINGIOSelectObject[MU].continueCalculateRNTObject();
}
}
for (int MU=0; MU<this.NUM_USERS; MU++)
{
if (this.MOVINGInterfaceObject[MU] != null && this.drawObjects[MU] == false) this.MOVINGInterfaceObject[MU].computeAnimations();
if (this.MOVINGIOSelectObject[MU] != null && this.drawIObjects[MU] == false) this.MOVINGIOSelectObject[MU].computeAnimations();
}
if (this.drawNonMoveObject == false) this.animateInterfaceObject();
if (this.drawNonMoveObject == false) this.animateIOSelectObject();
for (int MU=0; MU<this.NUM_USERS; MU++)
{
if (this.doubleClick[MU] > 50000000) this.doubleClick[MU] = 0;
this.doubleClick[MU]++;
}
this.OpenGLWorkSpace.Refresh();
}
private void OpenGLWorkSpace_KeyPressed(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar == 27)
{
this.logfile.EndTrial();
this.OpenGLWorkSpace.Dispose();
// this.sbsdk.DetachOrient();
// System.Runtime.InteropServices.Marshal.ReleaseComObject(this.sbsdk);
this.Dispose();
this.Close();
}
if (e.KeyChar == 'i') this.drawGridInterface = !this.drawGridInterface;
if (e.KeyChar == 'g')
{
ArrayList InterfaceObjectList = ((ArrayList) this.interfaceMain.getAllGridObjects().Clone());
foreach(InterfaceObject IObject in InterfaceObjectList)
{
IObject.isIObjectInsideWorkspace();
}
}
}
private void WorkSpace_Load(object sender, System.EventArgs e)
{
/* End of Initialization */
this.OpenGLWorkSpace.Width = this.ClientSize.Width;
this.OpenGLWorkSpace.Height = this.ClientSize.Height;
Gl.glViewport(0, 0, this.OpenGLWorkSpace.Width, this.OpenGLWorkSpace.Height);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluOrtho2D(0.0, (double) this.OpenGLWorkSpace.Width, this.OpenGLWorkSpace.Height, 0.0);
this.interfaceMain = new InterfaceGrid(this.ClientSize.Width, this.ClientSize.Height);
this.initializeDesktop();
// this.sbsdk.RelativeTo = this.Handle.ToInt32();
/* End of Initialization */
}
/*******************************************************************/
/* ------------------------------------------------- */
/*******************************************************************/
}
}
See more files for this project here