Curious if your connection has been fixed yet?
I have been working on an cq_action Class with children classes for specific types.
Here is a snippet so far:
Action.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Action_Creator_V0._1.Action_Engine
{
public class Action
{
#region Variables and Properties
//Declare Variables (Global to any Action)
int id; //ID of current Action Code
int id_next; //ID of the next Action Code (If current Action Code returns true)
int id_nextfail; //ID of the next Action Code (If current Action Code returns false)
int type; //The type of Action that the Action Code is
int data; //The data to be used when executing the Action Code
string param; //The parameters to be used for the Action Code
bool valid = true; //Used to determine if the Action Code is valid or invalid
Action action_true; //The action information of the next Action if the code returns true
Action action_false; //The action information of the next Action if the code returns false
/// <summary>
/// Get the ID of the ActionCode.
/// </summary>
public int ID
{
get { return id; }
//Allows privately setting the value of the ID
private set { id = value; }
}
/// <summary>
/// Get the ID of the next ActionCode if the ActionCode is sucessful.
/// </summary>
public int ID_Next
{
get { return id_next; }
//Allows privately setting the value of the ID_Next
private set { id_next = value; }
}
/// <summary>
/// Get the ID of the next ActionCode if the ActionCode is un-sucessful.
/// </summary>
public int ID_NextFail
{
get { return id_nextfail; }
//Allows privately setting the value of the ID_NextFail
private set { id_nextfail = value; }
}
/// <summary>
/// Get the Type of the ActionCode.
/// </summary>
public int Type
{
get { return type; }
//Allows privately setting the value of the Type
private set { type = value; }
}
/// <summary>
/// Get the Data of the ActionCode.
/// </summary>
public int Data
{
get { return data; }
//Allows privately setting the value of the Data
private set { data = value; }
}
/// <summary>
/// Get the Parameters of the ActionCode.
/// </summary>
public string Parameters
{
get { return param; }
//Allows privately setting the value of the Parameters
private set { param = value; }
}
/// <summary>
/// Get boolean if the Action Code is valid or not.
/// </summary>
public bool IsValid
{
get { return valid; }
//Allows privately setting the value of IsValid
private set { valid = value; }
}
#endregion
#region Constructors
/// <summary>
/// Initialises the Action Class Object.
/// </summary>
/// <param name="id">ID of the Action Code.</param>
/// <param name="id_next">ID_Next of the Action Code.</param>
/// <param name="id_nextfail">ID_Next of the Action Code.</param>
/// <param name="type">Type of the Action Code.</param>
/// <param name="data">Data of the Action Code.</param>
/// <param name="param">Parameters of the Action Code.</param>
public Action(int id, int id_next, int id_nextfail, int type, int data, string param)
{
//Setup the ActionCode's Properties
try { ID = id; } catch { Error(1); }
try { ID_Next = id_next; } catch { Error(2); }
try { ID_NextFail = id_nextfail; } catch { Error(3); }
try { Type = type; } catch { Error(4); }
try { Data = data; } catch { Error(5); }
try { Parameters = param; } catch { Error(6); }
}
/// <summary>
/// Initialises the Action Class Object.
/// </summary>
/// <param name="action_code">Action Information.</param>
public Action(Action action_code)
{
//Setup the ActionCode's Properties
ID = action_code.ID;
ID_Next = action_code.ID_Next;
ID_NextFail = action_code.ID_NextFail;
Type = action_code.Type;
Data = action_code.Data;
Parameters = action_code.Parameters;
}
#endregion
#region Methods
#region Error Display Method
/// <summary>
/// Displays an error according to what calls the method.
/// </summary>
/// <param name="type">Error Type.</param>
public void Error(int type)
{
//Set IsValid to false as there is an error with the
//Action Code
IsValid = false;
switch (type)
{
case 1:
//Display Error Message for Action (Thus the AE) for type 001
MessageBox.Show("ERROR(AE001)\r\nInvalid Action ID!","ERROR(AE001)",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
break;
case 2:
//Display Error Message for Action (Thus the AE) for type 002
MessageBox.Show("ERROR(AE002)\r\nInvalid Action ID_Next!","ERROR(AE002)",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
break;
case 3:
//Display Error Message for Action (Thus the AE) for type 003
MessageBox.Show("ERROR(AE003)\r\nInvalid Action ID_NextFail!","ERROR(AE003)",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
break;
case 4:
//Display Error Message for Action (Thus the AE) for type 004
MessageBox.Show("ERROR(AE004)\r\nInvalid Action Type!","ERROR(AE004)",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
break;
case 5:
//Display Error Message for Action (Thus the AE) for type 005
MessageBox.Show("ERROR(AE005)\r\nInvalid Action Data!","ERROR(AE005)",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
break;
case 6:
//Display Error Message for Action (Thus the AE) for type 006
MessageBox.Show("ERROR(AE006)\r\nInvalid Action Parameters!","ERROR(AE006)",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
break;
//System ERROR Messages
//MenuText ERROR Messages (Type 102)
case 1020:
//Display Error Message for Action (Thus the AE) for type 1020
MessageBox.Show("ERROR(AE1020)\r\nInvalid MenuLink Parameters! Requires atleast 1 space!", "ERROR(AE1020)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1021:
//Display Error Message for Action (Thus the AE) for type 1021
MessageBox.Show("ERROR(AE1021)\r\nInvalid MenuLink Parameters! Requires atleast 1 character for both Text and TaskID!", "ERROR(AE1021)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1022:
//Display Error Message for Action (Thus the AE) for type 1022
MessageBox.Show("ERROR(AE1022)\r\nInvalid MenuLink Parameters! Invalid TaskID!", "ERROR(AE1022)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
//MenuPic ERROR Messages (Type 104)
case 1040:
//Display Error Message for Action (Thus the AE) for type 1040
MessageBox.Show("ERROR(AE1040)\r\nInvalid MenuPic Parameters! Requires atleast 2 spaces!", "ERROR(AE1040)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1041:
//Display Error Message for Action (Thus the AE) for type 1041
MessageBox.Show("ERROR(AE1041)\r\nInvalid MenuPic Parameters! Requires no more than 3 spaces!", "ERROR(AE1041)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1042:
//Display Error Message for Action (Thus the AE) for type 1042
MessageBox.Show("ERROR(AE1042)\r\nInvalid MenuPic Parameters! Invalid value for X!", "ERROR(AE1042)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1043:
//Display Error Message for Action (Thus the AE) for type 1043
MessageBox.Show("ERROR(AE1043)\r\nInvalid MenuPic Parameters! Invalid value for Y!", "ERROR(AE1043)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1044:
//Display Error Message for Action (Thus the AE) for type 1044
MessageBox.Show("ERROR(AE1044)\r\nInvalid MenuPic Parameters! Invalid value for PictureID!", "ERROR(AE1044)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case 1045:
//Display Error Message for Action (Thus the AE) for type 1045
MessageBox.Show("ERROR(AE1045)\r\nInvalid MenuPic Parameters! Invalid value for TaskID!", "ERROR(AE1045)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
//MenuCreate ERROR Messages (Type 120)
case 1200:
//Display Error Message for Action (Thus the AE) for type 1200
MessageBox.Show("ERROR(AE1200)\r\nInvalid MenuCreate Parameters! Invalid value for TaskID!", "ERROR(AE1200)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
default:
//Display Unknown Error Message for Action (Thus the AE)
MessageBox.Show("ERROR(Unkown)\r\nAn unknown error has occured!", "ERROR(Unknown)", MessageBoxButtons.OK, MessageBoxIcon.Warning);
break;
}
}
#endregion
#endregion
}
}
MenuText.cs (Type 101)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Action_Creator_V0._1.Action_Engine.Types.System
{
public class MenuText:Action
{
#region Variables and Properties
//Declare Variables (Only valid for this Type of Action Code)
string text; //The text to be displayed by the menu
/// <summary>
/// Get the Text of the MenuText Action Code.
/// </summary>
public string Text
{
get { return text; }
//Allows privately setting the value of the Text
private set { text = value; }
}
#endregion
#region Constructors
/// <summary>
/// Initialises the MenuText class object.
/// </summary>
/// <param name="action_code">Action Code information.</param>
public MenuText(Action action_code):base(action_code)
{
//Setup the MenuText's Properties
try { Text = action_code.Parameters; }
catch { Error(6); }
}
#endregion
#region Methods
#endregion
}
}
MenuLink.cs (Type 102)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Action_Creator_V0._1.Action_Engine.Types.System
{
public class MenuLink:Action
{
#region Variables and Properties
//Declare Variables (Only valid for this Type of Action Code)
string text; //The text displayed as the menu link
int task_id; //The cq_task ID used to link to
/// <summary>
/// Get the Text of the MenuLink Action Code.
/// </summary>
public string Text
{
get { return text; }
//Allows privately setting the value of the Text
private set { text = value; }
}
/// <summary>
/// Get the TaskID of the MenuLink Action Code.
/// </summary>
public int TaskID
{
get { return task_id; }
//Allows privately setting the value of the TaskID
private set { task_id = value; }
}
#endregion
#region Constructors
/// <summary>
/// Initialises the MenuLink class object.
/// </summary>
/// <param name="action_code">Action Code information.</param>
public MenuLink(Action action_code): base(action_code)
{
//Declare variables required for processing.
string _param; //Store the parameters of the action code
string _task_id; //Store the link_id in a string form
//Get the parameters from the actionCode parsed
_param = action_code.Parameters;
//Check if there is atleast 1 space character within the parameters
if (_param.Contains(" ") == false)
//Return an error and exit constructor
{ Error(1020); return; }
//Get the link_id area of the param string
_task_id = _param.Substring(_param.IndexOf(" ") + 1);
//Remove the link_id area from the param string
_param = _param.Substring(0, _param.IndexOf(" "));
//Make sure both link_id and param contain atleast 1 character
if (_task_id.Length < 1 || _param.Length < 1)
{ Error(1021); return; }
//Finally check if the link_id is a valid number
try { Convert.ToInt32(_task_id); }
catch { Error(1022); return; }
//Set the MenuLink's Properties
Text = _param;
TaskID = Convert.ToInt32(_task_id);
}
#endregion
#region Methods
#endregion
}
}
MenuPic.cs (Type 104)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Action_Creator_V0._1.Action_Engine.Types.System
{
public class MenuPic:Action
{
#region Variables and Properties
//Declare Variables (Only Valid for this Type of Action Code)
int x; //The X position of the MenuPic
int y; //The Y position of the MenuPic
int pic_id; //The ID of the MenuPic
int task_id; //Optional: The TaskID when the MenuPic is clicked
/// <summary>
/// Get the MenuPic's X position.
/// </summary>
public int X
{
get { return x; }
//Allows privately setting the value of the MenuPic's X
private set { x = value; }
}
/// <summary>
/// Get the MenuPic's Y position.
/// </summary>
public int Y
{
get { return y; }
//Allows privately setting the value of the MenuPic's Y
private set { y = value; }
}
/// <summary>
/// Get the ID of the MenuPic's Picture.
/// </summary>
public int PictureID
{
get { return pic_id; }
//Allows privately setting the value of the MenuPic's PictureID
private set { pic_id = value; }
}
/// <summary>
/// Get the Optional TaskID of the MenuPic. 0 By default.
/// </summary>
public int TaskID
{
get { return task_id; }
//Allows privately setting the value of the MenuPic's TaskID
private set { task_id = value; }
}
#endregion
#region Constructors
/// <summary>
/// Initialises the MenuPic class object.
/// </summary>
/// <param name="action_code">Action Code information.</param>
public MenuPic(Action action_code): base(action_code)
{
//Declare Variables required for processing
string _param; //Store the parameters of the action code
string _x; //Store the x in a string form
string _y; //Store the y in a string form
string _pic_id; //Store the pic_id in a string form
string _task_id; //Store the task_id in a string form
int space_count=0; //Counter used to count amount of spaces in param
//Get the parameters from the action code parsed
_param = action_code.Parameters;
//Check if there is atleast 2 spaces within the parameters
if (_param.IndexOf(" ") == _param.LastIndexOf(" "))
//Return an error and exit the constructor
{ Error(1040); return; }
//Count the amount of spaces within the param
for (int charIndex = _param.IndexOf(" "); charIndex < _param.LastIndexOf(" ")+1; charIndex++)
{
//If the current character is a space
//Add one to the space counter
if (_param[charIndex] == Convert.ToChar(" "))
{ space_count++; }
}
//If there is more than 3 spaces return an error and exit
if (space_count > 3)
{ Error(1041); return; }
//If there is 3 spaces then get the task_id
if (space_count == 3)
{
_task_id = _param.Substring(_param.IndexOf(" ") + 1);
//Remove the task_id from the param string
_param = _param.Substring(0, _param.IndexOf(" "));
}
else { _task_id = "0"; }
//Get the pic_id from the param string
_pic_id = _param.Substring(_param.IndexOf(" ") + 1);
//Remove the pic_id from the param string
_param = _param.Substring(0, _param.IndexOf(" "));
//Get the y value from the param string
_y = _param.Substring(_param.IndexOf(" ") + 1);
//Remove the y value from the param string
_param = _param.Substring(0, _param.IndexOf(" "));
//Get the x value from the param string
_x = _param;
//Validate all the values obtained
try { Convert.ToInt32(_x); }
catch { Error(1042); return; }
try { Convert.ToInt32(_y); }
catch { Error(1043); return; }
try { Convert.ToInt32(_pic_id); }
catch { Error(1044); return; }
try { Convert.ToInt32(_param); }
catch { Error(1045); return; }
//All values are valid begin setting properties
X = Convert.ToInt32(_x);
Y = Convert.ToInt32(_y);
PictureID = Convert.ToInt32(_pic_id);
TaskID = Convert.ToInt32(_task_id);
}
#endregion
#region Methods
#endregion
}
}
MenuCreate.cs (Type 120)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Action_Creator_V0._1.Action_Engine.Types.System
{
public class MenuCreate:Action
{
#region Variables and Properties
//Declare Variables (Only Valid for this Type of Action Code)
int task_id; //Optional: The TaskID when the Menu is forcebly closed.
/// <summary>
/// Get the Optional TaskID of the MenuCreate. 0 by default.
/// </summary>
public int TaskID
{
get { return task_id; }
//Allows privately settingt the value of the MenuCreate's TaskID
private set { task_id = value; }
}
#endregion
#region Constructors
/// <summary>
/// Initialises the MenuCreate class object.
/// </summary>
/// <param name="action_code">Action Code information.</param>
public MenuCreate(Action action_code): base(action_code)
{
//Declare variables required for processing
string _param; //Store the parameters of the action code
string _task_id; //Store the task_id in a string form
//Get the parameters from the action code parsed
_param = action_code.Parameters;
//Check if there is atleast 1 character in the parameters
if (_param.Length > 0)
{ _task_id = _param; }
else { _task_id = "0"; }
//Validate the task_id value
try { Convert.ToInt32(_task_id); }
catch { Error(1200); return; }
//All values are valid begin setting properties
TaskID = Convert.ToInt32(_task_id);
}
#endregion
#region Methods
#endregion
}
}