Merge branch 'feature/task/Universal-feature-UI-button-Show' into ' develop/Local-master'
This commit is contained in:
+107
@@ -0,0 +1,107 @@
|
||||
namespace Results.Forms
|
||||
{
|
||||
partial class MeterTile
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null) components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.heading = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.caption = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.actions = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.meterCaption = new System.Windows.Forms.Label();
|
||||
this.verdict = new System.Windows.Forms.Label();
|
||||
this.openButton = new System.Windows.Forms.Button();
|
||||
this.detailsButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
this.heading.SuspendLayout();
|
||||
this.caption.SuspendLayout();
|
||||
this.actions.SuspendLayout();
|
||||
// heading: caption expands, actions remain anchored at the right edge.
|
||||
this.heading.Name = "heading";
|
||||
this.heading.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.heading.AutoSize = true;
|
||||
this.heading.ColumnCount = 2;
|
||||
this.heading.RowCount = 1;
|
||||
this.heading.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.heading.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.heading.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.heading.Controls.Add(this.caption, 0, 0);
|
||||
this.heading.Controls.Add(this.actions, 1, 0);
|
||||
this.caption.Name = "caption";
|
||||
this.caption.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.caption.AutoSize = true;
|
||||
this.caption.WrapContents = true;
|
||||
this.caption.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.caption.Controls.Add(this.meterCaption);
|
||||
this.caption.Controls.Add(this.verdict);
|
||||
this.meterCaption.Name = "meterCaption";
|
||||
this.meterCaption.Text = "P1 | Serial number";
|
||||
this.meterCaption.AutoSize = true;
|
||||
this.meterCaption.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Bold);
|
||||
this.meterCaption.Margin = new System.Windows.Forms.Padding(5, 7, 4, 0);
|
||||
this.verdict.Name = "verdict";
|
||||
this.verdict.Text = "OK";
|
||||
this.verdict.AutoSize = true;
|
||||
this.verdict.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Bold);
|
||||
this.verdict.Margin = new System.Windows.Forms.Padding(3, 7, 3, 0);
|
||||
this.actions.Name = "actions";
|
||||
this.actions.AutoSize = true;
|
||||
this.actions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.actions.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.actions.WrapContents = false;
|
||||
this.actions.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.actions.Controls.Add(this.openButton);
|
||||
this.actions.Controls.Add(this.detailsButton);
|
||||
this.openButton.Name = "openButton";
|
||||
this.openButton.Text = "Open";
|
||||
this.openButton.AutoSize = true;
|
||||
this.openButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.openButton.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.openButton.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.openButton.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.openButton.UseVisualStyleBackColor = true;
|
||||
this.openButton.Click += new System.EventHandler(this.OpenButton_Click);
|
||||
this.detailsButton.Name = "detailsButton";
|
||||
this.detailsButton.Text = "Graphs / tracing";
|
||||
this.detailsButton.AutoSize = true;
|
||||
this.detailsButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.detailsButton.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.detailsButton.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.detailsButton.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.detailsButton.UseVisualStyleBackColor = true;
|
||||
this.detailsButton.Click += new System.EventHandler(this.DetailsButton_Click);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.Name = "MeterTile";
|
||||
this.Size = new System.Drawing.Size(540, 300);
|
||||
this.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.Controls.Add(this.heading);
|
||||
this.actions.ResumeLayout(false);
|
||||
this.actions.PerformLayout();
|
||||
this.caption.ResumeLayout(false);
|
||||
this.caption.PerformLayout();
|
||||
this.heading.ResumeLayout(false);
|
||||
this.heading.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel heading;
|
||||
private System.Windows.Forms.FlowLayoutPanel caption;
|
||||
private System.Windows.Forms.FlowLayoutPanel actions;
|
||||
private System.Windows.Forms.Label meterCaption;
|
||||
private System.Windows.Forms.Label verdict;
|
||||
private System.Windows.Forms.Button openButton;
|
||||
private System.Windows.Forms.Button detailsButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
/// <summary>Designer-editable meter card shell. The workspace supplies table/chart content and verdict colours.</summary>
|
||||
public partial class MeterTile : UserControl
|
||||
{
|
||||
public MeterTile()
|
||||
{
|
||||
InitializeComponent();
|
||||
DoubleBuffered = true;
|
||||
}
|
||||
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Color FrameColor { get; set; }
|
||||
|
||||
public event EventHandler OpenRequested;
|
||||
public event EventHandler DetailsRequested;
|
||||
|
||||
public void SetResult(string captionText, string verdictText, Color headingColor,
|
||||
Color textColor, Color bodyColor, Control content)
|
||||
{
|
||||
meterCaption.Text = captionText;
|
||||
verdict.Text = verdictText;
|
||||
BackColor = bodyColor;
|
||||
heading.BackColor = caption.BackColor = actions.BackColor = headingColor;
|
||||
meterCaption.ForeColor = verdict.ForeColor = textColor;
|
||||
// Keep content directly on the card: wheel routing and linked scrolling locate it here.
|
||||
Controls.Add(content);
|
||||
Controls.SetChildIndex(content, 0);
|
||||
}
|
||||
|
||||
private void OpenButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (OpenRequested != null) OpenRequested(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void DetailsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DetailsRequested != null) DetailsRequested(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
ControlPaint.DrawBorder(e.Graphics, ClientRectangle,
|
||||
FrameColor, 3, ButtonBorderStyle.Solid, FrameColor, 3, ButtonBorderStyle.Solid,
|
||||
FrameColor, 3, ButtonBorderStyle.Solid, FrameColor, 3, ButtonBorderStyle.Solid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
public sealed class MeterViewport : Panel
|
||||
{
|
||||
// A focused child must not undo explicit wheel scrolling or resize positioning.
|
||||
protected override Point ScrollToControl(Control activeControl) { return DisplayRectangle.Location; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
// CheckedListBox does not support MultiExtended. Extend the checked selection,
|
||||
// keeping the native checkboxes as the single source of truth.
|
||||
public sealed class RangeCheckedListBox : CheckedListBox
|
||||
{
|
||||
private int anchor = -1;
|
||||
private bool extending;
|
||||
public Action<int, int, bool> RangeRequested;
|
||||
protected override void OnSelectedIndexChanged(EventArgs e)
|
||||
{
|
||||
base.OnSelectedIndexChanged(e);
|
||||
if (!extending && SelectedIndex >= 0) anchor = SelectedIndex;
|
||||
}
|
||||
private void ExtendTo(int index, bool additive)
|
||||
{
|
||||
if (index < 0 || index >= Items.Count) return;
|
||||
if (anchor < 0) anchor = SelectedIndex >= 0 ? SelectedIndex : index;
|
||||
extending = true;
|
||||
try
|
||||
{
|
||||
Focus();
|
||||
SelectedIndex = index;
|
||||
if (RangeRequested != null) RangeRequested(anchor, index, additive);
|
||||
}
|
||||
finally { extending = false; }
|
||||
}
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
const int MouseDown = 0x0201, MouseDoubleClick = 0x0203, KeyDown = 0x0100;
|
||||
if ((ModifierKeys & Keys.Shift) != 0)
|
||||
{
|
||||
if (m.Msg == MouseDown || m.Msg == MouseDoubleClick)
|
||||
{
|
||||
long point = m.LParam.ToInt64();
|
||||
ExtendTo(IndexFromPoint(new Point((short)(point & 0xffff), (short)((point >> 16) & 0xffff))),
|
||||
(ModifierKeys & Keys.Control) != 0);
|
||||
return;
|
||||
}
|
||||
if (m.Msg == KeyDown)
|
||||
{
|
||||
Keys key = (Keys)m.WParam.ToInt32();
|
||||
int target = SelectedIndex;
|
||||
if (key == Keys.Up) target = Math.Max(0, target - 1);
|
||||
else if (key == Keys.Down) target = Math.Min(Items.Count - 1, target + 1);
|
||||
else if (key == Keys.Home) target = 0;
|
||||
else if (key == Keys.End) target = Items.Count - 1;
|
||||
else { base.WndProc(ref m); return; }
|
||||
ExtendTo(target, (ModifierKeys & Keys.Control) != 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using WaterMeter = Results.Entities.WaterMeter;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
// Small WinForms controls used only by the results workspace.
|
||||
public sealed partial class ResultsWorkspaceDlg
|
||||
{
|
||||
private sealed class MeterChoice
|
||||
{
|
||||
public WaterMeter Meter { get; private set; }
|
||||
public string Caption { get { return MeterCaption(Meter); } }
|
||||
public MeterChoice(WaterMeter meter) { Meter = meter; }
|
||||
}
|
||||
|
||||
private static string MeterCaption(WaterMeter meter)
|
||||
{
|
||||
return "P" + meter.WMPosition + " | " + (string.IsNullOrEmpty(meter.SerialNr) ? "(no serial number)" : meter.SerialNr);
|
||||
}
|
||||
|
||||
private static DataGridView NewGrid()
|
||||
{
|
||||
return new DataGridView { Dock = DockStyle.Fill, ReadOnly = true, AllowUserToAddRows = false,
|
||||
AllowUserToDeleteRows = false, AllowUserToOrderColumns = true, RowHeadersVisible = false,
|
||||
BackgroundColor = SystemColors.Window, BorderStyle = BorderStyle.None,
|
||||
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None,
|
||||
SelectionMode = DataGridViewSelectionMode.CellSelect, ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
namespace Results.Forms
|
||||
{
|
||||
partial class ResultsWorkspaceDlg
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null) components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.layout = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.toolbar = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.overviewSettings = new System.Windows.Forms.GroupBox();
|
||||
this.overviewOptions = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.tableSettings = new System.Windows.Forms.GroupBox();
|
||||
this.tableOptions = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.viewSettings = new System.Windows.Forms.GroupBox();
|
||||
this.viewOptions = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.columnsLabel = new System.Windows.Forms.Label();
|
||||
this.rowsLabel = new System.Windows.Forms.Label();
|
||||
this.columns = new System.Windows.Forms.NumericUpDown();
|
||||
this.rows = new System.Windows.Forms.NumericUpDown();
|
||||
this.resultFields = new System.Windows.Forms.Button();
|
||||
this.linkedScroll = new System.Windows.Forms.CheckBox();
|
||||
this.saveView = new System.Windows.Forms.Button();
|
||||
this.loadView = new System.Windows.Forms.Button();
|
||||
this.originalView = new System.Windows.Forms.Button();
|
||||
this.split = new System.Windows.Forms.SplitContainer();
|
||||
this.sidebar = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.selectionLabel = new System.Windows.Forms.Label();
|
||||
this.meterList = new Results.Forms.RangeCheckedListBox();
|
||||
this.selectionButtons = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.selectAll = new System.Windows.Forms.Button();
|
||||
this.selectNone = new System.Windows.Forms.Button();
|
||||
this.moveUp = new System.Windows.Forms.Button();
|
||||
this.moveDown = new System.Windows.Forms.Button();
|
||||
this.onlySelected = new System.Windows.Forms.CheckBox();
|
||||
this.openSelected = new System.Windows.Forms.Button();
|
||||
this.tabs = new System.Windows.Forms.TabControl();
|
||||
this.overview = new System.Windows.Forms.TabPage();
|
||||
this.graphs = new System.Windows.Forms.TabPage();
|
||||
this.compare = new System.Windows.Forms.TabPage();
|
||||
this.tiles = new Results.Forms.MeterViewport();
|
||||
this.compareLayout = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.compareToolbar = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.compareLabel = new System.Windows.Forms.Label();
|
||||
this.compareItem = new System.Windows.Forms.ComboBox();
|
||||
this.comparison = new System.Windows.Forms.DataGridView();
|
||||
this.statusBar = new System.Windows.Forms.StatusStrip();
|
||||
this.status = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.columns)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.rows)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.split)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comparison)).BeginInit();
|
||||
this.layout.SuspendLayout();
|
||||
this.toolbar.SuspendLayout();
|
||||
this.overviewSettings.SuspendLayout();
|
||||
this.overviewOptions.SuspendLayout();
|
||||
this.tableSettings.SuspendLayout();
|
||||
this.tableOptions.SuspendLayout();
|
||||
this.viewSettings.SuspendLayout();
|
||||
this.viewOptions.SuspendLayout();
|
||||
this.columnsLabel.SuspendLayout();
|
||||
this.rowsLabel.SuspendLayout();
|
||||
this.columns.SuspendLayout();
|
||||
this.rows.SuspendLayout();
|
||||
this.resultFields.SuspendLayout();
|
||||
this.linkedScroll.SuspendLayout();
|
||||
this.saveView.SuspendLayout();
|
||||
this.loadView.SuspendLayout();
|
||||
this.originalView.SuspendLayout();
|
||||
this.split.SuspendLayout();
|
||||
this.sidebar.SuspendLayout();
|
||||
this.selectionLabel.SuspendLayout();
|
||||
this.meterList.SuspendLayout();
|
||||
this.selectionButtons.SuspendLayout();
|
||||
this.selectAll.SuspendLayout();
|
||||
this.selectNone.SuspendLayout();
|
||||
this.moveUp.SuspendLayout();
|
||||
this.moveDown.SuspendLayout();
|
||||
this.onlySelected.SuspendLayout();
|
||||
this.openSelected.SuspendLayout();
|
||||
this.tabs.SuspendLayout();
|
||||
this.overview.SuspendLayout();
|
||||
this.graphs.SuspendLayout();
|
||||
this.compare.SuspendLayout();
|
||||
this.tiles.SuspendLayout();
|
||||
this.compareLayout.SuspendLayout();
|
||||
this.compareToolbar.SuspendLayout();
|
||||
this.compareLabel.SuspendLayout();
|
||||
this.compareItem.SuspendLayout();
|
||||
this.comparison.SuspendLayout();
|
||||
this.statusBar.SuspendLayout();
|
||||
this.layout.Name = "layout";
|
||||
this.layout.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.layout.ColumnCount = 1;
|
||||
this.layout.RowCount = 3;
|
||||
this.toolbar.Name = "toolbar";
|
||||
this.toolbar.AutoSize = true;
|
||||
this.toolbar.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.toolbar.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.overviewSettings.Name = "overviewSettings";
|
||||
this.overviewSettings.Text = "Overview layout — displayed meters";
|
||||
this.overviewSettings.Size = new System.Drawing.Size(410, 76);
|
||||
this.overviewSettings.Padding = new System.Windows.Forms.Padding(8);
|
||||
this.overviewOptions.Name = "overviewOptions";
|
||||
this.overviewOptions.AutoSize = true;
|
||||
this.overviewOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.overviewOptions.WrapContents = false;
|
||||
this.overviewOptions.Location = new System.Drawing.Point(8, 23);
|
||||
this.overviewOptions.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tableSettings.Name = "tableSettings";
|
||||
this.tableSettings.Text = "Results tables — shared settings";
|
||||
this.tableSettings.Size = new System.Drawing.Size(255, 76);
|
||||
this.tableSettings.Padding = new System.Windows.Forms.Padding(8);
|
||||
this.tableOptions.Name = "tableOptions";
|
||||
this.tableOptions.AutoSize = true;
|
||||
this.tableOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.tableOptions.WrapContents = false;
|
||||
this.tableOptions.Location = new System.Drawing.Point(8, 23);
|
||||
this.tableOptions.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.viewSettings.Name = "viewSettings";
|
||||
this.viewSettings.Text = "View";
|
||||
this.viewSettings.Size = new System.Drawing.Size(290, 76);
|
||||
this.viewSettings.Padding = new System.Windows.Forms.Padding(8);
|
||||
this.viewOptions.Name = "viewOptions";
|
||||
this.viewOptions.AutoSize = true;
|
||||
this.viewOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.viewOptions.WrapContents = false;
|
||||
this.viewOptions.Location = new System.Drawing.Point(8, 23);
|
||||
this.viewOptions.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.columnsLabel.Name = "columnsLabel";
|
||||
this.columnsLabel.Text = "Meters per row (0 = auto)";
|
||||
this.columnsLabel.AutoSize = true;
|
||||
this.columnsLabel.Margin = new System.Windows.Forms.Padding(6, 8, 3, 0);
|
||||
this.rowsLabel.Name = "rowsLabel";
|
||||
this.rowsLabel.Text = "Visible meter rows";
|
||||
this.rowsLabel.AutoSize = true;
|
||||
this.rowsLabel.Margin = new System.Windows.Forms.Padding(6, 8, 3, 0);
|
||||
this.columns.Name = "columns";
|
||||
this.columns.Maximum = new decimal(new int[] { 16, 0, 0, 0 });
|
||||
this.columns.Size = new System.Drawing.Size(55, 23);
|
||||
this.columns.Margin = new System.Windows.Forms.Padding(3, 7, 8, 3);
|
||||
this.rows.Name = "rows";
|
||||
this.rows.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
this.rows.Maximum = new decimal(new int[] { 12, 0, 0, 0 });
|
||||
this.rows.Value = new decimal(new int[] { 2, 0, 0, 0 });
|
||||
this.rows.Size = new System.Drawing.Size(55, 23);
|
||||
this.rows.Margin = new System.Windows.Forms.Padding(3, 7, 8, 3);
|
||||
this.resultFields.Name = "resultFields";
|
||||
this.resultFields.Text = "Result fields...";
|
||||
this.resultFields.AutoSize = true;
|
||||
this.resultFields.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.resultFields.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.resultFields.UseVisualStyleBackColor = true;
|
||||
this.linkedScroll.Name = "linkedScroll";
|
||||
this.linkedScroll.Text = "Link table scrolling";
|
||||
this.linkedScroll.AutoSize = true;
|
||||
this.linkedScroll.Margin = new System.Windows.Forms.Padding(8, 9, 3, 3);
|
||||
this.saveView.Name = "saveView";
|
||||
this.saveView.Text = "Save view...";
|
||||
this.saveView.AutoSize = true;
|
||||
this.saveView.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.saveView.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.saveView.UseVisualStyleBackColor = true;
|
||||
this.loadView.Name = "loadView";
|
||||
this.loadView.Text = "Load view...";
|
||||
this.loadView.AutoSize = true;
|
||||
this.loadView.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.loadView.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.loadView.UseVisualStyleBackColor = true;
|
||||
this.originalView.Name = "originalView";
|
||||
this.originalView.Text = "Original view";
|
||||
this.originalView.AutoSize = true;
|
||||
this.originalView.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.originalView.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.originalView.UseVisualStyleBackColor = true;
|
||||
this.split.Name = "split";
|
||||
this.split.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.split.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
|
||||
this.split.Size = new System.Drawing.Size(1200, 650);
|
||||
this.split.SplitterDistance = 230;
|
||||
this.split.Panel1MinSize = 190;
|
||||
this.split.Panel2MinSize = 300;
|
||||
this.sidebar.Name = "sidebar";
|
||||
this.sidebar.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.sidebar.ColumnCount = 1;
|
||||
this.sidebar.RowCount = 5;
|
||||
this.sidebar.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.selectionLabel.Name = "selectionLabel";
|
||||
this.selectionLabel.Text = "Water meters / selection";
|
||||
this.selectionLabel.AutoSize = true;
|
||||
this.selectionLabel.Margin = new System.Windows.Forms.Padding(3);
|
||||
this.meterList.Name = "meterList";
|
||||
this.meterList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.meterList.CheckOnClick = true;
|
||||
this.meterList.HorizontalScrollbar = true;
|
||||
this.meterList.DisplayMember = "Caption";
|
||||
this.selectionButtons.Name = "selectionButtons";
|
||||
this.selectionButtons.AutoSize = true;
|
||||
this.selectionButtons.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.selectAll.Name = "selectAll";
|
||||
this.selectAll.Text = "All";
|
||||
this.selectAll.AutoSize = true;
|
||||
this.selectAll.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.selectAll.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.selectAll.UseVisualStyleBackColor = true;
|
||||
this.selectNone.Name = "selectNone";
|
||||
this.selectNone.Text = "None";
|
||||
this.selectNone.AutoSize = true;
|
||||
this.selectNone.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.selectNone.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.selectNone.UseVisualStyleBackColor = true;
|
||||
this.moveUp.Name = "moveUp";
|
||||
this.moveUp.Text = "Up";
|
||||
this.moveUp.AutoSize = true;
|
||||
this.moveUp.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.moveUp.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.moveUp.UseVisualStyleBackColor = true;
|
||||
this.moveDown.Name = "moveDown";
|
||||
this.moveDown.Text = "Down";
|
||||
this.moveDown.AutoSize = true;
|
||||
this.moveDown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.moveDown.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.moveDown.UseVisualStyleBackColor = true;
|
||||
this.onlySelected.Name = "onlySelected";
|
||||
this.onlySelected.Text = "Show only selected";
|
||||
this.onlySelected.AutoSize = true;
|
||||
this.openSelected.Name = "openSelected";
|
||||
this.openSelected.Text = "Open selected in new window";
|
||||
this.openSelected.AutoSize = true;
|
||||
this.openSelected.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.openSelected.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.openSelected.UseVisualStyleBackColor = true;
|
||||
this.tabs.Name = "tabs";
|
||||
this.tabs.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.overview.Name = "overview";
|
||||
this.overview.Text = "Tables overview";
|
||||
this.graphs.Name = "graphs";
|
||||
this.graphs.Text = "Graphs overview";
|
||||
this.compare.Name = "compare";
|
||||
this.compare.Text = "Compare selected";
|
||||
this.tiles.Name = "tiles";
|
||||
this.tiles.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tiles.AutoScroll = true;
|
||||
this.tiles.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.compareLayout.Name = "compareLayout";
|
||||
this.compareLayout.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.compareLayout.ColumnCount = 1;
|
||||
this.compareLayout.RowCount = 2;
|
||||
this.compareToolbar.Name = "compareToolbar";
|
||||
this.compareToolbar.AutoSize = true;
|
||||
this.compareToolbar.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.compareLabel.Name = "compareLabel";
|
||||
this.compareLabel.Text = "Compare field";
|
||||
this.compareLabel.AutoSize = true;
|
||||
this.compareLabel.Margin = new System.Windows.Forms.Padding(5, 8, 5, 0);
|
||||
this.compareItem.Name = "compareItem";
|
||||
this.compareItem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.compareItem.Size = new System.Drawing.Size(280, 23);
|
||||
this.comparison.Name = "comparison";
|
||||
this.comparison.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.comparison.ReadOnly = true;
|
||||
this.comparison.AllowUserToAddRows = false;
|
||||
this.comparison.AllowUserToDeleteRows = false;
|
||||
this.comparison.AllowUserToOrderColumns = true;
|
||||
this.comparison.RowHeadersVisible = false;
|
||||
this.comparison.BackgroundColor = System.Drawing.SystemColors.Window;
|
||||
this.comparison.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.comparison.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.None;
|
||||
this.comparison.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
|
||||
this.comparison.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
|
||||
this.statusBar.Name = "statusBar";
|
||||
this.status.Name = "status";
|
||||
this.layout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.layout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.layout.Controls.Add(this.toolbar, 0, 0);
|
||||
this.overviewSettings.Controls.Add(this.overviewOptions);
|
||||
this.tableSettings.Controls.Add(this.tableOptions);
|
||||
this.viewSettings.Controls.Add(this.viewOptions);
|
||||
this.toolbar.Controls.Add(this.overviewSettings);
|
||||
this.toolbar.Controls.Add(this.tableSettings);
|
||||
this.toolbar.Controls.Add(this.viewSettings);
|
||||
this.overviewOptions.Controls.Add(this.columnsLabel);
|
||||
this.overviewOptions.Controls.Add(this.columns);
|
||||
this.overviewOptions.Controls.Add(this.rowsLabel);
|
||||
this.overviewOptions.Controls.Add(this.rows);
|
||||
this.tableOptions.Controls.Add(this.resultFields);
|
||||
this.tableOptions.Controls.Add(this.linkedScroll);
|
||||
this.viewOptions.Controls.Add(this.saveView);
|
||||
this.viewOptions.Controls.Add(this.loadView);
|
||||
this.viewOptions.Controls.Add(this.originalView);
|
||||
this.layout.Controls.Add(this.split, 0, 1);
|
||||
this.sidebar.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.sidebar.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.sidebar.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.sidebar.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.sidebar.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.sidebar.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.split.Panel1.Controls.Add(this.sidebar);
|
||||
this.sidebar.Controls.Add(this.selectionLabel, 0, 0);
|
||||
this.sidebar.Controls.Add(this.meterList, 0, 1);
|
||||
this.sidebar.Controls.Add(this.selectionButtons, 0, 2);
|
||||
this.selectionButtons.Controls.Add(this.selectAll);
|
||||
this.selectionButtons.Controls.Add(this.selectNone);
|
||||
this.selectionButtons.Controls.Add(this.moveUp);
|
||||
this.selectionButtons.Controls.Add(this.moveDown);
|
||||
this.sidebar.Controls.Add(this.onlySelected, 0, 3);
|
||||
this.sidebar.Controls.Add(this.openSelected, 0, 4);
|
||||
this.split.Panel2.Controls.Add(this.tabs);
|
||||
this.tabs.Controls.Add(this.overview);
|
||||
this.tabs.Controls.Add(this.graphs);
|
||||
this.tabs.Controls.Add(this.compare);
|
||||
this.overview.Controls.Add(this.tiles);
|
||||
this.compareLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.compareLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
this.compareLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.compare.Controls.Add(this.compareLayout);
|
||||
this.compareLayout.Controls.Add(this.compareToolbar, 0, 0);
|
||||
this.compareToolbar.Controls.Add(this.compareLabel);
|
||||
this.compareToolbar.Controls.Add(this.compareItem);
|
||||
this.compareLayout.Controls.Add(this.comparison, 0, 1);
|
||||
this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.status });
|
||||
this.layout.Controls.Add(this.statusBar, 0, 2);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.ClientSize = new System.Drawing.Size(1234, 781);
|
||||
this.MinimumSize = new System.Drawing.Size(800, 500);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Name = "ResultsWorkspaceDlg";
|
||||
this.Text = "Results workspace";
|
||||
this.Controls.Add(this.layout);
|
||||
((System.ComponentModel.ISupportInitialize)(this.columns)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.rows)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.split)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.comparison)).EndInit();
|
||||
this.statusBar.ResumeLayout(false);
|
||||
this.statusBar.PerformLayout();
|
||||
this.comparison.ResumeLayout(false);
|
||||
this.comparison.PerformLayout();
|
||||
this.compareItem.ResumeLayout(false);
|
||||
this.compareItem.PerformLayout();
|
||||
this.compareLabel.ResumeLayout(false);
|
||||
this.compareLabel.PerformLayout();
|
||||
this.compareToolbar.ResumeLayout(false);
|
||||
this.compareToolbar.PerformLayout();
|
||||
this.compareLayout.ResumeLayout(false);
|
||||
this.compareLayout.PerformLayout();
|
||||
this.tiles.ResumeLayout(false);
|
||||
this.tiles.PerformLayout();
|
||||
this.compare.ResumeLayout(false);
|
||||
this.compare.PerformLayout();
|
||||
this.graphs.ResumeLayout(false);
|
||||
this.graphs.PerformLayout();
|
||||
this.overview.ResumeLayout(false);
|
||||
this.overview.PerformLayout();
|
||||
this.tabs.ResumeLayout(false);
|
||||
this.tabs.PerformLayout();
|
||||
this.openSelected.ResumeLayout(false);
|
||||
this.openSelected.PerformLayout();
|
||||
this.onlySelected.ResumeLayout(false);
|
||||
this.onlySelected.PerformLayout();
|
||||
this.moveDown.ResumeLayout(false);
|
||||
this.moveDown.PerformLayout();
|
||||
this.moveUp.ResumeLayout(false);
|
||||
this.moveUp.PerformLayout();
|
||||
this.selectNone.ResumeLayout(false);
|
||||
this.selectNone.PerformLayout();
|
||||
this.selectAll.ResumeLayout(false);
|
||||
this.selectAll.PerformLayout();
|
||||
this.selectionButtons.ResumeLayout(false);
|
||||
this.selectionButtons.PerformLayout();
|
||||
this.meterList.ResumeLayout(false);
|
||||
this.meterList.PerformLayout();
|
||||
this.selectionLabel.ResumeLayout(false);
|
||||
this.selectionLabel.PerformLayout();
|
||||
this.sidebar.ResumeLayout(false);
|
||||
this.sidebar.PerformLayout();
|
||||
this.split.ResumeLayout(false);
|
||||
this.split.PerformLayout();
|
||||
this.originalView.ResumeLayout(false);
|
||||
this.originalView.PerformLayout();
|
||||
this.loadView.ResumeLayout(false);
|
||||
this.loadView.PerformLayout();
|
||||
this.saveView.ResumeLayout(false);
|
||||
this.saveView.PerformLayout();
|
||||
this.linkedScroll.ResumeLayout(false);
|
||||
this.linkedScroll.PerformLayout();
|
||||
this.resultFields.ResumeLayout(false);
|
||||
this.resultFields.PerformLayout();
|
||||
this.rows.ResumeLayout(false);
|
||||
this.rows.PerformLayout();
|
||||
this.columns.ResumeLayout(false);
|
||||
this.columns.PerformLayout();
|
||||
this.rowsLabel.ResumeLayout(false);
|
||||
this.rowsLabel.PerformLayout();
|
||||
this.columnsLabel.ResumeLayout(false);
|
||||
this.columnsLabel.PerformLayout();
|
||||
this.viewOptions.ResumeLayout(false);
|
||||
this.viewOptions.PerformLayout();
|
||||
this.viewSettings.ResumeLayout(false);
|
||||
this.viewSettings.PerformLayout();
|
||||
this.tableOptions.ResumeLayout(false);
|
||||
this.tableOptions.PerformLayout();
|
||||
this.tableSettings.ResumeLayout(false);
|
||||
this.tableSettings.PerformLayout();
|
||||
this.overviewOptions.ResumeLayout(false);
|
||||
this.overviewOptions.PerformLayout();
|
||||
this.overviewSettings.ResumeLayout(false);
|
||||
this.overviewSettings.PerformLayout();
|
||||
this.toolbar.ResumeLayout(false);
|
||||
this.toolbar.PerformLayout();
|
||||
this.layout.ResumeLayout(false);
|
||||
this.layout.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel layout;
|
||||
private System.Windows.Forms.FlowLayoutPanel toolbar;
|
||||
private System.Windows.Forms.GroupBox overviewSettings;
|
||||
private System.Windows.Forms.FlowLayoutPanel overviewOptions;
|
||||
private System.Windows.Forms.GroupBox tableSettings;
|
||||
private System.Windows.Forms.FlowLayoutPanel tableOptions;
|
||||
private System.Windows.Forms.GroupBox viewSettings;
|
||||
private System.Windows.Forms.FlowLayoutPanel viewOptions;
|
||||
private System.Windows.Forms.Label columnsLabel;
|
||||
private System.Windows.Forms.Label rowsLabel;
|
||||
private System.Windows.Forms.NumericUpDown columns;
|
||||
private System.Windows.Forms.NumericUpDown rows;
|
||||
private System.Windows.Forms.Button resultFields;
|
||||
private System.Windows.Forms.CheckBox linkedScroll;
|
||||
private System.Windows.Forms.Button saveView;
|
||||
private System.Windows.Forms.Button loadView;
|
||||
private System.Windows.Forms.Button originalView;
|
||||
private System.Windows.Forms.SplitContainer split;
|
||||
private System.Windows.Forms.TableLayoutPanel sidebar;
|
||||
private System.Windows.Forms.Label selectionLabel;
|
||||
private Results.Forms.RangeCheckedListBox meterList;
|
||||
private System.Windows.Forms.FlowLayoutPanel selectionButtons;
|
||||
private System.Windows.Forms.Button selectAll;
|
||||
private System.Windows.Forms.Button selectNone;
|
||||
private System.Windows.Forms.Button moveUp;
|
||||
private System.Windows.Forms.Button moveDown;
|
||||
private System.Windows.Forms.CheckBox onlySelected;
|
||||
private System.Windows.Forms.Button openSelected;
|
||||
private System.Windows.Forms.TabControl tabs;
|
||||
private System.Windows.Forms.TabPage overview;
|
||||
private System.Windows.Forms.TabPage graphs;
|
||||
private System.Windows.Forms.TabPage compare;
|
||||
private Results.Forms.MeterViewport tiles;
|
||||
private System.Windows.Forms.TableLayoutPanel compareLayout;
|
||||
private System.Windows.Forms.FlowLayoutPanel compareToolbar;
|
||||
private System.Windows.Forms.Label compareLabel;
|
||||
private System.Windows.Forms.ComboBox compareItem;
|
||||
private System.Windows.Forms.DataGridView comparison;
|
||||
private System.Windows.Forms.StatusStrip statusBar;
|
||||
private System.Windows.Forms.ToolStripStatusLabel status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using WaterMeter = Results.Entities.WaterMeter;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
// Window lifecycle, pointer/keyboard routing, checked selection and linked table scrolling.
|
||||
public sealed partial class ResultsWorkspaceDlg
|
||||
{
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
// A tab selected before Show is applied when the native handle is created,
|
||||
// without necessarily raising SelectedIndexChanged. Attach and render its content now.
|
||||
if (runtimeInitialized) RefreshView();
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
if (runtimeInitialized) Application.AddMessageFilter(this);
|
||||
}
|
||||
|
||||
protected override void OnHandleDestroyed(EventArgs e)
|
||||
{
|
||||
Application.RemoveMessageFilter(this);
|
||||
base.OnHandleDestroyed(e);
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
base.OnActivated(e);
|
||||
if (runtimeInitialized) SetControlSelection((ModifierKeys & Keys.Control) != 0);
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(EventArgs e)
|
||||
{
|
||||
SetControlSelection(false);
|
||||
base.OnDeactivate(e);
|
||||
}
|
||||
|
||||
// The filter is application-wide, so reject messages unless this workspace is active.
|
||||
// Intercept before child grids/charts consume wheel and Ctrl+click messages.
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
if (IsDisposed || (!ContainsFocus && ActiveForm != this)) return false;
|
||||
if (m.Msg == 0x020A) // WM_MOUSEWHEEL: use the pointer, not the focused child grid.
|
||||
{
|
||||
long position = m.LParam.ToInt64();
|
||||
var screenPoint = new Point((short)(position & 0xffff), (short)((position >> 16) & 0xffff));
|
||||
int delta = (short)((m.WParam.ToInt64() >> 16) & 0xffff);
|
||||
bool control = (m.WParam.ToInt64() & 0x0008) != 0; // MK_CONTROL
|
||||
return ScrollOverviewWheel(screenPoint, delta, control);
|
||||
}
|
||||
const int KeyDown = 0x0100, KeyUp = 0x0101, MouseDown = 0x0201, MouseDoubleClick = 0x0203;
|
||||
if (m.Msg == KeyDown || m.Msg == KeyUp)
|
||||
{
|
||||
Keys key = (Keys)m.WParam.ToInt32();
|
||||
if (key == Keys.ControlKey || key == Keys.LControlKey || key == Keys.RControlKey)
|
||||
SetControlSelection(m.Msg == KeyDown);
|
||||
}
|
||||
if ((m.Msg == MouseDown || m.Msg == MouseDoubleClick) && (ModifierKeys & Keys.Control) != 0)
|
||||
{
|
||||
Control clicked = Control.FromHandle(m.HWnd);
|
||||
// Leave scrollbar dragging available even while Ctrl is held.
|
||||
if (clicked is ScrollBar) return false;
|
||||
while (clicked != null && !(clicked is MeterTile)) clicked = clicked.Parent;
|
||||
if (clicked != null && clicked.Parent == tiles)
|
||||
{
|
||||
ToggleMeter((WaterMeter)clicked.Tag);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ScrollOverviewWheel(Point screenPoint, int delta, bool control)
|
||||
{
|
||||
if (tabs.SelectedIndex == ComparisonTab || !tiles.Visible ||
|
||||
!tiles.RectangleToScreen(tiles.ClientRectangle).Contains(screenPoint)) return false;
|
||||
if (tabs.SelectedIndex == GraphsOverviewTab && control) return true;
|
||||
DataGridView grid = null;
|
||||
if (control)
|
||||
{
|
||||
var tile = tiles.Controls.OfType<MeterTile>()
|
||||
.FirstOrDefault(t => t.RectangleToScreen(t.ClientRectangle).Contains(screenPoint));
|
||||
if (tile != null) grid = tile.Controls.OfType<DataGridView>().FirstOrDefault();
|
||||
if (grid == null) return true;
|
||||
}
|
||||
Control target = control ? (Control)grid : tiles;
|
||||
if (wheelTarget != target) { wheelTarget = target; wheelRemainder = 0; }
|
||||
wheelRemainder += delta;
|
||||
int notches = wheelRemainder / 120;
|
||||
wheelRemainder %= 120;
|
||||
if (notches == 0 || SystemInformation.MouseWheelScrollLines == 0) return true;
|
||||
int distance = SystemInformation.MouseWheelScrollLines < 0
|
||||
? (control ? grid.ClientSize.Width : tiles.ClientSize.Height)
|
||||
: SystemInformation.MouseWheelScrollLines * Math.Max(1, Font.Height);
|
||||
if (control)
|
||||
{
|
||||
var bar = grid.Controls.OfType<HScrollBar>().FirstOrDefault();
|
||||
int max = bar != null && bar.Visible ? Math.Max(0, bar.Maximum - bar.LargeChange + 1) : 0;
|
||||
grid.HorizontalScrollingOffset = Math.Max(0, Math.Min(max, grid.HorizontalScrollingOffset - notches * distance));
|
||||
}
|
||||
else
|
||||
{
|
||||
int max = tiles.VerticalScroll.Visible ? Math.Max(0, tiles.VerticalScroll.Maximum - tiles.VerticalScroll.LargeChange + 1) : 0;
|
||||
int y = Math.Max(0, Math.Min(max, -tiles.AutoScrollPosition.Y - notches * distance));
|
||||
tiles.AutoScrollPosition = new Point(-tiles.AutoScrollPosition.X, y);
|
||||
}
|
||||
// Consume even at an edge: a child table must never take over normal wheel scrolling.
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SetControlSelection(bool pressed)
|
||||
{
|
||||
if (controlSelection == pressed) return;
|
||||
controlSelection = pressed;
|
||||
UpdateFrames();
|
||||
}
|
||||
|
||||
private void UpdateFrames()
|
||||
{
|
||||
var selected = new HashSet<WaterMeter>(SelectedMeters());
|
||||
foreach (MeterTile tile in tiles.Controls.OfType<MeterTile>())
|
||||
{
|
||||
tile.FrameColor = selected.Contains((WaterMeter)tile.Tag) ? Color.DodgerBlue :
|
||||
controlSelection ? Color.DarkOrange : SystemColors.ControlDark;
|
||||
tile.AccessibleDescription = selected.Contains((WaterMeter)tile.Tag) ? "Selected water meter" : "Unselected water meter";
|
||||
tile.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleMeter(WaterMeter meter)
|
||||
{
|
||||
int index = meterList.Items.Cast<MeterChoice>().ToList().FindIndex(c => ReferenceEquals(c.Meter, meter));
|
||||
if (index < 0) return;
|
||||
meterList.SelectedIndex = index;
|
||||
meterList.SetItemChecked(index, !meterList.GetItemChecked(index));
|
||||
UpdateFrames();
|
||||
}
|
||||
|
||||
private void SelectRange(int anchor, int target, bool additive)
|
||||
{
|
||||
updating = true;
|
||||
try
|
||||
{
|
||||
int start = Math.Min(anchor, target), end = Math.Max(anchor, target);
|
||||
for (int i = 0; i < meterList.Items.Count; i++)
|
||||
meterList.SetItemChecked(i, (i >= start && i <= end) || (additive && meterList.GetItemChecked(i)));
|
||||
}
|
||||
finally { updating = false; }
|
||||
QueueSelectionRefresh();
|
||||
UpdateFrames();
|
||||
}
|
||||
|
||||
private void QueueSelectionRefresh()
|
||||
{
|
||||
if (selectionRefreshPending || !IsHandleCreated || IsDisposed) return;
|
||||
selectionRefreshPending = true;
|
||||
BeginInvoke((Action)(() =>
|
||||
{
|
||||
selectionRefreshPending = false;
|
||||
if (IsDisposed) return;
|
||||
// Keep the same grids, widths and scroll positions when only selection changes.
|
||||
if (onlySelected.Checked) RefreshView();
|
||||
else { RefreshSelectionStatus(); UpdateFrames(); if (tabs.SelectedIndex == ComparisonTab) RefreshComparison(); }
|
||||
}));
|
||||
}
|
||||
|
||||
private IEnumerable<DataGridView> OverviewGrids()
|
||||
{
|
||||
return tiles.Controls.OfType<MeterTile>().SelectMany(t => t.Controls.OfType<DataGridView>());
|
||||
}
|
||||
|
||||
// Link offsets, not measurement rows: meters may have different row counts and widths.
|
||||
// Clamp each destination independently and suppress the resulting recursive Scroll events.
|
||||
private void SynchronizeScroll(DataGridView source, ScrollOrientation orientation)
|
||||
{
|
||||
if (!linkedScroll.Checked || synchronizingScroll || source.IsDisposed) return;
|
||||
synchronizingScroll = true;
|
||||
try
|
||||
{
|
||||
foreach (var grid in OverviewGrids().Where(g => g != source && !g.IsDisposed))
|
||||
{
|
||||
if (orientation == ScrollOrientation.HorizontalScroll)
|
||||
{
|
||||
var bar = grid.Controls.OfType<HScrollBar>().FirstOrDefault();
|
||||
int max = bar != null && bar.Visible ? Math.Max(0, bar.Maximum - bar.LargeChange + 1) : 0;
|
||||
grid.HorizontalScrollingOffset = Math.Min(source.HorizontalScrollingOffset, max);
|
||||
}
|
||||
else if (source.FirstDisplayedScrollingRowIndex >= 0 && grid.Rows.Count > 0)
|
||||
{
|
||||
int index = Math.Min(source.FirstDisplayedScrollingRowIndex, grid.Rows.Count - 1);
|
||||
while (index >= 0 && (!grid.Rows[index].Visible || grid.Rows[index].Frozen)) index--;
|
||||
if (index >= 0) grid.FirstDisplayedScrollingRowIndex = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { synchronizingScroll = false; }
|
||||
}
|
||||
|
||||
private List<WaterMeter> SelectedMeters()
|
||||
{
|
||||
return meterList.CheckedItems.Cast<MeterChoice>().Select(c => c.Meter).ToList();
|
||||
}
|
||||
|
||||
private void SelectAll(bool selected)
|
||||
{
|
||||
updating = true;
|
||||
for (int i = 0; i < meterList.Items.Count; i++) meterList.SetItemChecked(i, selected);
|
||||
updating = false;
|
||||
if (onlySelected.Checked) RefreshView();
|
||||
else { RefreshSelectionStatus(); UpdateFrames(); if (tabs.SelectedIndex == ComparisonTab) RefreshComparison(); }
|
||||
}
|
||||
|
||||
private void MoveMeter(int direction)
|
||||
{
|
||||
int index = meterList.SelectedIndex, target = index + direction;
|
||||
if (index < 0 || target < 0 || target >= meterList.Items.Count) return;
|
||||
updating = true;
|
||||
var item = meterList.Items[index]; bool check = meterList.GetItemChecked(index);
|
||||
meterList.Items.RemoveAt(index); meterList.Items.Insert(target, item);
|
||||
meterList.SetItemChecked(target, check); meterList.SelectedIndex = target;
|
||||
updating = false;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
using WaterMeter = Results.Entities.WaterMeter;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
// Overview rebuilding, meter cards, charts, grid geometry and comparison rendering.
|
||||
public sealed partial class ResultsWorkspaceDlg
|
||||
{
|
||||
private void RefreshFields()
|
||||
{
|
||||
updating = true;
|
||||
int previous = compareItem.SelectedIndex;
|
||||
compareItem.Items.Clear();
|
||||
foreach (var item in items) compareItem.Items.Add(item.Caption ?? item.Name);
|
||||
if (items.Count > 0) compareItem.SelectedIndex = Math.Max(0, Math.Min(previous, items.Count - 1));
|
||||
updating = false;
|
||||
}
|
||||
|
||||
// Full rebuild: use for mode, fields, ordering or visibility changes. A checkmark-only
|
||||
// change goes through QueueSelectionRefresh so existing table scroll positions survive.
|
||||
private void RefreshView()
|
||||
{
|
||||
var selected = SelectedMeters();
|
||||
RefreshSelectionStatus();
|
||||
tableSettings.Enabled = tabs.SelectedIndex != GraphsOverviewTab;
|
||||
if (tabs.SelectedIndex == ComparisonTab) { RefreshComparison(); return; }
|
||||
// Reuse the same raster and selection behaviour for both overview modes.
|
||||
var overviewPage = tabs.TabPages[tabs.SelectedIndex == GraphsOverviewTab ? GraphsOverviewTab : TablesOverviewTab];
|
||||
if (tiles.Parent != overviewPage) overviewPage.Controls.Add(tiles);
|
||||
tiles.SuspendLayout();
|
||||
try
|
||||
{
|
||||
while (tiles.Controls.Count > 0) { var control = tiles.Controls[0]; tiles.Controls.RemoveAt(0); control.Dispose(); }
|
||||
var visible = meterList.Items.Cast<MeterChoice>().Select(c => c.Meter)
|
||||
.Where(m => !onlySelected.Checked || selected.Contains(m)).ToList();
|
||||
foreach (var meter in visible) tiles.Controls.Add(CreateTile(meter));
|
||||
if (visible.Count == 0) tiles.Controls.Add(new Label { AutoSize = true, Text = "No water meters to display." });
|
||||
ResizeTiles();
|
||||
UpdateFrames();
|
||||
}
|
||||
finally { tiles.ResumeLayout(); }
|
||||
}
|
||||
|
||||
private void RefreshSelectionStatus()
|
||||
{
|
||||
int count = SelectedMeters().Count;
|
||||
openSelected.Enabled = count > 0;
|
||||
status.Text = string.Format("Selected {0} / {1}. Wheel: overview; Ctrl+wheel: table horizontally. Ctrl+click: toggle; Shift+click list: range. Blue = selected.", count, meters.Count);
|
||||
if (tabs.SelectedIndex == GraphsOverviewTab)
|
||||
status.Text = string.Format("Selected {0} / {1}. Graphs: relative error vs flow. Wheel: overview; Ctrl+click: toggle; Shift+click list: range.", count, meters.Count);
|
||||
}
|
||||
|
||||
// Shared card shell for tables and graphs. Tag preserves meter identity for Ctrl+click;
|
||||
// frame colour expresses selection, while heading/body colour expresses the verdict.
|
||||
private Control CreateTile(WaterMeter meter)
|
||||
{
|
||||
string verdict;
|
||||
Color verdictColor = meter.GetColorOfResults(false, out verdict);
|
||||
// Workspace palette only; leave the legacy result colours and status evaluation intact.
|
||||
if (verdictColor.ToArgb() == Color.LightGreen.ToArgb()) verdictColor = Color.FromArgb(34, 158, 78);
|
||||
else if (verdictColor.ToArgb() == Color.LightPink.ToArgb()) verdictColor = Color.FromArgb(185, 28, 28);
|
||||
Color verdictTextColor = verdictColor.GetBrightness() < 0.45F ? Color.White : Color.Black;
|
||||
// Keep the full status colour in the meter heading; use a soft 22% tint in the body.
|
||||
Color bodyColor = Color.FromArgb(255 - (255 - verdictColor.R) * 22 / 100,
|
||||
255 - (255 - verdictColor.G) * 22 / 100, 255 - (255 - verdictColor.B) * 22 / 100);
|
||||
var panel = new MeterTile { Margin = new Padding(4), Tag = meter, BackColor = bodyColor };
|
||||
Control content = tabs.SelectedIndex == GraphsOverviewTab ? CreateMeterGraph(meter, bodyColor) : CreateMeterGrid(meter, bodyColor);
|
||||
panel.SetResult(MeterCaption(meter), verdict, verdictColor, verdictTextColor, bodyColor, content);
|
||||
panel.OpenRequested += (s, e) => OpenMeters(new List<WaterMeter> { meter });
|
||||
panel.DetailsRequested += (s, e) => OpenMore(meter);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private DataGridView CreateMeterGrid(WaterMeter meter, Color bodyColor)
|
||||
{
|
||||
var grid = NewGrid();
|
||||
grid.BackgroundColor = bodyColor;
|
||||
grid.DefaultCellStyle.BackColor = bodyColor;
|
||||
grid.DefaultCellStyle.ForeColor = Color.Black;
|
||||
grid.EnableHeadersVisualStyles = false;
|
||||
grid.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(240, 240, 240);
|
||||
grid.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black;
|
||||
grid.Columns.Add("test", "Test"); grid.Columns[0].Width = 120;
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
grid.Columns.Add("item" + i, items[i].Caption ?? items[i].Name);
|
||||
grid.Columns[i + 1].Width = columnWidths.ContainsKey(i) ? columnWidths[i] : 110;
|
||||
}
|
||||
foreach (string test in meter.GetAllDecoratedTestNames())
|
||||
{
|
||||
int row = grid.Rows.Add(); grid.Rows[row].Cells[0].Value = test;
|
||||
for (int i = 0; i < items.Count; i++) SetCell(grid.Rows[row].Cells[i + 1], items[i].Print(meter, test));
|
||||
}
|
||||
foreach (DataGridViewColumn column in grid.Columns) column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
grid.ColumnWidthChanged += (s, e) => { if (e.Column.Index > 0) columnWidths[e.Column.Index - 1] = e.Column.Width; };
|
||||
grid.CellDoubleClick += (s, e) => { if ((ModifierKeys & Keys.Control) == 0) OpenMeters(new List<WaterMeter> { meter }); };
|
||||
grid.Scroll += (s, e) => SynchronizeScroll(grid, e.ScrollOrientation);
|
||||
return grid;
|
||||
}
|
||||
|
||||
private Control CreateMeterGraph(WaterMeter meter, Color bodyColor)
|
||||
{
|
||||
Chart chart = null;
|
||||
try
|
||||
{
|
||||
if (meter.WaterMeterData == null)
|
||||
return GraphMessage("Meter parameters are unavailable.", bodyColor);
|
||||
chart = Output.WMChart.GetChart(meter, false);
|
||||
// Docking can temporarily leave no space below a wrapped meter heading.
|
||||
// Chart.OnResize throws for zero dimensions, including during initial layout.
|
||||
chart.MinimumSize = new Size(1, 1);
|
||||
bool hasPoints = chart.Series.Cast<Series>().Any(s => s.ChartType == SeriesChartType.Point && s.Points.Count > 0);
|
||||
if (!hasPoints)
|
||||
{
|
||||
chart.Dispose();
|
||||
return GraphMessage("No published flow/error results to plot.", bodyColor);
|
||||
}
|
||||
chart.BackColor = bodyColor;
|
||||
foreach (ChartArea area in chart.ChartAreas)
|
||||
{
|
||||
area.BackColor = Color.White;
|
||||
area.AxisX.MajorGrid.LineColor = Color.Gainsboro;
|
||||
area.AxisY.MajorGrid.LineColor = Color.Gainsboro;
|
||||
}
|
||||
foreach (Legend legend in chart.Legends)
|
||||
{
|
||||
legend.Docking = Docking.Bottom;
|
||||
legend.BackColor = bodyColor;
|
||||
}
|
||||
foreach (Series series in chart.Series)
|
||||
series.ToolTip = "#SERIESNAME: #VALX, #VALY %";
|
||||
chart.DoubleClick += (s, e) => { if ((ModifierKeys & Keys.Control) == 0) OpenMeters(new List<WaterMeter> { meter }); };
|
||||
return chart;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (chart != null) chart.Dispose();
|
||||
log4net.LogManager.GetLogger(typeof(ResultsWorkspaceDlg)).Warn("Cannot create graph for " + MeterCaption(meter), ex);
|
||||
return GraphMessage("Graph unavailable for these results.", bodyColor);
|
||||
}
|
||||
}
|
||||
|
||||
private static Label GraphMessage(string text, Color background)
|
||||
{
|
||||
return new Label { Dock = DockStyle.Fill, Text = text, TextAlign = ContentAlignment.MiddleCenter,
|
||||
BackColor = background, ForeColor = Color.Black };
|
||||
}
|
||||
|
||||
private void ResizeTiles()
|
||||
{
|
||||
if (arranging || tiles.IsDisposed || tiles.ClientSize.Width < 1) return;
|
||||
arranging = true;
|
||||
tiles.SuspendLayout();
|
||||
try
|
||||
{
|
||||
// Calculate from the viewport, never the previous scrollable content size.
|
||||
// Reserve scrollbar space consistently so adding a scrollbar cannot change the raster.
|
||||
int availableWidth = Math.Max(1, tiles.Width - SystemInformation.VerticalScrollBarWidth - 8);
|
||||
int availableHeight = Math.Max(1, tiles.Height - SystemInformation.HorizontalScrollBarHeight - 8);
|
||||
int count = columns.Value == 0 ? Math.Max(1, availableWidth / 420) : (int)columns.Value;
|
||||
int width = Math.Max(300, availableWidth / count - 8);
|
||||
int height = Math.Max(190, availableHeight / (int)rows.Value - 8);
|
||||
var panels = tiles.Controls.OfType<MeterTile>().ToList();
|
||||
int totalRows = (panels.Count + count - 1) / count;
|
||||
// Explicitly describe BOTH axes; the last row must remain reachable after maximize/restore.
|
||||
tiles.AutoScrollMinSize = panels.Count == 0 ? Size.Empty :
|
||||
new Size(Math.Min(count, panels.Count) * (width + 8) + 8, totalRows * (height + 8) + 8);
|
||||
Point offset = tiles.AutoScrollPosition;
|
||||
for (int i = 0; i < panels.Count; i++)
|
||||
panels[i].Bounds = new Rectangle(4 + (i % count) * (width + 8) + offset.X,
|
||||
4 + (i / count) * (height + 8) + offset.Y, width, height);
|
||||
}
|
||||
finally { tiles.ResumeLayout(true); arranging = false; }
|
||||
}
|
||||
|
||||
// WMeterRsltItemSpec.Print may append a legacy "|Green" / "|Red" colour hint.
|
||||
// Interpret it only for this cell, independently of the overall meter verdict.
|
||||
private static void SetCell(DataGridViewCell cell, string value)
|
||||
{
|
||||
string[] parts = (value ?? string.Empty).Split('|');
|
||||
cell.Value = string.IsNullOrWhiteSpace(parts[0]) ? "—" : parts[0];
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
if (parts[1] == "Green") { cell.Style.BackColor = Color.Honeydew; cell.Style.ForeColor = Color.DarkGreen; }
|
||||
if (parts[1] == "Red") { cell.Style.BackColor = Color.MistyRose; cell.Style.ForeColor = Color.DarkRed; }
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshComparison()
|
||||
{
|
||||
comparison.Rows.Clear(); comparison.Columns.Clear();
|
||||
var selected = SelectedMeters();
|
||||
if (selected.Count < 2 || compareItem.SelectedIndex < 0)
|
||||
{
|
||||
status.Text = selected.Count < 2 ? "Select at least two meters to compare." : "Choose result columns first.";
|
||||
return;
|
||||
}
|
||||
comparison.Columns.Add("test", "Test"); comparison.Columns[0].Width = 170;
|
||||
for (int i = 0; i < selected.Count; i++)
|
||||
{
|
||||
comparison.Columns.Add("meter" + i, MeterCaption(selected[i]));
|
||||
comparison.Columns[i + 1].Width = 170;
|
||||
}
|
||||
var names = selected.Select(m => m.GetAllDecoratedTestNames()).ToList();
|
||||
var field = items[compareItem.SelectedIndex];
|
||||
foreach (string test in names.SelectMany(n => n).Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
int row = comparison.Rows.Add(); comparison.Rows[row].Cells[0].Value = test;
|
||||
for (int i = 0; i < selected.Count; i++)
|
||||
{
|
||||
var cell = comparison.Rows[row].Cells[i + 1];
|
||||
int matches = names[i].Count(n => string.Equals(n, test, StringComparison.Ordinal));
|
||||
// Never silently align duplicate test names or turn a missing test into zero.
|
||||
if (matches != 1) cell.Value = matches == 0 ? "—" : "Ambiguous test";
|
||||
else SetCell(cell, field.Print(selected[i], test));
|
||||
}
|
||||
}
|
||||
foreach (DataGridViewColumn column in comparison.Columns) column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
status.Text = "Comparison by exact test name; — = missing result. Repeated names are marked ambiguous.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using Common;
|
||||
using SharedDatabase.Entities;
|
||||
using WaterMeter = Results.Entities.WaterMeter;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
// Result field configuration, independent child windows, legacy details and XML view presets.
|
||||
public sealed partial class ResultsWorkspaceDlg
|
||||
{
|
||||
private void ConfigureColumns()
|
||||
{
|
||||
using (var dialog = new ResultsConfigDlg(true))
|
||||
{
|
||||
dialog.SelectedItems = items.Select(i => i.Clone()).ToList();
|
||||
var data = meters.Select(m => m.WaterMeterData).FirstOrDefault(d => d != null);
|
||||
dialog.MetersKind = data != null && data.Compound ? MetersKind.Combined :
|
||||
data != null && data.HeatMeter ? MetersKind.HeatMeter : MetersKind.Single;
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
items = dialog.SelectedItems.Select(i => i.Clone()).ToList();
|
||||
columnWidths.Clear(); RefreshFields(); RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenSelected() { OpenMeters(SelectedMeters()); }
|
||||
|
||||
// Child windows share result objects but own controls and cloned field settings.
|
||||
// A single meter starts at 1 x 1; several meters inherit the parent's raster.
|
||||
private void OpenMeters(List<WaterMeter> selected)
|
||||
{
|
||||
if (selected.Count == 0) return;
|
||||
var window = new ResultsWorkspaceDlg(selected, items, null)
|
||||
{
|
||||
Text = Text + " — " + (selected.Count == 1 ? MeterCaption(selected[0]) : selected.Count + " meters")
|
||||
};
|
||||
window.columns.Value = selected.Count == 1 ? 1 : columns.Value;
|
||||
window.rows.Value = selected.Count == 1 ? 1 : rows.Value;
|
||||
window.linkedScroll.Checked = linkedScroll.Checked;
|
||||
if (tabs.SelectedIndex == GraphsOverviewTab) window.tabs.SelectedIndex = GraphsOverviewTab;
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void OpenMore(WaterMeter meter)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SharedDatabase.TracingDB.SessionFactory == null || string.IsNullOrEmpty(meter.SerialNr))
|
||||
{
|
||||
using (var dialog = new MoreWMResultsDlg(meter, null)) dialog.ShowDialog(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var session = SharedDatabase.TracingDB.SessionFactory.OpenSession())
|
||||
{
|
||||
var records = session.QueryOver<ReferenceRecord>().Where(r => r.Code1 == meter.SerialNr)
|
||||
.OrderBy(r => r.Timestamp).Desc.List();
|
||||
using (var dialog = new MoreWMResultsDlg(meter, records)) dialog.ShowDialog(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show(this, ex.Message, "Cannot open meter details", MessageBoxButtons.OK, MessageBoxIcon.Error); }
|
||||
}
|
||||
|
||||
// Version 1 is a presentation preset, not a saved batch: no result data, meter selection,
|
||||
// active tab or scroll offsets are serialized. Keep LoadView compatible with older presets.
|
||||
private void SaveView()
|
||||
{
|
||||
using (var dialog = new SaveFileDialog { Filter = "Results view (*.xml)|*.xml", DefaultExt = "xml", FileName = "results-view.xml" })
|
||||
{
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
try
|
||||
{
|
||||
new XElement("ResultsWorkspace", new XAttribute("version", 1),
|
||||
new XAttribute("columns", columns.Value), new XAttribute("rows", rows.Value),
|
||||
new XAttribute("linkedScroll", linkedScroll.Checked),
|
||||
new XElement("Items", WMeterRsltItemSpec.ToStrArray(items).Select(s => new XElement("Item", s))))
|
||||
.Save(dialog.FileName);
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show(this, ex.Message, "Cannot save view", MessageBoxButtons.OK, MessageBoxIcon.Error); }
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadView()
|
||||
{
|
||||
using (var dialog = new OpenFileDialog { Filter = "Results view (*.xml)|*.xml" })
|
||||
{
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
try
|
||||
{
|
||||
var view = XElement.Load(dialog.FileName);
|
||||
if (view.Name != "ResultsWorkspace" || (int?)view.Attribute("version") != 1 || view.Element("Items") == null)
|
||||
throw new InvalidDataException("Unsupported results view.");
|
||||
int c = (int)view.Attribute("columns"), r = (int)view.Attribute("rows");
|
||||
if (c < columns.Minimum || c > columns.Maximum || r < rows.Minimum || r > rows.Maximum)
|
||||
throw new InvalidDataException("Invalid grid dimensions.");
|
||||
var loaded = WMeterRsltItemSpec.FromStrArray(view.Element("Items").Elements("Item").Select(e => e.Value).ToArray());
|
||||
bool link = (bool?)view.Attribute("linkedScroll") ?? false;
|
||||
items = loaded.Select(i => i.Clone()).ToList();
|
||||
columns.Value = c; rows.Value = r;
|
||||
columnWidths.Clear(); RefreshFields(); RefreshView();
|
||||
linkedScroll.Checked = link;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show(this, ex.Message, "Cannot load view", MessageBoxButtons.OK, MessageBoxIcon.Error); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using WaterMeter = Results.Entities.WaterMeter;
|
||||
|
||||
namespace Results.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Independent, read-only results workspace. Presentation settings and selections belong
|
||||
/// to this window; neither the batch nor the legacy screen configuration is modified.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Start here for state and runtime wiring; Designer contains the static UI. Interaction handles input and selection;
|
||||
/// Rendering builds the active view; Views handles child windows and XML presets;
|
||||
/// Controls contains the small WinForms helpers.
|
||||
/// All control access and refresh operations run on the UI thread.
|
||||
/// </remarks>
|
||||
public sealed partial class ResultsWorkspaceDlg : Form, IMessageFilter
|
||||
{
|
||||
// Keep these in the same order as TabPages.Add below.
|
||||
private const int TablesOverviewTab = 0;
|
||||
private const int GraphsOverviewTab = 1;
|
||||
private const int ComparisonTab = 2;
|
||||
|
||||
// Meter objects are shared read-only; field specifications are cloned per window.
|
||||
private readonly List<WaterMeter> meters;
|
||||
private List<WMeterRsltItemSpec> items;
|
||||
// Key = index in items (excludes the leading Test column). Reset when fields change.
|
||||
private readonly Dictionary<int, int> columnWidths = new Dictionary<int, int>();
|
||||
// Suppress intermediate events while a selection or field list is being updated.
|
||||
private bool updating;
|
||||
// Layout and synchronized scroll setters raise their own events; prevent re-entry.
|
||||
private bool arranging;
|
||||
private bool controlSelection;
|
||||
private bool selectionRefreshPending;
|
||||
private bool synchronizingScroll;
|
||||
// High-resolution wheels may send less than one notch; accumulate per target control.
|
||||
private int wheelRemainder;
|
||||
private Control wheelTarget;
|
||||
private bool runtimeInitialized;
|
||||
|
||||
/// <summary>Opens enabled meters, optionally filtered by serial number, with independent view settings.</summary>
|
||||
/// <param name="results">Source batch; its meters and measurement results are not modified.</param>
|
||||
/// <param name="initialItems">Initial table fields, cloned before use.</param>
|
||||
/// <param name="serialNrs">Null includes all enabled meters; otherwise only matching serial numbers.</param>
|
||||
/// <param name="openLegacy">Optional action for Original view; absent in child workspaces.</param>
|
||||
public ResultsWorkspaceDlg(BatchResults results, IList<WMeterRsltItemSpec> initialItems,
|
||||
IList<string> serialNrs, Action openLegacy)
|
||||
: this(results.Batch.WaterMeters.Where(w => !w.Disabled &&
|
||||
(serialNrs == null || serialNrs.Contains(w.SerialNr))).ToList(), initialItems, openLegacy)
|
||||
{
|
||||
}
|
||||
|
||||
private ResultsWorkspaceDlg(List<WaterMeter> waterMeters,
|
||||
IList<WMeterRsltItemSpec> initialItems, Action openLegacy)
|
||||
{
|
||||
meters = waterMeters.ToList();
|
||||
items = (initialItems ?? new List<WMeterRsltItemSpec>()).Select(i => i.Clone()).ToList();
|
||||
InitializeComponent();
|
||||
Icon = Properties.Resources.TBF_icon;
|
||||
originalView.Visible = openLegacy != null;
|
||||
originalView.Click += (s, e) => { if (openLegacy != null) openLegacy(); };
|
||||
if (meters.Count == 1) { columns.Value = 1; rows.Value = 1; }
|
||||
foreach (var meter in meters) meterList.Items.Add(new MeterChoice(meter), true);
|
||||
runtimeInitialized = true;
|
||||
WireRuntimeEvents();
|
||||
RefreshFields();
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
/// <summary>Designer constructor: builds only the static UI, without batch data or message filters.</summary>
|
||||
public ResultsWorkspaceDlg()
|
||||
{
|
||||
meters = new List<WaterMeter>();
|
||||
items = new List<WMeterRsltItemSpec>();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void WireRuntimeEvents()
|
||||
{
|
||||
resultFields.Click += (s, e) => ConfigureColumns();
|
||||
saveView.Click += (s, e) => SaveView();
|
||||
loadView.Click += (s, e) => LoadView();
|
||||
selectAll.Click += (s, e) => SelectAll(true);
|
||||
selectNone.Click += (s, e) => SelectAll(false);
|
||||
moveUp.Click += (s, e) => MoveMeter(-1);
|
||||
moveDown.Click += (s, e) => MoveMeter(1);
|
||||
openSelected.Click += (s, e) => OpenSelected();
|
||||
// ItemCheck fires before CheckedItems changes. Defer one UI turn.
|
||||
meterList.ItemCheck += (s, e) => { if (!updating) QueueSelectionRefresh(); };
|
||||
meterList.RangeRequested = SelectRange;
|
||||
meterList.DoubleClick += (s, e) => { var choice = meterList.SelectedItem as MeterChoice; if (choice != null && ModifierKeys == Keys.None) OpenMeters(new List<WaterMeter> { choice.Meter }); };
|
||||
linkedScroll.CheckedChanged += (s, e) =>
|
||||
{
|
||||
var source = OverviewGrids().FirstOrDefault(g => g.ContainsFocus) ?? OverviewGrids().FirstOrDefault();
|
||||
if (source != null) { SynchronizeScroll(source, ScrollOrientation.HorizontalScroll); SynchronizeScroll(source, ScrollOrientation.VerticalScroll); }
|
||||
};
|
||||
onlySelected.CheckedChanged += (s, e) => { if (!updating) RefreshView(); };
|
||||
columns.ValueChanged += (s, e) => ResizeTiles();
|
||||
rows.ValueChanged += (s, e) => ResizeTiles();
|
||||
tiles.ClientSizeChanged += (s, e) => ResizeTiles();
|
||||
compareItem.SelectedIndexChanged += (s, e) => { if (!updating) RefreshComparison(); };
|
||||
tabs.SelectedIndexChanged += (s, e) => RefreshView();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+35
-1
@@ -85,6 +85,40 @@
|
||||
<Compile Include="Entities\WaterMeterData.cs" />
|
||||
<Compile Include="Entities\WaterMeter.cs" />
|
||||
<Compile Include="DB.cs" />
|
||||
<Compile Include="Forms\ResultsWorkspace\ResultsWorkspaceDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\ResultsWorkspaceDlg.Designer.cs">
|
||||
<DependentUpon>ResultsWorkspaceDlg.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\MeterTile.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\MeterTile.Designer.cs">
|
||||
<DependentUpon>MeterTile.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\MeterViewport.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\RangeCheckedListBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\ResultsWorkspaceDlg.Controls.cs">
|
||||
<DependentUpon>ResultsWorkspaceDlg.cs</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\ResultsWorkspaceDlg.Interaction.cs">
|
||||
<DependentUpon>ResultsWorkspaceDlg.cs</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\ResultsWorkspaceDlg.Rendering.cs">
|
||||
<DependentUpon>ResultsWorkspaceDlg.cs</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ResultsWorkspace\ResultsWorkspaceDlg.Views.cs">
|
||||
<DependentUpon>ResultsWorkspaceDlg.cs</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\BatchResultsDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -288,4 +322,4 @@
|
||||
<Compile Include="Mappings\MeterTestCalibFactorRsltMap.cs" />
|
||||
<Compile Include="Mappings\TestRsltCalibFactorMap.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.9.3147.106")]
|
||||
[assembly: AssemblyFileVersion("3.9.3147.106")]
|
||||
[assembly: AssemblyVersion("3.9.3147.107")]
|
||||
[assembly: AssemblyFileVersion("3.9.3147.107")]
|
||||
|
||||
@@ -447,7 +447,7 @@ namespace TBF.UI.ResultsMI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens batch details using the configured meter-specific result layout and serial-number filter.
|
||||
/// Opens the independent results workspace, retaining the original view as a fallback.
|
||||
/// </summary>
|
||||
public void DoShowResults(object sender, PreviousResultIdEventArgs data)
|
||||
{
|
||||
@@ -488,26 +488,36 @@ namespace TBF.UI.ResultsMI
|
||||
items = new List<WMeterRsltItemSpec>();
|
||||
}
|
||||
|
||||
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg
|
||||
Action openLegacy = () =>
|
||||
{
|
||||
Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
|
||||
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,
|
||||
SerialNrs = data.SerialNrs,
|
||||
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg
|
||||
{
|
||||
Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
|
||||
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,
|
||||
SerialNrs = data.SerialNrs,
|
||||
};
|
||||
|
||||
dlg.Show();
|
||||
};
|
||||
|
||||
dlg.Show();
|
||||
var workspace = new Results.Forms.ResultsWorkspaceDlg(BatchResults.FromBatch(b), items,
|
||||
data.SerialNrs, openLegacy)
|
||||
{
|
||||
Text = string.Format(Strings.Results_of_batch_0, b.BatchNr),
|
||||
};
|
||||
workspace.Show();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Forms.DataVisualization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Xylem.Common.Metrology.Measurements">
|
||||
@@ -110,6 +111,7 @@
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="UI\ResultsMI\BatchOkNokDiagnosticsTests.cs" />
|
||||
<Compile Include="UI\ResultsMI\ResultsWorkspaceTests.cs" />
|
||||
<Compile Include="Entities\MeasurementCorrectionTest.cs" />
|
||||
<Compile Include="Rig\DataEntry\Uni\RegisterReaderSelectionTests.cs" />
|
||||
<Compile Include="Rig\DataEntry\Uni\SmartMeterReaderFamilyTests.cs" />
|
||||
|
||||
@@ -0,0 +1,440 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Results;
|
||||
using Results.Entities;
|
||||
using Results.Forms;
|
||||
|
||||
namespace TBFTests.UI.ResultsMI
|
||||
{
|
||||
[TestClass]
|
||||
public class ResultsWorkspaceTests
|
||||
{
|
||||
private sealed class Meter : WaterMeter
|
||||
{
|
||||
public readonly List<string> Tests = new List<string>();
|
||||
public override IList<string> GetAllDecoratedTestNames() { return Tests; }
|
||||
}
|
||||
|
||||
private static T Field<T>(object instance, string name)
|
||||
{
|
||||
return (T)instance.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance);
|
||||
}
|
||||
|
||||
private static void Call(object instance, string name, params object[] args)
|
||||
{
|
||||
instance.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, args);
|
||||
}
|
||||
|
||||
private static void Sta(Action action)
|
||||
{
|
||||
Exception error = null;
|
||||
var thread = new Thread(() => { try { action(); } catch (Exception e) { error = e; } });
|
||||
thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join();
|
||||
if (error != null) throw new AssertFailedException(error.ToString());
|
||||
}
|
||||
|
||||
private static BatchResults Results(params WaterMeter[] meters)
|
||||
{
|
||||
var batch = new Batch();
|
||||
foreach (var meter in meters) { meter.Batch = batch; batch.WaterMeters.Add(meter); }
|
||||
return new BatchResults { Batch = batch };
|
||||
}
|
||||
|
||||
private static List<WMeterRsltItemSpec> Columns()
|
||||
{
|
||||
return new List<WMeterRsltItemSpec> { WMeterRsltItemSpec.AllItems.First(i => i.Uid == (int)ItemID.Serial_Nr).Clone() };
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SerialFilterAndDisabledPositions_PreserveSourceBatchAndDistinctPositions()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var source = Results(new Meter { WMPosition = 1, SerialNr = "same" },
|
||||
new Meter { WMPosition = 2, SerialNr = "same" },
|
||||
new Meter { WMPosition = 3, SerialNr = "other" },
|
||||
new Meter { WMPosition = 4, SerialNr = "same", Disabled = true });
|
||||
using (var window = new ResultsWorkspaceDlg(source, Columns(), new[] { "same" }, null))
|
||||
{
|
||||
var list = Field<CheckedListBox>(window, "meterList");
|
||||
Assert.AreEqual(2, list.Items.Count);
|
||||
Assert.AreEqual(2, list.CheckedItems.Count);
|
||||
Assert.AreEqual(4, source.Batch.WaterMeters.Count);
|
||||
Call(window, "SelectAll", false);
|
||||
Field<CheckBox>(window, "onlySelected").Checked = true;
|
||||
Assert.AreEqual(0, Field<Panel>(window, "tiles").Controls.Cast<Control>().Count(c => c is Panel));
|
||||
Assert.AreEqual(4, source.Batch.WaterMeters.Count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Comparison_AlignsNamesAndMarksMissingAndAmbiguousTests()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var first = new Meter { WMPosition = 1, SerialNr = "A" };
|
||||
first.Tests.AddRange(new[] { "Q3", "Q1", "Repeated", "Repeated" });
|
||||
var second = new Meter { WMPosition = 2, SerialNr = "B" };
|
||||
second.Tests.AddRange(new[] { "Q1", "Q2", "Repeated" });
|
||||
using (var window = new ResultsWorkspaceDlg(Results(first, second), Columns(), null, null))
|
||||
{
|
||||
Field<TabControl>(window, "tabs").SelectedIndex = 2;
|
||||
Call(window, "RefreshComparison");
|
||||
var grid = Field<DataGridView>(window, "comparison");
|
||||
var q1 = grid.Rows.Cast<DataGridViewRow>().Single(r => (string)r.Cells[0].Value == "Q1");
|
||||
Assert.AreEqual("A", q1.Cells[1].Value);
|
||||
Assert.AreEqual("B", q1.Cells[2].Value);
|
||||
var q3 = grid.Rows.Cast<DataGridViewRow>().Single(r => (string)r.Cells[0].Value == "Q3");
|
||||
Assert.AreEqual("—", q3.Cells[2].Value);
|
||||
var repeated = grid.Rows.Cast<DataGridViewRow>().Single(r => (string)r.Cells[0].Value == "Repeated");
|
||||
Assert.AreEqual("Ambiguous test", repeated.Cells[1].Value);
|
||||
Assert.AreEqual("B", repeated.Cells[2].Value);
|
||||
Assert.AreEqual(4, first.Tests.Count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WorkspaceColumns_AreIsolatedFromLegacySettingsAndOtherWindows()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var columns = Columns();
|
||||
var source = Results(new Meter { WMPosition = 1 });
|
||||
using (var first = new ResultsWorkspaceDlg(source, columns, null, null))
|
||||
using (var second = new ResultsWorkspaceDlg(source, columns, null, null))
|
||||
{
|
||||
string original = columns[0].Caption;
|
||||
Field<List<WMeterRsltItemSpec>>(first, "items")[0].Caption = "Changed";
|
||||
Assert.AreEqual(original, columns[0].Caption);
|
||||
Assert.AreEqual(original, Field<List<WMeterRsltItemSpec>>(second, "items")[0].Caption);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExplicitRaster_KeepsRequestedColumnsWhenHorizontalScrollingIsNeeded()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var meters = Enumerable.Range(1, 7).Select(i => (WaterMeter)new Meter { WMPosition = i }).ToArray();
|
||||
using (var window = new ResultsWorkspaceDlg(Results(meters), Columns(), null, null))
|
||||
{
|
||||
window.Opacity = 0; window.ShowInTaskbar = false;
|
||||
window.Size = new Size(900, 600);
|
||||
window.Show();
|
||||
Field<NumericUpDown>(window, "columns").Value = 6;
|
||||
Application.DoEvents();
|
||||
var tiles = Field<Panel>(window, "tiles");
|
||||
Assert.AreEqual(tiles.Controls[0].Top, tiles.Controls[5].Top);
|
||||
Assert.IsTrue(tiles.Controls[6].Top > tiles.Controls[0].Top);
|
||||
Assert.IsTrue(tiles.HorizontalScroll.Visible,
|
||||
"Client=" + tiles.ClientSize + "; display=" + tiles.DisplayRectangle + "; window=" + window.Size);
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OverviewSelectionAndListRange_ShareChecksAndFrameColorsWithoutRecreatingGrids()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var meters = Enumerable.Range(1, 5).Select(i => (WaterMeter)new Meter { WMPosition = i }).ToArray();
|
||||
using (var window = new ResultsWorkspaceDlg(Results(meters), Columns(), null, null))
|
||||
{
|
||||
window.Opacity = 0; window.ShowInTaskbar = false; window.Show();
|
||||
var list = Field<CheckedListBox>(window, "meterList");
|
||||
var tiles = Field<Panel>(window, "tiles");
|
||||
var originalTile = tiles.Controls[0];
|
||||
Func<int, Color> color = i => (Color)tiles.Controls[i].GetType().GetProperty("FrameColor").GetValue(tiles.Controls[i]);
|
||||
Call(window, "SelectAll", false);
|
||||
Call(window, "SetControlSelection", true);
|
||||
Assert.AreEqual(Color.DarkOrange, color(0));
|
||||
Call(window, "ToggleMeter", meters[0]);
|
||||
Application.DoEvents();
|
||||
Assert.IsTrue(list.GetItemChecked(0));
|
||||
Assert.AreEqual(Color.DodgerBlue, color(0));
|
||||
Assert.AreSame(originalTile, tiles.Controls[0]);
|
||||
Call(window, "ToggleMeter", meters[0]);
|
||||
Application.DoEvents();
|
||||
Assert.IsFalse(list.GetItemChecked(0));
|
||||
Assert.AreEqual(Color.DarkOrange, color(0));
|
||||
|
||||
list.SelectedIndex = 1;
|
||||
Call(list, "ExtendTo", 3, false);
|
||||
Application.DoEvents();
|
||||
CollectionAssert.AreEqual(new[] { 1, 2, 3 }, list.CheckedIndices.Cast<int>().ToArray());
|
||||
Assert.AreEqual(Color.DodgerBlue, color(2));
|
||||
Call(list, "ExtendTo", 2, false);
|
||||
Application.DoEvents();
|
||||
CollectionAssert.AreEqual(new[] { 1, 2 }, list.CheckedIndices.Cast<int>().ToArray());
|
||||
list.SetItemChecked(4, true);
|
||||
Call(list, "ExtendTo", 0, true);
|
||||
Application.DoEvents();
|
||||
CollectionAssert.AreEqual(new[] { 0, 1, 2, 4 }, list.CheckedIndices.Cast<int>().ToArray());
|
||||
Call(window, "OnDeactivate", EventArgs.Empty);
|
||||
Assert.AreEqual(SystemColors.ControlDark, color(3));
|
||||
Assert.AreEqual(Color.DodgerBlue, color(4));
|
||||
Assert.AreSame(originalTile, tiles.Controls[0]);
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LinkedScrolling_PropagatesBothAxesAndClampsShortAndEmptyTables()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var meters = Enumerable.Range(1, 4).Select(i => new Meter { WMPosition = i }).ToArray();
|
||||
foreach (var meter in meters.Take(2)) meter.Tests.AddRange(Enumerable.Range(1, 80).Select(i => "Q" + i));
|
||||
meters[2].Tests.AddRange(new[] { "Q1", "Q2" });
|
||||
var fields = Enumerable.Range(0, 8).Select(i => Columns()[0]).ToList();
|
||||
using (var window = new ResultsWorkspaceDlg(Results(meters), fields, null, null))
|
||||
{
|
||||
window.Opacity = 0; window.ShowInTaskbar = false; window.Show();
|
||||
Field<NumericUpDown>(window, "columns").Value = 2;
|
||||
Application.DoEvents();
|
||||
var grids = Field<Panel>(window, "tiles").Controls.Cast<Control>()
|
||||
.SelectMany(t => t.Controls.OfType<DataGridView>()).ToArray();
|
||||
Field<CheckBox>(window, "linkedScroll").Checked = true;
|
||||
grids[0].FirstDisplayedScrollingRowIndex = 20;
|
||||
grids[0].HorizontalScrollingOffset = 160;
|
||||
Application.DoEvents();
|
||||
Assert.AreEqual(20, grids[1].FirstDisplayedScrollingRowIndex);
|
||||
Assert.AreEqual(grids[0].HorizontalScrollingOffset, grids[1].HorizontalScrollingOffset);
|
||||
Assert.IsTrue(grids[1].HorizontalScrollingOffset > 0);
|
||||
Assert.IsTrue(grids[2].FirstDisplayedScrollingRowIndex <= 1);
|
||||
Assert.AreEqual(-1, grids[3].FirstDisplayedScrollingRowIndex);
|
||||
grids[1].FirstDisplayedScrollingRowIndex = 10;
|
||||
Assert.AreEqual(10, grids[0].FirstDisplayedScrollingRowIndex);
|
||||
Call(window, "ToggleMeter", meters[0]);
|
||||
Application.DoEvents();
|
||||
Assert.AreEqual(10, grids[0].FirstDisplayedScrollingRowIndex);
|
||||
Assert.IsFalse(grids[0].IsDisposed);
|
||||
Field<CheckBox>(window, "linkedScroll").Checked = false;
|
||||
int offset = grids[1].HorizontalScrollingOffset;
|
||||
grids[0].FirstDisplayedScrollingRowIndex = 30;
|
||||
grids[0].HorizontalScrollingOffset = 0;
|
||||
Assert.AreEqual(10, grids[1].FirstDisplayedScrollingRowIndex);
|
||||
Assert.AreEqual(offset, grids[1].HorizontalScrollingOffset);
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MouseWheel_RoutesToOverviewInNormalAndMaximizedWindows_AndCtrlToHoveredTable()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var meters = Enumerable.Range(1, 10).Select(i => new Meter { WMPosition = i }).ToArray();
|
||||
foreach (var meter in meters) meter.Tests.AddRange(Enumerable.Range(1, 60).Select(i => "Q" + i));
|
||||
var fields = Enumerable.Range(0, 12).Select(i => Columns()[0]).ToList();
|
||||
using (var window = new ResultsWorkspaceDlg(Results(meters), fields, null, null))
|
||||
{
|
||||
window.Opacity = 0; window.ShowInTaskbar = false; window.Show();
|
||||
Field<NumericUpDown>(window, "columns").Value = 2;
|
||||
var tiles = Field<Panel>(window, "tiles");
|
||||
var first = tiles.Controls[0].Controls.OfType<DataGridView>().Single();
|
||||
var second = tiles.Controls[1].Controls.OfType<DataGridView>().Single();
|
||||
foreach (var state in new[] { FormWindowState.Normal, FormWindowState.Maximized })
|
||||
{
|
||||
window.WindowState = state;
|
||||
Application.DoEvents();
|
||||
tiles.AutoScrollPosition = Point.Empty;
|
||||
first.Focus(); // The focused grid must not steal the wheel from the overview.
|
||||
var point = first.PointToScreen(new Point(20, 40));
|
||||
Assert.IsTrue(Wheel(window, first, point, -120, false));
|
||||
Assert.IsTrue(tiles.AutoScrollPosition.Y < 0, state.ToString());
|
||||
Assert.AreEqual(0, first.FirstDisplayedScrollingRowIndex);
|
||||
Assert.AreEqual(0, first.HorizontalScrollingOffset);
|
||||
|
||||
tiles.AutoScrollPosition = Point.Empty;
|
||||
second.HorizontalScrollingOffset = 0;
|
||||
point = second.PointToScreen(new Point(20, 40));
|
||||
Assert.IsTrue(Wheel(window, first, point, -120, true));
|
||||
Assert.IsTrue(second.HorizontalScrollingOffset > 0, "Ctrl wheel must use the hovered table, not the focused table.");
|
||||
Assert.AreEqual(0, first.HorizontalScrollingOffset);
|
||||
Assert.AreEqual(0, tiles.AutoScrollPosition.Y);
|
||||
|
||||
// At the top edge, normal wheel is still consumed rather than scrolling a table.
|
||||
Assert.IsTrue(Wheel(window, first, point, 120, false));
|
||||
Assert.AreEqual(0, tiles.AutoScrollPosition.Y);
|
||||
Assert.AreEqual(0, second.FirstDisplayedScrollingRowIndex);
|
||||
second.HorizontalScrollingOffset = 0;
|
||||
}
|
||||
Field<CheckBox>(window, "linkedScroll").Checked = true;
|
||||
var hovered = second.PointToScreen(new Point(20, 40));
|
||||
Assert.IsTrue(Wheel(window, first, hovered, -120, true));
|
||||
Assert.AreEqual(second.HorizontalScrollingOffset, first.HorizontalScrollingOffset);
|
||||
var list = Field<CheckedListBox>(window, "meterList");
|
||||
Assert.IsFalse(Wheel(window, list, list.PointToScreen(new Point(10, 10)), -120, false));
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static bool Wheel(ResultsWorkspaceDlg window, Control recipient, Point position, int delta, bool control)
|
||||
{
|
||||
var message = Message.Create(recipient.Handle, 0x020A,
|
||||
new IntPtr(unchecked(((delta & 0xffff) << 16) | (control ? 8 : 0))),
|
||||
new IntPtr(unchecked(((position.Y & 0xffff) << 16) | (position.X & 0xffff))));
|
||||
return window.PreFilterMessage(ref message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AutoRaster_EightSingleResultMeters_LastMeterReachableAfterRepeatedMaximizeAndRestore()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var meters = Enumerable.Range(1, 8).Select(i => new Meter { WMPosition = i }).ToArray();
|
||||
foreach (var meter in meters) meter.Tests.Add("FLOW35GPM");
|
||||
using (var window = new ResultsWorkspaceDlg(Results(meters), Columns(), null, null))
|
||||
{
|
||||
window.Opacity = 0; window.ShowInTaskbar = false; window.Show();
|
||||
var viewport = Field<Panel>(window, "tiles");
|
||||
for (int cycle = 0; cycle < 3; cycle++)
|
||||
{
|
||||
foreach (var state in new[] { FormWindowState.Normal, FormWindowState.Maximized })
|
||||
{
|
||||
window.WindowState = state;
|
||||
if (state == FormWindowState.Normal) window.Size = new Size(1250 - cycle * 100, 820);
|
||||
Application.DoEvents();
|
||||
viewport.AutoScrollPosition = Point.Empty;
|
||||
Assert.AreEqual(8, viewport.Controls.Count);
|
||||
Assert.IsTrue(viewport.VerticalScroll.Visible, "Missing overview scrollbar: " + state);
|
||||
Assert.IsTrue(viewport.AutoScrollMinSize.Height > viewport.ClientSize.Height);
|
||||
var visibleViewport = viewport.RectangleToScreen(viewport.ClientRectangle);
|
||||
var windowArea = window.RectangleToScreen(window.ClientRectangle);
|
||||
Assert.IsTrue(windowArea.Contains(visibleViewport), "Viewport is clipped by the form.");
|
||||
var firstGrid = viewport.Controls[0].Controls.OfType<DataGridView>().Single();
|
||||
firstGrid.Focus();
|
||||
Assert.IsTrue(Wheel(window, firstGrid, firstGrid.PointToScreen(new Point(20, 40)), -120, false));
|
||||
Assert.IsTrue(viewport.AutoScrollPosition.Y < 0);
|
||||
viewport.AutoScrollPosition = new Point(0, viewport.AutoScrollMinSize.Height);
|
||||
Application.DoEvents();
|
||||
var last = viewport.Controls[7];
|
||||
Assert.IsTrue(last.Top >= 0 && last.Bottom <= viewport.ClientSize.Height,
|
||||
"Last meter is unreachable: " + last.Bounds + " / " + viewport.ClientSize);
|
||||
Assert.AreEqual(0, firstGrid.FirstDisplayedScrollingRowIndex);
|
||||
}
|
||||
}
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GraphOverview_RendersResultsAndEmptyStates_AndSharesSelectionWithTables()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
var meter = new WaterMeter { WMPosition = 1, SerialNr = "graph",
|
||||
WaterMeterData = new WaterMeterData { Q1_Qmin = .025, Q2_Qt = .04, Q3_Qn = 2.5,
|
||||
Q4_Qmax = 3.125, Qnames = (sbyte)Common.FlowNames.Q3Q2Q1, ErrLimLoQ = 5, ErrLimHiQ = 2 } };
|
||||
meter.MeterTestRslts.Add(new MeterTestRslt { WaterMeter = meter, TestDone = true,
|
||||
CompoundMeterId = (byte)Common.CompoundMeterId.Single, Error = .5,
|
||||
TestRslt = new TestRslt { Flow = 2.5, TestData = new TestData { Name = "Q3",
|
||||
Evaluate = true, Publish = (sbyte)Common.Publish.Always } } });
|
||||
var missing = new Meter { WMPosition = 2 };
|
||||
var empty = new Meter { WMPosition = 3, WaterMeterData = meter.WaterMeterData };
|
||||
using (var window = new ResultsWorkspaceDlg(Results(meter, missing, empty), Columns(), null, null))
|
||||
{
|
||||
window.Opacity = 0; window.ShowInTaskbar = false; window.Show();
|
||||
var tabs = Field<TabControl>(window, "tabs");
|
||||
Assert.AreEqual("Tables overview", tabs.TabPages[0].Text);
|
||||
Assert.AreEqual("Graphs overview", tabs.TabPages[1].Text);
|
||||
tabs.SelectedIndex = 1;
|
||||
Application.DoEvents();
|
||||
var viewport = Field<Panel>(window, "tiles");
|
||||
Assert.AreSame(tabs.TabPages[1], viewport.Parent);
|
||||
Assert.AreEqual(3, viewport.Controls.Count);
|
||||
var chart = viewport.Controls[0].Controls.OfType<System.Windows.Forms.DataVisualization.Charting.Chart>().Single();
|
||||
Assert.IsTrue(chart.Series.Cast<System.Windows.Forms.DataVisualization.Charting.Series>()
|
||||
.Any(s => s.ChartType == System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point && s.Points.Count == 1));
|
||||
// A wrapped title or an intermediate docking pass can consume the whole tile.
|
||||
var graphTile = chart.Parent;
|
||||
Size originalSize = graphTile.Size;
|
||||
graphTile.Size = new Size(100, 20);
|
||||
graphTile.PerformLayout();
|
||||
Assert.IsTrue(chart.Width > 0 && chart.Height > 0);
|
||||
graphTile.Size = originalSize;
|
||||
using (var bitmap = new Bitmap(window.Width, window.Height))
|
||||
window.DrawToBitmap(bitmap, new Rectangle(Point.Empty, window.Size));
|
||||
Assert.IsTrue(viewport.Controls[1].Controls.OfType<Label>().Any(l => l.Text.Contains("parameters")));
|
||||
Assert.IsTrue(viewport.Controls[2].Controls.OfType<Label>().Any(l => l.Text.Contains("No published")));
|
||||
AssertSelectedWindowImmediatelyVisible(window, 1, 3);
|
||||
Call(window, "SelectAll", false);
|
||||
Call(window, "ToggleMeter", meter);
|
||||
Field<CheckBox>(window, "onlySelected").Checked = true;
|
||||
Application.DoEvents();
|
||||
Assert.AreEqual(1, viewport.Controls.Count);
|
||||
AssertSelectedWindowImmediatelyVisible(window, 1, 1);
|
||||
tabs.SelectedIndex = 0;
|
||||
Application.DoEvents();
|
||||
Assert.AreSame(tabs.TabPages[0], viewport.Parent);
|
||||
Assert.AreEqual(1, viewport.Controls.Count);
|
||||
Assert.IsTrue(viewport.Controls[0].Controls.OfType<DataGridView>().Any());
|
||||
AssertSelectedWindowImmediatelyVisible(window, 0, 1);
|
||||
Assert.IsTrue(chart.IsDisposed);
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EmptyBatchAndEmptyColumns_AreSupported()
|
||||
{
|
||||
Sta(() =>
|
||||
{
|
||||
using (var window = new ResultsWorkspaceDlg(Results(), new List<WMeterRsltItemSpec>(), null, null))
|
||||
{
|
||||
Assert.IsFalse(Field<Button>(window, "openSelected").Enabled);
|
||||
Call(window, "RefreshComparison");
|
||||
Assert.AreEqual(0, Field<DataGridView>(window, "comparison").Rows.Count);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void AssertSelectedWindowImmediatelyVisible(ResultsWorkspaceDlg parent, int mode, int count)
|
||||
{
|
||||
var existing = Application.OpenForms.Cast<Form>().ToList();
|
||||
Call(parent, "OpenSelected");
|
||||
using (var child = Application.OpenForms.Cast<Form>().OfType<ResultsWorkspaceDlg>().Single(f => !existing.Contains(f)))
|
||||
{
|
||||
child.Opacity = 0;
|
||||
child.ShowInTaskbar = false;
|
||||
Application.DoEvents();
|
||||
var tabs = Field<TabControl>(child, "tabs");
|
||||
var viewport = Field<Panel>(child, "tiles");
|
||||
Assert.AreEqual(mode, tabs.SelectedIndex);
|
||||
Assert.AreSame(tabs.SelectedTab, viewport.Parent, "The viewport must be on the initial tab without switching tabs.");
|
||||
Assert.IsTrue(viewport.Visible);
|
||||
Assert.AreEqual(count, viewport.Controls.Count);
|
||||
Assert.AreEqual(count == 1 ? 1M : Field<NumericUpDown>(parent, "columns").Value,
|
||||
Field<NumericUpDown>(child, "columns").Value);
|
||||
Assert.AreEqual(count == 1 ? 1M : Field<NumericUpDown>(parent, "rows").Value,
|
||||
Field<NumericUpDown>(child, "rows").Value);
|
||||
if (count == 1)
|
||||
{
|
||||
Assert.IsTrue(viewport.Controls[0].Width >= viewport.ClientSize.Width - 50);
|
||||
Assert.IsTrue(viewport.Controls[0].Height >= viewport.ClientSize.Height - 50);
|
||||
}
|
||||
Assert.IsTrue(viewport.Controls[0].Visible);
|
||||
if (mode == 1)
|
||||
Assert.IsTrue(viewport.Controls[0].Controls.OfType<System.Windows.Forms.DataVisualization.Charting.Chart>().Any());
|
||||
else Assert.IsTrue(viewport.Controls[0].Controls.OfType<DataGridView>().Any());
|
||||
child.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user