using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
namespace IssueVision
{
public class IssueEditForm : Form, IObserver
{
private Panel Panel2;
private PaneCaption PaneCaption2;
private Button btnCancel;
private Button btnSave;
private Label Label10;
private ComboBox cmbAssignedTo;
private Panel Panel9;
private RadioButton rbActive;
private RadioButton rbClosed;
private Panel Panel10;
private TextBox txtComment;
private Panel Panel11;
private Panel Panel1;
private Panel Panel3;
private HistoryList listHistory;
private IssueSubject m_subject;
private PaneCaption PaneCaption1;
private PaneCaption PaneCaption3;
private EllipsisLabel labelTitle;
private EllipsisLabel labelDescription;
public DataRowView m_datarowview = null;
public int m_issueID = 0;
private bool m_originalOpenState = false;
private string m_originalAssignedTo = string.Empty;
private IContainer components = null;
public ISubject Subject
{
set
{
m_subject = (IssueSubject)value;
}
}
#region Windows Form Designer generated code
public IssueEditForm()
{
InitializeComponent();
}
public IssueEditForm(Form ownerForm) : this()
{
Owner = ownerForm;
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
[DebuggerStepThroughAttribute()]
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(IssueEditForm));
this.Panel1 = new System.Windows.Forms.Panel();
this.Panel11 = new System.Windows.Forms.Panel();
this.txtComment = new System.Windows.Forms.TextBox();
this.Panel10 = new System.Windows.Forms.Panel();
this.rbClosed = new System.Windows.Forms.RadioButton();
this.rbActive = new System.Windows.Forms.RadioButton();
this.Panel9 = new System.Windows.Forms.Panel();
this.cmbAssignedTo = new System.Windows.Forms.ComboBox();
this.Label10 = new System.Windows.Forms.Label();
this.btnSave = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.PaneCaption2 = new IssueVision.PaneCaption();
this.Panel2 = new System.Windows.Forms.Panel();
this.labelDescription = new IssueVision.EllipsisLabel();
this.labelTitle = new IssueVision.EllipsisLabel();
this.PaneCaption1 = new IssueVision.PaneCaption();
this.Panel3 = new System.Windows.Forms.Panel();
this.listHistory = new IssueVision.HistoryList();
this.PaneCaption3 = new IssueVision.PaneCaption();
this.Panel1.SuspendLayout();
this.Panel11.SuspendLayout();
this.Panel10.SuspendLayout();
this.Panel9.SuspendLayout();
this.Panel2.SuspendLayout();
this.Panel3.SuspendLayout();
this.SuspendLayout();
//
// Panel1
//
this.Panel1.Controls.Add(this.Panel11);
this.Panel1.Controls.Add(this.Panel10);
this.Panel1.Controls.Add(this.Panel9);
this.Panel1.Location = new System.Drawing.Point(8, 86);
this.Panel1.Name = "Panel1";
this.Panel1.Size = new System.Drawing.Size(256, 260);
this.Panel1.TabIndex = 6;
//
// Panel11
//
this.Panel11.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(255)));
this.Panel11.Controls.Add(this.txtComment);
this.Panel11.Dock = System.Windows.Forms.DockStyle.Fill;
this.Panel11.DockPadding.Left = 8;
this.Panel11.DockPadding.Right = 8;
this.Panel11.Location = new System.Drawing.Point(0, 40);
this.Panel11.Name = "Panel11";
this.Panel11.Size = new System.Drawing.Size(256, 164);
this.Panel11.TabIndex = 18;
//
// txtComment
//
this.txtComment.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtComment.Location = new System.Drawing.Point(8, 0);
this.txtComment.Multiline = true;
this.txtComment.Name = "txtComment";
this.txtComment.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtComment.Size = new System.Drawing.Size(240, 164);
this.txtComment.TabIndex = 0;
this.txtComment.Text = "";
//
// Panel10
//
this.Panel10.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(255)));
this.Panel10.Controls.Add(this.rbClosed);
this.Panel10.Controls.Add(this.rbActive);
this.Panel10.Dock = System.Windows.Forms.DockStyle.Bottom;
this.Panel10.Location = new System.Drawing.Point(0, 204);
this.Panel10.Name = "Panel10";
this.Panel10.Size = new System.Drawing.Size(256, 56);
this.Panel10.TabIndex = 17;
//
// rbClosed
//
this.rbClosed.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.rbClosed.Location = new System.Drawing.Point(24, 32);
this.rbClosed.Name = "rbClosed";
this.rbClosed.Size = new System.Drawing.Size(104, 20);
this.rbClosed.TabIndex = 1;
this.rbClosed.Text = "Closed";
//
// rbActive
//
this.rbActive.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.rbActive.Location = new System.Drawing.Point(24, 8);
this.rbActive.Name = "rbActive";
this.rbActive.TabIndex = 0;
this.rbActive.Text = "Open";
//
// Panel9
//
this.Panel9.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(255)));
this.Panel9.Controls.Add(this.cmbAssignedTo);
this.Panel9.Controls.Add(this.Label10);
this.Panel9.Dock = System.Windows.Forms.DockStyle.Top;
this.Panel9.Location = new System.Drawing.Point(0, 0);
this.Panel9.Name = "Panel9";
this.Panel9.Size = new System.Drawing.Size(256, 40);
this.Panel9.TabIndex = 16;
//
// cmbAssignedTo
//
this.cmbAssignedTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbAssignedTo.Location = new System.Drawing.Point(80, 8);
this.cmbAssignedTo.Name = "cmbAssignedTo";
this.cmbAssignedTo.Size = new System.Drawing.Size(160, 21);
this.cmbAssignedTo.TabIndex = 14;
//
// Label10
//
this.Label10.Location = new System.Drawing.Point(8, 12);
this.Label10.Name = "Label10";
this.Label10.Size = new System.Drawing.Size(72, 16);
this.Label10.TabIndex = 13;
this.Label10.Text = "Assigned To:";
//
// btnSave
//
this.btnSave.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(255)));
this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnSave.Location = new System.Drawing.Point(104, 352);
this.btnSave.Name = "btnSave";
this.btnSave.TabIndex = 2;
this.btnSave.Text = "Save";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// btnCancel
//
this.btnCancel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(255)));
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnCancel.Location = new System.Drawing.Point(184, 352);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// PaneCaption2
//
this.PaneCaption2.AllowActive = false;
this.PaneCaption2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PaneCaption2.AntiAlias = false;
this.PaneCaption2.Caption = "Issue Comment";
this.PaneCaption2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.PaneCaption2.ForeColor = System.Drawing.SystemColors.AppWorkspace;
this.PaneCaption2.InactiveGradientHighColor = System.Drawing.Color.FromArgb(((System.Byte)(175)), ((System.Byte)(200)), ((System.Byte)(245)));
this.PaneCaption2.InactiveGradientLowColor = System.Drawing.Color.FromArgb(((System.Byte)(205)), ((System.Byte)(225)), ((System.Byte)(250)));
this.PaneCaption2.InactiveTextColor = System.Drawing.Color.Black;
this.PaneCaption2.Location = new System.Drawing.Point(8, 64);
this.PaneCaption2.Name = "PaneCaption2";
this.PaneCaption2.Size = new System.Drawing.Size(256, 22);
this.PaneCaption2.TabIndex = 10;
//
// Panel2
//
this.Panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("Panel2.BackgroundImage")));
this.Panel2.Controls.Add(this.labelDescription);
this.Panel2.Controls.Add(this.labelTitle);
this.Panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.Panel2.DockPadding.All = 5;
this.Panel2.Location = new System.Drawing.Point(0, 0);
this.Panel2.Name = "Panel2";
this.Panel2.Size = new System.Drawing.Size(562, 56);
this.Panel2.TabIndex = 11;
this.Panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel2_Paint);
//
// labelDescription
//
this.labelDescription.Alignment = System.Drawing.ContentAlignment.TopLeft;
this.labelDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelDescription.BackColor = System.Drawing.Color.Transparent;
this.labelDescription.Ellipsis = System.Drawing.StringTrimming.EllipsisCharacter;
this.labelDescription.Location = new System.Drawing.Point(8, 32);
this.labelDescription.Name = "labelDescription";
this.labelDescription.Size = new System.Drawing.Size(552, 16);
this.labelDescription.TabIndex = 20;
this.labelDescription.Text = "< description >";
//
// labelTitle
//
this.labelTitle.Alignment = System.Drawing.ContentAlignment.TopLeft;
this.labelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelTitle.BackColor = System.Drawing.Color.Transparent;
this.labelTitle.Ellipsis = System.Drawing.StringTrimming.EllipsisCharacter;
this.labelTitle.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.labelTitle.Location = new System.Drawing.Point(8, 8);
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(552, 23);
this.labelTitle.TabIndex = 19;
this.labelTitle.Text = "< title >";
//
// PaneCaption1
//
this.PaneCaption1.AllowActive = false;
this.PaneCaption1.AntiAlias = false;
this.PaneCaption1.Dock = System.Windows.Forms.DockStyle.Fill;
this.PaneCaption1.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
this.PaneCaption1.InactiveGradientHighColor = System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(231)), ((System.Byte)(255)));
this.PaneCaption1.InactiveGradientLowColor = System.Drawing.Color.FromArgb(((System.Byte)(165)), ((System.Byte)(199)), ((System.Byte)(255)));
this.PaneCaption1.Location = new System.Drawing.Point(0, 0);
this.PaneCaption1.Name = "PaneCaption1";
this.PaneCaption1.Size = new System.Drawing.Size(562, 384);
this.PaneCaption1.TabIndex = 12;
//
// Panel3
//
this.Panel3.Controls.Add(this.listHistory);
this.Panel3.Controls.Add(this.PaneCaption3);
this.Panel3.Location = new System.Drawing.Point(280, 64);
this.Panel3.Name = "Panel3";
this.Panel3.Size = new System.Drawing.Size(272, 286);
this.Panel3.TabIndex = 13;
//
// listHistory
//
this.listHistory.Dock = System.Windows.Forms.DockStyle.Fill;
this.listHistory.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.listHistory.Location = new System.Drawing.Point(0, 22);
this.listHistory.Name = "listHistory";
this.listHistory.Size = new System.Drawing.Size(272, 264);
this.listHistory.TabIndex = 10;
//
// PaneCaption3
//
this.PaneCaption3.AllowActive = false;
this.PaneCaption3.AntiAlias = false;
this.PaneCaption3.Caption = "History";
this.PaneCaption3.Dock = System.Windows.Forms.DockStyle.Top;
this.PaneCaption3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.PaneCaption3.ForeColor = System.Drawing.SystemColors.AppWorkspace;
this.PaneCaption3.InactiveGradientHighColor = System.Drawing.Color.FromArgb(((System.Byte)(175)), ((System.Byte)(200)), ((System.Byte)(245)));
this.PaneCaption3.InactiveGradientLowColor = System.Drawing.Color.FromArgb(((System.Byte)(205)), ((System.Byte)(225)), ((System.Byte)(250)));
this.PaneCaption3.InactiveTextColor = System.Drawing.Color.Black;
this.PaneCaption3.Location = new System.Drawing.Point(0, 0);
this.PaneCaption3.Name = "PaneCaption3";
this.PaneCaption3.Size = new System.Drawing.Size(272, 22);
this.PaneCaption3.TabIndex = 11;
//
// IssueEditForm
//
this.AllowDrop = true;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(562, 384);
this.Controls.Add(this.Panel3);
this.Controls.Add(this.Panel2);
this.Controls.Add(this.PaneCaption2);
this.Controls.Add(this.Panel1);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.PaneCaption1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "IssueEditForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Edit Issue";
this.Load += new System.EventHandler(this.IssueEditForm_Load);
this.Panel1.ResumeLayout(false);
this.Panel11.ResumeLayout(false);
this.Panel10.ResumeLayout(false);
this.Panel9.ResumeLayout(false);
this.Panel2.ResumeLayout(false);
this.Panel3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void IssueEditForm_Load(object sender, EventArgs e)
{
CenterWindow();
//initialize the form's data from Subject.CurrentItem
DataRowView row = m_subject.CurrentItem;
m_issueID = (int)row["IssueID"];
labelTitle.Text = (string)row["Title"];
Text = labelTitle.Text;
labelDescription.Text = (string)row["Description"];
cmbAssignedTo.DataSource = m_subject.Staffers;
cmbAssignedTo.DisplayMember = "DisplayName";
cmbAssignedTo.ValueMember = "StafferID";
m_originalAssignedTo = (string)row["DisplayName"];
cmbAssignedTo.SelectedValue = (int)row["StafferID"];
txtComment.Text = string.Empty;
m_originalOpenState = (bool)row["IsOpen"];
if (m_originalOpenState)
{
rbActive.Checked = true;
}
else
{
rbClosed.Checked = true;
}
listHistory.DataSource = row.Row.GetChildRows("History");
}
private void btnSave_Click(object sender, EventArgs e)
{
//Inject comment if issue status (open/closed) is changed
if (rbActive.Checked != m_originalOpenState)
{
if (rbActive.Checked)
{
PrependToComment("Status changed to Opened.");
}
else
{
PrependToComment("Status changed to Closed.");
}
}
//Inject comment if Assigned To is changed
if (cmbAssignedTo.Text != m_originalAssignedTo)
{
PrependToComment("Reassigned from " + m_originalAssignedTo + " to " + cmbAssignedTo.Text + ".");
}
//update issue
m_subject.UpdateIssue(m_issueID, (int)cmbAssignedTo.SelectedValue, cmbAssignedTo.Text, txtComment.Text, rbActive.Checked);
Close();
}
private void PrependToComment(string comment)
{
string commentTxt = string.Empty;
if (txtComment.Text != string.Empty)
{
commentTxt = " " + txtComment.Text;
}
txtComment.Text = comment + commentTxt;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}
private void CenterWindow()
{
if (Owner != null)
{
Location = new Point(Owner.Location.X + (Owner.Width - Width) / 2, Owner.Location.Y + (Owner.Height - Height) / 2);
}
}
private void Panel2_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(SystemColors.InactiveCaption), 0, Panel2.Height - 1, Panel2.Width - 1, Panel2.Height - 1);
}
}
}