Show NonMoveAbleSpline.cs syntax highlighted
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Tao.Platform.Windows;
using Tao.OpenGl;
namespace New_Study_Project
{
public class NonMoveAbleSpline : Spline
{
/* Definitions of the Program */
private PointF TopLeft;
private PointF TopRight;
private PointF BottomRight;
private PointF BottomLeft;
private float openThickness;
private PointF ResizePoint;
private ObjectButton ResizeButton;
private ControlPoint COTopLeft;
private ControlPoint COTopRight;
private ControlPoint COBottomRight;
private ControlPoint COBottomLeft;
private ControlPoint CITopLeft;
private ControlPoint CITopRight;
private ControlPoint CIBottomRight;
private ControlPoint CIBottomLeft;
private ControlPoint[] CListLeft;
private ControlPoint[] CListRight;
private ControlPoint[] CListDown;
private ControlPoint[] CListUp;
private bool resizing;
/* for logfile stuff */
private int logStartLeft;
private int logStartTop;
private int logStartRight;
private int logStartBottom;
private int logUserID;
private Point logStartPoint;
/* Create Drawing Stuff */
private int GlList_FG;
private int GlList_BG;
private int GLListArms;
/* End of Definitions of the Program */
public NonMoveAbleSpline(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft, InterfaceGrid IG, int objID, int[] IT, float OTness)
{
this.typ = Typ.NoneMoveAbleSpline;
this.TopLeft = topLeft;
this.TopRight = topRight;
this.BottomRight = bottomRight;
this.BottomLeft = bottomLeft;
this.fuzzyWidth = 30;
this.objScaleValue = 0.35f;
//this.logfile = log;
this.ObjectID = objID;
this.interfaceSP = IG;
this.IconTextures = IT;
this.openThickness = OTness;
this.InterfaceObjectList = new ArrayList();
this.IOSelectObjectList = new ArrayList();
this.drawInterfaceObject = false;
this.COTopLeft = new ControlPoint(new PointF(this.TopLeft.X+this.openThickness, this.TopLeft.Y+this.openThickness), this, ControlPoint.State.CornerUpLeft);
this.COTopRight = new ControlPoint(new PointF(this.TopRight.X-this.openThickness, this.TopRight.Y+this.openThickness), this, ControlPoint.State.CornerUpRight);
this.COBottomRight = new ControlPoint(new PointF(this.BottomRight.X-this.openThickness, this.BottomRight.Y-this.openThickness), this, ControlPoint.State.CornerDownRight);
this.COBottomLeft = new ControlPoint(new PointF(this.BottomLeft.X+this.openThickness, this.BottomLeft.Y-this.openThickness), this, ControlPoint.State.CornerDownLeft);
this.ResizePoint = new PointF(0.0f, 0.0f);
this.ResizeButton = new ObjectButton(this, new PointF(0.0f, 0.0f), ObjectButton.State.StoreResize);
this.nodeList = new List();
this.nodeList.InsertAtBack(this.COTopLeft);
this.nodeList.InsertAtBack(this.COTopRight);
this.nodeList.InsertAtBack(this.COBottomRight);
this.nodeList.InsertAtBack(this.COBottomLeft);
this.CListLeft = new ControlPoint[4];
this.CListRight = new ControlPoint[4];
this.CListDown = new ControlPoint[4];
this.CListUp = new ControlPoint[4];
this.calculateOutsideList();
this.AddControlPoints();
this.menuArmScale = 15.0f;
this.fadeMenu = 0.0f;
this.menuScale = 0.0f;
this.waitCloseTime = 0;
this.MOVINGControlPoint = null;
this.SAVEControlPoint = null;
/* setting values */
this.drawMenus = false;
this.drawOpenMenu = false;
this.resizing = false;
this.createFGList();
this.createBGList();
this.create_List_Star();
/* create GLList for arms */
this.GLListArms = Gl.glGenLists(1);
Gl.glNewList(this.GLListArms, Gl.GL_COMPILE);
Gl.glPushMatrix();
Gl.glBegin(Gl.GL_LINE_STRIP);
Gl.glVertex2f(0.0f, 0.0f);
Gl.glVertex2f(0.0f, -32.0f);
Gl.glEnd();
Gl.glPopMatrix();
Gl.glEndList();
//this.logfile.StorageTerritoryFixedCreate(this.ObjectID, (int) this.openThickness);
}
/*******************************************************************/
/* End of the head of this Object - now the user code stuff begins */
/*******************************************************************/
private void AddControlPoints()
{
ListNode currentNode = this.nodeList.FirstNode;
ListNode lastNode = this.nodeList.LastNode;
while(currentNode != lastNode)
{
this.interfaceSP.addControlPoint(currentNode.getControlPoint);
currentNode = currentNode.Next;
}
this.interfaceSP.addControlPoint(lastNode.getControlPoint);
}
private void RemoveControlPoints()
{
ListNode currentNode = this.nodeList.FirstNode;
ListNode lastNode = this.nodeList.LastNode;
while(currentNode != lastNode)
{
this.interfaceSP.removeControlPoint(currentNode.getControlPoint);
currentNode = currentNode.Next;
}
this.interfaceSP.removeControlPoint(lastNode.getControlPoint);
}
private void calculateOutsideList()
{
float dist;
dist = (this.COBottomLeft.getY-this.COTopLeft.getY)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListLeft[i] = new ControlPoint(new PointF(this.COTopLeft.getX, this.COTopLeft.getY+(i+1)*dist), this, ControlPoint.State.LineLeft);
this.nodeList.InsertBehind(this.COTopLeft, this.CListLeft[i]);
}
dist = (this.COBottomRight.getX-this.COBottomLeft.getX)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListDown[i] = new ControlPoint(new PointF(this.COBottomLeft.getX+(i+1)*dist, this.COBottomLeft.getY), this, ControlPoint.State.LineDown);
this.nodeList.InsertBehind(this.COBottomLeft, this.CListDown[i]);
}
dist = (this.COTopRight.getY-this.COBottomRight.getY)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListRight[i] = new ControlPoint(new PointF(this.COBottomRight.getX, this.COBottomRight.getY+(i+1)*dist), this, ControlPoint.State.LineRight);
this.nodeList.InsertBehind(this.COBottomRight, this.CListRight[i]);
}
dist = (this.COTopLeft.getX-this.COTopRight.getX)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListUp[i] = new ControlPoint(new PointF(this.COTopRight.getX+(i+1)*dist, this.COTopRight.getY), this, ControlPoint.State.LineUp);
this.nodeList.InsertBehind(this.COBottomRight, this.CListUp[i]);
}
this.CITopLeft = new ControlPoint(new PointF(this.COTopLeft.getX-this.fuzzyWidth, this.COTopLeft.getY-this.fuzzyWidth), this, ControlPoint.State.OnlyCircle);
this.CITopRight = new ControlPoint(new PointF(this.COTopRight.getX+this.fuzzyWidth, this.COTopRight.getY-this.fuzzyWidth), this, ControlPoint.State.OnlyCircle);
this.CIBottomRight = new ControlPoint(new PointF(this.COBottomRight.getX+this.fuzzyWidth, this.COBottomRight.getY+this.fuzzyWidth), this, ControlPoint.State.OnlyCircle);
this.CIBottomLeft = new ControlPoint(new PointF(this.COBottomLeft.getX-this.fuzzyWidth, this.COBottomLeft.getY+this.fuzzyWidth), this, ControlPoint.State.OnlyCircle);
}
private void reCalculateOutsideList()
{
float dist;
dist = (this.COBottomLeft.getY-this.COTopLeft.getY)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListLeft[i].setControlPoint(new PointF(this.COTopLeft.getX, this.COTopLeft.getY+(i+1)*dist));
}
dist = (this.COBottomRight.getX-this.COBottomLeft.getX)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListDown[i].setControlPoint(new PointF(this.COBottomLeft.getX+(i+1)*dist, this.COBottomLeft.getY));
}
dist = (this.COTopRight.getY-this.COBottomRight.getY)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListRight[i].setControlPoint(new PointF(this.COBottomRight.getX, this.COBottomRight.getY+(i+1)*dist));
}
dist = (this.COTopLeft.getX-this.COTopRight.getX)/5.0f;
for (int i=3; i >= 0; i--)
{
this.CListUp[i].setControlPoint(new PointF(this.COTopRight.getX+(i+1)*dist, this.COTopRight.getY));
}
this.CITopLeft.setControlPoint(new PointF(this.COTopLeft.getX-this.fuzzyWidth, this.COTopLeft.getY-this.fuzzyWidth));
this.CITopRight.setControlPoint(new PointF(this.COTopRight.getX+this.fuzzyWidth, this.COTopRight.getY-this.fuzzyWidth));
this.CIBottomRight.setControlPoint(new PointF(this.COBottomRight.getX+this.fuzzyWidth, this.COBottomRight.getY+this.fuzzyWidth));
this.CIBottomLeft.setControlPoint(new PointF(this.COBottomLeft.getX-this.fuzzyWidth, this.COBottomLeft.getY+this.fuzzyWidth));
}
private void resizeStorageArea(PointF difPoint)
{
if (this.MOVINGControlPoint != null)
{
if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineDown)
{
this.COBottomLeft.getY += difPoint.Y;
this.COBottomRight.getY += difPoint.Y;
if (this.COBottomLeft.getY > this.BottomLeft.Y-40.0f)
{
this.COBottomLeft.getY = this.BottomLeft.Y-40.0f;
this.COBottomRight.getY = this.BottomLeft.Y-40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineLeft)
{
this.COBottomLeft.getX += difPoint.X;
this.COTopLeft.getX += difPoint.X;
if (this.COBottomLeft.getX < 40.0f)
{
this.COBottomLeft.getX = 40.0f;
this.COTopLeft.getX = 40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineUp)
{
this.COTopLeft.getY += difPoint.Y;
this.COTopRight.getY += difPoint.Y;
if(this.COTopLeft.getY < 40.0f)
{
this.COTopLeft.getY = 40.0f;
this.COTopRight.getY = 40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineRight)
{
this.COTopRight.getX += difPoint.X;
this.COBottomRight.getX += difPoint.X;
if (this.COTopRight.getX > this.TopRight.X-40.0f)
{
this.COTopRight.getX = this.TopRight.X-40.0f;
this.COBottomRight.getX = this.TopRight.X-40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerDownLeft)
{
this.COBottomLeft.getY += difPoint.Y;
this.COBottomRight.getY += difPoint.Y;
if (this.COBottomLeft.getY > this.BottomLeft.Y-40.0f)
{
this.COBottomLeft.getY = this.BottomLeft.Y-40.0f;
this.COBottomRight.getY = this.BottomLeft.Y-40.0f;
}
this.COBottomLeft.getX += difPoint.X;
this.COTopLeft.getX += difPoint.X;
if (this.COBottomLeft.getX < 40.0f)
{
this.COBottomLeft.getX = 40.0f;
this.COTopLeft.getX = 40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerDownRight)
{
this.COBottomLeft.getY += difPoint.Y;
this.COBottomRight.getY += difPoint.Y;
if (this.COBottomLeft.getY > this.BottomLeft.Y-40.0f)
{
this.COBottomLeft.getY = this.BottomLeft.Y-40.0f;
this.COBottomRight.getY = this.BottomLeft.Y-40.0f;
}
this.COTopRight.getX += difPoint.X;
this.COBottomRight.getX += difPoint.X;
if (this.COTopRight.getX > this.TopRight.X-40.0f)
{
this.COTopRight.getX = this.TopRight.X-40.0f;
this.COBottomRight.getX = this.TopRight.X-40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerUpLeft)
{
this.COTopLeft.getY += difPoint.Y;
this.COTopRight.getY += difPoint.Y;
if(this.COTopLeft.getY < 40.0f)
{
this.COTopLeft.getY = 40.0f;
this.COTopRight.getY = 40.0f;
}
this.COBottomLeft.getX += difPoint.X;
this.COTopLeft.getX += difPoint.X;
if (this.COBottomLeft.getX < 40.0f)
{
this.COBottomLeft.getX = 40.0f;
this.COTopLeft.getX = 40.0f;
}
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerUpRight)
{
this.COTopLeft.getY += difPoint.Y;
this.COTopRight.getY += difPoint.Y;
if(this.COTopLeft.getY < 40.0f)
{
this.COTopLeft.getY = 40.0f;
this.COTopRight.getY = 40.0f;
}
this.COTopRight.getX += difPoint.X;
this.COBottomRight.getX += difPoint.X;
if (this.COTopRight.getX > this.TopRight.X-40.0f)
{
this.COTopRight.getX = this.TopRight.X-40.0f;
this.COBottomRight.getX = this.TopRight.X-40.0f;
}
}
this.reCalculateOutsideList();
}
}
private void addStoreButtontoGrid()
{
this.interfaceSP.removeObjectButtons(this.ResizeButton);
this.ResizeButton.Location = new PointF(this.ResizePoint.X, this.ResizePoint.Y);
this.ResizeButton.LastLocation = this.ResizeButton.Location;
this.interfaceSP.addObjectButton(this.ResizeButton);
}
private void removeStoreButtonfromGrid()
{
this.interfaceSP.removeObjectButtons(this.ResizeButton);
}
private void refreshButtonPositions()
{
if (this.MOVINGControlPoint != null)
{
if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineDown)
{
this.ResizePoint.X = this.menuPos.X;
this.ResizePoint.Y = this.menuPos.Y-32.0f;
this.menuAngle = 0.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineLeft)
{
this.ResizePoint.X = this.menuPos.X+32.0f;
this.ResizePoint.Y = this.menuPos.Y;
this.menuAngle = 90.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineUp)
{
this.ResizePoint.X = this.menuPos.X;
this.ResizePoint.Y = this.menuPos.Y+32.0f;
this.menuAngle = 180.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineRight)
{
this.ResizePoint.X = this.menuPos.X-32.0f;
this.ResizePoint.Y = this.menuPos.Y;
this.menuAngle = -90.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerDownLeft)
{
this.ResizePoint.X = this.menuPos.X+22.5f;
this.ResizePoint.Y = this.menuPos.Y-22.5f;
this.menuAngle = 45.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerDownRight)
{
this.ResizePoint.X = this.menuPos.X-22.5f;
this.ResizePoint.Y = this.menuPos.Y-22.5f;
this.menuAngle = -45.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerUpLeft)
{
this.ResizePoint.X = this.menuPos.X+22.5f;
this.ResizePoint.Y = this.menuPos.Y+22.5f;
this.menuAngle = 135.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerUpRight)
{
this.ResizePoint.X = this.menuPos.X-22.5f;
this.ResizePoint.Y = this.menuPos.Y+22.5f;
this.menuAngle = -135.0f;
}
}
}
protected override void repositonIOSelectObjectToInside(IOSelectObject IOSEL, PointF lastP)
{
PointF rePos;
double dist, distSave;
distSave = Math.Abs(this.CITopLeft.getX-lastP.X);
if (lastP.Y < this.CITopLeft.getY) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else if (lastP.Y > this.CIBottomLeft.getY) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CIBottomLeft.getY-lastP.Y);
else rePos = new PointF(this.CITopLeft.getX-lastP.X, 0.0f);
dist = Math.Abs(this.CITopLeft.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
if ( lastP.X < this.CITopLeft.getX) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else if (lastP.X > this.CITopRight.getX) rePos = new PointF(this.CITopRight.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else rePos = new PointF(0.0f, this.CITopLeft.getY-lastP.Y);
}
dist = Math.Abs(this.CIBottomRight.getX-lastP.X);
if (dist < distSave)
{
distSave = dist;
if (lastP.Y < this.CITopLeft.getY) rePos = new PointF(this.CIBottomRight.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else if (lastP.Y > this.CIBottomLeft.getY) rePos = new PointF(this.CIBottomRight.getX-lastP.X, this.CIBottomLeft.getY-lastP.Y);
else rePos = new PointF(this.CIBottomRight.getX-lastP.X, 0.0f);
}
dist = Math.Abs(this.CIBottomRight.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
if ( lastP.X < this.CITopLeft.getX) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CIBottomRight.getY-lastP.Y);
else if (lastP.X > this.CITopRight.getX) rePos = new PointF(this.CITopRight.getX-lastP.X, this.CIBottomRight.getY-lastP.Y);
else rePos = new PointF(0.0f, this.CIBottomRight.getY-lastP.Y);
}
IOSEL.translateIOSelectObject(rePos);
}
protected override void repositonIOSelectObjectToOutside(IOSelectObject IOSEL, PointF lastP)
{
PointF rePos;
double dist, distSave;
distSave = Math.Abs(this.COTopLeft.getX-lastP.X);
rePos = new PointF(this.COTopLeft.getX-lastP.X, 0.0f);
dist = Math.Abs(this.COTopLeft.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
rePos = new PointF(0.0f, this.COTopLeft.getY-lastP.Y);
}
dist = Math.Abs(this.COBottomRight.getX-lastP.X);
if (dist < distSave)
{
distSave = dist;
rePos = new PointF(this.COBottomRight.getX-lastP.X, 0.0f);
}
dist = Math.Abs(this.COBottomRight.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
rePos = new PointF(0.0f, this.COBottomRight.getY-lastP.Y);
}
IOSEL.translateIOSelectObject(rePos);
}
protected override void repositonInterfaceObjectToInside(InterfaceObject obj, PointF lastP)
{
PointF rePos;
double dist, distSave;
distSave = Math.Abs(this.CITopLeft.getX-lastP.X);
if (lastP.Y < this.CITopLeft.getY) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else if (lastP.Y > this.CIBottomLeft.getY) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CIBottomLeft.getY-lastP.Y);
else rePos = new PointF(this.CITopLeft.getX-lastP.X, 0.0f);
dist = Math.Abs(this.CITopLeft.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
if ( lastP.X < this.CITopLeft.getX) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else if (lastP.X > this.CITopRight.getX) rePos = new PointF(this.CITopRight.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else rePos = new PointF(0.0f, this.CITopLeft.getY-lastP.Y);
}
dist = Math.Abs(this.CIBottomRight.getX-lastP.X);
if (dist < distSave)
{
distSave = dist;
if (lastP.Y < this.CITopLeft.getY) rePos = new PointF(this.CIBottomRight.getX-lastP.X, this.CITopLeft.getY-lastP.Y);
else if (lastP.Y > this.CIBottomLeft.getY) rePos = new PointF(this.CIBottomRight.getX-lastP.X, this.CIBottomLeft.getY-lastP.Y);
else rePos = new PointF(this.CIBottomRight.getX-lastP.X, 0.0f);
}
dist = Math.Abs(this.CIBottomRight.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
if ( lastP.X < this.CITopLeft.getX) rePos = new PointF(this.CITopLeft.getX-lastP.X, this.CIBottomRight.getY-lastP.Y);
else if (lastP.X > this.CITopRight.getX) rePos = new PointF(this.CITopRight.getX-lastP.X, this.CIBottomRight.getY-lastP.Y);
else rePos = new PointF(0.0f, this.CIBottomRight.getY-lastP.Y);
}
obj.translateInterfaceObject(rePos);
}
protected override void repositonInterfaceObjectToOutside(InterfaceObject obj, PointF lastP)
{
PointF rePos;
double dist, distSave;
distSave = Math.Abs(this.COTopLeft.getX-lastP.X);
rePos = new PointF(this.COTopLeft.getX-lastP.X, 0.0f);
dist = Math.Abs(this.COTopLeft.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
rePos = new PointF(0.0f, this.COTopLeft.getY-lastP.Y);
}
dist = Math.Abs(this.COBottomRight.getX-lastP.X);
if (dist < distSave)
{
distSave = dist;
rePos = new PointF(this.COBottomRight.getX-lastP.X, 0.0f);
}
dist = Math.Abs(this.COBottomRight.getY-lastP.Y);
if (dist < distSave)
{
distSave = dist;
rePos = new PointF(0.0f, this.COBottomRight.getY-lastP.Y);
}
obj.translateInterfaceObject(rePos);
}
/*******************************************************************/
/* This are the drawing Functions which draw MoveSpline stuff */
/*******************************************************************/
private void createFGList()
{
this.GlList_FG = Gl.glGenLists(1);
Gl.glNewList(this.GlList_FG, Gl.GL_COMPILE);
Gl.glColor4f(0.2f, 0.4f, 0.8f, 0.3f);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.TopRight.X, this.TopRight.Y);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.BottomRight.X, this.BottomRight.Y);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.BottomLeft.X, this.BottomLeft.Y);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glColor4f(0.3f, 0.6f, 0.9f, 0.15f);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.COTopRight.getX, this.COTopRight.getY);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.COBottomRight.getX, this.COBottomRight.getY);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.COBottomLeft.getX, this.COBottomLeft.getY);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glLineWidth(1.5f);
Gl.glColor4f(0.2f, 0.5f, 0.9f, 1.0f);
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.TopRight.X, this.TopRight.Y);
Gl.glVertex2f(this.BottomRight.X, this.BottomRight.Y);
Gl.glVertex2f(this.BottomLeft.X, this.BottomLeft.Y);
Gl.glEnd();
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glVertex2f(this.COTopRight.getX, this.COTopRight.getY);
Gl.glVertex2f(this.COBottomRight.getX, this.COBottomRight.getY);
Gl.glVertex2f(this.COBottomLeft.getX, this.COBottomLeft.getY);
Gl.glEnd();
Gl.glLineWidth(1.0f);
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glEnd();
Gl.glEndList();
}
private void createBGList()
{
this.GlList_BG = Gl.glGenLists(1);
Gl.glNewList(this.GlList_BG, Gl.GL_COMPILE);
Gl.glPushName(99);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.TopRight.X, this.TopRight.Y);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.BottomRight.X, this.BottomRight.Y);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.BottomLeft.X, this.BottomLeft.Y);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glPopName();
Gl.glPushName(66);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COTopRight.getX, this.COTopRight.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COBottomRight.getX, this.COBottomRight.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COBottomLeft.getX, this.COBottomLeft.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glPopName();
Gl.glEndList();
}
public override void drawSpline(bool moveSP)
{
if (moveSP == true)
{
Gl.glPushMatrix();
Gl.glColor4f(0.2f, 0.4f, 0.8f, 0.3f);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.TopRight.X, this.TopRight.Y);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.BottomRight.X, this.BottomRight.Y);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.BottomLeft.X, this.BottomLeft.Y);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glColor4f(0.3f, 0.6f, 0.9f, 0.15f);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.COTopRight.getX, this.COTopRight.getY);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.COBottomRight.getX, this.COBottomRight.getY);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.COBottomLeft.getX, this.COBottomLeft.getY);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glLineWidth(1.5f);
Gl.glColor4f(0.2f, 0.5f, 0.9f, 1.0f);
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.TopRight.X, this.TopRight.Y);
Gl.glVertex2f(this.BottomRight.X, this.BottomRight.Y);
Gl.glVertex2f(this.BottomLeft.X, this.BottomLeft.Y);
Gl.glEnd();
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glVertex2f(this.COTopRight.getX, this.COTopRight.getY);
Gl.glVertex2f(this.COBottomRight.getX, this.COBottomRight.getY);
Gl.glVertex2f(this.COBottomLeft.getX, this.COBottomLeft.getY);
Gl.glEnd();
Gl.glLineWidth(1.0f);
Gl.glBegin(Gl.GL_LINE_LOOP);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glEnd();
Gl.glPopMatrix();
}
else
{
Gl.glPushMatrix();
Gl.glCallList(this.GlList_FG);
Gl.glPopMatrix();
}
/* drawing Controlpoints */
ListNode currentNode = nodeList.FirstNode;
ListNode lastNode = nodeList.LastNode;
while(currentNode != lastNode)
{
Gl.glPushMatrix();
Gl.glTranslatef(currentNode.getControlPoint.getX, currentNode.getControlPoint.getY, 0.0f);
this.drawControlPoints();
Gl.glPopMatrix();
currentNode = currentNode.Next;
}
Gl.glPushMatrix();
Gl.glTranslatef(currentNode.getControlPoint.getX, currentNode.getControlPoint.getY, 0.0f);
this.drawControlPoints();
Gl.glPopMatrix();
/* draw InterfaceObjects if there are any inside */
if(this.drawInterfaceObject == true)
{
foreach (IOSelectObject IOSEL in this.IOSelectObjectList)
{
IOSEL.drawIOSelectObject(true);
}
foreach (InterfaceObject obj in this.InterfaceObjectList)
{
obj.drawInterfaceObject(true);
}
}
/* draw the menus */
if (this.drawMenus == true)
{
Gl.glPushMatrix();
Gl.glTranslatef(menuPos.X, menuPos.Y, 0.0f);
Gl.glRotatef(this.menuAngle, 0.0f, 0.0f, 1.0f);
Gl.glPushMatrix();
Gl.glLineWidth(1.0f);
Gl.glColor4f(0.2f, 0.5f, 1.0f, this.fadeMenu);
Gl.glScalef(this.menuArmScale, this.menuArmScale, 1.0f);
Gl.glCallList(this.GLListArms);
Gl.glPopMatrix();
this.drawResizeIcon(new PointF(-1.0f, -32.0f));
Gl.glPopMatrix();
/* calculations for the effect of the menu */
if (this.drawOpenMenu == true)
{
if (this.fadeMenu >= 1.0f)
{
if (this.fadeMenu > 1.0f) this.fadeMenu = 1.0f;
this.menuScale = this.menuScale + 0.2f;
if (this.menuScale >= 1.0f)
{
this.menuScale = 1.0f;
if (this.resizing == false) this.addStoreButtontoGrid();
this.drawOpenMenu = false;
}
}
else
{
this.fadeMenu = this.fadeMenu + 0.2f;
this.menuArmScale = this.menuArmScale + 0.2f;
}
}
if (this.drawCloseMenu == true && this.drawOpenMenu == false)
{
if (this.waitCloseTime < 100) this.waitCloseTime++;
else
{
this.menuScale = this.menuScale - 0.2f;
if (this.menuScale <= 0.0f)
{
if (this.menuScale < 0.0f) this.menuScale = 0.0f;
this.fadeMenu = this.fadeMenu - 0.2f;
this.menuArmScale = this.menuArmScale - 0.2f;
if (this.fadeMenu <= 0.0f)
{
this.fadeMenu = 0.0f;
this.removeStoreButtonfromGrid();
this.drawMenus = false;
this.drawCloseMenu = false;
}
}
}
}
}
/* End of calculations for the effect of the menu */
}
public override void drawBackGround(bool moveSP)
{
if (moveSP == true)
{
Gl.glPushMatrix();
Gl.glPushName(99);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glVertex2f(this.TopRight.X, this.TopRight.Y);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glVertex2f(this.BottomRight.X, this.BottomRight.Y);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glVertex2f(this.BottomLeft.X, this.BottomLeft.Y);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glVertex2f(this.TopLeft.X, this.TopLeft.Y);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glPopName();
Gl.glPushName(66);
Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COTopRight.getX, this.COTopRight.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CITopRight.getX, this.CITopRight.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COBottomRight.getX, this.COBottomRight.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CIBottomRight.getX, this.CIBottomRight.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COBottomLeft.getX, this.COBottomLeft.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CIBottomLeft.getX, this.CIBottomLeft.getY);
Gl.glColor3f(1.0f, 1.0f, 1.0f);
Gl.glVertex2f(this.COTopLeft.getX, this.COTopLeft.getY);
Gl.glColor3f(this.objScaleValue, this.objScaleValue, this.objScaleValue);
Gl.glVertex2f(this.CITopLeft.getX, this.CITopLeft.getY);
Gl.glEnd();
Gl.glPopName();
Gl.glPopMatrix();
}
else
{
Gl.glPushMatrix();
Gl.glCallList(this.GlList_BG);
Gl.glPopMatrix();
}
}
private void drawResizeIcon(PointF pos)
{
Gl.glPushMatrix();
Gl.glTranslatef(pos.X, pos.Y, 0.0f);
Gl.glRotatef(-45.0f, 0.0f, 0.0f, 1.0f);
Gl.glScalef(this.menuScale, this.menuScale, 1.0f);
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBlendFunc(Gl.GL_DST_COLOR,Gl.GL_ZERO);// Blend Screen Color With Zero (Black)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[4]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_ONE, Gl.GL_ONE);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.IconTextures[5]);
Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(-16.0f, -16.0f); // bottom Left
Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(-16.0f, +16.0f); // top Left
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(+16.0f, +16.0f); // top Right
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(+16.0f, -16.0f); // bottom Right
Gl.glEnd();
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glDisable(Gl.GL_TEXTURE_2D);
Gl.glPopMatrix();
}
/*******************************************************************/
/* Mouse Events */
/*******************************************************************/
private void open_menu(PointF pos)
{
if (this.drawMenus == false || this.MOVINGControlPoint != this.SAVEControlPoint)
{
this.menuPos = pos;
if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineDown)
{
this.ResizePoint.X = this.menuPos.X;
this.ResizePoint.Y = this.menuPos.Y-32.0f;
this.menuAngle = 0.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineLeft)
{
this.ResizePoint.X = this.menuPos.X+32.0f;
this.ResizePoint.Y = this.menuPos.Y;
this.menuAngle = 90.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineUp)
{
this.ResizePoint.X = this.menuPos.X;
this.ResizePoint.Y = this.menuPos.Y+32.0f;
this.menuAngle = 180.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.LineRight)
{
this.ResizePoint.X = this.menuPos.X-32.0f;
this.ResizePoint.Y = this.menuPos.Y;
this.menuAngle = -90.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerDownLeft)
{
this.ResizePoint.X = this.menuPos.X+22.5f;
this.ResizePoint.Y = this.menuPos.Y-22.5f;
this.menuAngle = 45.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerDownRight)
{
this.ResizePoint.X = this.menuPos.X-22.5f;
this.ResizePoint.Y = this.menuPos.Y-22.5f;
this.menuAngle = -45.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerUpLeft)
{
this.ResizePoint.X = this.menuPos.X+22.5f;
this.ResizePoint.Y = this.menuPos.Y+22.5f;
this.menuAngle = 135.0f;
}
else if (this.MOVINGControlPoint.getState() == ControlPoint.State.CornerUpRight)
{
this.ResizePoint.X = this.menuPos.X-22.5f;
this.ResizePoint.Y = this.menuPos.Y+22.5f;
this.menuAngle = -135.0f;
}
this.fadeMenu = 0.0f;
this.menuScale = 0.0f;
this.menuArmScale = 0.0f;
}
this.drawOpenMenu = true;
this.drawMenus = true;
this.drawCloseMenu = false;
}
private void close_menu()
{
this.waitCloseTime = 0;
this.drawCloseMenu = true;
}
public override void mouseDOWN(ControlPoint MOVINGCP, int inputID)
{
this.interfaceSP.removeWholeMoveSpline(this);
this.removeInterfaceObjectsFromGrid();
this.RemoveControlPoints();
this.drawInterfaceObject = true;
this.MOVINGControlPoint = MOVINGCP;
this.open_menu(new PointF(MOVINGCP.getX, MOVINGCP.getY));
this.SAVEControlPoint = MOVINGCP;
this.logUserID = inputID;
this.resizing = false;
}
public override void mouseMOVE(Point MOVEPoint)
{
if (this.resizing == false)
{
ObjectButton getStoreButton = this.interfaceSP.getAssociatedObjectButton(new Point((int)(MOVEPoint.X), (int) (MOVEPoint.Y)));
if (getStoreButton != null && getStoreButton == this.ResizeButton)
{
this.MOVINGSplinePoint = MOVEPoint;
this.resizing = true;
this.removeStoreButtonfromGrid();
/* for logfile stuff */
this.logStartLeft = (int) (this.COTopLeft.getX);
this.logStartTop = (int) (this.COTopLeft.getY);
this.logStartRight = (int) (this.BottomRight.X - this.COBottomRight.getX);
this.logStartBottom = (int) (this.BottomRight.Y -this.COBottomRight.getY);
this.logStartPoint = MOVEPoint;
/* end of for logfile stuff */
}
}
else
{
PointF MOVPoint = new PointF((MOVEPoint.X-this.MOVINGSplinePoint.X), (MOVEPoint.Y-this.MOVINGSplinePoint.Y));
this.resizeStorageArea(MOVPoint);
this.menuPos.X = MOVINGControlPoint.getX;
this.menuPos.Y = MOVINGControlPoint.getY;
this.MOVINGSplinePoint = MOVEPoint;
this.testInterfaceObjectsInStorageArea();
this.testIOSelectObjectsInStorageArea();
}
}
public override void mouseUP(Point UPPoint)
{
int logEndLeft, logEndTop , logEndRight, logEndBottom;
this.createFGList();
this.createBGList();
/* for logfile stuff */
if (this.resizing == true)
{
logEndLeft = (int) (this.COTopLeft.getX);
logEndTop = (int) (this.COTopLeft.getY);
logEndRight = (int) (this.BottomRight.X - this.COBottomRight.getX);
logEndBottom = (int) (this.BottomRight.Y -this.COBottomRight.getY);
//this.logfile.StorageTerritoryFixedResize(this.logUserID, this.ObjectID, this.logStartPoint, UPPoint, this.logStartLeft, this.logStartTop, this.logStartRight, this.logStartBottom, logEndLeft, logEndTop, logEndRight, logEndBottom);
}
/* end of for logfile stuff */
this.resizing = false;
this.drawInterfaceObject = false;
this.interfaceSP.addWholeMoveSpline(this);
this.addInterfaceObjectsToGrid();
this.AddControlPoints();
this.refreshButtonPositions();
this.addStoreButtontoGrid();
this.close_menu();
}
public override void clickedStorageButton(Point CLICKEDPoint, ObjectButton getStoreButton, int inputID)
{
this.open_menu(new PointF(this.MOVINGControlPoint.getX, this.MOVINGControlPoint.getY));
if (getStoreButton.getState.Equals(ObjectButton.State.StoreResize))
{
this.MOVINGSplinePoint = CLICKEDPoint;
this.resizing = true;
/* for logfile stuff */
this.logStartLeft = (int) (this.COTopLeft.getX);
this.logStartTop = (int) (this.COTopLeft.getY);
this.logStartRight = (int) (this.BottomRight.X - this.COBottomRight.getX);
this.logStartBottom = (int) (this.BottomRight.Y -this.COBottomRight.getY);
this.logUserID = inputID;
this.logStartPoint = CLICKEDPoint;
/* end of for logfile stuff */
}
this.interfaceSP.removeWholeMoveSpline(this);
this.removeInterfaceObjectsFromGrid();
this.RemoveControlPoints();
this.removeStoreButtonfromGrid();
this.drawInterfaceObject = true;
}
public override void changeBorderSize(int valueSize)
{
}
public override void changeObjectSize(float objSize)
{
}
/*******************************************************************/
/* ----------------------------------------------------------- */
/*******************************************************************/
}
}
See more files for this project here