/*
* Created by SharpDevelop.
* User: andy
* Date: 21/12/2007
* Time: 20:33
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using log4net;
using uk.org.aspellclark.common.gui;
using uk.org.aspellclark.todolist.engine;
namespace uk.org.aspellclark.todolist
{
/// <summary>
/// <name>TaskDetailsCtrl</name>
/// <namespace>uk.org.aspellclark.todolist</namespace>
/// <version>1.0</version>
/// <author>Andy Aspell-Clark</author>
/// <description>Display a simple about box
/// </description>
/// <history>
/// <historyitem> 1 Jan 2008 1.0 ARAC Initial Version.</historyitem>
/// </history>
/// </summary>
public class TaskDetailsCtrl : System.Windows.Forms.UserControl
{
#region Events
public event EventHandler TodolistDataChanged;
protected virtual void OnTodolistDataChanged(EventArgs e)
{
if (TodolistDataChanged != null)
{
TodolistDataChanged(this, e);
}
}
#endregion
// Create a logger for use in this class
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private TodolistEngine engine;
private System.Windows.Forms.TextBox txtPercentComplete;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox cmbAllocatedTo;
private System.Windows.Forms.ComboBox cmbPriority;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RichTextBox richComments;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private CTask m_selectedTask;
private bool updatingData;
#region properties
public CTask Task
{
get {return m_selectedTask;}
set {m_selectedTask=value;UpdateDetails();}
}
public TodolistEngine Engine
{
set
{
this.engine = value;
#if (PLATFORM_MONO_1_2_6)
//Todo: put back in when EeePc has mono 1.2.6
cmbAllocatedTo.AutoCompleteSource = AutoCompleteSource.CustomSource;
cmbStatus.AutoCompleteSource = AutoCompleteSource.CustomSource;
cmbCategory.AutoCompleteSource = AutoCompleteSource.CustomSource;
cmbAllocatedTo.AutoCompleteCustomSource = ComboFunctions.CreateStrCol(this.engine.UserNames);
cmbStatus.AutoCompleteCustomSource = ComboFunctions.CreateStrCol(this.engine.StatusList);
cmbCategory.AutoCompleteCustomSource = ComboFunctions.CreateStrCol(this.engine.CategoryList);
cmbAllocatedTo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cmbStatus.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cmbCategory.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
#endif
}
}
#endregion
public TaskDetailsCtrl()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.richComments = new System.Windows.Forms.RichTextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.cmbPriority = new System.Windows.Forms.ComboBox();
this.cmbStatus = new System.Windows.Forms.ComboBox();
this.cmbAllocatedTo = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.txtPercentComplete = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.cmbCategory = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.lnkLabelFileLink = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// richComments
//
this.richComments.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.richComments.Location = new System.Drawing.Point(3, 214);
this.richComments.Name = "richComments";
this.richComments.Size = new System.Drawing.Size(217, 101);
this.richComments.TabIndex = 0;
this.richComments.Text = "richTextBox1";
this.richComments.TextChanged += new System.EventHandler(this.RichCommentsTextChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(3, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 18);
this.label1.TabIndex = 1;
this.label1.Text = "Alloctd To";
//
// label2
//
this.label2.Location = new System.Drawing.Point(3, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 18);
this.label2.TabIndex = 3;
this.label2.Text = "Status";
//
// label3
//
this.label3.Location = new System.Drawing.Point(3, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 18);
this.label3.TabIndex = 5;
this.label3.Text = "Priority";
//
// cmbPriority
//
this.cmbPriority.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cmbPriority.FormattingEnabled = true;
this.cmbPriority.Items.AddRange(new object[] {
"none",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10"});
this.cmbPriority.Location = new System.Drawing.Point(61, 53);
this.cmbPriority.Name = "cmbPriority";
this.cmbPriority.Size = new System.Drawing.Size(160, 21);
this.cmbPriority.TabIndex = 6;
this.cmbPriority.SelectedIndexChanged += new System.EventHandler(this.CmbPrioritySelectedIndexChanged);
//
// cmbStatus
//
this.cmbStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cmbStatus.FormattingEnabled = true;
this.cmbStatus.Items.AddRange(new object[] {
"done",
"in progress",
"pending",
"test ready"});
this.cmbStatus.Location = new System.Drawing.Point(61, 29);
this.cmbStatus.Name = "cmbStatus";
this.cmbStatus.Size = new System.Drawing.Size(160, 21);
this.cmbStatus.Sorted = true;
this.cmbStatus.TabIndex = 2;
this.cmbStatus.SelectedIndexChanged += new System.EventHandler(this.CmdStatusSelectedIndexChanged);
//
// cmbAllocatedTo
//
this.cmbAllocatedTo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cmbAllocatedTo.FormattingEnabled = true;
this.cmbAllocatedTo.Location = new System.Drawing.Point(61, 5);
this.cmbAllocatedTo.Name = "cmbAllocatedTo";
this.cmbAllocatedTo.Size = new System.Drawing.Size(160, 21);
this.cmbAllocatedTo.Sorted = true;
this.cmbAllocatedTo.TabIndex = 8;
this.cmbAllocatedTo.SelectedIndexChanged += new System.EventHandler(this.CmbAllocatedToSelectedIndexChanged);
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label4.Location = new System.Drawing.Point(3, 191);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 18);
this.label4.TabIndex = 9;
this.label4.Text = "% complete";
//
// txtPercentComplete
//
this.txtPercentComplete.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtPercentComplete.Location = new System.Drawing.Point(61, 188);
this.txtPercentComplete.Name = "txtPercentComplete";
this.txtPercentComplete.Size = new System.Drawing.Size(160, 20);
this.txtPercentComplete.TabIndex = 10;
this.txtPercentComplete.TextChanged += new System.EventHandler(this.TxtPercentCompleteTextChanged);
//
// label5
//
this.label5.Location = new System.Drawing.Point(3, 102);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 18);
this.label5.TabIndex = 11;
this.label5.Text = "Link";
//
// cmbCategory
//
this.cmbCategory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cmbCategory.FormattingEnabled = true;
this.cmbCategory.Items.AddRange(new object[] {
"none",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10"});
this.cmbCategory.Location = new System.Drawing.Point(61, 77);
this.cmbCategory.Name = "cmbCategory";
this.cmbCategory.Size = new System.Drawing.Size(160, 21);
this.cmbCategory.TabIndex = 14;
this.cmbCategory.SelectedIndexChanged += new System.EventHandler(this.CmbCategorySelectedIndexChanged);
//
// label6
//
this.label6.Location = new System.Drawing.Point(3, 80);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(64, 18);
this.label6.TabIndex = 13;
this.label6.Text = "Category";
//
// lnkLabelFileLink
//
this.lnkLabelFileLink.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lnkLabelFileLink.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.lnkLabelFileLink.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lnkLabelFileLink.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.lnkLabelFileLink.Location = new System.Drawing.Point(61, 101);
this.lnkLabelFileLink.Name = "lnkLabelFileLink";
this.lnkLabelFileLink.Size = new System.Drawing.Size(160, 21);
this.lnkLabelFileLink.TabIndex = 15;
//
// TaskDetailsCtrl
//
this.Controls.Add(this.lnkLabelFileLink);
this.Controls.Add(this.cmbCategory);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtPercentComplete);
this.Controls.Add(this.label4);
this.Controls.Add(this.cmbAllocatedTo);
this.Controls.Add(this.cmbStatus);
this.Controls.Add(this.cmbPriority);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.richComments);
this.MinimumSize = new System.Drawing.Size(224, 318);
this.Name = "TaskDetailsCtrl";
this.Size = new System.Drawing.Size(224, 318);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.LinkLabel lnkLabelFileLink;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ComboBox cmbCategory;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox cmbStatus;
#endregion
private void UpdateDetails()
{
log.Info("UpdateDetails() current todolist");
if (m_selectedTask !=null)
{
updatingData = true;
cmbStatus.Text=m_selectedTask.Status;
cmbAllocatedTo.Text=m_selectedTask.AllocatedTo;
cmbCategory.Text=m_selectedTask.Category;
lnkLabelFileLink.Text=m_selectedTask.FileLink;
richComments.Text=m_selectedTask.CommentsStr;
txtPercentComplete.Text=m_selectedTask.PercentComplete.ToString();
}
updatingData = false;
}
void CmbAllocatedToSelectedIndexChanged(object sender, EventArgs e)
{
if (!updatingData)
{
m_selectedTask.AllocatedTo=cmbAllocatedTo.Text;
OnTodolistDataChanged(new EventArgs());
}
}
void CmdStatusSelectedIndexChanged(object sender, EventArgs e)
{
if (!updatingData)
{
m_selectedTask.Status=cmbStatus.Text;
OnTodolistDataChanged(new EventArgs());
}
}
void CmbPrioritySelectedIndexChanged(object sender, EventArgs e)
{
if (!updatingData)
{
m_selectedTask.Priority=Convert.ToInt16(cmbPriority.Text);
OnTodolistDataChanged(new EventArgs());
}
}
void TxtPercentCompleteTextChanged(object sender, EventArgs e)
{
if (!updatingData)
{
m_selectedTask.PercentComplete=Convert.ToInt16(txtPercentComplete.Text);
OnTodolistDataChanged(new EventArgs());
}
}
void RichCommentsTextChanged(object sender, EventArgs e)
{
if (!updatingData)
{
m_selectedTask.PercentComplete=Convert.ToInt16(txtPercentComplete.Text);
OnTodolistDataChanged(new EventArgs());
}
}
void CmbCategorySelectedIndexChanged(object sender, EventArgs e)
{
if (!updatingData)
{
m_selectedTask.Category=cmbCategory.SelectedText;
OnTodolistDataChanged(new EventArgs());
}
}
}//class
}//namespace