Dramatic changes in displaying results on screen, ver. 2.18.1290
This commit is contained in:
parent
2d42ae95f8
commit
da220f4e7f
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,5 +29,6 @@ Users/obj/
|
||||
UserManagement/bin/
|
||||
UserManagement/obj/
|
||||
Doc/
|
||||
.vs/
|
||||
*.suo
|
||||
*.bak
|
||||
|
||||
@ -528,6 +528,12 @@ namespace Results.Entities
|
||||
return NokColor;
|
||||
}
|
||||
}
|
||||
else if (Disabled)
|
||||
{
|
||||
/// Water meter was not completed yet => did not pass, did not fail
|
||||
message = Strings.This_position_is_disabled;
|
||||
return NotCompletedColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Water meter was not completed yet => did not pass, did not fail
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
@ -18,43 +13,33 @@ namespace Results.Forms
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(BatchResultsDlg));
|
||||
|
||||
|
||||
DateTime lastRedraw;
|
||||
DateTime lastSizeChange;
|
||||
bool loaded;
|
||||
|
||||
///
|
||||
/// Public members
|
||||
///
|
||||
public Results.BatchResults Results;
|
||||
public IList<Results.WMeterRsltItemSpec> Items;
|
||||
public MetersArrangement MetersArrangement;
|
||||
public TestsArrangement TestsArrangement;
|
||||
public int NrMetersInOneGroup;
|
||||
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_SingleWM;
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_CombinedWM;
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_HeatM;
|
||||
public int[] RsltsClmnWidths { set { rsltsClmnWidths = value; } }
|
||||
|
||||
public bool ShowDisabledPositions;
|
||||
public int MinWidth;
|
||||
public int MinHeight;
|
||||
public int PopupResultsLeft;
|
||||
public int PopupResultsTop;
|
||||
public int PopupResultsWidth;
|
||||
public int PopupResultsHeight;
|
||||
public int[] RsltsClmnWidths;
|
||||
|
||||
public Results.BatchResults Results { set { Display(value); } }
|
||||
|
||||
///
|
||||
/// Private members
|
||||
///
|
||||
Results.BatchResults results;
|
||||
MetersKind metersKind;
|
||||
|
||||
OneWMResultsCtrl firstListView;
|
||||
public int[] rsltsClmnWidths;
|
||||
int rsltsClmnCount { get { return (rsltsClmnWidths != null) ? rsltsClmnWidths.Length : 0; } }
|
||||
|
||||
int lvWidth;
|
||||
int lvHeight;
|
||||
|
||||
IOneWMResultsCtrl[] wmRsltsCtrl; /// An array of controls with water meter results.
|
||||
IOneWMResultsCtrl firstEnabledControl;
|
||||
DateTime lastRedraw;
|
||||
DateTime lastSizeChange;
|
||||
int metersInOneGroup;
|
||||
int nrGroups;
|
||||
|
||||
Timer timer;
|
||||
|
||||
@ -62,310 +47,193 @@ namespace Results.Forms
|
||||
public BatchResultsDlg()
|
||||
{
|
||||
InitializeComponent();
|
||||
Text = Strings.Results;
|
||||
|
||||
firstEnabledControl = null;
|
||||
lastSizeChange = DateTime.Now;
|
||||
nrGroups = 1;
|
||||
metersInOneGroup = 1;
|
||||
|
||||
// Create a timer with a ten second interval.
|
||||
/// Create a timer with one second interval.
|
||||
timer = new Timer();
|
||||
timer.Interval = 500; /// ms
|
||||
timer.Interval = 1000; /// ms
|
||||
timer.Tick += new EventHandler(OnTimer);
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void BatchResultsDlg_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (PopupResultsLeft != 0) Left = PopupResultsLeft;
|
||||
if (PopupResultsTop != 0) Top = PopupResultsTop;
|
||||
if (PopupResultsWidth != 0) Width = PopupResultsWidth;
|
||||
if (PopupResultsLeft != 0) Left = PopupResultsLeft;
|
||||
if (PopupResultsTop != 0) Top = PopupResultsTop;
|
||||
if (PopupResultsWidth != 0) Width = PopupResultsWidth;
|
||||
if (PopupResultsHeight != 0) Height = PopupResultsHeight;
|
||||
|
||||
loaded = true;
|
||||
if (results != null) Redraw();
|
||||
}
|
||||
|
||||
public void Display(Results.BatchResults results)
|
||||
{
|
||||
this.results = results;
|
||||
if (loaded) Redraw();
|
||||
CreateControlsAndFillPanel(Results);
|
||||
UpdateColumnWidths(RsltsClmnWidths);
|
||||
UpdateResults(Results);
|
||||
}
|
||||
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> GetRsltItems(MetersKind metersKind)
|
||||
///
|
||||
/// Handle double-click inside a water meter results control
|
||||
///
|
||||
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
IList<Results.WMeterRsltItemSpec> srcItems;
|
||||
switch (metersKind)
|
||||
if (Results.WaterMeters != null && args.WMPosition > 0)
|
||||
{
|
||||
default:
|
||||
case MetersKind.Single: srcItems = RsltItems_Screen_SingleWM; break;
|
||||
case MetersKind.Combined: srcItems = RsltItems_Screen_CombinedWM; break;
|
||||
case MetersKind.HeatMeter: srcItems = RsltItems_Screen_HeatM; break;
|
||||
foreach (var wm in Results.WaterMeters)
|
||||
{
|
||||
if ((wm != null) && (wm.WMPosition == args.WMPosition))
|
||||
{
|
||||
ShowMoreWMResults(wm);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> copiedItems = new List<Results.WMeterRsltItemSpec>();
|
||||
foreach (var it in srcItems) copiedItems.Add(it.Clone());
|
||||
return copiedItems;
|
||||
MessageBox.Show(Strings.No_water_meter);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void UpdateColumnWidths(int[] columnWidths)
|
||||
{
|
||||
foreach (var ctrl in wmRsltsCtrl) ctrl.Update(columnWidths);
|
||||
}
|
||||
|
||||
void UpdateScrollpositions(int scrollStart)
|
||||
{
|
||||
/// TODO
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Re-draw the results. Apply new settings if they changed.
|
||||
/// </summary>
|
||||
public void Redraw()
|
||||
void CreateControlsAndFillPanel(Results.BatchResults results)
|
||||
{
|
||||
lastRedraw = DateTime.Now;
|
||||
|
||||
this.SuspendLayout();
|
||||
|
||||
try
|
||||
if ((results == null) || (results.WMPositionsCount == 0))
|
||||
{
|
||||
/// Determine how many water meters were enabled for result evaluation and printing
|
||||
int enabledWMsCount = 0;
|
||||
for (int i = 0; i < results.WMPositionsCount; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
enabledWMsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
|
||||
int nrGroups = Math.Max(1, (enabledWMsCount + metersInOneGroup - 1) / metersInOneGroup);
|
||||
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
|
||||
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
|
||||
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
|
||||
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
|
||||
}
|
||||
/// There are no water meters at all
|
||||
flowLayoutPanel.Controls.Clear();
|
||||
flowLayoutPanel.WrapContents = true;
|
||||
flowLayoutPanel.AutoScroll = true;
|
||||
|
||||
bool first = true;
|
||||
for (int i = 0; i < results.WMPositionsCount; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
OneWMResultsCtrl lview = (TestsArrangement == TestsArrangement.Rows)
|
||||
? GetResultsTestsAreRows(results.WaterMeters[i], i + 1)
|
||||
: GetResultsTestsAreColumns(results.WaterMeters[i], i + 1);
|
||||
if (lview != null)
|
||||
{
|
||||
flowLayoutPanel.Controls.Add(lview);
|
||||
if (first)
|
||||
{
|
||||
firstListView = lview;
|
||||
first = false;
|
||||
}
|
||||
|
||||
lview.WMResultsClickedHandler += delegate(object sender, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), sender, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnDoubleClick(sender, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.FatalFormat("Redrawing results failed : {0}", e.Message);
|
||||
if (e.InnerException != null)
|
||||
{
|
||||
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
|
||||
}
|
||||
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
|
||||
}
|
||||
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get an empty ListView control with appropriate parameters.
|
||||
/// </summary>
|
||||
/// <returns>ListView control</returns>
|
||||
OneWMResultsCtrl GetListView(Color backColor, Results.Entities.WaterMeter wm)
|
||||
{
|
||||
return new OneWMResultsCtrl(backColor, lvWidth, lvHeight, wm);
|
||||
}
|
||||
///
|
||||
OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm)
|
||||
{
|
||||
return GetListView(Color.White, wm);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a ListView control filled with results of the meter 'mtr'
|
||||
/// </summary>
|
||||
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
|
||||
/// <returns>ListView object</returns>
|
||||
OneWMResultsCtrl GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
|
||||
{
|
||||
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
|
||||
|
||||
string message = string.Empty;
|
||||
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
|
||||
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
|
||||
#if ORACLE_DB
|
||||
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
|
||||
|
||||
if (items == null || items.Count == 0) return lview;
|
||||
|
||||
// Header
|
||||
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
|
||||
int col = 1;
|
||||
foreach (var item in items)
|
||||
{
|
||||
lview.Columns.Add(item.Caption, (rsltsClmnCount > col) ? rsltsClmnWidths[col] : 70);
|
||||
col++;
|
||||
}
|
||||
|
||||
|
||||
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
|
||||
int ix = 0;
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never
|
||||
&& mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(testNames[ix++]);
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
string str = items[i].Print(wMtr, mtr.Name());
|
||||
|
||||
/// Extract and use color information
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
lview.Items.Add(lvi);
|
||||
}
|
||||
}
|
||||
|
||||
return lview;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a ListView control filled with results of the meter 'mtr'
|
||||
/// </summary>
|
||||
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
|
||||
/// <returns>ListView object</returns>
|
||||
OneWMResultsCtrl GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
|
||||
{
|
||||
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
|
||||
|
||||
string message;
|
||||
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
|
||||
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
|
||||
#if ORACLE_DB
|
||||
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
|
||||
|
||||
if (items == null || items.Count == 0) return lview;
|
||||
|
||||
// Header
|
||||
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
|
||||
int i = 1;
|
||||
foreach (var str in wMtr.GetAllDecoratedTestNames())
|
||||
{
|
||||
lview.Columns.Add(str, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70);
|
||||
i++;
|
||||
}
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(item.Caption);
|
||||
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
string str = item.Print(wMtr, mtr.Name());
|
||||
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lview.Items.Add(lvi);
|
||||
}
|
||||
|
||||
return lview;
|
||||
}
|
||||
|
||||
|
||||
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
if ( args.WM == null || args.WM.Disabled)
|
||||
{
|
||||
MessageBox.Show(Strings.No_water_meter);
|
||||
wmRsltsCtrl = new OneWMResultsRowsCtrl[0];
|
||||
firstEnabledControl = null;
|
||||
return;
|
||||
}
|
||||
else if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(args.WM.SerialNr))
|
||||
|
||||
///
|
||||
/// Determine water meter positions count
|
||||
///
|
||||
int displayedControlsCount = 0;
|
||||
for (int i = 0; i < results.WaterMeters.Length; i++)
|
||||
{
|
||||
new Results.Forms.MoreWMResultsDlg( args.WM, null).ShowDialog();
|
||||
if (results.WaterMeters[i] != null)
|
||||
{
|
||||
if (ShowDisabledPositions || !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
displayedControlsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Calculate geometry
|
||||
///
|
||||
metersInOneGroup = Math.Max(1, Math.Min(displayedControlsCount, NrMetersInOneGroup));
|
||||
nrGroups = Math.Max(1, (displayedControlsCount + metersInOneGroup - 1) / metersInOneGroup);
|
||||
|
||||
int oneWidth;
|
||||
int oneHeight;
|
||||
///
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
|
||||
}
|
||||
|
||||
///
|
||||
/// Create controls and fill the FlowLayoutPanel
|
||||
///
|
||||
flowLayoutPanel.SuspendLayout();
|
||||
flowLayoutPanel.Controls.Clear();
|
||||
flowLayoutPanel.WrapContents = true;
|
||||
flowLayoutPanel.AutoScroll = true;
|
||||
|
||||
wmRsltsCtrl = new IOneWMResultsCtrl[displayedControlsCount];
|
||||
int ix = 0;
|
||||
firstEnabledControl = null;
|
||||
for (int i = 0; i < results.WaterMeters.Length; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null)
|
||||
{
|
||||
if (!results.WaterMeters[i].Disabled || ShowDisabledPositions)
|
||||
{
|
||||
/// Create one water meter position / control
|
||||
wmRsltsCtrl[ix] = (TestsArrangement == TestsArrangement.Rows)
|
||||
? new OneWMResultsRowsCtrl() as IOneWMResultsCtrl
|
||||
: new OneWMResultsColumnsCtrl() as IOneWMResultsCtrl;
|
||||
wmRsltsCtrl[ix].Width = oneWidth;
|
||||
wmRsltsCtrl[ix].Height = oneHeight;
|
||||
wmRsltsCtrl[ix].Update(Items);
|
||||
wmRsltsCtrl[ix].WMResultsClickedHandler += delegate(object s, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), s, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnDoubleClick(s, args);
|
||||
}
|
||||
};
|
||||
|
||||
flowLayoutPanel.Controls.Add(wmRsltsCtrl[ix] as UserControl);
|
||||
if ((firstEnabledControl == null) && !results.WaterMeters[i].Disabled) firstEnabledControl = wmRsltsCtrl[ix];
|
||||
ix++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flowLayoutPanel.ResumeLayout();
|
||||
|
||||
lastRedraw = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
void UpdateResults(Results.BatchResults batchResults)
|
||||
{
|
||||
if ((batchResults != null) && (batchResults.WaterMeters != null))
|
||||
{
|
||||
int ctrlIx = 0;
|
||||
for (int i = 0; i < batchResults.WaterMeters.Length; i++)
|
||||
{
|
||||
if (!batchResults.WaterMeters[i].Disabled || ShowDisabledPositions)
|
||||
{
|
||||
if (ctrlIx < wmRsltsCtrl.Length) wmRsltsCtrl[ctrlIx++].Update(batchResults.WaterMeters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShowMoreWMResults(Results.Entities.WaterMeter wm)
|
||||
{
|
||||
if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(wm.SerialNr))
|
||||
{
|
||||
new Results.Forms.MoreWMResultsDlg(wm, null).ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
using (ISession session = TracingDB.DB.SessionFactory.OpenSession())
|
||||
{
|
||||
IList<ReferenceRecord> refRecords = session.QueryOver<ReferenceRecord>()
|
||||
.Where(x => (x.Code == args.WM.SerialNr))
|
||||
.Where(x => (x.Code == wm.SerialNr))
|
||||
.OrderBy(x => x.TimeStamp).Desc
|
||||
.List();
|
||||
for (int i = 0; i < refRecords.Count; i++)
|
||||
@ -391,7 +259,7 @@ namespace Results.Forms
|
||||
}
|
||||
}
|
||||
|
||||
new Results.Forms.MoreWMResultsDlg(args.WM, refRecords).ShowDialog();
|
||||
new Results.Forms.MoreWMResultsDlg(wm, refRecords).ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -405,6 +273,7 @@ namespace Results.Forms
|
||||
PopupResultsHeight = Height;
|
||||
}
|
||||
|
||||
|
||||
private void flowLayoutPanel_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
lastSizeChange = DateTime.Now;
|
||||
@ -414,13 +283,40 @@ namespace Results.Forms
|
||||
{
|
||||
if (DateTime.Compare(lastSizeChange, lastRedraw) > 0)
|
||||
{
|
||||
/// The last size change was later then the last redraw
|
||||
/// The last size change was more recent then the last redraw
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
if (DateTime.Compare(lastSizeChange + new TimeSpan(0, 0, 1), now) < 0)
|
||||
{
|
||||
/// More then 1s since the last size change
|
||||
Redraw();
|
||||
/// More then 1 second since the last panel size change
|
||||
|
||||
/// Calculate geometry
|
||||
int oneWidth;
|
||||
int oneHeight;
|
||||
///
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
|
||||
}
|
||||
|
||||
/// Update size of controls
|
||||
flowLayoutPanel.SuspendLayout();
|
||||
///
|
||||
foreach (var oneCtrl in wmRsltsCtrl)
|
||||
{
|
||||
oneCtrl.Width = oneWidth;
|
||||
oneCtrl.Height = oneHeight;
|
||||
}
|
||||
///
|
||||
flowLayoutPanel.ResumeLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
Results/Forms/IOneWMResultsCtrl.cs
Normal file
25
Results/Forms/IOneWMResultsCtrl.cs
Normal file
@ -0,0 +1,25 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
public interface IOneWMResultsCtrl
|
||||
{
|
||||
event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
|
||||
|
||||
bool Disabled { get; } /// true when water meter position is disabled
|
||||
int WMPosition { get; } /// 1-based WM position
|
||||
int Width { get; set; } /// Control width
|
||||
int Height { get; set; } /// Control height
|
||||
ListView.ColumnHeaderCollection Columns { get; } /// Embedded ListView control columns
|
||||
|
||||
void Update(int[] columnWidths);
|
||||
void Update(IList<Results.WMeterRsltItemSpec> items);
|
||||
void Update(Results.Entities.WaterMeter wMtr);
|
||||
}
|
||||
}
|
||||
35
Results/Forms/MoreWMResultsDlg.Designer.cs
generated
35
Results/Forms/MoreWMResultsDlg.Designer.cs
generated
@ -29,15 +29,13 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.allResultsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.graphsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.productionTracingTabPage = new System.Windows.Forms.TabPage();
|
||||
this.productionTracingSplitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.messageLabel = new System.Windows.Forms.Label();
|
||||
this.tracingResultsListView = new System.Windows.Forms.ListView();
|
||||
this.oneWMResultsCtrl = new Results.Forms.OneWMResultsCtrl();
|
||||
this.allResultsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.allResultsTabPage.SuspendLayout();
|
||||
this.productionTracingTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.productionTracingSplitContainer)).BeginInit();
|
||||
this.productionTracingSplitContainer.Panel1.SuspendLayout();
|
||||
@ -57,17 +55,6 @@
|
||||
this.tabControl1.Size = new System.Drawing.Size(1195, 448);
|
||||
this.tabControl1.TabIndex = 0;
|
||||
//
|
||||
// allResultsTabPage
|
||||
//
|
||||
this.allResultsTabPage.Controls.Add(this.oneWMResultsCtrl);
|
||||
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.allResultsTabPage.Name = "allResultsTabPage";
|
||||
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
|
||||
this.allResultsTabPage.TabIndex = 0;
|
||||
this.allResultsTabPage.Text = "All results";
|
||||
this.allResultsTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// graphsTabPage
|
||||
//
|
||||
this.graphsTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
@ -133,14 +120,15 @@
|
||||
this.tracingResultsListView.UseCompatibleStateImageBehavior = false;
|
||||
this.tracingResultsListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// oneWMResultsCtrl
|
||||
// allResultsTabPage
|
||||
//
|
||||
this.oneWMResultsCtrl.Caption = "";
|
||||
this.oneWMResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.oneWMResultsCtrl.Location = new System.Drawing.Point(3, 3);
|
||||
this.oneWMResultsCtrl.Name = "oneWMResultsCtrl";
|
||||
this.oneWMResultsCtrl.Size = new System.Drawing.Size(1181, 416);
|
||||
this.oneWMResultsCtrl.TabIndex = 0;
|
||||
this.allResultsTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.allResultsTabPage.Name = "allResultsTabPage";
|
||||
this.allResultsTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.allResultsTabPage.Size = new System.Drawing.Size(1187, 422);
|
||||
this.allResultsTabPage.TabIndex = 0;
|
||||
this.allResultsTabPage.Text = "All results";
|
||||
this.allResultsTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// MoreWMResultsDlg
|
||||
//
|
||||
@ -152,7 +140,6 @@
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Water meter results";
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.allResultsTabPage.ResumeLayout(false);
|
||||
this.productionTracingTabPage.ResumeLayout(false);
|
||||
this.productionTracingSplitContainer.Panel1.ResumeLayout(false);
|
||||
this.productionTracingSplitContainer.Panel1.PerformLayout();
|
||||
@ -166,12 +153,12 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage allResultsTabPage;
|
||||
private OneWMResultsCtrl oneWMResultsCtrl;
|
||||
private OneWMResultsRowsCtrl oneWMResultsCtrl;
|
||||
private System.Windows.Forms.TabPage graphsTabPage;
|
||||
private System.Windows.Forms.TabPage productionTracingTabPage;
|
||||
private System.Windows.Forms.SplitContainer productionTracingSplitContainer;
|
||||
private System.Windows.Forms.Label messageLabel;
|
||||
private System.Windows.Forms.ListView tracingResultsListView;
|
||||
private System.Windows.Forms.TabPage allResultsTabPage;
|
||||
}
|
||||
}
|
||||
@ -51,57 +51,57 @@ namespace Results.Forms
|
||||
/// <param name="wMtr">Water meter entity</param>
|
||||
void ShowAllResults(Results.Entities.WaterMeter wMtr)
|
||||
{
|
||||
string message;
|
||||
Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
|
||||
#if ORACLE_DB
|
||||
oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
// string message;
|
||||
// Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
|
||||
//#if ORACLE_DB
|
||||
// oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
//#else
|
||||
// oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
//#endif
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
|
||||
// IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
|
||||
|
||||
// Header
|
||||
oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
|
||||
int i = 1;
|
||||
foreach (var str in wMtr.GetAllDecoratedTestNames())
|
||||
{
|
||||
oneWMResultsCtrl.Columns.Add(str, 100);
|
||||
i++;
|
||||
}
|
||||
// // Header
|
||||
// oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
|
||||
// int i = 1;
|
||||
// foreach (var str in wMtr.GetAllDecoratedTestNames())
|
||||
// {
|
||||
// oneWMResultsCtrl.Columns.Add(str, 100);
|
||||
// i++;
|
||||
// }
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(item.Name);
|
||||
// foreach (var item in items)
|
||||
// {
|
||||
// ListViewItem lvi = new ListViewItem(item.Name);
|
||||
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
string str = item.Print(wMtr, mtr.Name());
|
||||
// foreach (var mtr in wMtr.MeterTestRslts)
|
||||
// {
|
||||
// if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
// mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
// {
|
||||
// string str = item.Print(wMtr, mtr.Name());
|
||||
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
// string[] texts = str.Split(new char[] { '|' });
|
||||
// if (texts.Length == 1)
|
||||
// {
|
||||
// lvi.SubItems.Add(str);
|
||||
// }
|
||||
// else if (texts.Length == 2)
|
||||
// {
|
||||
// Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
||||
// lvi.UseItemStyleForSubItems = false;
|
||||
// lvi.SubItems.Add(texts[0]);
|
||||
// lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// lvi.SubItems.Add(string.Empty);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
oneWMResultsCtrl.Items.Add(lvi);
|
||||
}
|
||||
// oneWMResultsCtrl.Items.Add(lvi);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
103
Results/Forms/OneWMResultsColumnsCtrl.Designer.cs
generated
Normal file
103
Results/Forms/OneWMResultsColumnsCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
namespace Results.Forms
|
||||
{
|
||||
partial class OneWMResultsColumnsCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.tBox = new System.Windows.Forms.TextBox();
|
||||
this.lView = new System.Windows.Forms.ListView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.tBox);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.lView);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(352, 318);
|
||||
this.splitContainer1.SplitterDistance = 25;
|
||||
this.splitContainer1.SplitterWidth = 1;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// tBox
|
||||
//
|
||||
this.tBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.tBox.Name = "tBox";
|
||||
this.tBox.Size = new System.Drawing.Size(352, 20);
|
||||
this.tBox.TabIndex = 0;
|
||||
this.tBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.tBox_MouseDoubleClick);
|
||||
//
|
||||
// lView
|
||||
//
|
||||
this.lView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lView.FullRowSelect = true;
|
||||
this.lView.GridLines = true;
|
||||
this.lView.Location = new System.Drawing.Point(0, 0);
|
||||
this.lView.Name = "lView";
|
||||
this.lView.Size = new System.Drawing.Size(352, 292);
|
||||
this.lView.TabIndex = 0;
|
||||
this.lView.UseCompatibleStateImageBehavior = false;
|
||||
this.lView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// OneWMResultsCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Name = "OneWMResultsCtrl";
|
||||
this.Size = new System.Drawing.Size(352, 318);
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.TextBox tBox;
|
||||
private System.Windows.Forms.ListView lView;
|
||||
}
|
||||
}
|
||||
159
Results/Forms/OneWMResultsColumnsCtrl.cs
Normal file
159
Results/Forms/OneWMResultsColumnsCtrl.cs
Normal file
@ -0,0 +1,159 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
public partial class OneWMResultsColumnsCtrl : UserControl, IOneWMResultsCtrl
|
||||
{
|
||||
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
|
||||
///
|
||||
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (WMResultsClickedHandler != null) WMResultsClickedHandler(sender, new WaterMeterEventArgs(wmPosition));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool disabled;
|
||||
int wmPosition; /// 1-based water meter position
|
||||
string caption;
|
||||
Color bkColor;
|
||||
int[] columnWidths;
|
||||
IList<Results.WMeterRsltItemSpec> items;
|
||||
|
||||
|
||||
public bool Disabled { get { return disabled; } } /// Read only
|
||||
public int WMPosition { get { return wmPosition; } } /// Read only
|
||||
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } } /// Read only
|
||||
|
||||
|
||||
public OneWMResultsColumnsCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
disabled = false;
|
||||
wmPosition = 0;
|
||||
tBox.Text = caption = "---";
|
||||
tBox.BackColor = lView.BackColor = bkColor = Color.White;
|
||||
items = new List<Results.WMeterRsltItemSpec>();
|
||||
columnWidths = new int[0];
|
||||
}
|
||||
|
||||
public void Update(int[] columnWidths)
|
||||
{
|
||||
this.columnWidths = columnWidths;
|
||||
|
||||
/// Always update ListView column widths
|
||||
int col = 0;
|
||||
foreach (ColumnHeader column in lView.Columns)
|
||||
{
|
||||
column.Width = (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : ((col == 0) ? 40 : 70);
|
||||
col++;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(IList<Results.WMeterRsltItemSpec> items)
|
||||
{
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void Update(Results.Entities.WaterMeter wMtr)
|
||||
{
|
||||
if (wMtr == null || wMtr.Disabled)
|
||||
{
|
||||
/// Water meter position is disabled
|
||||
this.disabled = true;
|
||||
lView.Items.Clear();
|
||||
tBox.Text = caption = "---";
|
||||
tBox.BackColor = lView.BackColor = bkColor = Color.White;
|
||||
return;
|
||||
}
|
||||
|
||||
/// Update background color
|
||||
string message = string.Empty;
|
||||
Update(wMtr.GetColorOfResults(false, out message));
|
||||
|
||||
/// Update caption
|
||||
#if ORACLE_DB
|
||||
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
|
||||
/// Header
|
||||
lView.Columns.Add(wmPosition.ToString(), (columnWidths.Length > 0) ? columnWidths[0] : 40);
|
||||
int col = 1;
|
||||
foreach (var str in wMtr.GetAllDecoratedTestNames())
|
||||
{
|
||||
lView.Columns.Add(str, (columnWidths.Length > col) ? columnWidths[col] : 70);
|
||||
col++;
|
||||
}
|
||||
|
||||
lView.Items.Clear();
|
||||
if (items == null || items.Count == 0) return;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(item.Caption);
|
||||
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
string str = item.Print(wMtr, mtr.Name());
|
||||
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lView.Items.Add(lvi);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Private
|
||||
///
|
||||
|
||||
void Update(int wmPosition)
|
||||
{
|
||||
this.wmPosition = wmPosition;
|
||||
if (lView.Columns.Count > 0)
|
||||
{
|
||||
lView.Columns[0].Text = wmPosition.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
void Update(Color backColor)
|
||||
{
|
||||
if (this.bkColor != backColor)
|
||||
{
|
||||
tBox.BackColor = lView.BackColor = this.bkColor = backColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
public partial class OneWMResultsCtrl : UserControl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(OneWMResultsCtrl));
|
||||
|
||||
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
|
||||
|
||||
public OneWMResultsCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public OneWMResultsCtrl(Color backColor, int lvWidth, int lvHeight, Results.Entities.WaterMeter wm)
|
||||
: this()
|
||||
{
|
||||
lView.BackColor = backColor;
|
||||
tBox.BackColor = backColor;
|
||||
Size = new System.Drawing.Size(lvWidth, lvHeight);
|
||||
WM = wm;
|
||||
}
|
||||
|
||||
public Results.Entities.WaterMeter WM;
|
||||
public string Caption { get { return tBox.Text; } set { tBox.Text = value; } }
|
||||
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } }
|
||||
public ListView.ListViewItemCollection Items { get { return lView.Items; } }
|
||||
public Color BColor { set { lView.BackColor = value; tBox.BackColor = value; } }
|
||||
|
||||
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (WMResultsClickedHandler == null) return;
|
||||
try { WMResultsClickedHandler(sender, new WaterMeterEventArgs(WM)); }
|
||||
catch (Exception exc) { log.Error("WMResultsClickedHandler(...) failed", exc); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Results.Forms
|
||||
{
|
||||
partial class OneWMResultsCtrl
|
||||
partial class OneWMResultsRowsCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
169
Results/Forms/OneWMResultsRowsCtrl.cs
Normal file
169
Results/Forms/OneWMResultsRowsCtrl.cs
Normal file
@ -0,0 +1,169 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
public partial class OneWMResultsRowsCtrl : UserControl, IOneWMResultsCtrl
|
||||
{
|
||||
public event EventHandler<WaterMeterEventArgs> WMResultsClickedHandler;
|
||||
///
|
||||
private void tBox_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (WMResultsClickedHandler != null) WMResultsClickedHandler(sender, new WaterMeterEventArgs(wmPosition));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool disabled;
|
||||
int wmPosition; /// 1-based water meter position
|
||||
string caption;
|
||||
Color bkColor;
|
||||
int[] columnWidths;
|
||||
IList<Results.WMeterRsltItemSpec> items;
|
||||
|
||||
|
||||
public bool Disabled { get { return disabled; } } /// Read only
|
||||
public int WMPosition { get { return wmPosition; } } /// Read only
|
||||
public ListView.ColumnHeaderCollection Columns { get { return lView.Columns; } } /// Read only
|
||||
|
||||
|
||||
public OneWMResultsRowsCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
disabled = false;
|
||||
wmPosition = 0;
|
||||
tBox.Text = caption = "---";
|
||||
tBox.BackColor = lView.BackColor = bkColor = Color.White;
|
||||
items = new List<Results.WMeterRsltItemSpec>();
|
||||
columnWidths = new int[0];
|
||||
}
|
||||
|
||||
public void Update(int[] columnWidths)
|
||||
{
|
||||
this.columnWidths = columnWidths;
|
||||
|
||||
/// Always update ListView column widths
|
||||
int col = 0;
|
||||
foreach (ColumnHeader column in lView.Columns)
|
||||
{
|
||||
column.Width = (columnWidths != null && columnWidths.Length > col) ? columnWidths[col] : ((col == 0) ? 40 : 70);
|
||||
col++;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(IList<Results.WMeterRsltItemSpec> items)
|
||||
{
|
||||
this.items = items;
|
||||
|
||||
/// Always draw ListView header
|
||||
lView.Columns.Clear();
|
||||
lView.Columns.Add(wmPosition.ToString(), (columnWidths.Length > 0) ? columnWidths[0] : 40);
|
||||
|
||||
if (items == null || items.Count == 0) return;
|
||||
int col = 1;
|
||||
foreach (var item in items)
|
||||
{
|
||||
lView.Columns.Add(item.Caption, (columnWidths.Length > col) ? columnWidths[col] : 70);
|
||||
col++;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(Results.Entities.WaterMeter wMtr)
|
||||
{
|
||||
if (wMtr == null || wMtr.Disabled)
|
||||
{
|
||||
/// Water meter position is disabled
|
||||
this.disabled = true;
|
||||
lView.Items.Clear();
|
||||
tBox.Text = caption = "---";
|
||||
tBox.BackColor = lView.BackColor = bkColor = Color.White;
|
||||
return;
|
||||
}
|
||||
|
||||
/// Update background color
|
||||
string message = string.Empty;
|
||||
Update(wMtr.GetColorOfResults(false, out message));
|
||||
|
||||
/// Update caption
|
||||
#if ORACLE_DB
|
||||
tBox.Text = caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
tBox.Text = caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
|
||||
Update(wMtr.WMPosition);
|
||||
|
||||
/// Update test results
|
||||
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
|
||||
int ix = 0;
|
||||
lView.Items.Clear();
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Config.Entities.Publish.Never
|
||||
&& mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(testNames[ix++]);
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
string str = items[i].Print(wMtr, mtr.Name());
|
||||
|
||||
/// Extract and use color information
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lView.Items.Add(lvi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Private
|
||||
///
|
||||
|
||||
void Update(int wmPosition)
|
||||
{
|
||||
this.wmPosition = wmPosition;
|
||||
if (lView.Columns.Count > 0)
|
||||
{
|
||||
lView.Columns[0].Text = wmPosition.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
void Update(Color backColor)
|
||||
{
|
||||
if (this.bkColor != backColor)
|
||||
{
|
||||
tBox.BackColor = lView.BackColor = this.bkColor = backColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Results/Forms/OneWMResultsRowsCtrl.resx
Normal file
120
Results/Forms/OneWMResultsRowsCtrl.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -7,8 +7,8 @@ namespace Results.Forms
|
||||
{
|
||||
public class WaterMeterEventArgs : EventArgs
|
||||
{
|
||||
public Results.Entities.WaterMeter WM;
|
||||
public int WMPosition;
|
||||
|
||||
public WaterMeterEventArgs(Results.Entities.WaterMeter wm) { WM = wm; }
|
||||
public WaterMeterEventArgs(int wmPosition) { WMPosition = wmPosition; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.18.1278.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1278.0")]
|
||||
[assembly: AssemblyVersion("2.18.1290.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1290.0")]
|
||||
|
||||
9
Results/Resources/Strings.Designer.cs
generated
9
Results/Resources/Strings.Designer.cs
generated
@ -1230,6 +1230,15 @@ namespace Results.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This position is disabled.
|
||||
/// </summary>
|
||||
internal static string This_position_is_disabled {
|
||||
get {
|
||||
return ResourceManager.GetString("This_position_is_disabled", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to to.
|
||||
/// </summary>
|
||||
|
||||
@ -333,4 +333,7 @@
|
||||
<data name="Flow" xml:space="preserve">
|
||||
<value>Průtok</value>
|
||||
</data>
|
||||
<data name="This_position_is_disabled" xml:space="preserve">
|
||||
<value>Taro pozice je vypnuta</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -816,4 +816,7 @@
|
||||
<data name="Relative_error" xml:space="preserve">
|
||||
<value>Relative error</value>
|
||||
</data>
|
||||
<data name="This_position_is_disabled" xml:space="preserve">
|
||||
<value>This position is disabled</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -75,6 +75,7 @@
|
||||
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
|
||||
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
|
||||
<Compile Include="Forms\ListViewEx.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@ -87,11 +88,17 @@
|
||||
<Compile Include="Forms\MoreWMResultsDlg.Designer.cs">
|
||||
<DependentUpon>MoreWMResultsDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\OneWMResultsCtrl.cs">
|
||||
<Compile Include="Forms\OneWMResultsColumnsCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\OneWMResultsCtrl.Designer.cs">
|
||||
<DependentUpon>OneWMResultsCtrl.cs</DependentUpon>
|
||||
<Compile Include="Forms\OneWMResultsColumnsCtrl.designer.cs">
|
||||
<DependentUpon>OneWMResultsColumnsCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\OneWMResultsRowsCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\OneWMResultsRowsCtrl.Designer.cs">
|
||||
<DependentUpon>OneWMResultsRowsCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsConfigCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
@ -187,8 +194,11 @@
|
||||
<EmbeddedResource Include="Forms\MoreWMResultsDlg.resx">
|
||||
<DependentUpon>MoreWMResultsDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\OneWMResultsCtrl.resx">
|
||||
<DependentUpon>OneWMResultsCtrl.cs</DependentUpon>
|
||||
<EmbeddedResource Include="Forms\OneWMResultsColumnsCtrl.resx">
|
||||
<DependentUpon>OneWMResultsColumnsCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\OneWMResultsRowsCtrl.resx">
|
||||
<DependentUpon>OneWMResultsRowsCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\ResultsConfigCtrl.resx">
|
||||
<DependentUpon>ResultsConfigCtrl.cs</DependentUpon>
|
||||
|
||||
@ -235,43 +235,62 @@ namespace TBF.Forms
|
||||
|
||||
public void DoShowResults(object sender, PreviousResultIdEventArgs data)
|
||||
{
|
||||
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg();
|
||||
dlg.PopupResultsLeft = Program.LocalSettings.PopupResultsLeft;
|
||||
dlg.PopupResultsTop = Program.LocalSettings.PopupResultsTop;
|
||||
dlg.PopupResultsWidth = Program.LocalSettings.PopupResultsWidth;
|
||||
dlg.PopupResultsHeight = Program.LocalSettings.PopupResultsHeight;
|
||||
|
||||
dlg.MetersArrangement = Program.LocalSettings.ResultsConfigMeters;
|
||||
dlg.TestsArrangement = Program.LocalSettings.ResultsConfigTests;
|
||||
dlg.NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
|
||||
|
||||
dlg.RsltItems_Screen_SingleWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
|
||||
dlg.RsltItems_Screen_CombinedWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
|
||||
dlg.RsltItems_Screen_HeatM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_HeatM);
|
||||
dlg.RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths;
|
||||
|
||||
foreach (var b in batches)
|
||||
{
|
||||
if (b.BatchNr == data.BatchNr)
|
||||
{
|
||||
dlg.Results = Results.BatchResults.FromBatch(b);
|
||||
dlg.Text = string.Format(Strings.Results_of_batch_0, b.BatchNr);
|
||||
if (b.WaterMeters == null || b.WaterMeters.Count == 0)
|
||||
{
|
||||
return; /// No water meters in the selected batch
|
||||
}
|
||||
|
||||
/// Prepare result items
|
||||
IList<Results.WMeterRsltItemSpec> items = null;
|
||||
foreach (var wm in b.WaterMeters)
|
||||
{
|
||||
if (wm != null)
|
||||
{
|
||||
if (wm.WaterMeterData.Compound)
|
||||
{
|
||||
items = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
|
||||
}
|
||||
else if (wm.WaterMeterData.HeatMeter)
|
||||
{
|
||||
items = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_HeatM);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (items == null) items = new List<Results.WMeterRsltItemSpec>();
|
||||
|
||||
/// Show dialog with results
|
||||
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg
|
||||
{
|
||||
Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
|
||||
Results = Results.BatchResults.FromBatch(b),
|
||||
Items = items,
|
||||
PopupResultsLeft = Program.LocalSettings.PopupResultsLeft,
|
||||
PopupResultsTop = Program.LocalSettings.PopupResultsTop,
|
||||
PopupResultsWidth = Program.LocalSettings.PopupResultsWidth,
|
||||
PopupResultsHeight = Program.LocalSettings.PopupResultsHeight,
|
||||
MetersArrangement = Program.LocalSettings.ResultsConfigMeters,
|
||||
TestsArrangement = Program.LocalSettings.ResultsConfigTests,
|
||||
NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup),
|
||||
ShowDisabledPositions = Program.LocalSettings.ShowDisabledPositions,
|
||||
MinWidth = Program.LocalSettings.ResultsConfigMinWidth,
|
||||
MinHeight = Program.LocalSettings.ResultsConfigMinHeight,
|
||||
RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths,
|
||||
};
|
||||
|
||||
dlg.Show();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//if (dlg.PopupResultsLeft != Program.LocalSettings.PopupResultsLeft ||
|
||||
// dlg.PopupResultsTop != Program.LocalSettings.PopupResultsTop ||
|
||||
// dlg.PopupResultsWidth != Program.LocalSettings.PopupResultsWidth ||
|
||||
// dlg.PopupResultsHeight != Program.LocalSettings.PopupResultsHeight)
|
||||
//{
|
||||
// Program.LocalSettings.PopupResultsLeft = dlg.PopupResultsLeft;
|
||||
// Program.LocalSettings.PopupResultsTop = dlg.PopupResultsTop;
|
||||
// Program.LocalSettings.PopupResultsWidth = dlg.PopupResultsWidth;
|
||||
// Program.LocalSettings.PopupResultsHeight = dlg.PopupResultsHeight;
|
||||
// Program.LocalSettings.Save();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
14
TBF/Forms/ResultsArrangementDlg.Designer.cs
generated
14
TBF/Forms/ResultsArrangementDlg.Designer.cs
generated
@ -35,6 +35,7 @@ namespace TBF.Forms
|
||||
this.testsColumnsRadioButton = new System.Windows.Forms.RadioButton();
|
||||
this.testsArangementGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.metersArangementGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.showDisabledCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.minHeightTextBox = new System.Windows.Forms.TextBox();
|
||||
this.minHeightLabel = new System.Windows.Forms.Label();
|
||||
this.minWidthTextBox = new System.Windows.Forms.TextBox();
|
||||
@ -88,6 +89,7 @@ namespace TBF.Forms
|
||||
//
|
||||
// metersArangementGroupBox
|
||||
//
|
||||
this.metersArangementGroupBox.Controls.Add(this.showDisabledCheckBox);
|
||||
this.metersArangementGroupBox.Controls.Add(this.minHeightTextBox);
|
||||
this.metersArangementGroupBox.Controls.Add(this.minHeightLabel);
|
||||
this.metersArangementGroupBox.Controls.Add(this.minWidthTextBox);
|
||||
@ -103,6 +105,17 @@ namespace TBF.Forms
|
||||
this.metersArangementGroupBox.TabStop = false;
|
||||
this.metersArangementGroupBox.Text = "Arangement of tested meters";
|
||||
//
|
||||
// showDisabledCheckBox
|
||||
//
|
||||
this.showDisabledCheckBox.AutoSize = true;
|
||||
this.showDisabledCheckBox.Enabled = false;
|
||||
this.showDisabledCheckBox.Location = new System.Drawing.Point(200, 44);
|
||||
this.showDisabledCheckBox.Name = "showDisabledCheckBox";
|
||||
this.showDisabledCheckBox.Size = new System.Drawing.Size(139, 17);
|
||||
this.showDisabledCheckBox.TabIndex = 10;
|
||||
this.showDisabledCheckBox.Text = "Show disabled positions";
|
||||
this.showDisabledCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// minHeightTextBox
|
||||
//
|
||||
this.minHeightTextBox.Enabled = false;
|
||||
@ -263,5 +276,6 @@ namespace TBF.Forms
|
||||
private System.Windows.Forms.Label minHeightLabel;
|
||||
private System.Windows.Forms.TextBox minWidthTextBox;
|
||||
private System.Windows.Forms.Label minWidthLabel;
|
||||
private System.Windows.Forms.CheckBox showDisabledCheckBox;
|
||||
}
|
||||
}
|
||||
@ -22,6 +22,7 @@ namespace TBF.Forms
|
||||
public TestsArrangement TestsArrangement;
|
||||
public MetersArrangement MetersArrangement;
|
||||
public int NrMetersInOneGroup;
|
||||
public bool ShowDisabledPositions;
|
||||
public int MinWidth;
|
||||
public int MinHeight;
|
||||
|
||||
@ -62,6 +63,7 @@ namespace TBF.Forms
|
||||
horizontallyRadioButton.Text = Strings.Horizontally;
|
||||
verticallyRadioButton.Text = Strings.Vertically;
|
||||
nrMetersLabel.Text = string.Format("{0}:", Strings.Nr_meters_in_a_group);
|
||||
showDisabledCheckBox.Text = Strings.Show_disabled_positions;
|
||||
minWidthLabel.Text = string.Format("{0}:", Strings.Min_width);
|
||||
minHeightLabel.Text = string.Format("{0}:", Strings.Min_height);
|
||||
unlockButton.Text = Strings.UnlockBtnText;
|
||||
@ -79,6 +81,7 @@ namespace TBF.Forms
|
||||
horizontallyRadioButton.Checked = (MetersArrangement == MetersArrangement.Horizontally);
|
||||
verticallyRadioButton.Checked = (MetersArrangement == MetersArrangement.Vertically);
|
||||
nrMetersTextBox.Text = NrMetersInOneGroup.ToString();
|
||||
showDisabledCheckBox.Checked = ShowDisabledPositions;
|
||||
minWidthTextBox.Text = MinWidth.ToString();
|
||||
minHeightTextBox.Text = MinHeight.ToString();
|
||||
}
|
||||
@ -113,6 +116,7 @@ namespace TBF.Forms
|
||||
verticallyRadioButton.Enabled = true;
|
||||
horizontallyRadioButton.Enabled = true;
|
||||
nrMetersTextBox.Enabled = true;
|
||||
showDisabledCheckBox.Enabled = true;
|
||||
minWidthTextBox.Enabled = true;
|
||||
minHeightTextBox.Enabled = true;
|
||||
resultsConfigCtrl.Unlocked = true;
|
||||
@ -121,11 +125,9 @@ namespace TBF.Forms
|
||||
|
||||
void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (testsColumnsRadioButton.Checked) TestsArrangement = TestsArrangement.Columns;
|
||||
else TestsArrangement = TestsArrangement.Rows;
|
||||
|
||||
if (horizontallyRadioButton.Checked) MetersArrangement = MetersArrangement.Horizontally;
|
||||
else MetersArrangement = MetersArrangement.Vertically;
|
||||
TestsArrangement = testsColumnsRadioButton.Checked ? TestsArrangement.Columns : TestsArrangement.Rows;
|
||||
MetersArrangement = horizontallyRadioButton.Checked ? MetersArrangement.Horizontally : MetersArrangement.Vertically;
|
||||
ShowDisabledPositions = showDisabledCheckBox.Checked;
|
||||
|
||||
int tmpInt;
|
||||
if (int.TryParse(nrMetersTextBox.Text, out tmpInt) && tmpInt > 0) { NrMetersInOneGroup = tmpInt; }
|
||||
|
||||
@ -240,6 +240,7 @@ namespace TBF
|
||||
public Config.Entities.MetersArrangement ResultsConfigMeters;
|
||||
public Config.Entities.TestsArrangement ResultsConfigTests;
|
||||
public int ResultsConfigMetersInOneGroup;
|
||||
public bool ShowDisabledPositions;
|
||||
public int ResultsConfigMinWidth;
|
||||
public int ResultsConfigMinHeight;
|
||||
public string[] RsltItems_Screen_SingleWM;
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1285.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1285.0")]
|
||||
[assembly: AssemblyVersion("2.18.1290.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1290.0")]
|
||||
|
||||
9
TBF/Resources/Strings.Designer.cs
generated
9
TBF/Resources/Strings.Designer.cs
generated
@ -4506,6 +4506,15 @@ namespace TBF.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show disabled positions.
|
||||
/// </summary>
|
||||
internal static string Show_disabled_positions {
|
||||
get {
|
||||
return ResourceManager.GetString("Show_disabled_positions", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shut down computer after exiting Test Bench Framework.
|
||||
/// </summary>
|
||||
|
||||
@ -1461,4 +1461,7 @@
|
||||
<data name="Saving_results_failed" xml:space="preserve">
|
||||
<value>Ukládání výsledků zlyhalo</value>
|
||||
</data>
|
||||
<data name="Show_disabled_positions" xml:space="preserve">
|
||||
<value>Zobrazit vypnuté pozice</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -2032,4 +2032,7 @@
|
||||
<data name="Saving_results_failed" xml:space="preserve">
|
||||
<value>Saving results failed</value>
|
||||
</data>
|
||||
<data name="Show_disabled_positions" xml:space="preserve">
|
||||
<value>Show disabled positions</value>
|
||||
</data>
|
||||
</root>
|
||||
1
TBF/Screens/ResultsTabPageCtrl.Designer.cs
generated
1
TBF/Screens/ResultsTabPageCtrl.Designer.cs
generated
@ -246,6 +246,7 @@ namespace TBF.Screens
|
||||
this.flowLayoutPanel.Name = "flowLayoutPanel";
|
||||
this.flowLayoutPanel.Size = new System.Drawing.Size(1315, 660);
|
||||
this.flowLayoutPanel.TabIndex = 0;
|
||||
this.flowLayoutPanel.SizeChanged += new System.EventHandler(this.flowLayoutPanel_SizeChanged);
|
||||
//
|
||||
// ResultsTabPageCtrl
|
||||
//
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -35,6 +35,7 @@ namespace TBF.Screens
|
||||
public MetersArrangement MetersArrangement;
|
||||
public TestsArrangement TestsArrangement;
|
||||
public int NrMetersInOneGroup;
|
||||
public bool ShowDisabledPositions;
|
||||
public int MinWidth;
|
||||
public int MinHeight;
|
||||
|
||||
@ -42,11 +43,17 @@ namespace TBF.Screens
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_CombinedWM;
|
||||
public IList<Results.WMeterRsltItemSpec> RsltItems_Screen_HeatM;
|
||||
|
||||
MetersKind metersKind;
|
||||
OneWMResultsCtrl firstListView;
|
||||
MetersKind metersKind;
|
||||
IList<Results.WMeterRsltItemSpec> currentItems;
|
||||
IOneWMResultsCtrl[] wmRsltsCtrl; /// An array of controls with water meter results.
|
||||
IOneWMResultsCtrl firstEnabledControl;
|
||||
DateTime lastRedraw;
|
||||
DateTime lastSizeChange;
|
||||
int metersInOneGroup;
|
||||
int nrGroups;
|
||||
|
||||
Timer timer;
|
||||
|
||||
int lvWidth;
|
||||
int lvHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
@ -55,16 +62,25 @@ namespace TBF.Screens
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
wmRsltsCtrl = new IOneWMResultsCtrl[0]; /// No water meters displayed => array with zero length
|
||||
firstEnabledControl = null; /// No water meters displayed => firstListView is null
|
||||
currentItems = new List<Results.WMeterRsltItemSpec>();
|
||||
nrGroups = 1;
|
||||
metersInOneGroup = 1;
|
||||
|
||||
if (Program.LocalSettings != null)
|
||||
{
|
||||
MetersArrangement = Program.LocalSettings.ResultsConfigMeters;
|
||||
TestsArrangement = Program.LocalSettings.ResultsConfigTests;
|
||||
NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
|
||||
ShowDisabledPositions = Program.LocalSettings.ShowDisabledPositions;
|
||||
MinWidth = Program.LocalSettings.ResultsConfigMinWidth;
|
||||
MinHeight = Program.LocalSettings.ResultsConfigMinHeight;
|
||||
RsltItems_Screen_SingleWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
|
||||
RsltItems_Screen_CombinedWM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
|
||||
RsltItems_Screen_HeatM = Results.WMeterRsltItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_HeatM);
|
||||
|
||||
currentItems = GetRsltItems(metersKind);
|
||||
}
|
||||
|
||||
Bridge.ProcedureSelectedHandler += delegate(object sender, ProcedureSelectedEventArgs args)
|
||||
@ -90,24 +106,41 @@ namespace TBF.Screens
|
||||
else
|
||||
OnButtonsEtc(sndr, args);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
lastSizeChange = DateTime.Now;
|
||||
|
||||
/// Create a timer with one second interval.
|
||||
timer = new Timer();
|
||||
timer.Interval = 1000; /// ms
|
||||
timer.Tick += new EventHandler(OnTimer);
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
void OnProcedureSelected(object sender, ProcedureSelectedEventArgs args)
|
||||
{
|
||||
if ((TBF.BenchControl.Sequences.ProcessData.BatchRslts != null) && (Program.LocalSettings != null))
|
||||
Results.BatchResults batchResults = TBF.BenchControl.Sequences.ProcessData.BatchRslts;
|
||||
|
||||
if ((batchResults != null) && (Program.LocalSettings != null))
|
||||
{
|
||||
Results.Utils.GetCounterStates(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
Results.Utils.GetCounterStates(batchResults.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
|
||||
if (IsLayoutChangedDueToData(batchResults)) CreateControlsAndFillPanel(batchResults);
|
||||
UpdateResults(batchResults);
|
||||
}
|
||||
|
||||
void OnTestCompleted(object sender, TestCompletedEventArgs args)
|
||||
{
|
||||
if ((TBF.BenchControl.Sequences.ProcessData.BatchRslts != null) && (Program.LocalSettings != null))
|
||||
Results.BatchResults batchResults = TBF.BenchControl.Sequences.ProcessData.BatchRslts;
|
||||
|
||||
if ((batchResults != null) && (Program.LocalSettings != null))
|
||||
{
|
||||
Results.Utils.GetCounterStates(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
Results.Utils.GetCounterStates(batchResults.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
|
||||
if (IsLayoutChangedDueToData(batchResults)) CreateControlsAndFillPanel(batchResults);
|
||||
UpdateResults(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
}
|
||||
|
||||
void OnButtonsEtc(object sender, UiBridge.ButtonsEtcEventArgs args)
|
||||
@ -154,7 +187,9 @@ namespace TBF.Screens
|
||||
{
|
||||
Results.Utils.GetCounterStates(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
|
||||
CreateControlsAndFillPanel(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
UpdateResults(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
}
|
||||
|
||||
|
||||
@ -179,7 +214,7 @@ namespace TBF.Screens
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Invoke a configuration dialog
|
||||
/// Handle button at the top of this form: Invoke a configuration dialog
|
||||
/// </summary>
|
||||
private void configureButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -189,6 +224,7 @@ namespace TBF.Screens
|
||||
dlg.TestsArrangement = TestsArrangement;
|
||||
dlg.MetersArrangement = MetersArrangement;
|
||||
dlg.NrMetersInOneGroup = NrMetersInOneGroup;
|
||||
dlg.ShowDisabledPositions = ShowDisabledPositions;
|
||||
dlg.MinWidth = MinWidth;
|
||||
dlg.MinHeight = MinHeight;
|
||||
dlg.SelectedItems = GetRsltItems(metersKind);
|
||||
@ -196,13 +232,25 @@ namespace TBF.Screens
|
||||
DialogResult dr = dlg.ShowDialog();
|
||||
if (dr == DialogResult.OK && dlg.Unlocked)
|
||||
{
|
||||
Program.LocalSettings.ResultsConfigMeters = MetersArrangement = dlg.MetersArrangement;;
|
||||
Program.LocalSettings.ResultsConfigTests = TestsArrangement = dlg.TestsArrangement;
|
||||
Program.LocalSettings.ResultsConfigMetersInOneGroup = NrMetersInOneGroup = dlg.NrMetersInOneGroup;
|
||||
Program.LocalSettings.ResultsConfigMinWidth = MinWidth = dlg.MinWidth;
|
||||
Program.LocalSettings.ResultsConfigMinHeight = MinHeight = dlg.MinHeight;
|
||||
bool isLayoutChangedDueToConfig = false;
|
||||
|
||||
switch (metersKind)
|
||||
if ((MetersArrangement != dlg.MetersArrangement) ||
|
||||
(TestsArrangement != dlg.TestsArrangement) ||
|
||||
(NrMetersInOneGroup != dlg.NrMetersInOneGroup) ||
|
||||
(ShowDisabledPositions != dlg.ShowDisabledPositions) ||
|
||||
(MinWidth != dlg.MinWidth) ||
|
||||
(MinHeight != dlg.MinHeight))
|
||||
{
|
||||
Program.LocalSettings.ResultsConfigMeters = MetersArrangement = dlg.MetersArrangement;;
|
||||
Program.LocalSettings.ResultsConfigTests = TestsArrangement = dlg.TestsArrangement;
|
||||
Program.LocalSettings.ResultsConfigMetersInOneGroup = NrMetersInOneGroup = dlg.NrMetersInOneGroup;
|
||||
Program.LocalSettings.ShowDisabledPositions = ShowDisabledPositions = dlg.ShowDisabledPositions;
|
||||
Program.LocalSettings.ResultsConfigMinWidth = MinWidth = dlg.MinWidth;
|
||||
Program.LocalSettings.ResultsConfigMinHeight = MinHeight = dlg.MinHeight;
|
||||
isLayoutChangedDueToConfig = true;
|
||||
}
|
||||
|
||||
switch (metersKind)
|
||||
{
|
||||
default:
|
||||
case MetersKind.Single:
|
||||
@ -218,313 +266,36 @@ namespace TBF.Screens
|
||||
Program.LocalSettings.RsltItems_Screen_HeatM = Results.WMeterRsltItemSpec.ToStrArray(RsltItems_Screen_HeatM);
|
||||
break;
|
||||
}
|
||||
UpdateItems(dlg.SelectedItems);
|
||||
|
||||
Program.LocalSettings.Save();
|
||||
}
|
||||
|
||||
if ((TBF.BenchControl.Sequences.ProcessData.BatchRslts != null) && (Program.LocalSettings != null))
|
||||
{
|
||||
Results.Utils.GetCounterStates(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the results
|
||||
/// </summary>
|
||||
private void showPreviousResultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new TBF.Forms.PreviousResultsDlg().ShowDialog();
|
||||
}
|
||||
|
||||
private void reloadPreviousResultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new TBF.Forms.PreviousResultsDlg(TBF.Forms.PreviousResultsMode.Reload).ShowDialog();
|
||||
}
|
||||
|
||||
private void fixPreviousResultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new TBF.Forms.PreviousResultsDlg(TBF.Forms.PreviousResultsMode.Fix).ShowDialog();
|
||||
}
|
||||
|
||||
#region Redraw
|
||||
|
||||
/// <summary>
|
||||
/// Re-draw the results. Apply new settings if they changed.
|
||||
/// </summary>
|
||||
void RedrawAll(Results.BatchResults results)
|
||||
{
|
||||
this.SuspendLayout();
|
||||
|
||||
if (results == null)
|
||||
{
|
||||
flowLayoutPanel.Controls.Clear();
|
||||
ResumeLayout(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
/// Determine how many water meters were enabled for result evaluation and printing
|
||||
int enabledWMsCount = 0;
|
||||
for (int i = 0; i < results.WMPositionsCount; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
enabledWMsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
|
||||
int nrGroups = Math.Max(1, (enabledWMsCount + metersInOneGroup - 1) / metersInOneGroup);
|
||||
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||
lvWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
|
||||
lvHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
|
||||
lvWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
|
||||
lvHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
|
||||
}
|
||||
flowLayoutPanel.Controls.Clear();
|
||||
flowLayoutPanel.WrapContents = true;
|
||||
flowLayoutPanel.AutoScroll = true;
|
||||
|
||||
bool first = true;
|
||||
for (int i = 0; i < results.WMPositionsCount; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
OneWMResultsCtrl lview = (TestsArrangement == TestsArrangement.Rows)
|
||||
? GetResultsTestsAreRows(results.WaterMeters[i], i + 1)
|
||||
: GetResultsTestsAreColumns(results.WaterMeters[i], i + 1);
|
||||
if (lview != null)
|
||||
{
|
||||
flowLayoutPanel.Controls.Add(lview);
|
||||
if (first)
|
||||
{
|
||||
firstListView = lview;
|
||||
first = false;
|
||||
}
|
||||
|
||||
lview.WMResultsClickedHandler += delegate(object sender, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), sender, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnDoubleClick(sender, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.FatalFormat("Redrawing results failed : {0}", e.Message);
|
||||
if (e.InnerException != null)
|
||||
{
|
||||
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
|
||||
}
|
||||
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
|
||||
}
|
||||
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get an empty ListView control with appropriate parameters.
|
||||
/// </summary>
|
||||
/// <returns>ListView control</returns>
|
||||
OneWMResultsCtrl GetListView(Color backColor, Results.Entities.WaterMeter wm)
|
||||
{
|
||||
return new OneWMResultsCtrl(backColor, lvWidth, lvHeight, wm);
|
||||
}
|
||||
///
|
||||
OneWMResultsCtrl GetListView(Results.Entities.WaterMeter wm)
|
||||
{
|
||||
return GetListView(Color.White, wm);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a ListView control filled with results of the meter 'mtr'
|
||||
/// </summary>
|
||||
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
|
||||
/// <returns>ListView object</returns>
|
||||
OneWMResultsCtrl GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
|
||||
{
|
||||
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
|
||||
|
||||
string message = string.Empty;
|
||||
#if ORACLE_DB
|
||||
bool maxRepeatsExceeded = ((TBF.BenchControl.Sequences.ProcessData.BenchInfo is TBF.BenchControl.BenchInfo.iPerl.Component) &&
|
||||
(wMtr.Pruefindex % 100) >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex);
|
||||
Color commonBackColor = wMtr.GetColorOfResults(maxRepeatsExceeded, out message);
|
||||
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
|
||||
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
|
||||
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
|
||||
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
|
||||
|
||||
if (items == null || items.Count == 0) return lview;
|
||||
|
||||
// Header
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
lview.Columns.Add(printedWMNr.ToString(), (ls.RsltsClmnCount > 0) ? ls.RsltsClmnWidths[0] : 40);
|
||||
int col = 1;
|
||||
foreach (var item in items)
|
||||
{
|
||||
lview.Columns.Add(item.Caption, (ls.RsltsClmnCount > col) ? ls.RsltsClmnWidths[col] : 70);
|
||||
col++;
|
||||
}
|
||||
|
||||
|
||||
IList<string> testNames = wMtr.GetAllDecoratedTestNames();
|
||||
int ix = 0;
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
{
|
||||
if (mtr != null &&
|
||||
(mtr.CompoundMeterId == (byte)CompoundMeterId.Single ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.Compound ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) &&
|
||||
mtr.TestDone &&
|
||||
mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(testNames[ix++]);
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
string str = items[i].Print(wMtr, mtr.Name());
|
||||
|
||||
/// Extract and use color information
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : commonBackColor);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
lview.Items.Add(lvi);
|
||||
}
|
||||
}
|
||||
|
||||
return lview;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a ListView control filled with results of the meter 'mtr'
|
||||
/// </summary>
|
||||
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
|
||||
/// <returns>ListView object</returns>
|
||||
OneWMResultsCtrl GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
|
||||
{
|
||||
metersKind = wMtr.Compound() ? MetersKind.Combined : (wMtr.HeatMeter() ? MetersKind.HeatMeter : MetersKind.Single);
|
||||
|
||||
string message;
|
||||
#if ORACLE_DB
|
||||
bool maxRepeatsExceeded = ((TBF.BenchControl.Sequences.ProcessData.BenchInfo is TBF.BenchControl.BenchInfo.iPerl.Component) &&
|
||||
(wMtr.Pruefindex % 100) >= (TBF.BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.iPerl.Component).MaxTestIndex);
|
||||
Color commonBackColor = wMtr.GetColorOfResults(maxRepeatsExceeded, out message);
|
||||
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
|
||||
lview.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
||||
#else
|
||||
Color commonBackColor = wMtr.GetColorOfResults(false, out message);
|
||||
OneWMResultsCtrl lview = GetListView(commonBackColor, wMtr);
|
||||
lview.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
||||
#endif
|
||||
|
||||
IList<Results.WMeterRsltItemSpec> items = GetRsltItems(metersKind);
|
||||
|
||||
if (items == null || items.Count == 0) return lview;
|
||||
|
||||
// Header
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
lview.Columns.Add(printedWMNr.ToString(), (ls.RsltsClmnCount > 0) ? ls.RsltsClmnWidths[0] : 40);
|
||||
int i = 1;
|
||||
foreach (var str in wMtr.GetAllDecoratedTestNames())
|
||||
{
|
||||
lview.Columns.Add(str, (ls.RsltsClmnCount > i) ? ls.RsltsClmnWidths[i] : 70);
|
||||
i++;
|
||||
}
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
ListViewItem lvi = new ListViewItem(item.Caption);
|
||||
|
||||
foreach (var mtr in wMtr.MeterTestRslts)
|
||||
if ((TBF.BenchControl.Sequences.ProcessData.BatchRslts != null) && (Program.LocalSettings != null))
|
||||
{
|
||||
if (mtr != null &&
|
||||
(mtr.CompoundMeterId == (byte)CompoundMeterId.Single ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.Compound ||
|
||||
mtr.CompoundMeterId == (byte)CompoundMeterId.HeatMeterEnergy) &&
|
||||
mtr.TestDone &&
|
||||
mtr.Publish() != Config.Entities.Publish.Never &&
|
||||
mtr.Publish() != Config.Entities.Publish.Internal)
|
||||
{
|
||||
string str = item.Print(wMtr, mtr.Name());
|
||||
|
||||
string[] texts = str.Split(new char[] { '|' });
|
||||
if (texts.Length == 1)
|
||||
{
|
||||
lvi.SubItems.Add(str);
|
||||
}
|
||||
else if (texts.Length == 2)
|
||||
{
|
||||
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : commonBackColor);
|
||||
lvi.UseItemStyleForSubItems = false;
|
||||
lvi.SubItems.Add(texts[0]);
|
||||
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvi.SubItems.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
Results.Utils.GetCounterStates(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
|
||||
lview.Items.Add(lvi);
|
||||
}
|
||||
if (isLayoutChangedDueToConfig)
|
||||
{
|
||||
CreateControlsAndFillPanel(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
}
|
||||
|
||||
return lview;
|
||||
UpdateResults(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Redraw
|
||||
|
||||
/// <summary>
|
||||
/// Handle button at the top of this form: Propagate column widths
|
||||
/// </summary>
|
||||
private void columnWidthsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (firstListView == null) return;
|
||||
if (firstEnabledControl == null) return;
|
||||
|
||||
/// Update the column widths
|
||||
Program.LocalSettings.RsltsClmnWidths = new int[firstListView.Columns.Count];
|
||||
for (int i = 0; i < firstListView.Columns.Count; i++)
|
||||
/// Get column widths from the first control
|
||||
Program.LocalSettings.RsltsClmnWidths = new int[firstEnabledControl.Columns.Count];
|
||||
for (int i = 0; i < firstEnabledControl.Columns.Count; i++)
|
||||
{
|
||||
Program.LocalSettings.RsltsClmnWidths[i] = firstListView.Columns[i].Width;
|
||||
Program.LocalSettings.RsltsClmnWidths[i] = firstEnabledControl.Columns[i].Width;
|
||||
}
|
||||
Program.LocalSettings.Save();
|
||||
|
||||
@ -532,30 +303,243 @@ namespace TBF.Screens
|
||||
{
|
||||
Results.Utils.GetCounterStates(TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch, Program.LocalSettings.Counters);
|
||||
}
|
||||
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
|
||||
|
||||
UpdateColumnWidths(Program.LocalSettings.RsltsClmnWidths);
|
||||
}
|
||||
|
||||
///
|
||||
/// Handle other buttons at the top of this form
|
||||
///
|
||||
private void showPreviousResultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new TBF.Forms.PreviousResultsDlg().ShowDialog();
|
||||
}
|
||||
private void reloadPreviousResultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new TBF.Forms.PreviousResultsDlg(TBF.Forms.PreviousResultsMode.Reload).ShowDialog();
|
||||
}
|
||||
private void fixPreviousResultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new TBF.Forms.PreviousResultsDlg(TBF.Forms.PreviousResultsMode.Fix).ShowDialog();
|
||||
}
|
||||
|
||||
///
|
||||
/// Handle double-click inside a water meter results control
|
||||
///
|
||||
void OnDoubleClick(object sender, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
if (args.WM == null || args.WM.Disabled)
|
||||
int waterMetersCount = TBF.BenchControl.Sequences.ProcessData.BatchRslts.WaterMeters.Length;
|
||||
|
||||
Results.Entities.WaterMeter wm;
|
||||
if ((args.WMPosition <= 0) || (args.WMPosition > waterMetersCount) ||
|
||||
((wm = TBF.BenchControl.Sequences.ProcessData.BatchRslts.WaterMeters[args.WMPosition - 1]) == null))
|
||||
{
|
||||
MessageBox.Show(Strings.No_water_meter);
|
||||
return;
|
||||
}
|
||||
else if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(args.WM.SerialNr))
|
||||
|
||||
ShowMoreWMResults(wm);
|
||||
}
|
||||
|
||||
|
||||
void UpdateColumnWidths(int[] columnWidths)
|
||||
{
|
||||
foreach (var ctrl in wmRsltsCtrl) ctrl.Update(columnWidths);
|
||||
}
|
||||
|
||||
void UpdateScrollpositions(int scrollStart)
|
||||
{
|
||||
/// TODO
|
||||
}
|
||||
|
||||
|
||||
void UpdateItems(IList<Results.WMeterRsltItemSpec> items)
|
||||
{
|
||||
bool updateItems = false;
|
||||
if (currentItems.Count != items.Count)
|
||||
{
|
||||
new Results.Forms.MoreWMResultsDlg(args.WM, null).ShowDialog();
|
||||
/// Current and new item counts are different
|
||||
updateItems = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Current and new item counts are the same
|
||||
for (int i = 0; i < currentItems.Count; i++)
|
||||
{
|
||||
if (currentItems[i] != items[i])
|
||||
{
|
||||
updateItems = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateItems)
|
||||
{
|
||||
/// Update items in all controls
|
||||
currentItems = items;
|
||||
foreach (var oneCtrl in wmRsltsCtrl) oneCtrl.Update(items);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IsLayoutChangedDueToData(Results.BatchResults results)
|
||||
{
|
||||
if (results == null || results.WaterMeters == null || results.WaterMeters.Length == 0)
|
||||
{
|
||||
/// 'results' contain no water meters, wmRsltsCtrl.Lenght == 0 expected
|
||||
return (wmRsltsCtrl.Length != 0); /// true when there are currently water meters on screen
|
||||
}
|
||||
|
||||
///
|
||||
/// Determine water meter positions count
|
||||
///
|
||||
int displayedWatermetersCount = 0;
|
||||
for (int i = 0; i < results.WaterMeters.Length; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null)
|
||||
{
|
||||
if (ShowDisabledPositions || !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
displayedWatermetersCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (displayedWatermetersCount != wmRsltsCtrl.Length);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Re-draw the results. Apply new settings if they changed.
|
||||
/// </summary>
|
||||
void CreateControlsAndFillPanel(Results.BatchResults results)
|
||||
{
|
||||
if ((results == null) || (results.WMPositionsCount == 0))
|
||||
{
|
||||
/// There are no water meters at all
|
||||
flowLayoutPanel.Controls.Clear();
|
||||
wmRsltsCtrl = new OneWMResultsRowsCtrl[0];
|
||||
firstEnabledControl = null;
|
||||
return;
|
||||
}
|
||||
|
||||
///
|
||||
/// Determine water meter positions count
|
||||
///
|
||||
int displayedControlsCount = 0;
|
||||
for (int i = 0; i < results.WaterMeters.Length; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null)
|
||||
{
|
||||
if (ShowDisabledPositions || !results.WaterMeters[i].Disabled)
|
||||
{
|
||||
displayedControlsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Calculate geometry
|
||||
///
|
||||
metersInOneGroup = Math.Max(1, Math.Min(displayedControlsCount, NrMetersInOneGroup));
|
||||
nrGroups = Math.Max(1, (displayedControlsCount + metersInOneGroup - 1) / metersInOneGroup);
|
||||
|
||||
int oneWidth;
|
||||
int oneHeight;
|
||||
///
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
|
||||
}
|
||||
|
||||
///
|
||||
/// Create controls and fill the FlowLayoutPanel
|
||||
///
|
||||
flowLayoutPanel.SuspendLayout();
|
||||
flowLayoutPanel.Controls.Clear();
|
||||
flowLayoutPanel.WrapContents = true;
|
||||
flowLayoutPanel.AutoScroll = true;
|
||||
|
||||
wmRsltsCtrl = new IOneWMResultsCtrl[displayedControlsCount];
|
||||
int ix = 0;
|
||||
firstEnabledControl = null;
|
||||
for (int i = 0; i < results.WaterMeters.Length; i++)
|
||||
{
|
||||
if (results.WaterMeters[i] != null)
|
||||
{
|
||||
if (!results.WaterMeters[i].Disabled || ShowDisabledPositions)
|
||||
{
|
||||
/// Create one water meter position / control
|
||||
wmRsltsCtrl[ix] = (TestsArrangement == TestsArrangement.Rows)
|
||||
? new OneWMResultsRowsCtrl() as IOneWMResultsCtrl
|
||||
: new OneWMResultsColumnsCtrl() as IOneWMResultsCtrl;
|
||||
wmRsltsCtrl[ix].Width = oneWidth;
|
||||
wmRsltsCtrl[ix].Height = oneHeight;
|
||||
wmRsltsCtrl[ix].Update(currentItems);
|
||||
wmRsltsCtrl[ix].WMResultsClickedHandler += delegate(object s, Results.Forms.WaterMeterEventArgs args)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new EventHandler<Results.Forms.WaterMeterEventArgs>(OnDoubleClick), s, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnDoubleClick(s, args);
|
||||
}
|
||||
};
|
||||
|
||||
flowLayoutPanel.Controls.Add(wmRsltsCtrl[ix] as UserControl);
|
||||
if ((firstEnabledControl == null) && !results.WaterMeters[i].Disabled) firstEnabledControl = wmRsltsCtrl[ix];
|
||||
ix++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateColumnWidths(Program.LocalSettings.RsltsClmnWidths);
|
||||
|
||||
flowLayoutPanel.ResumeLayout();
|
||||
}
|
||||
|
||||
|
||||
void UpdateResults(Results.BatchResults batchResults)
|
||||
{
|
||||
if ((batchResults != null) && (batchResults.WaterMeters != null))
|
||||
{
|
||||
int ctrlIx = 0;
|
||||
for (int i = 0; i < batchResults.WaterMeters.Length; i++)
|
||||
{
|
||||
if (!batchResults.WaterMeters[i].Disabled || ShowDisabledPositions)
|
||||
{
|
||||
if (ctrlIx < wmRsltsCtrl.Length) wmRsltsCtrl[ctrlIx++].Update(batchResults.WaterMeters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShowMoreWMResults(Results.Entities.WaterMeter wm)
|
||||
{
|
||||
if ((TracingDB.DB.SessionFactory == null) || string.IsNullOrEmpty(wm.SerialNr))
|
||||
{
|
||||
new Results.Forms.MoreWMResultsDlg(wm, null).ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
IList<ReferenceRecord> refRecords = null;
|
||||
using (ISession session = TracingDB.DB.SessionFactory.OpenSession())
|
||||
{
|
||||
refRecords = session.QueryOver<ReferenceRecord>()
|
||||
.Where(x => (x.Code == args.WM.SerialNr))
|
||||
.OrderBy(x => x.TimeStamp).Desc
|
||||
.List();
|
||||
IList<ReferenceRecord> refRecords = session.QueryOver<ReferenceRecord>()
|
||||
.Where(x => (x.Code == wm.SerialNr))
|
||||
.OrderBy(x => x.TimeStamp).Desc
|
||||
.List();
|
||||
for (int i = 0; i < refRecords.Count; i++)
|
||||
{
|
||||
ReferenceRecord refR = refRecords[i];
|
||||
@ -579,7 +563,55 @@ namespace TBF.Screens
|
||||
}
|
||||
}
|
||||
|
||||
new Results.Forms.MoreWMResultsDlg(args.WM, refRecords).ShowDialog();
|
||||
new Results.Forms.MoreWMResultsDlg(wm, refRecords).ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void flowLayoutPanel_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
lastSizeChange = DateTime.Now;
|
||||
}
|
||||
|
||||
private void OnTimer(object source, EventArgs e)
|
||||
{
|
||||
if (DateTime.Compare(lastSizeChange, lastRedraw) > 0)
|
||||
{
|
||||
/// The last size change was more recent then the last redraw
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
if (DateTime.Compare(lastSizeChange + new TimeSpan(0, 0, 1), now) < 0)
|
||||
{
|
||||
/// More then 1 second since the last panel size change
|
||||
|
||||
/// Calculate geometry
|
||||
int oneWidth;
|
||||
int oneHeight;
|
||||
///
|
||||
if (MetersArrangement == MetersArrangement.Horizontally)
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / metersInOneGroup - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / nrGroups - 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
|
||||
oneWidth = Math.Max(MinWidth, flowLayoutPanel.Width / nrGroups - 6);
|
||||
oneHeight = Math.Max(MinHeight, flowLayoutPanel.Height / metersInOneGroup - 6);
|
||||
}
|
||||
|
||||
/// Update size of controls
|
||||
flowLayoutPanel.SuspendLayout();
|
||||
///
|
||||
foreach (var oneCtrl in wmRsltsCtrl)
|
||||
{
|
||||
oneCtrl.Width = oneWidth;
|
||||
oneCtrl.Height = oneHeight;
|
||||
}
|
||||
///
|
||||
flowLayoutPanel.ResumeLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user