147 lines
4.9 KiB
C#
147 lines
4.9 KiB
C#
///
|
|
/// Copyright (c) 2013-2017 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using Common;
|
|
using Results;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UI.ResultsMI
|
|
{
|
|
public partial class ResultsArrangementDlg : Form
|
|
{
|
|
/// <summary>
|
|
/// Required access rights to make changes with this form
|
|
/// </summary>
|
|
static readonly Common.GID[] RequiredGroupMembership = new Common.GID[] { Common.GID.TestingSpecialists, Common.GID.Metrologists };
|
|
|
|
public bool Unlocked; /// true = changes enabled
|
|
|
|
public TestsArrangement TestsArrangement;
|
|
public MetersArrangement MetersArrangement;
|
|
public int NrMetersInOneGroup;
|
|
public bool ShowDisabledPositions;
|
|
public int MinWidth;
|
|
public int MinHeight;
|
|
|
|
public IList<WMeterRsltItemSpec> SelectedItems
|
|
{
|
|
set { resultsConfigCtrl.SelectedItems = value; }
|
|
get { return resultsConfigCtrl.SelectedItems; }
|
|
}
|
|
|
|
public MetersKind MetersKind
|
|
{
|
|
set
|
|
{
|
|
resultsConfigCtrl.MetersKind = mtrsKind = value;
|
|
Text = string.Format("{0} ({1})", Strings.Configuration, mtrsKind.ToDescription());
|
|
}
|
|
}
|
|
|
|
MetersKind mtrsKind;
|
|
|
|
|
|
public ResultsArrangementDlg()
|
|
{
|
|
InitializeComponent();
|
|
resultsConfigCtrl.SupressTestIDColumn = true;
|
|
|
|
Unlocked = false;
|
|
cancelButton.Visible = false;
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = string.Format("{0} ({1})", Strings.Configuration, mtrsKind.ToDescription());
|
|
testsArangementGroupBox.Text = Strings.Arrangement_of_tests;
|
|
metersArangementGroupBox.Text = Strings.Arrangement_of_meters;
|
|
testsRowsRadioButton.Text = Strings.Tests_are_rows;
|
|
testsColumnsRadioButton.Text = Strings.Tests_are_columns;
|
|
horizontallyRadioButton.Text = Strings.Horizontally;
|
|
verticallyRadioButton.Text = Strings.Vertically;
|
|
nrMetersLabel.Text = string.Format("{0}:", Strings.Nr_meters_in_a_group);
|
|
showDisabledCheckBox.Text = Strings.Show_disabled_positions;
|
|
minWidthLabel.Text = string.Format("{0}:", Strings.Min_width);
|
|
minHeightLabel.Text = string.Format("{0}:", Strings.Min_height);
|
|
unlockButton.Text = Strings.UnlockBtnText;
|
|
okButton.Text = Strings.CloseBtnText;
|
|
cancelButton.Text = Strings.CancelBtnText;
|
|
}
|
|
|
|
void ResultsConfig_Load(object sender, EventArgs e)
|
|
{
|
|
Localize();
|
|
|
|
testsRowsRadioButton.Checked = (TestsArrangement == TestsArrangement.Rows);
|
|
testsColumnsRadioButton.Checked = (TestsArrangement == TestsArrangement.Columns);
|
|
|
|
horizontallyRadioButton.Checked = (MetersArrangement == MetersArrangement.Horizontally);
|
|
verticallyRadioButton.Checked = (MetersArrangement == MetersArrangement.Vertically);
|
|
nrMetersTextBox.Text = NrMetersInOneGroup.ToString();
|
|
showDisabledCheckBox.Checked = ShowDisabledPositions;
|
|
minWidthTextBox.Text = MinWidth.ToString();
|
|
minHeightTextBox.Text = MinHeight.ToString();
|
|
}
|
|
|
|
void unlockButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (!Unlocked)
|
|
{
|
|
if (!Users.CurrentUser.IsMemberOf(RequiredGroupMembership))
|
|
{
|
|
if ((new Users.Forms.LoginDlg(RequiredGroupMembership, this)).ShowDialog() != DialogResult.OK)
|
|
return;
|
|
}
|
|
else if (Program.LocalSettings.AlwaysAskPasswdWhenUnlocking)
|
|
{
|
|
if ((new Users.Forms.LoginDlg(Users.CurrentUser.UserName(), RequiredGroupMembership, this)).ShowDialog() != DialogResult.OK)
|
|
return;
|
|
}
|
|
|
|
Unlocked = true;
|
|
|
|
///
|
|
/// Unlock user interface controls
|
|
///
|
|
unlockButton.Enabled = false;
|
|
okButton.Text = Strings.OkBtnText;
|
|
cancelButton.Visible = true;
|
|
testsRowsRadioButton.Enabled = true;
|
|
testsColumnsRadioButton.Enabled = true;
|
|
verticallyRadioButton.Enabled = true;
|
|
horizontallyRadioButton.Enabled = true;
|
|
nrMetersTextBox.Enabled = true;
|
|
showDisabledCheckBox.Enabled = true;
|
|
minWidthTextBox.Enabled = true;
|
|
minHeightTextBox.Enabled = true;
|
|
resultsConfigCtrl.Unlocked = true;
|
|
|
|
if (Program.MainWnd != null) Program.MainWnd.UpdateUser();
|
|
}
|
|
}
|
|
|
|
void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
TestsArrangement = testsColumnsRadioButton.Checked ? TestsArrangement.Columns : TestsArrangement.Rows;
|
|
MetersArrangement = horizontallyRadioButton.Checked ? MetersArrangement.Horizontally : MetersArrangement.Vertically;
|
|
ShowDisabledPositions = showDisabledCheckBox.Checked;
|
|
|
|
int tmpInt;
|
|
if (int.TryParse(nrMetersTextBox.Text, out tmpInt) && tmpInt > 0) { NrMetersInOneGroup = tmpInt; }
|
|
if (int.TryParse(minWidthTextBox.Text, out tmpInt) && tmpInt >= 0) { MinWidth = tmpInt; }
|
|
if (int.TryParse(minHeightTextBox.Text, out tmpInt) && tmpInt >= 0) { MinHeight = tmpInt; }
|
|
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void ResultsArrangementDlg_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if (Users.CurrentUser.Restore(this)) Program.MainWnd.UpdateUser();
|
|
}
|
|
}
|
|
}
|