From 2f788adb7d14c2d37ea21cf3ed4a92c40aaa27cd Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 18 Jul 2019 14:02:53 +0200 Subject: [PATCH] (1) ProcedureDlg is initially unlocked after New/Copy/Import, (2) ProceduresDlg displays extra information in 'More' column. --- TBF/ProcedureDlg.cs | 17 +++++++++++++---- TBF/ProceduresDlg.cs | 2 +- TBF/Resources/Strings.Designer.cs | 9 +++++++++ TBF/Resources/Strings.resx | 3 +++ TBF/UiControls/ProceduresCtrl.cs | 29 ++++++++++++++++++++++------- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/TBF/ProcedureDlg.cs b/TBF/ProcedureDlg.cs index 60106fc32..b7b48349b 100644 --- a/TBF/ProcedureDlg.cs +++ b/TBF/ProcedureDlg.cs @@ -24,6 +24,8 @@ namespace TBF public readonly int Dpi; public const int Dpi100pct = 96; + readonly bool openUnlocked; + /// /// Procedure to be updated by this dialog. /// Set by the constructor or updated by the parent after creation and before loading. @@ -58,6 +60,7 @@ namespace TBF { /// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi. Dpi = (int)this.CreateGraphics().DpiX; + openUnlocked = false; InitializeComponent(); @@ -93,14 +96,14 @@ namespace TBF SelectedTestIx = -1; } - public ProcedureDlg(Config.Entities.Procedure procedure, IList usedNames) + public ProcedureDlg(Config.Entities.Procedure procedure, IList usedNames, bool openUnlocked = false) : this() { if (procedure == null) throw new ArgumentNullException("procedure"); - LoadedProcedure = procedure; - + LoadedProcedure = procedure; this.usedNames = usedNames; + this.openUnlocked = openUnlocked; sharedButtons.RequiredGroupMembership = procedure.Protected ? new Users.Grp.GID[] { Users.Grp.GID.Metrologists } : new Users.Grp.GID[] { Users.Grp.GID.TestingSpecialists, Users.Grp.GID.Metrologists }; @@ -366,6 +369,13 @@ namespace TBF { ctrl.Initialize(); } + + /// Optionally unlock this dialog + if (openUnlocked) + { + sharedButtons.UnlockButtons(); + Unlocked(sender, e); + } } void Localize() @@ -401,7 +411,6 @@ namespace TBF metersKindRadioButton3.Text = Strings.Heat_meter; } - #region General void RefreshGeneralTab() diff --git a/TBF/ProceduresDlg.cs b/TBF/ProceduresDlg.cs index 99b13d8d9..91ad9845b 100644 --- a/TBF/ProceduresDlg.cs +++ b/TBF/ProceduresDlg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2017 Sensus Slovensko a.s. +/// Copyright (c) 2013-2019 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index eed790cd5..e0c8b8d5b 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -2589,6 +2589,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to More. + /// + internal static string More { + get { + return ResourceManager.GetString("More", resourceCulture); + } + } + /// /// Looks up a localized string similar to More. /// diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 040f315a6..8a34ff94e 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2005,4 +2005,7 @@ No water meter + + More + \ No newline at end of file diff --git a/TBF/UiControls/ProceduresCtrl.cs b/TBF/UiControls/ProceduresCtrl.cs index 0b68d23c6..d033aecde 100644 --- a/TBF/UiControls/ProceduresCtrl.cs +++ b/TBF/UiControls/ProceduresCtrl.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2017 Sensus Metering Systems +/// Copyright (c) 2013-2019 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -12,6 +12,7 @@ using Config.Entities; using TBF.BenchControl; using TBF.BenchControl.GenericDevices; using TBF.Resources; +using System.Text; namespace TBF.UiControls { @@ -27,6 +28,7 @@ namespace TBF.UiControls ItemNr, Name, Description, + More, ColumnsCount, } readonly int columnsCount = (int)Column.ColumnsCount; @@ -56,17 +58,22 @@ namespace TBF.UiControls Columns.Add(Strings.Nr, (ls.ProceduresColumnCount > 0) ? ls.ProceduresColumnWidths[0] : (30 * parent.Dpi / PathsDlg.Dpi100pct)); Columns.Add(Strings.Name, (ls.ProceduresColumnCount > 1) ? ls.ProceduresColumnWidths[1] : (100 * parent.Dpi / PathsDlg.Dpi100pct)); Columns.Add(Strings.DescriptionColHdr, (ls.ProceduresColumnCount > 2) ? ls.ProceduresColumnWidths[2] : (300 * parent.Dpi / PathsDlg.Dpi100pct)); + Columns.Add(Strings.More, (ls.ProceduresColumnCount > 3) ? ls.ProceduresColumnWidths[3] : (300 * parent.Dpi / PathsDlg.Dpi100pct)); editors = new Control[columnsCount]; /// editors[(int)Column.ItemNr] = new TextBox(); /// ItemNr editors[(int)Column.Name] = new TextBox(); /// Name editors[(int)Column.Description] = new TextBox(); /// Description - /// + editors[(int)Column.More] = null; + /// for (int i = 0; i < editors.Length; i++) { - editors[i].Visible = false; - parent.Controls.Add(editors[i]); + if (editors[i] != null) + { + editors[i].Visible = false; + parent.Controls.Add(editors[i]); + } } ReloadAndRedrawAll(); @@ -97,9 +104,17 @@ namespace TBF.UiControls { Procedure entity = (Procedure)myItem; + StringBuilder tests = new StringBuilder(); + foreach (var test in entity.Tests) + { + tests.Append(test.Name); + tests.Append(", "); + } + ListViewItem lvi = new ListViewItem((entity.ItemNr + 1).ToString()); lvi.SubItems.Add(entity.Name); lvi.SubItems.Add(entity.Description); + lvi.SubItems.Add(tests.ToString()); lvi.Tag = entity; Items.Add(lvi); @@ -193,7 +208,7 @@ namespace TBF.UiControls newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationTime = DateTime.Now; - if (new ProcedureDlg(newProcedure, GetUsedNames()).ShowDialog() == DialogResult.OK) + if (new ProcedureDlg(newProcedure, GetUsedNames(), true).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock(); @@ -329,7 +344,7 @@ namespace TBF.UiControls newProcedure.CreationTime = DateTime.Now; newProcedure.Protected = false; - if ((new ProcedureDlg(newProcedure, GetUsedNames())).ShowDialog() == DialogResult.OK) + if ((new ProcedureDlg(newProcedure, GetUsedNames(), true)).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock(); @@ -382,7 +397,7 @@ namespace TBF.UiControls newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationTime = DateTime.Now; - if ((new ProcedureDlg(newProcedure, GetUsedNames())).ShowDialog() == DialogResult.OK) + if ((new ProcedureDlg(newProcedure, GetUsedNames(), true)).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock();