Show Workspace.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 System.Reflection;
using System.Timers;
using System.Threading;
using Tao.Platform.Windows;
using Tao.OpenGl;
using Whiteboard;
using Whiteboard.MaseWS;
using EStory;
using Whiteboard.Business_Interfaces;
namespace New_Study_Project
{
// public class Workspace : System.Windows.Forms.UserControl
// {
public class Workspace : System.Windows.Forms.Form
{
// [STAThread]
// static void Main()
// {
// Application.Run(new Workspace());
// }
private Assembly workSpaceDLL;
private MenuForm menu = null;
/* Definitions of the Program */
private int NUM_USERS;
/* Create InterfaceGrid - Stuff and other things */
private Tao.Platform.Windows.SimpleOpenGlControl OpenGLWorkSpace;
private static System.Windows.Forms.Timer DoingNothing;
//private System.Timers.Timer DoingNothing;
private System.ComponentModel.IContainer components;
public TabletVO newStoryTabletVO;
public InterfaceGrid interfaceMain;
private int[] IconTextures;
//private webServicesService ws;
private EStoryForm doubleClickedStoryForm;
/* Create Moving Object and Spline Stuff */
private Spline[] MOVINGSpline;
private InterfaceObject[] MOVINGInterfaceObject;
private IOSelectObject[] MOVINGIOSelectObject;
private bool MouseDOWN;
private bool MouseMOVE;
private bool MouseUP;
private bool splineMovFromBorder;
private Point lastMouseUPLoction;
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 */
public Dashboard dashboard;
private Bitmap labelImage;
private int[] texture;
public InterfaceObject doubleClickedStory;
public long doubleClickedStoryIterationIDBeforeUpdate;
public long doubleClickedStoryIDBeforeUpdate;
public TabletVO updatedStoryVO;
public MoveAbleSpline[] currIterations;
private MoveAbleSpline completedArea;
private Thread MASEUpdateThread;
private Thread MASEListenThread;
public static bool pulibWorkspaceOrNot = true;
public Queue receivedUpdatedQueue = new Queue();
public bool forceClosing = false;
public bool stroyLocationLocked = false;
/* for MultiUser - Mod */
//private SBSDKEXWRAPPERLib.SbSdkBase sbsdk;
/* End of Definitions of the Program */
private void initializeWorkSpace()
{
this.texture = new int[1];
this.NUM_USERS = 1;
this.doubleClickedStory = null;
this.animateInterfaceObjectList = new ArrayList();
this.animateIOSelectObjectList = new ArrayList();
this.MouseDOWN = false;
this.MouseMOVE = false;
this.MouseUP = false;
this.splineMovFromBorder = false;
this.drawNonMoveObject = false;
this.drawGridInterface = false;
this.globalObjectCounter = 0;
this.components = null;
this.newStoryTabletVO = new TabletVO();
this.newStoryTabletVO.tabletProcess = new TabletProcessVO();
this.updatedStoryVO = new TabletVO();
this.updatedStoryVO.tabletProcess = new TabletProcessVO();
this.InitializeComponent();
//this.interfaceMain = new InterfaceGrid(this.ClientSize.Width, this.ClientSize.Height);
this.OpenGLWorkSpace.InitializeContexts();
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);
}
createLabelImage();
System.Drawing.Imaging.BitmapData bitmapdata;
Rectangle rect = new Rectangle(0, 0, labelImage.Width, labelImage.Height);
bitmapdata = labelImage.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Gl.glGenTextures(1, texture);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.texture[0]);
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_MIPMAP_LINEAR);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_COMPRESSED_RGB , labelImage.Width, labelImage.Height, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
labelImage.UnlockBits(bitmapdata);
labelImage.Dispose();
this.loadIconTextures();
this.SELRGBCount = 3;
this.SELColorNum = new ArrayList();
this.createMousePointList();
this.OpenGLWorkSpace.Focus();
}
public Workspace()
{
initializeWorkSpace();
}
public Workspace(Dashboard dashboard)
{
/* Initialize all Variables */
this.dashboard = dashboard;
initializeWorkSpace();
}
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 */
workSpaceDLL = Assembly.GetExecutingAssembly();
System.IO.Stream file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.ControlPoint_mask.bmp");
Bitmap image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.ControlPoint_pic.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.areaMove_mask.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.areaMove_pic.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.areaResize_mask.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.areaResize_pic.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.ControlPointMove_mask.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.ControlPointMove_pic.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.resize4_mask.bmp");
image = new Bitmap(file);
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();
file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.resize4_pic.bmp");
image = new Bitmap(file);
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 InitializeOpenGLComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Workspace));
this.OpenGLWorkSpace = new Tao.Platform.Windows.SimpleOpenGlControl();
DoingNothing = new System.Windows.Forms.Timer(this.components);
//this.DoingNothing = new System.Timers.Timer();
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.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);
this.OpenGLWorkSpace.DoubleClick += new EventHandler(OpenGLWorkSpace_DoubleClick);
//
// DoingNothing
//
DoingNothing.Tick += new System.EventHandler(this.DoingNothing_Tick);
DoingNothing.Enabled = true;
DoingNothing.Interval = 10;
//this.DoingNothing.AutoReset = true;
// Add OpenGLControl into Controls
this.Controls.Add(this.OpenGLWorkSpace);
}
private void InitializeComponent()
{
InitializeOpenGLComponent();
//
// Workspace
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ActiveBorder;
//this.ClientSize = new System.Drawing.Size(ApplicationProperties.clientSizeX, ApplicationProperties.clientSizeY);
this.Cursor = System.Windows.Forms.Cursors.Cross;
this.Name = "Workspace";
this.Text = "Tabletop";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.WorkSpace_Load);
this.Closing += new CancelEventHandler(Workspace_Closing);
}
private PointF[] calaulcateMaseIterationMoveableSplineBoundry(PointF center, float territoryWidth, float territoryHeight)
{
PointF[] pointStore = new PointF[8];
// when specify points for the border of a territory colockwise specification is needed
float half = 0.5f;
//float full = 1.0f;
float adjustmentWidth = territoryWidth*half;
float adjustmentHeight = territoryHeight*half;
pointStore[0] = new PointF(center.X-adjustmentWidth, center.Y-adjustmentHeight);
pointStore[1] = new PointF(center.X, center.Y-adjustmentHeight);
pointStore[2] = new PointF(center.X+adjustmentWidth, center.Y-adjustmentHeight);
pointStore[3] = new PointF(center.X+adjustmentWidth, center.Y);
pointStore[4] = new PointF(center.X+adjustmentWidth, center.Y+adjustmentHeight);
pointStore[5] = new PointF(center.X, center.Y+adjustmentHeight);
pointStore[6] = new PointF(center.X-adjustmentWidth, center.Y+adjustmentHeight);
pointStore[7] = new PointF(center.X-adjustmentWidth, center.Y);
return pointStore;
}
private void initializeDesktop()
{
PointF[] pointStore;
PointF center;
for (int MU=0; MU<this.NUM_USERS; MU++)
{
this.posCursor[MU] = new Point((int) (this.ClientSize.Width/2), (int) (this.ClientSize.Height/2));
}
if(MASEListenThread==null)
{
MaseListen.dashboard = this.dashboard;
MASEListenThread = new Thread(new ThreadStart(MaseListen.startListening));
MaseListen.registerCallback();
MASEListenThread.Start();
}
if(MASEUpdateThread==null)
{
MaseUpdate.setSelectedIterations(dashboard.getSelectedIterations());
MaseUpdate.setProductBacklog(dashboard.productBacklog);
MASEUpdateThread = new Thread(new ThreadStart(MaseUpdate.monitorUpdatedQueue));
MASEUpdateThread.Start();
}
if(this.dashboard.workspace_cb.SelectedIndex == 1)
{
MASEUpdateThread.Suspend();
pulibWorkspaceOrNot = false;
}
IEnumerator it = null;
PointF storyCenterPoint = new PointF(-1.0f, -1.0f);
TabletVO[] selectedIterations = dashboard.getSelectedIterations();
int numberofSelectedIterations = selectedIterations.Length;
currIterations = new MoveAbleSpline[numberofSelectedIterations];
for(int iterationIndex =0; iterationIndex<numberofSelectedIterations; iterationIndex++)
{
TabletVO selectedIteration = dashboard.getSelectedIterations()[iterationIndex];
if(selectedIteration.horizontalCenter.centerX == -1.0f && selectedIteration.horizontalCenter.centerY == -1.0f)
{
center = ApplicationProperties.iterationCenter;
selectedIteration.horizontalCenter.centerX = center.X;
selectedIteration.horizontalCenter.centerY = center.Y;
MaseUpdate.registerUpdated(selectedIteration, RegisterObj.UpdateStoryLocation);
}
else
{
selectedIteration.horizontalCenter.centerX = selectedIteration.horizontalCenter.centerX * MaseUpdate.S_width;
selectedIteration.horizontalCenter.centerY = selectedIteration.horizontalCenter.centerY * MaseUpdate.S_height;
center = new PointF(selectedIteration.horizontalCenter.centerX, selectedIteration.horizontalCenter.centerY);
}
// Make an oval along the top of the workspace
float territoryWidth = ApplicationProperties.iterationWidth;
float territoryHeight = ApplicationProperties.iterationHeight;
pointStore = calaulcateMaseIterationMoveableSplineBoundry(center, territoryWidth, territoryHeight);
string currentIterationName = dashboard.getSelectedIterations()[iterationIndex].iterationName;
long currentIterationID = dashboard.getSelectedIterations()[iterationIndex].iterationID;
TabletContentandUtil tabUtil = new TabletContentandUtil(selectedIteration);
currIterations[iterationIndex] = new MoveAbleSpline(tabUtil.makeDeepCopy(), ref dashboard, center, pointStore, this.interfaceMain, this.globalObjectCounter, this.IconTextures, ApplicationProperties.iterationBackgroundColor);
this.interfaceMain.addWholeMoveSpline(currIterations[iterationIndex]);
this.globalObjectCounter++;
it = dashboard.getMyProcessList(iterationIndex).GetEnumerator();
PointF currIterationCenter = currIterations[iterationIndex].getCenter();
//the base location for index card to be displyed within a territory area
PointF currIterationLeftTopBase = new PointF(currIterations[iterationIndex].getLeftTop().X - 0.5f*ApplicationProperties.CardWidth*ApplicationProperties.shrink_ratio + 10, currIterations[iterationIndex].getLeftTop().Y + 0.5f*ApplicationProperties.CardHeight*ApplicationProperties.shrink_ratio + 40);
storyCenterPoint = new PointF(-1.0f, -1.0f);
while(it.MoveNext())
{
TabletVO tabletVO = (TabletVO)it.Current;
StoryObj storyObj = new StoryObj(tabletVO, ApplicationProperties.CardWidth, ApplicationProperties.CardHeight);
if(tabletVO.horizontalCenter.centerX == -1.0f && tabletVO.horizontalCenter.centerY == -1.0f)
{
if(storyCenterPoint.X == -1.0f && storyCenterPoint.Y == -1.0f)
storyCenterPoint = cauclateNextValidPositionInTerritory(currIterationLeftTopBase, currIterations[iterationIndex]);
else
storyCenterPoint = cauclateNextValidPositionInTerritory(storyCenterPoint, currIterations[iterationIndex]);
tabletVO.horizontalCenter.centerX = storyCenterPoint.X;
tabletVO.horizontalCenter.centerY = storyCenterPoint.Y;
MaseUpdate.registerUpdated(tabletVO, RegisterObj.UpdateStoryLocation);
}
else
{
tabletVO.horizontalCenter.centerX = tabletVO.horizontalCenter.centerX * MaseUpdate.S_width;
tabletVO.horizontalCenter.centerY = tabletVO.horizontalCenter.centerY * MaseUpdate.S_height;
storyCenterPoint = new PointF(tabletVO.horizontalCenter.centerX, tabletVO.horizontalCenter.centerY);
}
float storyRotationAngle = tabletVO.horizontalCenter.rotationAngle;
InterfaceObject newCard = new InterfaceObject(storyCenterPoint, (Displayable_Interface) storyObj, this.interfaceMain, storyRotationAngle, this.animateInterfaceObjectList, this.IconTextures, false);
newCard.initializationMovement = true;
Point storyCenter = new Point(Convert.ToInt32(storyCenterPoint.X), Convert.ToInt32(storyCenterPoint.Y));
/*The following three lines is to simulate a mouse click event so that the index card can be resized
*properly
*/
newCard.mouseDOWN(storyCenter, 0); // why 0? I do not know. Can be deemed as a hack.
newCard.mouseMOVE(storyCenter, true, currIterations[iterationIndex], 99); // why 99? I do not know. Can be deemed as a hack.
currIterations[iterationIndex].addInterfaceObjectToSpline(newCard);
newCard.mouseUP(storyCenter);
newCard.getRNTObj().Center = storyCenterPoint;
}
}
storyCenterPoint = new PointF(-1.0f, -1.0f);
PointF productBacklogLeftTopBase = new PointF( 10, 0.5f*ApplicationProperties.CardHeight + 40);
it = dashboard.getMyBacklogList().GetEnumerator();
while(it.MoveNext())
{
TabletVO tabletVO = (TabletVO)it.Current;
StoryObj storyObj = new StoryObj(tabletVO, ApplicationProperties.CardWidth, ApplicationProperties.CardHeight);
if(tabletVO.horizontalCenter.centerX == -1.0f && tabletVO.horizontalCenter.centerY == -1.0f)
{
if(storyCenterPoint.X == -1.0f && storyCenterPoint.Y == -1.0f)
storyCenterPoint = cauclateNextValidPositionInProductBacklog(productBacklogLeftTopBase, currIterations);
else
storyCenterPoint = cauclateNextValidPositionInProductBacklog(storyCenterPoint, currIterations);
tabletVO.horizontalCenter.centerX = storyCenterPoint.X;
tabletVO.horizontalCenter.centerY = storyCenterPoint.Y;
MaseUpdate.registerUpdated(tabletVO, RegisterObj.UpdateStoryLocation);
}
else
{
tabletVO.horizontalCenter.centerX = tabletVO.horizontalCenter.centerX * MaseUpdate.S_width;
tabletVO.horizontalCenter.centerY = tabletVO.horizontalCenter.centerY * MaseUpdate.S_height;
storyCenterPoint = new PointF(tabletVO.horizontalCenter.centerX, tabletVO.horizontalCenter.centerY);
}
float storyRotationAngle = tabletVO.horizontalCenter.rotationAngle;
InterfaceObject newCard = new InterfaceObject(storyCenterPoint, (Displayable_Interface) storyObj, this.interfaceMain, storyRotationAngle, this.animateInterfaceObjectList, this.IconTextures, false);
this.interfaceMain.addObject(newCard);
}
}
private PointF cauclateNextValidPositionInProductBacklog(PointF previousStoryCenter, Spline[] currIterations)
{
float cardWidth = ApplicationProperties.CardWidth;
float cardHeight = ApplicationProperties.CardHeight;
float newCardX = 0.0f;
float newCardY = 0.0f;
float newCardBoundryX;
float newCardBoundryY;
bool locationFound = false;
while(!locationFound)
{
newCardX = previousStoryCenter.X + 0.5f*cardWidth;
newCardY = previousStoryCenter.Y;
newCardBoundryX = newCardX + 0.5f*cardWidth;
newCardBoundryY = newCardY + 0.5f*cardHeight;
if(newCardBoundryX > this.ClientSize.Width)
{
previousStoryCenter.X = 10;
previousStoryCenter.Y = previousStoryCenter.Y + 0.5f*cardHeight;
}
else
{//overlap with current iteration
int numberofSelectedIteration = currIterations.Length;
bool notViolateIterationBoundry = true;
for(int index=0; index < numberofSelectedIteration; index++)
{
if((newCardBoundryX > currIterations[index].getLeftTop().X && newCardBoundryX < currIterations[index].getRightTop().X + cardWidth)&&(newCardBoundryY > currIterations[index].getLeftTop().Y && newCardBoundryY < currIterations[index].getLeftBut().Y + cardHeight))
notViolateIterationBoundry = notViolateIterationBoundry&false;
else
notViolateIterationBoundry = notViolateIterationBoundry&true;
}
previousStoryCenter.X = newCardX;
previousStoryCenter.Y = newCardY;
if(notViolateIterationBoundry == true)
{
locationFound = true;
}
}
}
return new PointF(newCardX, newCardY);
}
private PointF cauclateNextValidPositionInTerritory(PointF previousStoryCenter, MoveAbleSpline territory)
{
float cardWidth = ApplicationProperties.CardWidth*ApplicationProperties.shrink_ratio;
float cardHeight = ApplicationProperties.CardHeight*ApplicationProperties.shrink_ratio;
float newCardX;
float newCardY;
if(previousStoryCenter.X + cardWidth < territory.getRightTop().X)
{
newCardX = previousStoryCenter.X + cardWidth;
newCardY = previousStoryCenter.Y;
}
else
{
newCardX = territory.getLeftTop().X + 0.5f*cardWidth + 10;
newCardY = previousStoryCenter.Y + 0.5f*cardHeight;
}
return new PointF(newCardX, newCardY);
}
/*******************************************************************/
/* 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.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 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();
else if (IObjToBG != null)
{
//this.interfaceMain.addObjectToBG(IObjToBG);
}
}
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));
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)
{
// if(true == SingleWS.getInstance("").acquireTabletLock(IObj.displayObj.getTabletVO().tabletProcess.id))
// {
// if(pulibWorkspaceOrNot == true)
// {
this.MOVINGInterfaceObject[inputID] = IObj;
this.MOVINGInterfaceObject[inputID].mouseDOWN(new Point(e.X, e.Y), inputID);
// }
// }
// else
// {
// MessageBox.Show("The card you moved is under modification. Please try later.");
// }
}
else if (IOSELObj != null)
{
bool lockable = true;
// foreach(InterfaceObject ifObj in this.MOVINGIOSelectObject[inputID].getIOSelectObjectList())
// {
// lockable = lockable&SingleWS.getInstance("").acquireTabletLock(ifObj.displayObj.getTabletVO().tabletProcess.id);
// }
// if(lockable == true)
// {
// if(pulibWorkspaceOrNot == true)
// {
this.MOVINGIOSelectObject[inputID] = IOSELObj;
this.MOVINGIOSelectObject[inputID].mouseDOWN(new Point(e.X, e.Y), inputID);
// }
// }
// else
// {
// MessageBox.Show("One of the card you moved is under modification. Please try later.");
// }
}
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)
{
bool lockable = true; //SingleWS.getInstance("").acquireTabletLock(splineMove.splineID);
if(lockable == true)
{
if(pulibWorkspaceOrNot == true)
{
this.MOVINGSpline[inputID] = splineMove;
((MoveAbleSpline) (this.MOVINGSpline[inputID])).mouseDOWNSplineMove(new Point(e.X, e.Y));
}
}
else
{
MessageBox.Show("The iteration is under modification. Please try later.");
}
}
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)
{
MoveAbleSpline movingSpline = (MoveAbleSpline)this.MOVINGSpline[inputID];
// if(movingSpline.isNextLocationValid(new Point(e.X, e.Y)))
// {
//movingSpline.isNextLocationValid(new Point(e.X, e.Y));
movingSpline.mouseMOVE(new Point(e.X, e.Y));
// }
// else
// {
// OnXYUp(e.X, e.Y, 0, 0);
// }
}
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;
this.lastMouseUPLoction = e;
if (this.MOVINGInterfaceObject[inputID] != null)
{
SingleWS.getInstance("").releaseTabletLock(this.MOVINGInterfaceObject[inputID].displayObj.getTabletVO().tabletProcess.id);
this.MOVINGInterfaceObject[inputID].mouseUP(new Point(e.X, e.Y));
this.MOVINGInterfaceObject[inputID] = null;
}
else if (this.MOVINGIOSelectObject[inputID] != null)
{
foreach(InterfaceObject ifObj in this.MOVINGIOSelectObject[inputID].getIOSelectObjectList())
{
SingleWS.getInstance("").releaseTabletLock(ifObj.displayObj.getTabletVO().tabletProcess.id);
}
this.MOVINGIOSelectObject[inputID].mouseUP(new Point(e.X, e.Y));
this.MOVINGIOSelectObject[inputID] = null;
}
else if (this.MOVINGSpline[inputID] != null)
{
MoveAbleSpline movingSpline = (MoveAbleSpline)this.MOVINGSpline[inputID];
//SingleWS.getInstance("").releaseTabletLock(movingSpline.splineID);
movingSpline.mouseUP(new Point(e.X, e.Y));
foreach( TabletVO tabVO in dashboard.getSelectedIterations())
{
if(tabVO.iterationID == movingSpline.splineID)
{
MaseUpdate.registerUpdated(movingSpline, tabVO);
break;
}
}
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;
}
public static void stopTimer()
{
DoingNothing.Stop();
}
public static void startTimer()
{
DoingNothing.Start();
}
private bool testSwitching(Point swPointDown, Point swPointUp)
{
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);
}
}
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 createLabelImage()
{
float labelImgWidth = ApplicationProperties.territoryLabelImgWidth;
float labelImgHeight = ApplicationProperties.territoryLabelImgHeight;
labelImage = new Bitmap(Convert.ToInt32(labelImgWidth), Convert.ToInt32(labelImgHeight));
Graphics gf = Graphics.FromImage(labelImage);
// Set the size of the sting for drawing the ellipsises (for title)
StringFormat titleFormat = new StringFormat();
titleFormat.Trimming = StringTrimming.EllipsisCharacter;
RectangleF titleRec = new RectangleF(2, 2, labelImgWidth, labelImgHeight);
gf.Clear(ApplicationProperties.storyBGColor);
Pen pen = new Pen(ApplicationProperties.storyFGColor, 1);
Font nameFont = new Font("Arial", 10, System.Drawing.FontStyle.Bold);
ApplicationProperties.backLogName = dashboard.productBacklog.iterationName;
ApplicationProperties.backLogID = dashboard.productBacklog.iterationID;
string backLogName = ApplicationProperties.backLogName;
gf.DrawString(backLogName, nameFont, new SolidBrush(ApplicationProperties.storyFGColor), titleRec, titleFormat);
gf.Save();
}
private void OpenGLWorkSpace_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
float rColor = Convert.ToSingle(ApplicationProperties.backLogBackgroundColor.R)/255.0f;
float gColor = Convert.ToSingle(ApplicationProperties.backLogBackgroundColor.G)/255.0f;
float bColor = Convert.ToSingle(ApplicationProperties.backLogBackgroundColor.B)/255.0f;
float transparency = Convert.ToSingle(ApplicationProperties.backLogBackgroundColor.A)/255.0f;
Gl.glClearColor(rColor, gColor, bColor, transparency);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
//drawing label image on to the territory area
// Gl.glPushMatrix();
// Gl.glEnable(Gl.GL_TEXTURE_2D);
// Gl.glBindTexture(Gl.GL_TEXTURE_2D, this.texture[0]);
// Gl.glColor4f(1.0f,1.0f,1.0f, 1.0f);
// Gl.glBegin(Gl.GL_QUADS);
// float labelImgWidth = ApplicationProperties.territoryLabelImgWidth;
// float labelImgHeight = ApplicationProperties.territoryLabelImgHeight;
// float topLeftX = 10.0f;
// float topLeftY = 10.0f;
// Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex2f(topLeftX, topLeftY);
// Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex2f(topLeftX, topLeftY + labelImgHeight);
// Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex2f(topLeftX + labelImgWidth, topLeftY + labelImgHeight);
// Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex2f(topLeftX + labelImgWidth, topLeftY);
// Gl.glEnd();
// Gl.glDisable(Gl.GL_TEXTURE_2D);
// Gl.glPopMatrix();
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.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.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]++;
}
while(MaseListen.recevivedUpdateQueue.Count!=0)
{
MaseListenResult maseListenResult = (MaseListenResult)MaseListen.recevivedUpdateQueue.Dequeue();
if(maseListenResult.updatedContentType == RegisterObj.CreateStoryContent)
{
for(int i=0; i<currIterations.Length; i++)
{
if(maseListenResult.updatedTabletVOContent.iterationID == currIterations[i].splineID)
{
currIterations[i].tabVO = SingleWS.getInstance("").getIndividualTabletVO(currIterations[i].splineID);
currIterations[i].createLabelImage();
currIterations[i].createFGList();
}
}
if(maseListenResult.originator == false)
{
TabletContentandUtil newTabUtil = new TabletContentandUtil(this.newStoryTabletVO);
newTabUtil.updateReference(maseListenResult.updatedTabletVOContent);
newCardCreatedHandling(true, false);
}
}
else if(maseListenResult.updatedContentType == RegisterObj.UpdateStoryContent || maseListenResult.updatedContentType == RegisterObj.UpdateStoryLocation || maseListenResult.updatedContentType == RegisterObj.UpdateRollback)
{
for(int i=0; i<currIterations.Length; i++)
{
currIterations[i].tabVO = SingleWS.getInstance("").getIndividualTabletVO(currIterations[i].splineID);
currIterations[i].createLabelImage();
currIterations[i].createFGList();
}
if(maseListenResult.originator == false)
{
if(maseListenResult.updatedContentType == RegisterObj.UpdateRollback)
MessageBox.Show("The card you moved is currently under edition. Application will reverse story modifications.");
TabletContentandUtil updateTabUtil = new TabletContentandUtil(this.updatedStoryVO);
updateTabUtil.updateReference(maseListenResult.updatedTabletVOContent);
//this.updatedStoryVO = maseListenResult.updatedTabletVOContent;
long updatedID = updatedStoryVO.tabletProcess.id;
ArrayList allGridObjects = this.interfaceMain.getAllGridObjects();
doubleClickedStoryIterationIDBeforeUpdate = -2;
if(updatedStoryVO.tabletProcess.id != updatedStoryVO.iterationID)
{
foreach(InterfaceObject obj in allGridObjects)
{
if(obj.displayObj.getTabletVO().tabletProcess.id == updatedID)
{
doubleClickedStory = obj;
doubleClickedStoryIterationIDBeforeUpdate = doubleClickedStory.displayObj.getTabletVO().iterationID;
}
}
}
updateEventHandling(true);
}
}
}
this.OpenGLWorkSpace.Refresh();
}
private void OpenGLWorkSpace_KeyPressed(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar == 27)
{
this.OpenGLWorkSpace.Dispose();
this.Close();
this.Dispose();
}
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;
ApplicationProperties.clientSizeWidth = this.ClientSize.Width;
ApplicationProperties.clientSizeHeight = 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();
if(this.menu == null)
{
EventHandler createCardEventHandler = new EventHandler(this.newCardCreated);
EventHandler reArrangeCardsEventHandler = new EventHandler(this.reArrangeAllCardsInWorkspace);
EventHandler createIterationEventHandler = new EventHandler(this.newIterationCreated);
EventHandler workspaceSwitchEventHandler = new EventHandler(this.workspaceSwitched);
menu = new MenuForm(dashboard.selectedProject, ref this.newStoryTabletVO, pulibWorkspaceOrNot, createCardEventHandler, reArrangeCardsEventHandler, createIterationEventHandler, workspaceSwitchEventHandler);
menu.Show();
}
/* End of Initialization */
}
private void workspaceSwitched(object sender, System.EventArgs e)
{
pulibWorkspaceOrNot = !pulibWorkspaceOrNot;
if(pulibWorkspaceOrNot == true)
{
MASEUpdateThread.Resume();
this.Visible = false;
this.Close();
dashboard.refershPlanningContent();
}
else
MASEUpdateThread.Suspend();
}
private void newIterationCreated(object sender, System.EventArgs e)
{
if(newStoryTabletVO.iterationName == null)
return;
TabletContentandUtil newTabUtil = new TabletContentandUtil(this.newStoryTabletVO);
TabletVO newIteration = newTabUtil.makeDeepCopy();
MaseUpdate.registerUpdated(newIteration, RegisterObj.CreateIterationContent);
ArrayList newMyIterationAryList = new ArrayList();
for(int i=0; i<this.dashboard.myIterationList.Length; i++)
{
newMyIterationAryList.Add(this.dashboard.myIterationList[i]);
}
newMyIterationAryList.Add(newIteration);
TabletVO[] newMyItertionList = new TabletVO[newMyIterationAryList.Count];
for(int i=0; i<newMyIterationAryList.Count; i++)
{
newMyItertionList[i] = (TabletVO)newMyIterationAryList[i];
}
this.dashboard.updateIterationComboBox(newMyItertionList);
}
private void reArrangeAllCardsInWorkspace(object sender, System.EventArgs e)
{
TabletVO[] selectedIterations = this.dashboard.getSelectedIterations();
int numberOfSelectedIterations = selectedIterations.Length;
for(int index = 0; index < numberOfSelectedIterations; index++)
{
selectedIterations[index].horizontalCenter.centerX = -1.0f;
selectedIterations[index].horizontalCenter.centerY = -1.0f;
TabletVO[] processesList = this.dashboard.getMyProcessList(index);
foreach(TabletVO tabVO in processesList)
{
tabVO.horizontalCenter.centerX = -1.0f;
tabVO.horizontalCenter.centerY = -1.0f;
tabVO.horizontalCenter.rotationAngle = 0.0f;
}
}
TabletVO[] backlogList = this.dashboard.getMyBacklogList();
foreach(TabletVO tabVO in backlogList)
{
tabVO.horizontalCenter.centerX = -1.0f;
tabVO.horizontalCenter.centerY = -1.0f;
tabVO.horizontalCenter.rotationAngle = 0.0f;
}
this.WorkSpace_Load(sender, e);
}
public void newCardCreatedHandling(bool foreginUpdate, bool testing)
{
InterfaceObject newInterfaceObj = null;
PointF newCardCenter = new PointF(-1.0f, -1.0f);
int imgWidth = ApplicationProperties.CardWidth;
int imgHeight = ApplicationProperties.CardHeight;
float imgAngle = 0.0f;
int index = dashboard.findBelongingIterationIndexinSelectedIterationsforTabletVO(this.newStoryTabletVO);
TabletContentandUtil newTabUtil = new TabletContentandUtil(this.newStoryTabletVO);
TabletVO newTabletVO = newTabUtil.makeDeepCopy();
if(foreginUpdate == false&&testing==false)
MaseUpdate.registerUpdated(newTabletVO, RegisterObj.CreateStoryContent);
StoryObj storyContent = new StoryObj(newTabletVO, imgWidth, imgHeight);
if(index > -2)
{
if(index == -1)
{
newTabletVO.horizontalCenter.centerX = ApplicationProperties.backlogShowUpPnt.X;
newTabletVO.horizontalCenter.centerY = ApplicationProperties.backlogShowUpPnt.Y;
TabletVO[] backlogProcesses = dashboard.getMyBacklogList();
Utility.addToTabletVOAry(ref backlogProcesses, newTabletVO);
dashboard.setMyBacklogList(backlogProcesses);
Point storyCenter = new Point(Convert.ToInt32(ApplicationProperties.backlogShowUpPnt.X), Convert.ToInt32(ApplicationProperties.backlogShowUpPnt.Y));
newInterfaceObj = new InterfaceObject(storyCenter, (Displayable_Interface)storyContent, this.interfaceMain, imgAngle, this.animateInterfaceObjectList, this.IconTextures, false);
newInterfaceObj.mouseDOWN(storyCenter, 0); // why 0? I do not know. Can be deemed as a hack.
newInterfaceObj.mouseUP(storyCenter);
}
else
{
newTabletVO.horizontalCenter.centerX = currIterations[index].getCenter().X;
newTabletVO.horizontalCenter.centerY = currIterations[index].getCenter().Y;
TabletVO[] iterationProcesses = dashboard.getMyProcessList(index);
Utility.addToTabletVOAry(ref iterationProcesses, newTabletVO);
dashboard.setMyProcessList(iterationProcesses, index);
Point storyCenter = new Point(Convert.ToInt32(currIterations[index].getCenter().X), Convert.ToInt32(currIterations[index].getCenter().Y));
newInterfaceObj = new InterfaceObject(storyCenter, (Displayable_Interface)storyContent, this.interfaceMain, imgAngle, this.animateInterfaceObjectList, this.IconTextures, false);
newInterfaceObj.mouseDOWN(storyCenter, 0); // why 0? I do not know. Can be deemed as a hack.
newInterfaceObj.mouseMOVE(storyCenter, true, currIterations[index], 99); // why 99? I do not know. Can be deemed as a hack.
this.currIterations[index].addInterfaceObjectToSpline(newInterfaceObj);
newInterfaceObj.mouseUP(storyCenter);
}
}
else
{
}
}
private void newCardCreated(object sender, System.EventArgs e)
{
newCardCreatedHandling(false, false);
}
private void Workspace_Closing(object sender, CancelEventArgs e)
{
stopTimer();
this.menu.Close();
this.menu.Dispose();
if(MASEUpdateThread.ThreadState.Equals(ThreadState.WaitSleepJoin&ThreadState.Suspended)||MASEUpdateThread.ThreadState.Equals(ThreadState.Suspended))
{
MASEUpdateThread.Resume();
}
if(MASEUpdateThread.ThreadState.Equals(ThreadState.WaitSleepJoin)||MASEUpdateThread.ThreadState.Equals(ThreadState.Running))
{
MASEUpdateThread.Interrupt();
}
if(MASEUpdateThread.IsAlive)
{
if(MASEUpdateThread.Join(10000))
{
MessageBox.Show("MASE updator thread terminats successfully.");
}
else
{
MessageBox.Show("MASE updator thread DOES not terminate properly. Time elapsed for 2 seconds.");
}
}
MASEUpdateThread.Abort();
if(MASEListenThread.ThreadState.Equals(ThreadState.WaitSleepJoin))
{
MASEListenThread.Interrupt();
}
if(MASEListenThread.IsAlive)
{
if(MASEListenThread.Join(10000))
{
MessageBox.Show("MASE listener thread terminats successfully.");
}
else
{
MessageBox.Show("MASE listener thread DOES not terminate properly. Time elapsed for 2 seconds.");
}
}
MASEListenThread.Abort();
}
private void OpenGLWorkSpace_DoubleClick(object sender, EventArgs e)
{
doubleClickedStory = this.interfaceMain.getTopObject(this.lastMouseUPLoction);
Double_Cliecked(false);
}
public void Double_Cliecked(bool testing)
{
long projectID = dashboard.selectedProject.id;
int iterationCount = dashboard.myIterationList.Length + 1;
TabletVO productbacklog = dashboard.productBacklog;
TabletVO[] iterations = new TabletVO[iterationCount];
iterations[0] = productbacklog;
int tempInt = 0;
for(int index = 1; index < iterationCount; index++)
{
tempInt = index-1;
iterations[index] = dashboard.myIterationList[tempInt];
}
string[] ebProcessTypes = new string[1];
if(doubleClickedStory != null)
{
updatedStoryVO = doubleClickedStory.displayObj.getTabletVO();
bool acquireTabletLock = false;
if(pulibWorkspaceOrNot == true)
acquireTabletLock = SingleWS.getInstance("").acquireTabletLock(updatedStoryVO.tabletProcess.id);
if(pulibWorkspaceOrNot == false || acquireTabletLock == true)
{
doubleClickedStoryIterationIDBeforeUpdate = updatedStoryVO.iterationID;
doubleClickedStoryIDBeforeUpdate = updatedStoryVO.tabletProcess.id;
if(testing==false)
{
doubleClickedStoryForm = new EStoryForm(projectID, iterations, ref updatedStoryVO, ebProcessTypes, new EventHandler(updateEventHandelFromCallingProcess));
doubleClickedStoryForm.ShowDialog();
}
}
else if(acquireTabletLock == false)
{
MessageBox.Show("The story is being locked for modification by others. Please try later.");
}
}
}
private int retireveContainedTabletVO(TabletVO[] tabletVoAry, TabletVO checkedVO)
{
int count = tabletVoAry.Length;
int returnIndex = -1;
for(int index=0; index < count; index++)
{
if(tabletVoAry[index].tabletProcess.id == checkedVO.tabletProcess.id)
{
returnIndex = index;
}
}
return returnIndex;
}
public void updateEventHandling(bool foreginUpdate)
{
int cardWidth = ApplicationProperties.CardWidth;
int cardHeight = ApplicationProperties.CardHeight;
bool changedToProductBacklog = false;
bool changedToSelectedIteration = false;
bool changedToOtherIteration = false;
TabletVO[] selectedIterations = dashboard.getSelectedIterations();
TabletVO productBacklog = dashboard.productBacklog;
TabletVO[] backlogProcesses = dashboard.getMyBacklogList();
TabletVO[][] iterationProcesses = dashboard.getMyProcessLsts();
if(updatedStoryVO.iterationID != updatedStoryVO.tabletProcess.id)
if(doubleClickedStory!=null)
doubleClickedStory.displayObj.setOriginalTabletContent(new TabletContentandUtil(doubleClickedStory.displayObj.getTabletVO()));
if(foreginUpdate == false)
{
MaseUpdate.registerUpdated(updatedStoryVO, RegisterObj.UpdateStoryContent);
SingleWS.getInstance("").releaseTabletLock(updatedStoryVO.tabletProcess.id);
int preIndex = -1;
for(int k=0; k<currIterations.Length; k++)
{
if(doubleClickedStoryIterationIDBeforeUpdate == currIterations[k].splineID)
{
preIndex = k;
}
}
int index = dashboard.findBelongingIterationIndexinSelectedIterationsforTabletVO(doubleClickedStory.displayObj.getTabletVO());
if(updatedStoryVO.iterationID != doubleClickedStoryIterationIDBeforeUpdate)
{
this.interfaceMain.removeObject(doubleClickedStory);
if (updatedStoryVO.iterationID == productBacklog.iterationID)
changedToProductBacklog = true;
else
{
if(index >= 0)
changedToSelectedIteration = true;
else
changedToOtherIteration = true;
}
if(preIndex>=0)
{
long currIterationId =doubleClickedStory.displayObj.getTabletVO().iterationID;
doubleClickedStory.displayObj.getTabletVO().iterationID = doubleClickedStoryIterationIDBeforeUpdate;
currIterations[preIndex].removeInterfaceObjectFromSpline(doubleClickedStory);
doubleClickedStory.displayObj.getTabletVO().iterationID = currIterationId;
}
}
if(changedToOtherIteration)
{
if(doubleClickedStoryIterationIDBeforeUpdate == productBacklog.iterationID)
{
Utility.removeFromTabletVOAry(ref backlogProcesses, updatedStoryVO);
dashboard.setMyBacklogList(backlogProcesses);
}
else if(doubleClickedStoryIterationIDBeforeUpdate == selectedIterations[preIndex].iterationID)
{
Utility.removeFromTabletVOAry(ref iterationProcesses[preIndex], updatedStoryVO);
dashboard.setMyProcessList(iterationProcesses[preIndex], preIndex);
Utility.removeFromTabletVOAry(ref backlogProcesses, updatedStoryVO);
dashboard.setMyBacklogList(backlogProcesses);
}
}
else if(changedToSelectedIteration)
{
Utility.removeFromTabletVOAry(ref backlogProcesses, updatedStoryVO);
dashboard.setMyBacklogList(backlogProcesses);
Utility.addToTabletVOAry(ref iterationProcesses[index], updatedStoryVO);
dashboard.setMyProcessList(iterationProcesses[index], index);
PointF storyCenterPoint;
storyCenterPoint = currIterations[index].getCenter();
Point storyCenter = new Point(Convert.ToInt32(storyCenterPoint.X), Convert.ToInt32(storyCenterPoint.Y));
InterfaceObject newCard = new InterfaceObject(storyCenterPoint, doubleClickedStory.displayObj, this.interfaceMain, updatedStoryVO.horizontalCenter.rotationAngle, this.animateInterfaceObjectList, this.IconTextures, false);
newCard.mouseDOWN(storyCenter, 0); // why 0? I do not know. Can be deemed as a hack.
newCard.mouseMOVE(storyCenter, true, currIterations[index], 99); // why 99? I do not know. Can be deemed as a hack.
currIterations[index].addInterfaceObjectToSpline(newCard);
newCard.mouseUP(storyCenter);
}
else if(changedToProductBacklog)
{
Utility.removeFromTabletVOAry(ref iterationProcesses[preIndex], updatedStoryVO);
dashboard.setMyProcessList(iterationProcesses[preIndex], preIndex);
Utility.addToTabletVOAry(ref backlogProcesses, updatedStoryVO);
dashboard.setMyBacklogList(backlogProcesses);
PointF storyCenterPoint;
storyCenterPoint = ApplicationProperties.backlogShowUpPnt;
Point storyCenter = new Point(Convert.ToInt32(storyCenterPoint.X), Convert.ToInt32(storyCenterPoint.Y));
InterfaceObject newCard = new InterfaceObject(storyCenterPoint, doubleClickedStory.displayObj, this.interfaceMain, updatedStoryVO.horizontalCenter.rotationAngle, this.animateInterfaceObjectList, this.IconTextures, false);
newCard.mouseDOWN(storyCenter, 0); // why 0? I do not know. Can be deemed as a hack.
newCard.mouseUP(storyCenter);
}
else
doubleClickedStory.createCardImage();
}
else
{
TabletVO foreignUpdatedVO = updatedStoryVO;
int preIndex = -2;
for(int k=0; k<currIterations.Length; k++)
{
if(doubleClickedStoryIterationIDBeforeUpdate == currIterations[k].splineID)
{
preIndex = k;
}
else if(doubleClickedStoryIterationIDBeforeUpdate == dashboard.productBacklog.iterationID)
{
preIndex = -1;
}
}
int index = dashboard.findBelongingIterationIndexinSelectedIterationsforTabletVO(foreignUpdatedVO);
TabletContentandUtil tabUtil = new TabletContentandUtil(this.updatedStoryVO);
if(foreignUpdatedVO.tabletProcess.id != foreignUpdatedVO.iterationID)
{
if(preIndex==-2)
{
for(int j=0; j<dashboard.unselectedIterations.Length; j++)
{
for(int k=0; k<dashboard.unselectedProcesList[j].Length; k++)
{
if(dashboard.unselectedProcesList[j][k].tabletProcess.id == updatedStoryVO.tabletProcess.id)
{
TabletVO[] updatedAry = dashboard.unselectedProcesList[j];
TabletContentandUtil tempTabUtil = new TabletContentandUtil(dashboard.unselectedProcesList[j][k]);
Utility.removeFromTabletVOAry(ref updatedAry, tempTabUtil.makeDeepCopy());
dashboard.setUnselectedProcessList(updatedAry, j);
if(index == -1)
{
updatedAry = dashboard.myBacklogList;
Utility.addToTabletVOAry(ref updatedAry, tabUtil.makeDeepCopy());
dashboard.setMyBacklogList(updatedAry);
}
else if(index>=0)
{
for(int i=0; i<dashboard.selectedIterations.Length; i++)
{
if(dashboard.selectedIterations[i].iterationID == updatedStoryVO.iterationID)
{
updatedAry = dashboard.myProcessList[i];
Utility.addToTabletVOAry(ref updatedAry, tabUtil.makeDeepCopy());
dashboard.setMyProcessList(updatedAry, i);
}
}
}
}
}
}
}
else
{
if(preIndex>-2)
this.interfaceMain.removeObject(doubleClickedStory);
if(preIndex >= 0)
for(int j=0; j<currIterations.Length; j++)
{
if(currIterations[j].splineID == doubleClickedStoryIterationIDBeforeUpdate)
{
currIterations[j].removeInterfaceObjectFromSpline(doubleClickedStory);
}
}
}
if(index == -2)
{
if(doubleClickedStoryIterationIDBeforeUpdate != -2)
{
TabletVO[] updatedAry = dashboard.myBacklogList;
Utility.removeFromTabletVOAry(ref updatedAry, tabUtil.makeDeepCopy());
dashboard.setMyBacklogList(updatedAry);
}
for(int j=0; j<dashboard.unselectedIterations.Length; j++)
{
if(dashboard.unselectedIterations[j].iterationID == updatedStoryVO.iterationID)
{
TabletVO[] updatedAry = dashboard.unselectedProcesList[j];
Utility.addToTabletVOAry(ref updatedAry, tabUtil.makeDeepCopy());
dashboard.setUnselectedProcessList(updatedAry, j);
}
}
return;
}
if(doubleClickedStory != null)
doubleClickedStory.displayObj.setTabletVO(tabUtil.makeDeepCopy());
PointF storyCenterPoint;
Point storyCenter;
InterfaceObject newCard;
/*
storyCenterPoint = new PointF(doubleClickedStory.displayObj.getTabletVO().horizontalCenter.centerX, doubleClickedStory.displayObj.getTabletVO().horizontalCenter.centerY);
*/
if(index == -1)
storyCenterPoint = new PointF(ApplicationProperties.backlogShowUpPnt.X, ApplicationProperties.backlogShowUpPnt.Y);
else
storyCenterPoint = new PointF(currIterations[index].getCenter().X, currIterations[index].getCenter().Y);
storyCenter = new Point(Convert.ToInt32(storyCenterPoint.X), Convert.ToInt32(storyCenterPoint.Y));
if(doubleClickedStory == null)
{
StoryObj storyObj = new StoryObj(tabUtil.makeDeepCopy(), ApplicationProperties.CardWidth, ApplicationProperties.CardHeight);
newCard = new InterfaceObject(storyCenterPoint, (Displayable_Interface)storyObj, this.interfaceMain, updatedStoryVO.horizontalCenter.rotationAngle, this.animateInterfaceObjectList, this.IconTextures, false);
}else
newCard = new InterfaceObject(storyCenterPoint, doubleClickedStory.displayObj, this.interfaceMain, updatedStoryVO.horizontalCenter.rotationAngle, this.animateInterfaceObjectList, this.IconTextures, false);
PointF pressPointF = new PointF(-1.0f, -1.0f);
if(storyCenterPoint.X >= 0 && storyCenterPoint.Y >= 0)
{
pressPointF = storyCenterPoint;
}
else if(newCard.getBottomLeft().X >= 0 && newCard.getBottomLeft().Y >= 0)
{
pressPointF = newCard.getBottomLeft();
}
else if(newCard.getBottomRight().X >= 0 && newCard.getBottomRight().Y >= 0)
{
pressPointF = newCard.getBottomRight();
}
else if(newCard.getTopLeft().X >= 0 && newCard.getTopLeft().Y >= 0)
{
pressPointF = newCard.getTopLeft();
}
else if(newCard.getTopRight().X >= 0 && newCard.getTopRight().Y >= 0)
{
pressPointF = newCard.getTopRight();
}
Point pressPoint = new Point(Convert.ToInt32(pressPointF.X), Convert.ToInt32(pressPointF.Y));
newCard.mouseDOWN(pressPoint, 0); // why 0? I do not know. Can be deemed as a hack.
if(index>=0)
{
newCard.mouseMOVE(pressPoint, true, currIterations[index], 99);
currIterations[index].addInterfaceObjectToSpline(newCard);
}
newCard.mouseUP(pressPoint);
}
else
{
ArrayList containedInterfaceObj = currIterations[index].dumpAllInterfaceObjs();
this.interfaceMain.removeWholeMoveSpline(currIterations[index]);
float territoryWidth = ApplicationProperties.iterationWidth;
float territoryHeight = ApplicationProperties.iterationHeight;
PointF center = new PointF( updatedStoryVO.horizontalCenter.centerX, updatedStoryVO.horizontalCenter.centerY);
PointF[] pointStore = calaulcateMaseIterationMoveableSplineBoundry(center, territoryWidth, territoryHeight);
//currIterations[index] = new MoveAbleSpline(currIterations[index].splineName, currIterations[index].splineID , ref dashboard, center, pointStore, this.interfaceMain, this.globalObjectCounter, this.IconTextures, ApplicationProperties.iterationBackgroundColor);
this.interfaceMain.addWholeMoveSpline(currIterations[index]);
foreach(InterfaceObject ifObj in containedInterfaceObj)
{
currIterations[index].addInterfaceObjectToSpline(ifObj);
}
}
}
long updatedStoryID = updatedStoryVO.tabletProcess.id;
doubleClickedStoryIterationIDBeforeUpdate = 0;
doubleClickedStoryForm = null;
doubleClickedStory = null;
}
private void updateEventHandelFromCallingProcess(object sender, EventArgs e)
{
updateEventHandling(false);
}
}
}
See more files for this project here