|
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace IssueVision
{
// This user control appears in the right pane when the selected issue has a conflict
// that must be resolved.
public class ConflictPane : UserControl, IObserver
{
private GroupBox GroupBox1;
private GroupBox GroupBox2;
private Label Label1;
private Label lblServer;
private PaneCaption PaneCaption1;
private Button btnKeepUser;
private Label lblUser;
private Button btnKeepServer;
private IssueSubject m_subject;
private IContainer components = null;
public ISubject Subject
{
set
{
m_subject = (IssueSubject)value;
m_subject.PositionChanged += new IssueSubject.PositionChangedEventHandler(this.m_subject_PositionChanged);
}
}
public ConflictPane()
{
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
[DebuggerStepThroughAttribute()]
private void InitializeComponent()
{
PaneCaption1 = new PaneCaption();
Label1 = new Label();
GroupBox1 = new GroupBox();
lblServer = new Label();
btnKeepServer = new Button();
GroupBox2 = new GroupBox();
lblUser = new Label();
btnKeepUser = new Button();
GroupBox1.SuspendLayout();
GroupBox2.SuspendLayout();
SuspendLayout();
PaneCaption1.Caption = "Issue Conflict";
PaneCaption1.Dock = DockStyle.Top;
PaneCaption1.Font = new Font("Tahoma", 12.0F, FontStyle.Bold);
PaneCaption1.Location = new Point(0, 0);
PaneCaption1.Name = "PaneCaption1";
PaneCaption1.Size = new Size(280, 31);
PaneCaption1.TabIndex = 0;
Label1.Location = new Point(16, 40);
Label1.Name = "Label1";
Label1.Size = new Size(248, 40);
Label1.TabIndex = 1;
Label1.Text = "The records on the server do not match yours. Please pick which version should be kept.";
GroupBox1.Controls.Add(lblServer);
GroupBox1.Controls.Add(btnKeepServer);
GroupBox1.FlatStyle = FlatStyle.System;
GroupBox1.Location = new Point(16, 88);
GroupBox1.Name = "GroupBox1";
GroupBox1.Size = new Size(248, 104);
GroupBox1.TabIndex = 2;
GroupBox1.TabStop = false;
GroupBox1.Text = "Server record";
lblServer.Location = new Point(16, 24);
lblServer.Name = "lblServer";
lblServer.Size = new Size(128, 72);
lblServer.TabIndex = 0;
btnKeepServer.BackColor = SystemColors.Control;
btnKeepServer.FlatStyle = FlatStyle.System;
btnKeepServer.ForeColor = SystemColors.ActiveCaption;
btnKeepServer.Location = new Point(144, 24);
btnKeepServer.Name = "btnKeepServer";
btnKeepServer.Size = new Size(88, 23);
btnKeepServer.TabIndex = 1;
btnKeepServer.Text = "Keep this one";
btnKeepServer.Click += new EventHandler(this.btnKeepServer_Click);
GroupBox2.Controls.Add(lblUser);
GroupBox2.Controls.Add(btnKeepUser);
GroupBox2.FlatStyle = FlatStyle.System;
GroupBox2.Location = new Point(16, 216);
GroupBox2.Name = "GroupBox2";
GroupBox2.Size = new Size(248, 104);
GroupBox2.TabIndex = 2;
GroupBox2.TabStop = false;
GroupBox2.Text = "Your record";
lblUser.Location = new Point(16, 24);
lblUser.Name = "lblUser";
lblUser.Size = new Size(128, 72);
lblUser.TabIndex = 3;
btnKeepUser.BackColor = SystemColors.Control;
btnKeepUser.FlatStyle = FlatStyle.System;
btnKeepUser.ForeColor = SystemColors.ActiveCaption;
btnKeepUser.Location = new Point(144, 24);
btnKeepUser.Name = "btnKeepUser";
btnKeepUser.Size = new Size(88, 23);
btnKeepUser.TabIndex = 2;
btnKeepUser.Text = "Keep this one";
btnKeepUser.Click += new EventHandler(this.btnKeepUser_Click);
BackColor = Color.OldLace;
Controls.Add(GroupBox1);
Controls.Add(Label1);
Controls.Add(PaneCaption1);
Controls.Add(GroupBox2);
Name = "ConflictPane";
Size = new Size(280, 368);
GroupBox1.ResumeLayout(false);
GroupBox2.ResumeLayout(false);
ResumeLayout(false);
}
// This event is raised when a different issue is selected.
private void m_subject_PositionChanged(object sender, EventArgs e)
{
// test to see whether selected item is in conflict. If not, return
if (m_subject.ConflictItems != null &&
m_subject.ConflictItems.Count > 0 &&
m_subject.ConflictItems.ContainsKey(m_subject.CurrentItem["IssueID"]))
{
this.Show();
}
else
{
this.Hide();
return;
}
// Populate conflict info into UI
ConflictItem conflict = (ConflictItem)m_subject.ConflictItems[m_subject.CurrentItem["IssueID"]];
lblServer.Text = "Assigned to: " + conflict.ServerVersion["DisplayName"] + "\r\nIssue is ";
if ((bool)conflict.ServerVersion["IsOpen"])
lblServer.Text += "open.";
else
lblServer.Text += "closed.";
lblUser.Text = "Assigned to: " + conflict.ClientVersion["DisplayName"] + "\r\nIssue is ";
if ((bool)conflict.ClientVersion["IsOpen"])
lblUser.Text += "open.";
else
lblUser.Text += "closed.";
}
private void btnKeepServer_Click(object sender, EventArgs e)
{
ConflictItem conflict = (ConflictItem)m_subject.ConflictItems[m_subject.CurrentItem["IssueID"]];
m_subject.ResolveConflict(conflict, false);
}
private void btnKeepUser_Click(object sender, EventArgs e)
{
ConflictItem conflict = (ConflictItem)m_subject.ConflictItems[m_subject.CurrentItem["IssueID"]];
m_subject.ResolveConflict(conflict, true);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET