UI.Procedures.ProceduresCtrl : More column content is optional.
This commit is contained in:
+1
@@ -159,6 +159,7 @@
|
|||||||
this.listViewEx.TabIndex = 0;
|
this.listViewEx.TabIndex = 0;
|
||||||
this.listViewEx.UseCompatibleStateImageBehavior = false;
|
this.listViewEx.UseCompatibleStateImageBehavior = false;
|
||||||
this.listViewEx.View = System.Windows.Forms.View.Details;
|
this.listViewEx.View = System.Windows.Forms.View.Details;
|
||||||
|
this.listViewEx.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewEx_ColumnClick);
|
||||||
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
||||||
this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick);
|
this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick);
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -55,11 +55,9 @@ namespace TBF.UI.Procedures
|
|||||||
{
|
{
|
||||||
ItemNr,
|
ItemNr,
|
||||||
Name,
|
Name,
|
||||||
Description,
|
|
||||||
More,
|
More,
|
||||||
ColumnsCount,
|
Count
|
||||||
}
|
}
|
||||||
readonly int columnsCount = (int)Column.ColumnsCount;
|
|
||||||
|
|
||||||
ProceduresDlg parent;
|
ProceduresDlg parent;
|
||||||
Control parentControl;
|
Control parentControl;
|
||||||
@@ -93,6 +91,8 @@ namespace TBF.UI.Procedures
|
|||||||
producerComboBox.Text = Strings.any;
|
producerComboBox.Text = Strings.any;
|
||||||
producerComboBox.Items.Add(Strings.any);
|
producerComboBox.Items.Add(Strings.any);
|
||||||
selectedProducer = null;
|
selectedProducer = null;
|
||||||
|
|
||||||
|
moreContent = MoreContent.Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(ProceduresDlg parent, Control parentControl)
|
public void Initialize(ProceduresDlg parent, Control parentControl)
|
||||||
@@ -109,14 +109,12 @@ namespace TBF.UI.Procedures
|
|||||||
TBF.LocalSettings ls = Program.LocalSettings;
|
TBF.LocalSettings ls = Program.LocalSettings;
|
||||||
listViewEx.Columns.Add(Strings.Nr, (ls.ProceduresColumnCount > 0) ? ls.ProceduresColumnWidths[0] : (30 * parent.Dpi / Constants.Dpi100pct));
|
listViewEx.Columns.Add(Strings.Nr, (ls.ProceduresColumnCount > 0) ? ls.ProceduresColumnWidths[0] : (30 * parent.Dpi / Constants.Dpi100pct));
|
||||||
listViewEx.Columns.Add(Strings.Name, (ls.ProceduresColumnCount > 1) ? ls.ProceduresColumnWidths[1] : (100 * parent.Dpi / Constants.Dpi100pct));
|
listViewEx.Columns.Add(Strings.Name, (ls.ProceduresColumnCount > 1) ? ls.ProceduresColumnWidths[1] : (100 * parent.Dpi / Constants.Dpi100pct));
|
||||||
listViewEx.Columns.Add(Strings.DescriptionColHdr, (ls.ProceduresColumnCount > 2) ? ls.ProceduresColumnWidths[2] : (300 * parent.Dpi / Constants.Dpi100pct));
|
listViewEx.Columns.Add(Strings.DescriptionColHdr, (ls.ProceduresColumnCount > 2) ? ls.ProceduresColumnWidths[2] : (500 * parent.Dpi / Constants.Dpi100pct));
|
||||||
listViewEx.Columns.Add(Strings.More, (ls.ProceduresColumnCount > 3) ? ls.ProceduresColumnWidths[3] : (300 * parent.Dpi / Constants.Dpi100pct));
|
|
||||||
|
|
||||||
editors = new Control[columnsCount];
|
editors = new Control[(int)Column.Count];
|
||||||
///
|
///
|
||||||
editors[(int)Column.ItemNr] = new TextBox(); /// ItemNr
|
editors[(int)Column.ItemNr] = new TextBox(); /// ItemNr
|
||||||
editors[(int)Column.Name] = new TextBox(); /// Name
|
editors[(int)Column.Name] = new TextBox(); /// Name
|
||||||
editors[(int)Column.Description] = new TextBox(); /// Description
|
|
||||||
editors[(int)Column.More] = null;
|
editors[(int)Column.More] = null;
|
||||||
///
|
///
|
||||||
for (int i = 0; i < editors.Length; i++)
|
for (int i = 0; i < editors.Length; i++)
|
||||||
@@ -233,18 +231,10 @@ namespace TBF.UI.Procedures
|
|||||||
|
|
||||||
void DrawOne(Procedure procedure)
|
void DrawOne(Procedure procedure)
|
||||||
{
|
{
|
||||||
StringBuilder tests = new StringBuilder();
|
|
||||||
foreach (var test in procedure.Tests)
|
|
||||||
{
|
|
||||||
tests.Append(test.Name);
|
|
||||||
tests.Append(", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
ListViewItem lvi = new ListViewItem((procedure.ItemNr + 1).ToString());
|
ListViewItem lvi = new ListViewItem((procedure.ItemNr + 1).ToString());
|
||||||
lvi.SubItems.Add(procedure.Name);
|
|
||||||
lvi.SubItems.Add(procedure.Description);
|
|
||||||
lvi.SubItems.Add(tests.ToString());
|
|
||||||
lvi.Tag = procedure;
|
lvi.Tag = procedure;
|
||||||
|
lvi.SubItems.Add(procedure.Name);
|
||||||
|
lvi.SubItems.Add(GetMoreContent(procedure, moreContent));
|
||||||
|
|
||||||
listViewEx.Items.Add(lvi);
|
listViewEx.Items.Add(lvi);
|
||||||
}
|
}
|
||||||
@@ -981,5 +971,107 @@ namespace TBF.UI.Procedures
|
|||||||
bool isFilterAny = (selectedDN == 0) && (selectedQ3 == 0) && (selectedMClass == null) && (selectedProducer == null);
|
bool isFilterAny = (selectedDN == 0) && (selectedQ3 == 0) && (selectedMClass == null) && (selectedProducer == null);
|
||||||
if (parent != null) parent.SelectedIndexChanged(listViewEx, isFilterAny);
|
if (parent != null) parent.SelectedIndexChanged(listViewEx, isFilterAny);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 'More' column content selector.
|
||||||
|
/// </summary>
|
||||||
|
enum MoreContent
|
||||||
|
{
|
||||||
|
Description,
|
||||||
|
Tests,
|
||||||
|
Writers,
|
||||||
|
Printers,
|
||||||
|
Count
|
||||||
|
}
|
||||||
|
MoreContent moreContent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 'More' column header clicked => change moreContent valiable, column header text and redraw the column.
|
||||||
|
/// </summary>
|
||||||
|
private void listViewEx_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Column == (int)Column.More)
|
||||||
|
{
|
||||||
|
if (++moreContent == MoreContent.Count) moreContent = 0;
|
||||||
|
switch(moreContent)
|
||||||
|
{
|
||||||
|
case MoreContent.Description:
|
||||||
|
listViewEx.Columns[(int)Column.More].Text = Strings.DescriptionColHdr;
|
||||||
|
break;
|
||||||
|
case MoreContent.Tests:
|
||||||
|
listViewEx.Columns[(int)Column.More].Text = Strings.Test;
|
||||||
|
break;
|
||||||
|
case MoreContent.Writers:
|
||||||
|
listViewEx.Columns[(int)Column.More].Text = "Writers";
|
||||||
|
break;
|
||||||
|
case MoreContent.Printers:
|
||||||
|
listViewEx.Columns[(int)Column.More].Text = "Printers";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
listViewEx.Columns[(int)Column.More].Text = string.Empty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RedrawMoreColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the complete 'More' column
|
||||||
|
/// </summary>
|
||||||
|
void RedrawMoreColumn()
|
||||||
|
{
|
||||||
|
foreach (ListViewItem item in listViewEx.Items)
|
||||||
|
{
|
||||||
|
item.SubItems[(int)Column.More].Text = GetMoreContent(item.Tag as Procedure, moreContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get content of the 'More' column.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="procedure">Procedure in this row</param>
|
||||||
|
/// <param name="content">'More' column content selector</param>
|
||||||
|
/// <returns>Text to be displayed</returns>
|
||||||
|
string GetMoreContent(Procedure procedure, MoreContent content)
|
||||||
|
{
|
||||||
|
if (procedure == null) return string.Empty;
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
switch (content)
|
||||||
|
{
|
||||||
|
case MoreContent.Description:
|
||||||
|
return string.IsNullOrEmpty(procedure.Description) ? string.Empty : procedure.Description;
|
||||||
|
|
||||||
|
case MoreContent.Tests:
|
||||||
|
foreach (var test in procedure.Tests)
|
||||||
|
{
|
||||||
|
sb.Append(test.Name);
|
||||||
|
sb.Append(" ");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MoreContent.Writers:
|
||||||
|
if (!string.IsNullOrEmpty(procedure.ResultsWriter))
|
||||||
|
{
|
||||||
|
string[] writers = procedure.ResultsWriter.Split(new char[] { '~' });
|
||||||
|
Array.Sort(writers);
|
||||||
|
foreach (var w in writers) { sb.Append(w); sb.Append(" "); }
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MoreContent.Printers:
|
||||||
|
if (!string.IsNullOrEmpty(procedure.ResultsPrinter))
|
||||||
|
{
|
||||||
|
string[] printers = procedure.ResultsPrinter.Split(new char[] { '~' });
|
||||||
|
Array.Sort(printers);
|
||||||
|
foreach (var p in printers) { sb.Append(p); sb.Append(" "); }
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user