Show Dashboard.cs syntax highlighted
using System;
using System.Net;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using TableWhiteboard_HCI_Intergration.HCI_Objs;
using Whiteboard;
using Whiteboard.MaseWS;
namespace New_Study_Project
{
public class Dashboard : System.Windows.Forms.Form
{
// public class Dashboard : System.Windows.Forms.UserControl
// {
[STAThread]
static void Main()
{
Application.Run(new Dashboard());
}
private System.Windows.Forms.Label project_lb;
private System.Windows.Forms.Label iteration_lb;
private System.Windows.Forms.ComboBox projectList_cb;
public System.Windows.Forms.ListBox iteration_lstbox;
private System.Windows.Forms.Button ok_bt;
private System.Windows.Forms.Button cancel_bt;
public String serverName;
public TabletVO[] myIterationList;
public ProjectVO selectedProject;
public ProjectVO[] myProjectList;
public TabletVO[] myBacklogList;
public TabletVO[][] myProcessList;
public TabletVO[] selectedIterations;
public TabletVO[] unselectedIterations;
public TabletVO[][] unselectedProcesList;
public TabletVO tempSelectedIteration;
public TabletVO productBacklog;
public Boolean completedOK = false;
public webServicesService ws;
private System.Windows.Forms.Label username_lb;
private System.Windows.Forms.Label server_lb;
private System.Windows.Forms.Label password_lb;
private System.Windows.Forms.TextBox server_tb;
private System.Windows.Forms.TextBox username_tb;
private System.Windows.Forms.TextBox password_tb;
private System.Windows.Forms.Button login_bt;
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label workspace_lb;
public System.Windows.Forms.ComboBox workspace_cb;
public System.Windows.Forms.RadioButton tabletop_rb;
public System.Windows.Forms.RadioButton tabletpc_rb;
public Workspace workingSpace = null;
public TabletUI tabletUI = null;
public Dashboard()
{
InitializeComponent();
completedOK = false;
project_lb.Visible = false;
projectList_cb.Visible = false;
iteration_lstbox.Visible = false;
iteration_lb.Visible = false;
workspace_cb.Visible = false;
workspace_lb.Visible = false;
ok_bt.Visible = false;
cancel_bt.Visible = false;
ws = SingleWS.getInstance(null);
username_tb.Text = ApplicationProperties.username;
password_tb.Text = ApplicationProperties.password;
}
public TabletVO[] getSelectedIterations()
{
return this.selectedIterations;
}
public void updateIterationComboBox(TabletVO[] newMyIterationList)
{
int arySize = newMyIterationList.Length;
this.myIterationList = newMyIterationList;
this.iteration_lstbox.Items.Add(newMyIterationList[arySize-1].iterationName);
this.iteration_lstbox.Refresh();
}
public void setMyBacklogList(TabletVO[] tabVOAry)
{
myBacklogList = tabVOAry;
}
public void setMyProcessList(TabletVO[] tabVOAry, int specifiedIterationIndex)
{
myProcessList[specifiedIterationIndex] = tabVOAry;
}
public void setUnselectedProcessList(TabletVO[] tabVOAry, int specifiedIterationIndex)
{
unselectedProcesList[specifiedIterationIndex] = tabVOAry;
}
public TabletVO[] getMyBacklogList()
{
return this.myBacklogList;
}
public TabletVO[] getMyProcessList(int specifiedIterationIndex)
{
return this.myProcessList[specifiedIterationIndex];
}
public TabletVO[][] getMyProcessLsts()
{
return this.myProcessList;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.project_lb = new System.Windows.Forms.Label();
this.iteration_lb = new System.Windows.Forms.Label();
this.projectList_cb = new System.Windows.Forms.ComboBox();
this.iteration_lstbox = new System.Windows.Forms.ListBox();
this.ok_bt = new System.Windows.Forms.Button();
this.cancel_bt = new System.Windows.Forms.Button();
this.password_lb = new System.Windows.Forms.Label();
this.username_lb = new System.Windows.Forms.Label();
this.server_lb = new System.Windows.Forms.Label();
this.server_tb = new System.Windows.Forms.TextBox();
this.username_tb = new System.Windows.Forms.TextBox();
this.password_tb = new System.Windows.Forms.TextBox();
this.login_bt = new System.Windows.Forms.Button();
this.workspace_cb = new System.Windows.Forms.ComboBox();
this.workspace_lb = new System.Windows.Forms.Label();
this.tabletop_rb = new System.Windows.Forms.RadioButton();
this.tabletpc_rb = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
//
// project_lb
//
this.project_lb.Location = new System.Drawing.Point(32, 136);
this.project_lb.Name = "project_lb";
this.project_lb.Size = new System.Drawing.Size(100, 21);
this.project_lb.TabIndex = 0;
this.project_lb.Text = "Project:";
//
// iteration_lb
//
this.iteration_lb.Location = new System.Drawing.Point(32, 176);
this.iteration_lb.Name = "iteration_lb";
this.iteration_lb.Size = new System.Drawing.Size(100, 21);
this.iteration_lb.TabIndex = 1;
this.iteration_lb.Text = "Iteration:";
//
// projectList_cb
//
this.projectList_cb.Location = new System.Drawing.Point(136, 136);
this.projectList_cb.Name = "projectList_cb";
this.projectList_cb.Size = new System.Drawing.Size(208, 21);
this.projectList_cb.TabIndex = 2;
this.projectList_cb.Text = "[Select a project]";
this.projectList_cb.SelectedIndexChanged += new System.EventHandler(this.projectList_cb_SelectedIndexChanged);
//
// iteration_lstbox
//
this.iteration_lstbox.Location = new System.Drawing.Point(136, 176);
this.iteration_lstbox.Name = "iteration_lstbox";
this.iteration_lstbox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.iteration_lstbox.Size = new System.Drawing.Size(208, 43);
this.iteration_lstbox.TabIndex = 3;
//
// ok_bt
//
this.ok_bt.Location = new System.Drawing.Point(352, 216);
this.ok_bt.Name = "ok_bt";
this.ok_bt.Size = new System.Drawing.Size(72, 32);
this.ok_bt.TabIndex = 4;
this.ok_bt.Text = "Accept";
this.ok_bt.Click += new System.EventHandler(this.ok_bt_Click);
//
// cancel_bt
//
this.cancel_bt.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancel_bt.Location = new System.Drawing.Point(432, 216);
this.cancel_bt.Name = "cancel_bt";
this.cancel_bt.Size = new System.Drawing.Size(72, 32);
this.cancel_bt.TabIndex = 5;
this.cancel_bt.Text = "Cancel";
//
// password_lb
//
this.password_lb.Location = new System.Drawing.Point(32, 96);
this.password_lb.Name = "password_lb";
this.password_lb.Size = new System.Drawing.Size(100, 21);
this.password_lb.TabIndex = 6;
this.password_lb.Text = "Password:";
//
// username_lb
//
this.username_lb.Location = new System.Drawing.Point(32, 56);
this.username_lb.Name = "username_lb";
this.username_lb.Size = new System.Drawing.Size(100, 21);
this.username_lb.TabIndex = 7;
this.username_lb.Text = "Username:";
//
// server_lb
//
this.server_lb.Location = new System.Drawing.Point(32, 16);
this.server_lb.Name = "server_lb";
this.server_lb.Size = new System.Drawing.Size(100, 21);
this.server_lb.TabIndex = 8;
this.server_lb.Text = "Server:";
//
// server_tb
//
this.server_tb.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.server_tb.Location = new System.Drawing.Point(136, 16);
this.server_tb.Name = "server_tb";
this.server_tb.Size = new System.Drawing.Size(336, 20);
this.server_tb.TabIndex = 9;
this.server_tb.Text = ApplicationProperties.serverWebServiceLocation;
this.server_tb.Leave += new System.EventHandler(this.server_tb_Leave);
//
// username_tb
//
this.username_tb.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.username_tb.Location = new System.Drawing.Point(136, 56);
this.username_tb.Name = "username_tb";
this.username_tb.Size = new System.Drawing.Size(208, 20);
this.username_tb.TabIndex = 10;
this.username_tb.Text = "";
//
// password_tb
//
this.password_tb.Font = new System.Drawing.Font("Arial Black", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.password_tb.Location = new System.Drawing.Point(136, 96);
this.password_tb.Name = "password_tb";
this.password_tb.PasswordChar = '*';
this.password_tb.Size = new System.Drawing.Size(208, 24);
this.password_tb.TabIndex = 11;
this.password_tb.Text = "";
//
// login_bt
//
this.login_bt.Location = new System.Drawing.Point(352, 96);
this.login_bt.Name = "login_bt";
this.login_bt.TabIndex = 0;
this.login_bt.Text = "Login";
this.login_bt.Click += new System.EventHandler(this.login_bt_Click);
//
// workspace_cb
//
this.workspace_cb.Items.AddRange(new object[] {
"Public Workspace",
"Private Workspace"});
this.workspace_cb.Location = new System.Drawing.Point(136, 216);
this.workspace_cb.Name = "workspace_cb";
this.workspace_cb.Size = new System.Drawing.Size(208, 21);
this.workspace_cb.TabIndex = 13;
this.workspace_cb.Text = "[Select the type of workspace]";
//
// workspace_lb
//
this.workspace_lb.Location = new System.Drawing.Point(32, 216);
this.workspace_lb.Name = "workspace_lb";
this.workspace_lb.Size = new System.Drawing.Size(100, 24);
this.workspace_lb.TabIndex = 12;
this.workspace_lb.Text = "Workspace Options:";
//
// tabletop_rb
//
this.tabletop_rb.Location = new System.Drawing.Point(360, 40);
this.tabletop_rb.Name = "tabletop_rb";
this.tabletop_rb.TabIndex = 14;
this.tabletop_rb.Text = "Table Top";
//
// tabletpc_rb
//
this.tabletpc_rb.Location = new System.Drawing.Point(360, 68);
this.tabletpc_rb.Name = "tabletpc_rb";
this.tabletpc_rb.TabIndex = 15;
this.tabletpc_rb.Text = "Tablet PC";
//
// Dashboard
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(512, 133);
this.Controls.Add(this.tabletpc_rb);
this.Controls.Add(this.tabletop_rb);
this.Controls.Add(this.workspace_cb);
this.Controls.Add(this.workspace_lb);
this.Controls.Add(this.login_bt);
this.Controls.Add(this.password_tb);
this.Controls.Add(this.server_tb);
this.Controls.Add(this.username_tb);
this.Controls.Add(this.server_lb);
this.Controls.Add(this.username_lb);
this.Controls.Add(this.password_lb);
this.Controls.Add(this.cancel_bt);
this.Controls.Add(this.ok_bt);
this.Controls.Add(this.iteration_lstbox);
this.Controls.Add(this.projectList_cb);
this.Controls.Add(this.iteration_lb);
this.Controls.Add(this.project_lb);
this.Name = "Dashboard";
this.Text = "Dashboard";
this.Closed += new System.EventHandler(this.Dashboard_Closed);
this.Activated += new System.EventHandler(this.becomeActivated);
this.ResumeLayout(false);
}
#endregion
private ProjectVO[] getAllProjects()
{
return ws.getAllProjects();
}
private TabletVO[] getAllIterations(ProjectVO project)
{
return ws.getAllIterationsByProject(project.id, false);
}
private TabletVO[] getAllProcesses(TabletVO iteration)
{
return ws.getAllStoriesByIterId(iteration.iterationID, false);
}
public void refershPlanningContent()
{
myBacklogList = getAllProcesses(this.productBacklog);
int selectedIterationCount = selectedIterations.Length;
for(int i=0; i< selectedIterationCount; i++)
{
myProcessList[i] = getAllProcesses(this.selectedIterations[i]);
}
}
private void initializeProject_cb()
{
projectList_cb.Items.Clear();
myProjectList = getAllProjects();
int count = 0;
foreach(ProjectVO i in myProjectList)
{
projectList_cb.Items.Add(i.name);
if (selectedProject!=null)
{
if (selectedProject.name == i.name)
projectList_cb.SelectedIndex = count;
}
count++;
}
if(myProjectList.Length > 0 && projectList_cb.SelectedIndex == -1)
projectList_cb.SelectedIndex = 1;
}
public void initalizeIteration_lstbox()
{
iteration_lstbox.Items.Clear();
ArrayList newIterations = new ArrayList();
productBacklog = new TabletVO();
myIterationList = getAllIterations(selectedProject);
bool hasMoreThanProductBacklogItertion = false;
// Extract the backlog from the arraylist
foreach(TabletVO i in myIterationList)
{
if (i.tabletProcess.name.Equals("Product Backlog"))
productBacklog = i;
else
{
newIterations.Add(i);
hasMoreThanProductBacklogItertion = true;
iteration_lstbox.Items.Add(i.tabletProcess.name);
}
}
if(hasMoreThanProductBacklogItertion )
{
myIterationList = new TabletVO[newIterations.Count];
for(int j = 0; j<newIterations.Count; j++)
{
myIterationList[j] = (TabletVO)newIterations[j];
}
}
else
myIterationList = null;
}
private void projectList_cb_SelectedIndexChanged(object sender, System.EventArgs e)
{
selectedProject = myProjectList[projectList_cb.SelectedIndex];
initalizeIteration_lstbox();
}
private void ok_bt_Click(object sender, System.EventArgs e)
{
ok_bt_clicked();
}
public void ok_bt_clicked()
{
completedOK = true;
if(this.iteration_lstbox.SelectedIndex == -1)
if(this.iteration_lstbox.Items.Count > 0)
{
this.iteration_lstbox.SelectedIndex = 0;
}
else
{
MessageBox.Show("The selected project does not have iterations. Please create a new iteration before proceeding.");
return;
}
if(this.workspace_cb.SelectedIndex == -1)
this.workspace_cb.SelectedIndex = 0;
System.Windows.Forms.ListBox.SelectedIndexCollection selcIndices = iteration_lstbox.SelectedIndices;
int selcIterationSize = selcIndices.Count;
int unselectedIterationSize = myIterationList.Length - selcIterationSize;
myProcessList = new TabletVO[selcIterationSize][];
unselectedProcesList = new TabletVO[unselectedIterationSize][];
selectedIterations = new TabletVO[selcIterationSize];
unselectedIterations = new TabletVO[unselectedIterationSize];
for(int i=0, j=0, k=0; i<myIterationList.Length; i++)
{
int selectedIndex = 0;
if(j<selcIterationSize)
selectedIndex = selcIndices[j];
if(i==selectedIndex)
{
selectedIterations[j] = myIterationList[i];
myProcessList[j] = getAllProcesses(myIterationList[i]);
j++;
}
else
{
unselectedIterations[k] = myIterationList[i];
unselectedProcesList[k] = getAllProcesses(myIterationList[i]);
k++;
}
}
myBacklogList = getAllProcesses(productBacklog);
if(this.tabletop_rb.Checked == true)
{
this.workingSpace = new Workspace(this);
MaseUpdate.appType = MaseUpdate.appTypeServer;
this.workingSpace.Show();
}
if(this.tabletpc_rb.Checked == true)
{
this.tabletUI = new TabletUI(this);
MaseUpdate.appType = MaseUpdate.appTypeClient;
this.tabletUI.Show();
}
}
private void server_tb_Leave(object sender, System.EventArgs e)
{
serverName = server_tb.Text;
ws.Url = serverName;
}
private void login_bt_Click(object sender, System.EventArgs e)
{
SingleWS.Username = username_tb.Text;
SingleWS.Password = password_tb.Text;
if((tabletop_rb.Checked|tabletop_rb.Checked)==false)
{
tabletpc_rb.Checked = true;
}
/*if(!tabletop_rb.Checked && !tabletpc_rb.Checked)
{
MessageBox.Show("Please specify the type of machine the program is running on.");
return;
}*/
try
{
ws = SingleWS.getInstance(server_tb.Text);
initializeProject_cb();
username_lb.Visible = false;
username_tb.Visible = false;
password_tb.Visible = false;
password_lb.Visible = false;
login_bt.Visible = false;
server_lb.Visible = false;
server_tb.Visible = false;
tabletop_rb.Visible = false;
tabletpc_rb.Visible = false;
project_lb.Location = server_lb.Location;
projectList_cb.Location = server_tb.Location;
iteration_lb.Location = username_lb.Location;
iteration_lstbox.Location = username_tb.Location;
Point workspaceLabelPoint = new Point(workspace_lb.Location.X, iteration_lstbox.Location.Y+60);
Point workspaceComboPoint = new Point(workspace_cb.Location.X, iteration_lstbox.Location.Y+60);
workspace_lb.Location = workspaceLabelPoint;
workspace_cb.Location = workspaceComboPoint;
//workspace_lb.Visible = true;
//workspace_cb.Visible = true;
Point newOkayPoint = new Point(ok_bt.Location.X, login_bt.Location.Y);
Point newCancelPoint = new Point(cancel_bt.Location.X, login_bt.Location.Y);
ok_bt.Location = newOkayPoint;
cancel_bt.Location = newCancelPoint;
project_lb.Visible = true;
projectList_cb.Visible = true;
iteration_lstbox.Visible = true;
iteration_lb.Visible = true;
ok_bt.Visible = true;
cancel_bt.Visible = true;
this.Height = this.Height;
}
catch(System.Net.WebException exception)
{
MessageBox.Show( "Either the username or password you entered is incorrect.", "Webservice Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
private void Dashboard_Closed(object sender, System.EventArgs e)
{
if(workingSpace!= null)
this.workingSpace.Close();
Application.Exit();
}
public int findBelongingIterationIndexinSelectedIterationsforTabletVO(TabletVO tabVO)
{
int returnedInx = -2;
int numberOfSelectedInteration = selectedIterations.Length;
for(int index=0; index < numberOfSelectedInteration; index++)
{
if(selectedIterations[index].iterationID == tabVO.iterationID)
{
returnedInx = index;
break;
}
}
if(tabVO.iterationID == productBacklog.iterationID)
{
returnedInx = -1;
}
return returnedInx;
}
private void becomeActivated(object sender, System.EventArgs e)
{
if(selectedProject != null)
initalizeIteration_lstbox();
}
}
}
See more files for this project here