488 lines
20 KiB
C#
488 lines
20 KiB
C#
///
|
|
/// Copyright (c) 2013-2017 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using Results.Forms;
|
|
using TBF.BenchControl;
|
|
using TBF.BenchControl.GenericDevices;
|
|
using TBF.Resources;
|
|
using TBF.UI.Shared;
|
|
|
|
namespace TBF.UI.Bench.Paths
|
|
{
|
|
public class PathsOutputCtrl : BaseWithListViewEx<Config.Entities.OutputPath>, ITabWithListViewEx
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(PathsOutputCtrl));
|
|
|
|
/// <summary>
|
|
/// Fixed ListViewEx columns
|
|
/// </summary>
|
|
enum Column
|
|
{
|
|
Name,
|
|
Qfrom,
|
|
Qto,
|
|
RefFlowmtr,
|
|
RegulValve,
|
|
PidCoef,
|
|
Div,
|
|
Tdiv,
|
|
Scale,
|
|
StartValve1,
|
|
InvertSV1,
|
|
StartValve2,
|
|
InvertSV2,
|
|
LagSV2,
|
|
StartValve3,
|
|
InvertSV3,
|
|
LagSV3,
|
|
FixedColumnsCount,
|
|
}
|
|
readonly int fixedColumnsCount = (int)Column.FixedColumnsCount;
|
|
|
|
PathsDlg parent;
|
|
Control parentControl;
|
|
Control[] editors;
|
|
|
|
public PathsOutputCtrl()
|
|
: base()
|
|
{
|
|
FixedRowsCount = 1;
|
|
}
|
|
|
|
public void Initialize(PathsDlg parent, Control parentControl)
|
|
{
|
|
this.parent = parent;
|
|
this.parentControl = parentControl;
|
|
|
|
/// Load the paths
|
|
MyItems = parent.Session.QueryOver<Config.Entities.OutputPath>()
|
|
.OrderBy(x => x.ItemNr).Asc
|
|
.List();
|
|
|
|
foreach (var path in MyItems) path.OriName = path.Name;
|
|
|
|
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
|
SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
|
|
SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
|
|
|
/// ListViewEx columns
|
|
TBF.LocalSettings ls = Program.LocalSettings;
|
|
Columns.Add(Strings.Name, (ls.OutputColumnCount > 0) ? ls.OutputColumnWidths[0] : 60 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.Q_from_m3h, (ls.OutputColumnCount > 1) ? ls.OutputColumnWidths[1] : 50 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.Q_to_m3h, (ls.OutputColumnCount > 2) ? ls.OutputColumnWidths[2] : 50 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.Flowmeter, (ls.OutputColumnCount > 3) ? ls.OutputColumnWidths[3] : 85 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.Reg_valve, (ls.OutputColumnCount > 4) ? ls.OutputColumnWidths[4] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.PID, (ls.OutputColumnCount > 5) ? ls.OutputColumnWidths[5] : 50 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.Diverter, (ls.OutputColumnCount > 6) ? ls.OutputColumnWidths[6] : 60 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.T_div, (ls.OutputColumnCount > 7) ? ls.OutputColumnWidths[7] : 70 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(Strings.Balance, (ls.OutputColumnCount > 8) ? ls.OutputColumnWidths[8] : 50 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("{0} 1", Strings.StartValve), (ls.OutputColumnCount > 9) ? ls.OutputColumnWidths[9] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("Inv. SV1"), (ls.OutputColumnCount > 10) ? ls.OutputColumnWidths[10] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("{0} 2", Strings.StartValve), (ls.OutputColumnCount > 11) ? ls.OutputColumnWidths[11] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("Inv.SV2"), (ls.OutputColumnCount > 12) ? ls.OutputColumnWidths[12] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("Lag SV2"), (ls.OutputColumnCount > 13) ? ls.OutputColumnWidths[13] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("{0} 3", Strings.StartValve), (ls.OutputColumnCount > 14) ? ls.OutputColumnWidths[14] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("Inv.SV3"), (ls.OutputColumnCount > 15) ? ls.OutputColumnWidths[15] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
Columns.Add(string.Format("Lag SV3"), (ls.OutputColumnCount > 16) ? ls.OutputColumnWidths[16] : 80 * parent.Dpi / Constants.Dpi100pct);
|
|
int clmn = (int)Column.FixedColumnsCount;
|
|
foreach (var vlv in parent.Valves)
|
|
{
|
|
if (vlv.Category == ValveCategory.All || vlv.Category == ValveCategory.Output)
|
|
{
|
|
Columns.Add(vlv.Cfg.Name, (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
|
|
clmn++;
|
|
}
|
|
}
|
|
|
|
/// Prepare fixed columns combo boxes
|
|
ComboBox flowMeterComboBox = new ComboBox();
|
|
ComboBox regulValveComboBox = new ComboBox();
|
|
ComboBox diverterComboBox = new ComboBox();
|
|
ComboBox tempMeterDivComboBox = new ComboBox();
|
|
ComboBox scaleComboBox = new ComboBox();
|
|
ComboBox startValve1ComboBox = new ComboBox();
|
|
ComboBox invertSV1ComboBox = new ComboBox();
|
|
ComboBox startValve2ComboBox = new ComboBox();
|
|
ComboBox invertSV2ComboBox = new ComboBox();
|
|
TextBox lagSV2TextBox = new TextBox();
|
|
ComboBox startValve3ComboBox = new ComboBox();
|
|
ComboBox invertSV3ComboBox = new ComboBox();
|
|
TextBox lagSV3TextBox = new TextBox();
|
|
flowMeterComboBox.Items.Add("---");
|
|
regulValveComboBox.Items.Add("---");
|
|
diverterComboBox.Items.Add("---");
|
|
tempMeterDivComboBox.Items.Add("---");
|
|
scaleComboBox.Items.Add("---");
|
|
startValve1ComboBox.Items.Add("---");
|
|
invertSV1ComboBox.Items.Add(Strings.no);
|
|
invertSV1ComboBox.Items.Add(Strings.yes);
|
|
startValve2ComboBox.Items.Add("---");
|
|
invertSV2ComboBox.Items.Add(Strings.no);
|
|
invertSV2ComboBox.Items.Add(Strings.yes);
|
|
startValve3ComboBox.Items.Add("---");
|
|
invertSV3ComboBox.Items.Add(Strings.no);
|
|
invertSV3ComboBox.Items.Add(Strings.yes);
|
|
foreach (var cmpnt in parent.TbfComponents)
|
|
{
|
|
if (cmpnt is IFlowMeter) flowMeterComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
if (cmpnt is IRegulValve) regulValveComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
if (cmpnt is IDiverter) diverterComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
if (cmpnt is ITempMeter) tempMeterDivComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
if (cmpnt is IScaleOrTank) scaleComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
if (cmpnt is IValve && (cmpnt as IValve).CoupledTo == null)
|
|
{
|
|
startValve1ComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
startValve2ComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
startValve3ComboBox.Items.Add(cmpnt.Cfg.Name);
|
|
}
|
|
}
|
|
|
|
editors = new Control[fixedColumnsCount + 64];
|
|
///
|
|
editors[(int)Column.Name] = new TextBox(); /// Name
|
|
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
|
|
editors[(int)Column.Qto] = new TextBox(); /// Q_to
|
|
editors[(int)Column.RefFlowmtr] = flowMeterComboBox;
|
|
editors[(int)Column.RegulValve] = regulValveComboBox;
|
|
editors[(int)Column.PidCoef] = new TextBox(); /// PID
|
|
editors[(int)Column.Div] = diverterComboBox;
|
|
editors[(int)Column.Tdiv] = tempMeterDivComboBox;
|
|
editors[(int)Column.Scale] = scaleComboBox;
|
|
editors[(int)Column.StartValve1] = startValve1ComboBox;
|
|
editors[(int)Column.InvertSV1] = invertSV1ComboBox;
|
|
editors[(int)Column.StartValve2] = startValve2ComboBox;
|
|
editors[(int)Column.InvertSV2] = invertSV2ComboBox;
|
|
editors[(int)Column.LagSV2] = lagSV2TextBox;
|
|
editors[(int)Column.StartValve3] = startValve3ComboBox;
|
|
editors[(int)Column.InvertSV3] = invertSV3ComboBox;
|
|
editors[(int)Column.LagSV3] = lagSV3TextBox;
|
|
/// Prepare valve combo-boxes (max. 64 valves)
|
|
for (int i = 0; i < 64; i++)
|
|
{
|
|
ComboBox cb = new ComboBox();
|
|
cb.Items.Add("---");
|
|
cb.Items.Add(Strings.open);
|
|
cb.Items.Add(Strings.close);
|
|
editors[fixedColumnsCount + i] = cb;
|
|
}
|
|
///
|
|
for (int i = 0; i < editors.Length; i++)
|
|
{
|
|
editors[i].Visible = false;
|
|
parent.Controls.Add(editors[i]);
|
|
}
|
|
|
|
base.RedrawAll();
|
|
}
|
|
|
|
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
|
{
|
|
if (!Unlocked || e.SubItem >= editors.Length) return;
|
|
if ((e.Item.Tag is IHasItemNr) &&
|
|
((e.Item.Tag as IHasItemNr).ItemNr < FixedRowsCount) &&
|
|
(e.SubItem < fixedColumnsCount))
|
|
{
|
|
return;
|
|
}
|
|
StartEditing(editors[e.SubItem], e.Item, e.SubItem);
|
|
}
|
|
|
|
void listViewEx_SubItemRightClicked(object sender, SubItemEventArgs e)
|
|
{
|
|
if (!Unlocked || e.SubItem >= editors.Length) return;
|
|
|
|
if (DialogResult.Yes == MessageBox.Show(Strings.Do_you_want_to_copy_this_value_to_all_cells_below_this_cell,
|
|
Strings.Confirmation, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
|
|
{
|
|
int columnNr = e.SubItem;
|
|
string value = null;
|
|
System.Drawing.Color backColor = System.Drawing.Color.White;
|
|
foreach (ListViewItem item in Items)
|
|
{
|
|
if (value != null && item.SubItems.Count > columnNr)
|
|
{
|
|
item.SubItems[columnNr].Text = value;
|
|
item.SubItems[columnNr].BackColor = backColor;
|
|
}
|
|
else if (item == e.Item)
|
|
{
|
|
value = item.SubItems[columnNr].Text;
|
|
backColor = item.SubItems[columnNr].BackColor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
|
{
|
|
if (e.SubItem >= fixedColumnsCount)
|
|
{
|
|
e.Item.SubItems[e.SubItem].BackColor = e.DisplayText == Strings.open ? Color.LightGray : Color.White;
|
|
}
|
|
}
|
|
|
|
public override void DrawOne(object myItem)
|
|
{
|
|
Config.Entities.OutputPath entity =(Config.Entities.OutputPath)myItem;
|
|
BenchControl.OutputPath path = new BenchControl.OutputPath(entity, parent.TbfComponents);
|
|
|
|
ListViewItem lvi = new ListViewItem(entity.Name);
|
|
lvi.UseItemStyleForSubItems = false;
|
|
|
|
lvi.SubItems.Add(path.Qfrom.ToString());
|
|
lvi.SubItems.Add(path.Qto.ToString());
|
|
lvi.SubItems.Add((path.FlowMeter != null) ? path.FlowMeter.Cfg.Name : "---");
|
|
lvi.SubItems.Add((path.RegulValve != null) ? path.RegulValve.Cfg.Name : "---");
|
|
lvi.SubItems.Add(path.PidCoef.ToString("F1"));
|
|
lvi.SubItems.Add((path.Diverter != null) ? path.Diverter.Cfg.Name : "---");
|
|
lvi.SubItems.Add((path.TempDiv != null) ? path.TempDiv.Cfg.Name : "---");
|
|
lvi.SubItems.Add((path.Scale != null) ? path.Scale.Cfg.Name : "---");
|
|
|
|
|
|
lvi.SubItems.Add((path.StartValve1 != null) ? path.StartValve1.Cfg.Name : "---");
|
|
lvi.SubItems.Add(path.InvertSV1 ? Strings.yes : Strings.no);
|
|
lvi.SubItems.Add((path.StartValve2 != null) ? path.StartValve2.Cfg.Name : "---");
|
|
lvi.SubItems.Add(path.InvertSV2 ? Strings.yes : Strings.no);
|
|
lvi.SubItems.Add(path.LagSV2.ToString());
|
|
lvi.SubItems.Add((path.StartValve3 != null) ? path.StartValve3.Cfg.Name : "---");
|
|
lvi.SubItems.Add(path.InvertSV3 ? Strings.yes : Strings.no);
|
|
lvi.SubItems.Add(path.LagSV3.ToString());
|
|
|
|
foreach (var valve in parent.Valves)
|
|
{
|
|
if (valve.Category == ValveCategory.All || valve.Category == ValveCategory.Output)
|
|
{
|
|
if (path.ValvesOpen != null && path.ValvesOpen.Contains(valve))
|
|
{
|
|
lvi.SubItems.Add(Strings.open);
|
|
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.LightGray;
|
|
}
|
|
else if (path.ValvesClose != null && path.ValvesClose.Contains(valve))
|
|
{
|
|
lvi.SubItems.Add(Strings.close);
|
|
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.White;
|
|
}
|
|
else
|
|
{
|
|
lvi.SubItems.Add("---");
|
|
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.White;
|
|
}
|
|
}
|
|
}
|
|
|
|
lvi.Tag = entity;
|
|
|
|
Items.Add(lvi);
|
|
}
|
|
|
|
public override void UpdateOne(ListViewItem lvi, object myItem)
|
|
{
|
|
Config.Entities.OutputPath entity = (Config.Entities.OutputPath)myItem;
|
|
|
|
entity.Name = lvi.Text;
|
|
|
|
float Qfrom;
|
|
bool allOk = Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qfrom].Text, out Qfrom);
|
|
entity.Qfrom = Qfrom;
|
|
|
|
float Qto;
|
|
allOk &= Utils.TryParseUFloat(lvi.SubItems[(int)Column.Qto].Text, out Qto);
|
|
entity.Qto = Qto;
|
|
|
|
entity.FlowMeter = lvi.SubItems[(int)Column.RefFlowmtr].Text.Equals("---") ? null : lvi.SubItems[(int)Column.RefFlowmtr].Text;
|
|
entity.RegulValve = lvi.SubItems[(int)Column.RegulValve].Text.Equals("---") ? null : lvi.SubItems[(int)Column.RegulValve].Text;
|
|
|
|
float pid;
|
|
allOk &= Utils.TryParseSFloat(lvi.SubItems[(int)Column.PidCoef].Text, out pid);
|
|
entity.PidCoef = pid;
|
|
|
|
entity.Diverter = lvi.SubItems[(int)Column.Div].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Div].Text;
|
|
entity.TempDiv = lvi.SubItems[(int)Column.Tdiv].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Tdiv].Text;
|
|
entity.Scale = lvi.SubItems[(int)Column.Scale].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Scale].Text;
|
|
|
|
string sv1 = lvi.SubItems[(int)Column.StartValve1].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)Column.StartValve1].Text;
|
|
bool invertSV1 = lvi.SubItems[(int)Column.InvertSV1].Text.Equals(Strings.yes);
|
|
string sv2 = lvi.SubItems[(int)Column.StartValve2].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)Column.StartValve2].Text;
|
|
bool invertSV2 = lvi.SubItems[(int)Column.InvertSV2].Text.Equals(Strings.yes);
|
|
int lagSV2 = 0;
|
|
int.TryParse(lvi.SubItems[(int)Column.LagSV2].Text, out lagSV2);
|
|
string sv3 = lvi.SubItems[(int)Column.StartValve3].Text.Equals("---") ? string.Empty : lvi.SubItems[(int)Column.StartValve3].Text;
|
|
bool invertSV3 = lvi.SubItems[(int)Column.InvertSV3].Text.Equals(Strings.yes);
|
|
int lagSV3 = 0;
|
|
int.TryParse(lvi.SubItems[(int)Column.LagSV3].Text, out lagSV3);
|
|
///
|
|
entity.StartValve = string.Format("{0}~{1}~{2}~{3}~{4}~{5}~{6}~{7}", sv1, (invertSV1 ? "i" : "n"), sv2, (invertSV2 ? "i" : "n"), lagSV2, sv3, (invertSV3 ? "i" : "n"), lagSV3);
|
|
|
|
string valvesOpen = string.Empty;
|
|
string valvesClose = string.Empty;
|
|
int k = 0;
|
|
for (int j = 0; j < parent.Valves.Count; j++)
|
|
{
|
|
if (parent.Valves[j].Category == ValveCategory.All || parent.Valves[j].Category == ValveCategory.Output)
|
|
{
|
|
string text = lvi.SubItems[fixedColumnsCount + k].Text;
|
|
if (text.Equals(Strings.open))
|
|
{
|
|
if (valvesOpen != string.Empty) valvesOpen += ";";
|
|
valvesOpen += parent.Valves[j].Cfg.Name;
|
|
}
|
|
if (text.Equals(Strings.close))
|
|
{
|
|
if (valvesClose != string.Empty) valvesClose += ";";
|
|
valvesClose += parent.Valves[j].Cfg.Name;
|
|
}
|
|
k++;
|
|
}
|
|
}
|
|
entity.ValvesOpen = valvesOpen;
|
|
entity.ValvesClose = valvesClose;
|
|
}
|
|
|
|
public void AddOne()
|
|
{
|
|
Config.Entities.OutputPath entity;
|
|
|
|
if (MyItems.Count < FixedRowsCount)
|
|
{
|
|
entity = new Config.Entities.OutputPath(Strings._none_, MyItems.Count);
|
|
}
|
|
else
|
|
{
|
|
/// Find an unused test name
|
|
string newName;
|
|
for (int nameId = 1; true; nameId++)
|
|
{
|
|
newName = Strings.New_output_path_name + nameId.ToString();
|
|
bool notUsed = true;
|
|
foreach (var t in MyItems) if (t.Name.Equals(newName)) notUsed = false;
|
|
if (notUsed) break;
|
|
}
|
|
entity = new Config.Entities.OutputPath(newName, MyItems.Count);
|
|
}
|
|
|
|
base.AddOne(entity);
|
|
}
|
|
|
|
public new void RemoveSelected()
|
|
{
|
|
bool lastOneRemoved = base.RemoveSelected();
|
|
if (lastOneRemoved && parent != null)
|
|
{
|
|
parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None);
|
|
}
|
|
}
|
|
|
|
public string GetWarningsBeforeSaving(ref Dictionary<string, string> renmInfo)
|
|
{
|
|
base.OkBtnClicked(); /// = UpdateAll()
|
|
|
|
string warnings = string.Empty;
|
|
|
|
foreach (var entity in ToBeRemovedItems)
|
|
{
|
|
if (!string.IsNullOrEmpty(entity.OriName))
|
|
{
|
|
int occurances = 0;
|
|
foreach (var tst in parent.Tests) if (!string.IsNullOrEmpty(tst.OutputPath) && tst.OutputPath.Equals(entity.OriName)) occurances++;
|
|
|
|
if (occurances > 0)
|
|
{
|
|
warnings += string.Format(Strings._0_path_1_used_by_2_tests_will_be_removed_3, Strings.OutputTabPageTitle, entity.Name, occurances, Environment.NewLine);
|
|
renmInfo.Add(entity.OriName, string.Empty);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var entity in MyItems)
|
|
{
|
|
if (!string.IsNullOrEmpty(entity.OriName) && entity.OriName != entity.Name)
|
|
{
|
|
int occurances = 0;
|
|
foreach (var tst in parent.Tests) if (!string.IsNullOrEmpty(tst.OutputPath) && tst.OutputPath.Equals(entity.OriName)) occurances++;
|
|
|
|
if (occurances > 0)
|
|
{
|
|
warnings += string.Format(Strings._0_path_1_used_by_2_tests_will_be_renamed_to_3_4, Strings.OutputTabPageTitle, entity.OriName, occurances, entity.Name, Environment.NewLine);
|
|
renmInfo.Add(entity.OriName, entity.Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
return warnings;
|
|
}
|
|
|
|
public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
|
|
{
|
|
foreach (var ri in renameInfo)
|
|
{
|
|
var tests = parent.Session.QueryOver<Config.Entities.Test>()
|
|
.Where(x => x.OutputPath == ri.Key)
|
|
.List();
|
|
|
|
foreach (var t in tests)
|
|
{
|
|
t.OutputPath = ri.Value;
|
|
parent.Session.Update(t);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update the entities and save them to the database
|
|
/// </summary>
|
|
public new void OkBtnClicked()
|
|
{
|
|
base.OkBtnClicked();
|
|
|
|
/// Update the database
|
|
foreach (var entity in ToBeRemovedItems)
|
|
{
|
|
parent.Session.Delete(entity);
|
|
}
|
|
foreach (var entity in MyItems)
|
|
{
|
|
parent.Session.SaveOrUpdate(entity);
|
|
}
|
|
|
|
SaveUISettings();
|
|
}
|
|
|
|
void SaveUISettings()
|
|
{
|
|
LocalSettings ls = Program.LocalSettings;
|
|
|
|
/// Compare list view column widths with the saved ones
|
|
bool anyColumnDiffers = false;
|
|
if (Columns.Count != ls.OutputColumnCount)
|
|
{
|
|
anyColumnDiffers = true;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < Columns.Count; i++)
|
|
{
|
|
if (Columns[i].Width != ls.OutputColumnWidths[i]) { anyColumnDiffers = true; break; }
|
|
}
|
|
}
|
|
|
|
if (anyColumnDiffers)
|
|
{
|
|
/// Update column widths
|
|
ls.OutputColumnWidths = new int[Columns.Count];
|
|
for (int i = 0; i < Columns.Count; i++)
|
|
{
|
|
ls.OutputColumnWidths[i] = Columns[i].Width;
|
|
}
|
|
|
|
ls.Save();
|
|
}
|
|
}
|
|
}
|
|
}
|