diff --git a/PROMS/DropDownPanel/Controls/DropDownPanel.cs b/PROMS/DropDownPanel/Controls/DropDownPanel.cs
index 49646260..660c8f85 100644
--- a/PROMS/DropDownPanel/Controls/DropDownPanel.cs
+++ b/PROMS/DropDownPanel/Controls/DropDownPanel.cs
@@ -1,6 +1,5 @@
using System;
using System.ComponentModel;
-using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
@@ -15,7 +14,7 @@ namespace AT.STO.UI.Win
{
#region Private Variable Declarations
private IDropDownAware _dropDownControl = null;
- private DropDownWindowHelper _dropDownHelper = null;
+ private readonly DropDownWindowHelper _dropDownHelper = null;
private Form _owner = null;
#endregion
#region Constructor / Destructor
@@ -47,7 +46,7 @@ namespace AT.STO.UI.Win
///
protected override void OnHandleCreated(EventArgs e)
{
- _owner = this.FindForm();
+ _owner = FindForm();
_dropDownHelper.ReleaseHandle();
if (_owner != null)
@@ -66,8 +65,8 @@ namespace AT.STO.UI.Win
{
base.OnResize(e);
combo.Location = new Point(0, 0);
- combo.Width = this.ClientRectangle.Width;
- this.Height = combo.Height;
+ combo.Width = ClientRectangle.Width;
+ Height = combo.Height;
}
#endregion
#region Event Handler
@@ -96,7 +95,7 @@ namespace AT.STO.UI.Win
else
{
_dropDownHelper.CloseDropDown();
- this.Focus();
+ Focus();
}
}
@@ -115,7 +114,7 @@ namespace AT.STO.UI.Win
private void DropDownHelper_DropDownCancel(object sender, DropDownCancelEventArgs e)
{
- if (this.Bounds.Contains(Parent.PointToClient(e.CursorLocation)))
+ if (Bounds.Contains(Parent.PointToClient(e.CursorLocation)))
{
e.Cancel = true;
}
@@ -137,31 +136,22 @@ namespace AT.STO.UI.Win
{
SetValue(e.Value as ILookupItem);
}
-
- if (this.FinishEditing != null)
- {
- this.FinishEditing(this, e);
- }
-
- _dropDownControl.FinishEditing -= new DropDownValueChangedEventHandler(DropDown_FinishEditing);
+
+ FinishEditing?.Invoke(this, e);
+
+ _dropDownControl.FinishEditing -= new DropDownValueChangedEventHandler(DropDown_FinishEditing);
_dropDownControl.ValueChanged -= new DropDownValueChangedEventHandler(DropDown_ValueChanged);
_dropDownHelper.CloseDropDown();
}
-
- private void DropDown_ValueChanged(object sender, DropDownValueChangedEventArgs e)
- {
- if (this.ValueChanged != null)
- {
- this.ValueChanged(this, e);
- }
- }
- #endregion
- #region Public Properties
- ///
- /// Get or set the control (has to implement IDropDownAware) that is to
- /// be displayed as the dropdown portion of the combobox.
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+
+ private void DropDown_ValueChanged(object sender, DropDownValueChangedEventArgs e) => ValueChanged?.Invoke(this, e);
+ #endregion
+ #region Public Properties
+ ///
+ /// Get or set the control (has to implement IDropDownAware) that is to
+ /// be displayed as the dropdown portion of the combobox.
+ ///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IDropDownAware DropDownControl
{
get { return _dropDownControl; }
@@ -169,24 +159,21 @@ namespace AT.STO.UI.Win
{
_dropDownControl = value;
- this.Controls.Add(_dropDownControl as Control);
+ Controls.Add(_dropDownControl as Control);
}
}
- #endregion
- #region Public Methods
- public override string ToString()
- {
- return this.Name;
- }
- #endregion
- #region Private Methods
- ///
- /// Calculate an acceptable position of the DropDownForm even in a
- /// multi screen environment.
- ///
- ///
- ///
- private Point GetDropDownPosition(DropDownForm DropDown)
+ #endregion
+ #region Public Methods
+ public override string ToString() => Name;
+ #endregion
+ #region Private Methods
+ ///
+ /// Calculate an acceptable position of the DropDownForm even in a
+ /// multi screen environment.
+ ///
+ ///
+ ///
+ private Point GetDropDownPosition(DropDownForm DropDown)
{
Point lt = Parent.PointToScreen(new Point(Left, Top));
Point rb = Parent.PointToScreen(new Point(Right, Bottom));
diff --git a/PROMS/DropDownPanel/Events/Events.cs b/PROMS/DropDownPanel/Events/Events.cs
index e5659774..3abc20ee 100644
--- a/PROMS/DropDownPanel/Events/Events.cs
+++ b/PROMS/DropDownPanel/Events/Events.cs
@@ -35,10 +35,9 @@ namespace AT.STO.UI.Win
///
public class DropDownCancelEventArgs : EventArgs
{
- #region Private Variable Declarations
- private bool _cancel = false;
- private Point _cursorLocation;
- private Form _dropDown = null;
+ #region Private Variable Declarations
+ private Point _cursorLocation;
+ private readonly Form _dropDown = null;
#endregion
#region Constructor / Destructor
///
@@ -51,36 +50,26 @@ namespace AT.STO.UI.Win
{
_dropDown = DropDown;
_cursorLocation = CursorLocation;
- _cancel = false;
- }
- #endregion
- #region Public Properties
- ///
- ///
- ///
- public bool Cancel
- {
- get { return _cancel; }
- set { _cancel = value; }
+ Cancel = false;
}
+ #endregion
+ #region Public Properties
+ ///
+ ///
+ ///
+ public bool Cancel { get; set; } = false;
- ///
- ///
- ///
- public Point CursorLocation
- {
- get { return _cursorLocation; }
- }
+ ///
+ ///
+ ///
+ public Point CursorLocation => _cursorLocation;
- ///
- ///
- ///
- public Form DropDown
- {
- get { return _dropDown; }
- }
- #endregion
- }
+ ///
+ ///
+ ///
+ public Form DropDown => _dropDown;
+ #endregion
+ }
///
/// Contains event information for a event.
@@ -91,64 +80,50 @@ namespace AT.STO.UI.Win
public class DropDownClosedEventArgs : EventArgs
{
#region Private Variable Declarations
- private Form _dropDown = null;
- #endregion
- #region Constructor / Destructor
- ///
- /// Constructs a new instance of this class for the specified
- /// popup form.
- ///
- /// DropDown Form which is being closed.
- public DropDownClosedEventArgs(Form DropDown)
- {
- _dropDown = DropDown;
- }
- #endregion
- #region Public Properties
- ///
- /// Gets the dropdown form which is being closed.
- ///
- public Form DropDown
- {
- get { return _dropDown; }
- }
- #endregion
- }
+ private readonly Form _dropDown = null;
+ #endregion
+ #region Constructor / Destructor
+ ///
+ /// Constructs a new instance of this class for the specified
+ /// popup form.
+ ///
+ /// DropDown Form which is being closed.
+ public DropDownClosedEventArgs(Form DropDown) => _dropDown = DropDown;
+ #endregion
+ #region Public Properties
+ ///
+ /// Gets the dropdown form which is being closed.
+ ///
+ public Form DropDown => _dropDown;
+ #endregion
+ }
///
/// Contains event information for DropDownValueChangedEventHandler.
///
public class DropDownValueChangedEventArgs : EventArgs
{
- #region Private Variable Declarations
- private object _value = null;
- #endregion
- #region Constructor / Destructor
- ///
- /// Default Constructor
- ///
- public DropDownValueChangedEventArgs()
+ #region Private Variable Declarations
+ #endregion
+ #region Constructor / Destructor
+ ///
+ /// Default Constructor
+ ///
+ public DropDownValueChangedEventArgs()
{
}
-
- ///
- /// Initialization with the control's value.
- ///
- ///
- public DropDownValueChangedEventArgs(object Value)
- {
- _value = Value;
- }
- #endregion
- #region Public Properties
- ///
- /// Gets or sets the control's value.
- ///
- public object Value
- {
- get { return _value; }
- set { _value = value; }
- }
- #endregion
- }
+
+ ///
+ /// Initialization with the control's value.
+ ///
+ ///
+ public DropDownValueChangedEventArgs(object Value) => this.Value = Value;
+ #endregion
+ #region Public Properties
+ ///
+ /// Gets or sets the control's value.
+ ///
+ public object Value { get; set; } = null;
+ #endregion
+ }
}
diff --git a/PROMS/DropDownPanel/Forms/DropDownForm.cs b/PROMS/DropDownPanel/Forms/DropDownForm.cs
index c6923a15..4916bf2f 100644
--- a/PROMS/DropDownPanel/Forms/DropDownForm.cs
+++ b/PROMS/DropDownPanel/Forms/DropDownForm.cs
@@ -13,22 +13,19 @@ namespace AT.STO.UI.Win
internal partial class DropDownForm : Form, IDropDownAware
{
#region Private Variable Declaration
- private IDropDownAware _control = null;
- #endregion
- #region Constructor / Destructor
- ///
- /// Default Constructor
- ///
- public DropDownForm()
- {
- InitializeComponent();
- }
+ private readonly IDropDownAware _control = null;
+ #endregion
+ #region Constructor / Destructor
+ ///
+ /// Default Constructor
+ ///
+ public DropDownForm() => InitializeComponent();
- ///
- /// Constructor to initialize the for with the control to display.
- ///
- /// The control to display.
- public DropDownForm(IDropDownAware Ctrl) : this()
+ ///
+ /// Constructor to initialize the for with the control to display.
+ ///
+ /// The control to display.
+ public DropDownForm(IDropDownAware Ctrl) : this()
{
if (Ctrl != null)
{
@@ -41,7 +38,7 @@ namespace AT.STO.UI.Win
#region Form Events
protected override void OnClosing(CancelEventArgs e)
{
- this.Controls.Remove(_control as Control);
+ Controls.Remove(_control as Control);
base.OnClosing(e);
}
@@ -58,29 +55,20 @@ namespace AT.STO.UI.Win
#region Event Handler
private void Ctrl_FinishEditing(object sender, DropDownValueChangedEventArgs e)
{
- if (this.FinishEditing != null)
- {
- this.FinishEditing(this, e);
- }
+ FinishEditing?.Invoke(this, e);
- _control.FinishEditing -= new DropDownValueChangedEventHandler(Ctrl_FinishEditing);
+ _control.FinishEditing -= new DropDownValueChangedEventHandler(Ctrl_FinishEditing);
_control.ValueChanged -= new DropDownValueChangedEventHandler(Ctrl_ValueChanged);
}
-
- private void Ctrl_ValueChanged(object sender, DropDownValueChangedEventArgs e)
- {
- if (this.ValueChanged != null)
- {
- this.ValueChanged(this, e);
- }
- }
- #endregion
- #region IDropDownAware Implementation
- ///
- /// Fired either on OK, Cancel or a click outside the control to indicate
- /// that the user has finished editing.
- ///
- public event DropDownValueChangedEventHandler FinishEditing;
+
+ private void Ctrl_ValueChanged(object sender, DropDownValueChangedEventArgs e) => ValueChanged?.Invoke(this, e);
+ #endregion
+ #region IDropDownAware Implementation
+ ///
+ /// Fired either on OK, Cancel or a click outside the control to indicate
+ /// that the user has finished editing.
+ ///
+ public event DropDownValueChangedEventHandler FinishEditing;
///
/// Fired on any change of the controls's value during the editing process.
@@ -100,15 +88,15 @@ namespace AT.STO.UI.Win
private void InitializeControl(Control Ctrl)
{
Size size = Ctrl.Size;
- Size inner = this.ClientRectangle.Size;
- Size outer = this.Size;
+ Size inner = ClientRectangle.Size;
+ Size outer = Size;
int gap = outer.Width - inner.Width;
size.Width += gap;
size.Height += gap;
- this.Size = size;
- this.Controls.Add(Ctrl);
+ Size = size;
+ Controls.Add(Ctrl);
Ctrl.Location = new Point(0, 0);
Ctrl.Visible = true;
Ctrl.Invalidate();
diff --git a/PROMS/DropDownPanel/Helper/DropDownMessageFilter.cs b/PROMS/DropDownPanel/Helper/DropDownMessageFilter.cs
index cca60462..d0ad764d 100644
--- a/PROMS/DropDownPanel/Helper/DropDownMessageFilter.cs
+++ b/PROMS/DropDownPanel/Helper/DropDownMessageFilter.cs
@@ -1,4 +1,3 @@
-using System;
using System.Drawing;
using System.Windows.Forms;
@@ -21,59 +20,48 @@ namespace AT.STO.UI.Win
private const int WM_NCLBUTTONDOWN = 0x0A1;
private const int WM_NCRBUTTONDOWN = 0x0A4;
private const int WM_NCMBUTTONDOWN = 0x0A7;
- #endregion
- #region Private Variable Declarations
- private Form _dropDown = null;
- private DropDownWindowHelper _owner = null;
+ #endregion
+ #region Private Variable Declarations
+ private readonly DropDownWindowHelper _owner = null;
#endregion
#region Event Declarations
public event DropDownCancelEventHandler DropDownCancel;
- #endregion
- #region Constructor / Destructor
- ///
- /// Constructs a new instance of this class and sets the owning
- /// object.
- ///
- /// The object
- /// which owns this class.
- public DropDownMessageFilter(DropDownWindowHelper Owner)
- {
- _owner = Owner;
- }
- #endregion
- #region Public Properties
- ///
- /// Gets/sets the dropdown form which is being displayed.
- ///
- public Form DropDown
- {
- get { return _dropDown; }
- set { _dropDown = value; }
- }
- #endregion
- #region Private Methods
- private void OnMouseDown()
+ #endregion
+ #region Constructor / Destructor
+ ///
+ /// Constructs a new instance of this class and sets the owning
+ /// object.
+ ///
+ /// The object
+ /// which owns this class.
+ public DropDownMessageFilter(DropDownWindowHelper Owner) => _owner = Owner;
+ #endregion
+ #region Public Properties
+ ///
+ /// Gets/sets the dropdown form which is being displayed.
+ ///
+ public Form DropDown { get; set; } = null;
+ #endregion
+ #region Private Methods
+ private void OnMouseDown()
{
Point cursorPos = Cursor.Position; // Get the cursor location
- if (!_dropDown.Bounds.Contains(cursorPos)) // Check if it is within the popup form
+ if (!DropDown.Bounds.Contains(cursorPos)) // Check if it is within the popup form
{
- OnDropDownCancel(new DropDownCancelEventArgs(_dropDown, cursorPos)); // If not, then call to see if it should be closed
+ OnDropDownCancel(new DropDownCancelEventArgs(DropDown, cursorPos)); // If not, then call to see if it should be closed
}
}
#endregion
#region DropDownCancelEvent Implementation
protected virtual void OnDropDownCancel(DropDownCancelEventArgs e)
{
- if (this.DropDownCancel != null)
- {
- this.DropDownCancel(this, e);
- }
+ DropDownCancel?.Invoke(this, e);
- if (!e.Cancel)
+ if (!e.Cancel)
{
_owner.CloseDropDown();
- _dropDown = null; // Clear reference for GC
+ DropDown = null; // Clear reference for GC
}
}
#endregion
@@ -90,7 +78,7 @@ namespace AT.STO.UI.Win
/// This implementation always returns false.
public bool PreFilterMessage(ref Message m)
{
- if (_dropDown != null)
+ if (DropDown != null)
{
switch (m.Msg)
{
diff --git a/PROMS/DropDownPanel/Helper/DropDownWindowHelper.cs b/PROMS/DropDownPanel/Helper/DropDownWindowHelper.cs
index e3eb0308..2f291045 100644
--- a/PROMS/DropDownPanel/Helper/DropDownWindowHelper.cs
+++ b/PROMS/DropDownPanel/Helper/DropDownWindowHelper.cs
@@ -1,6 +1,5 @@
using System;
using System.Drawing;
-using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace AT.STO.UI.Win
@@ -22,7 +21,7 @@ namespace AT.STO.UI.Win
private Form _dropDown = null;
private bool _dropDownShowing = false;
- private DropDownMessageFilter _filter = null;
+ private readonly DropDownMessageFilter _filter = null;
private Form _owner = null;
private bool _skipClose = false;
#endregion
@@ -42,31 +41,25 @@ namespace AT.STO.UI.Win
_filter.DropDownCancel -= new DropDownCancelEventHandler(Popup_Cancel);
_filter.DropDownCancel += new DropDownCancelEventHandler(Popup_Cancel);
}
- #endregion
- #region Event Handler
- private void Popup_Cancel(object sender, DropDownCancelEventArgs e)
- {
- OnDropDownCancel(e);
- }
+ #endregion
+ #region Event Handler
+ private void Popup_Cancel(object sender, DropDownCancelEventArgs e) => OnDropDownCancel(e);
- ///
- /// Responds to the
- /// event from the popup form.
- ///
- /// Popup form that has been closed.
- /// Not used.
- private void Popup_Closed(object sender, EventArgs e)
- {
- CloseDropDown();
- }
-
- ///
- /// Subclasses the owning form's existing Window Procedure to enables the
- /// title bar to remain active when a popup is show, and to detect if
- /// the user clicks onto another application whilst the popup is visible.
- ///
- /// Window Procedure Message
- protected override void WndProc(ref Message m)
+ ///
+ /// Responds to the
+ /// event from the popup form.
+ ///
+ /// Popup form that has been closed.
+ /// Not used.
+ private void Popup_Closed(object sender, EventArgs e) => CloseDropDown();
+
+ ///
+ /// Subclasses the owning form's existing Window Procedure to enables the
+ /// title bar to remain active when a popup is show, and to detect if
+ /// the user clicks onto another application whilst the popup is visible.
+ ///
+ /// Window Procedure Message
+ protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
@@ -76,7 +69,7 @@ namespace AT.STO.UI.Win
{
if (((int)m.WParam) == 0) // Check if the title bar will made inactive:
{ // Note it's no good to try and consume this message; if you try to do that you'll end up with windows
- UIApiCalls.SendMessage(this.Handle, UIApiCalls.WM_NCACTIVATE, 1, IntPtr.Zero); // If so reactivate it.
+ UIApiCalls.SendMessage(Handle, UIApiCalls.WM_NCACTIVATE, 1, IntPtr.Zero); // If so reactivate it.
}
}
else if (m.Msg == UIApiCalls.WM_ACTIVATEAPP)
@@ -84,7 +77,7 @@ namespace AT.STO.UI.Win
if ((int)m.WParam == 0) // Check if the application is being deactivated.
{
CloseDropDown(); // It is so cancel the popup:
- UIApiCalls.PostMessage(this.Handle, UIApiCalls.WM_NCACTIVATE, 0, IntPtr.Zero); // And put the title bar into the inactive state:
+ UIApiCalls.PostMessage(Handle, UIApiCalls.WM_NCACTIVATE, 0, IntPtr.Zero); // And put the title bar into the inactive state:
}
}
}
@@ -168,22 +161,19 @@ namespace AT.STO.UI.Win
_owner = null;
}
}
- #endregion
- #region Public Properties
- ///
- /// Indicator weither the DropDown is showing.
- ///
- public bool DropDownShowing
+ #endregion
+ #region Public Properties
+ ///
+ /// Indicator weither the DropDown is showing.
+ ///
+ public bool DropDownShowing => _dropDownShowing;
+ #endregion
+ #region Event Implementation
+ protected virtual void OnDropDownCancel(DropDownCancelEventArgs e)
{
- get { return _dropDownShowing; }
- }
- #endregion
- #region Event Implementation
- protected virtual void OnDropDownCancel(DropDownCancelEventArgs e)
- {
- if (this.DropDownCancel != null)
+ if (DropDownCancel != null)
{
- this.DropDownCancel(this, e);
+ DropDownCancel(this, e);
if (!e.Cancel)
{
@@ -191,14 +181,8 @@ namespace AT.STO.UI.Win
}
}
}
-
- protected virtual void OnPDropDownClosed(DropDownClosedEventArgs e)
- {
- if (this.DropDownClosed != null)
- {
- this.DropDownClosed(this, e);
- }
- }
- #endregion
- }
+
+ protected virtual void OnPDropDownClosed(DropDownClosedEventArgs e) => DropDownClosed?.Invoke(this, e);
+ #endregion
+ }
}
diff --git a/PROMS/DropDownPanel/Interfaces/IDropDownAware.cs b/PROMS/DropDownPanel/Interfaces/IDropDownAware.cs
index 94874f2b..b5dd43ab 100644
--- a/PROMS/DropDownPanel/Interfaces/IDropDownAware.cs
+++ b/PROMS/DropDownPanel/Interfaces/IDropDownAware.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace AT.STO.UI.Win
{
///
diff --git a/PROMS/DropDownPanel/Interfaces/ILookupItem.cs b/PROMS/DropDownPanel/Interfaces/ILookupItem.cs
index b3181e2a..7470b14a 100644
--- a/PROMS/DropDownPanel/Interfaces/ILookupItem.cs
+++ b/PROMS/DropDownPanel/Interfaces/ILookupItem.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace AT.STO.UI.Win
{
public interface ILookupItem where T: struct
diff --git a/PROMS/Volian.Controls.Library/ImageItem.cs b/PROMS/Volian.Controls.Library/ImageItem.cs
index c7bce8f7..fc8fad32 100644
--- a/PROMS/Volian.Controls.Library/ImageItem.cs
+++ b/PROMS/Volian.Controls.Library/ImageItem.cs
@@ -124,7 +124,7 @@ namespace Volian.Controls.Library
}
public override void SetActive()
{
- this.BackColor = MyStepPanel.ActiveColor;
+ BackColor = MyStepPanel.ActiveColor;
}
public override void SetText()
{
@@ -231,7 +231,7 @@ namespace Volian.Controls.Library
private int _origCfgHt = 0; // keep track if original size was stored in cfg
private int _origCfgWd = 0;
private bool _pastedNew = false; // need this for flagging newly pasted image (may need to clear cfg)
- private DisplayTags _displayTags = new DisplayTags();
+ private readonly DisplayTags _displayTags = new DisplayTags();
#endregion
#region Constructors
@@ -281,8 +281,8 @@ namespace Volian.Controls.Library
MyPictureBox.Width = wd;
MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
- this.Width = MyPictureBox.Width + ImageMargin;
- this.Height = MyPictureBox.Height + 10;
+ Width = MyPictureBox.Width + ImageMargin;
+ Height = MyPictureBox.Height + 10;
_newSizeWd = wd / (MyStepPanel.DPI / 72);
_newSizeHt = ht / (MyStepPanel.DPI / 72);
@@ -310,13 +310,10 @@ namespace Volian.Controls.Library
MyPictureBox.Width = wd;
MyPictureBox.Height = ht;
MyPictureBox.SizeMode = PictureBoxSizeMode.Zoom; // as resize matches width/height.
- this.Width = MyPictureBox.Width + ImageMargin;
- this.Height = MyPictureBox.Height + 10;
- if (_displayTags != null)
- {
- // Set the Height and Width on the step properties page for the new image
- _displayTags.SetNewImageHeightAndWidth(ht, wd);
- }
+ Width = MyPictureBox.Width + ImageMargin;
+ Height = MyPictureBox.Height + 10;
+ // Set the Height and Width on the step properties page for the new image
+ _displayTags?.SetNewImageHeightAndWidth(ht, wd);
}
@@ -358,8 +355,8 @@ namespace Volian.Controls.Library
InsType = insType;
FileName = null;
SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem, false);
- this.Width = 100 + ImageMargin;
- this.Height = 100;
+ Width = 100 + ImageMargin;
+ Height = 100;
if (insType == ImageItem.E_ImageSource.File)
{
ImageFileDialog();
@@ -384,21 +381,22 @@ namespace Volian.Controls.Library
}
}
AdjustTableWidthAndLocation();
- this.Controls.Add(this._MyPictureBox);
+ Controls.Add(_MyPictureBox);
AddEventHandlers();
MyStepRTB.RemoveEventHandlers();
MyStepRTB.Visible = false;
}
private void ImageFileDialog()
{
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
+ OpenFileDialog openFileDialog1 = new OpenFileDialog
+ {
+ InitialDirectory = "c:\\",
+ Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*",
+ FilterIndex = 0,
+ RestoreDirectory = true
+ };
- openFileDialog1.InitialDirectory = "c:\\";
- openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
- openFileDialog1.FilterIndex = 0;
- openFileDialog1.RestoreDirectory = true;
-
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
+ if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
@@ -412,13 +410,14 @@ namespace Volian.Controls.Library
_IsDirty = true;
}
}
- catch (Exception ex)
- {
+ catch (Exception)
+ {
FlexibleMessageBox.Show("Could not create image, check file type.", "Error on Image File Selection");
return;
}
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping img for potential future use")]
private static string GetImageFormatExtension(System.Drawing.Image img) => ("jpg"); // seems that this is the only one that works.
#endregion
#region RO_Images
@@ -471,13 +470,11 @@ namespace Volian.Controls.Library
if (val != null && val != "?")
{
string imgname = null;
- int W = 0;
- int H = 0;
- string[] vals = val.Split("\n".ToCharArray());
- W = (int)(Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips);
- int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
- H = lines * 12;
- try
+ string[] vals = val.Split("\n".ToCharArray());
+ int W = (int)(Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips);
+ int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
+ int H = lines * 12;
+ try
{
imgname = vals[0];
ROImageInfo roImage = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
@@ -492,9 +489,9 @@ namespace Volian.Controls.Library
AddROImageToScreen(W, H, imageText);
}
- catch (Exception ex)
- {
- string msg = string.Format("Could not display image {0}.", imgname);
+ catch (Exception)
+ {
+ string msg = $"Could not display image {imgname}.";
FlexibleMessageBox.Show(msg);
}
}
@@ -511,9 +508,8 @@ namespace Volian.Controls.Library
ProcedureInfo proc = MyItemInfo.MyProcedure;
DocVersionInfo dvi = proc.ActiveParent as DocVersionInfo;
ROFstInfo rofst = dvi.DocVersionAssociations[0].MyROFst;
- ROImageInfo roImageInfo = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]);
- if (roImageInfo == null) roImageInfo = rofst.GetROImageByFilename(vals[0], MyItemInfo);
- if (roImageInfo != null)
+ ROImageInfo roImageInfo = ROImageInfo.GetByROFstID_FileName(rofst.ROFstID, vals[0]) ?? rofst.GetROImageByFilename(vals[0], MyItemInfo);
+ if (roImageInfo != null)
{
System.Drawing.Image.GetThumbnailImageAbort myCallback =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
@@ -526,7 +522,7 @@ namespace Volian.Controls.Library
// if there is config data that saves the resize of the image, use it, otherwise use what was passed in:
StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
SizeF sizef = new Size(1, 1);
- if (sc.Step_ImageHeight == null || sc.Step_ImageHeight == 0)
+ if (sc?.Step_ImageHeight == null || sc.Step_ImageHeight == 0)
{
sizef = new SizeF((img2.Width / img2.HorizontalResolution),
(img2.Height / img2.VerticalResolution));
@@ -555,16 +551,16 @@ namespace Volian.Controls.Library
{
// Always be sure to add the same event handlers to RemoveEventHandlers
MyItemInfo.MyContent.Changed += new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed);
- this.Enter += new System.EventHandler(ImageItem_Enter);
- this.MyPictureBox.Enter += new System.EventHandler(ImageItem_Enter);
- this.Click += new EventHandler(ImageItem_Click);
- this.MyPictureBox.Click += new EventHandler(ImageItem_Click);
- this.MyPictureBox.PreviewKeyDown += new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown); //note that PictureBox does not have cursorkey events
- this.MyPictureBox.KeyDown += new KeyEventHandler(ImageItem_KeyDown);
- this.MyStepRTB.RoInsert += new StepRTBRoEvent(MyStepRTB_RoInsert);
- this.MyStepRTB.DoSaveContents += new StepRTBEvent(MyStepRTB_DoSaveContents); // for storing RO data
- this.MyPictureBox.Resize += MyPictureBox_Resize;
- this.MyPictureBox.MouseDown += MyPictureBox_MouseDown;
+ Enter += new System.EventHandler(ImageItem_Enter);
+ MyPictureBox.Enter += new System.EventHandler(ImageItem_Enter);
+ Click += new EventHandler(ImageItem_Click);
+ MyPictureBox.Click += new EventHandler(ImageItem_Click);
+ MyPictureBox.PreviewKeyDown += new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown); //note that PictureBox does not have cursorkey events
+ MyPictureBox.KeyDown += new KeyEventHandler(ImageItem_KeyDown);
+ MyStepRTB.RoInsert += new StepRTBRoEvent(MyStepRTB_RoInsert);
+ MyStepRTB.DoSaveContents += new StepRTBEvent(MyStepRTB_DoSaveContents); // for storing RO data
+ MyPictureBox.Resize += MyPictureBox_Resize;
+ MyPictureBox.MouseDown += MyPictureBox_MouseDown;
}
void MyPictureBox_MouseDown(object sender, MouseEventArgs e)
@@ -574,10 +570,10 @@ namespace Volian.Controls.Library
void MyPictureBox_Resize(object sender, EventArgs e)
{
- if (this.Height != _MyPictureBox.Height + _MyPictureBox.Top + 7) // add in 7 to make it look good // + 10)
+ if (Height != _MyPictureBox.Height + _MyPictureBox.Top + 7) // add in 7 to make it look good // + 10)
{
LastMethodsPush(string.Format("MyPictureBox_Resize {0}", _MyPictureBox.Height));
- this.Height = _MyPictureBox.Height + _MyPictureBox.Top + 7;
+ Height = _MyPictureBox.Height + _MyPictureBox.Top + 7;
LastMethodsPop();
}
}
@@ -585,16 +581,16 @@ namespace Volian.Controls.Library
{
// Always be sure to add the same event handlers to RemoveEventHandlers
MyItemInfo.MyContent.Changed -= new VEPROMS.CSLA.Library.ContentInfoEvent(MyContent_Changed);
- this.Enter -= new System.EventHandler(ImageItem_Enter);
- this.MyPictureBox.Enter -= new System.EventHandler(ImageItem_Enter);
- this.Click -= new EventHandler(ImageItem_Click);
- this.MyPictureBox.Click -= new EventHandler(ImageItem_Click);
- this.MyPictureBox.PreviewKeyDown -= new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown);
- this.MyPictureBox.KeyDown -= new KeyEventHandler(ImageItem_KeyDown);
- this.MyStepRTB.RoInsert -= new StepRTBRoEvent(MyStepRTB_RoInsert);
- this.MyStepRTB.DoSaveContents -= new StepRTBEvent(MyStepRTB_DoSaveContents);
- this.MyPictureBox.Resize -= MyPictureBox_Resize;
- this.MyPictureBox.MouseDown -= MyPictureBox_MouseDown;
+ Enter -= new System.EventHandler(ImageItem_Enter);
+ MyPictureBox.Enter -= new System.EventHandler(ImageItem_Enter);
+ Click -= new EventHandler(ImageItem_Click);
+ MyPictureBox.Click -= new EventHandler(ImageItem_Click);
+ MyPictureBox.PreviewKeyDown -= new PreviewKeyDownEventHandler(ImageItem_PreviewKeyDown);
+ MyPictureBox.KeyDown -= new KeyEventHandler(ImageItem_KeyDown);
+ MyStepRTB.RoInsert -= new StepRTBRoEvent(MyStepRTB_RoInsert);
+ MyStepRTB.DoSaveContents -= new StepRTBEvent(MyStepRTB_DoSaveContents);
+ MyPictureBox.Resize -= MyPictureBox_Resize;
+ MyPictureBox.MouseDown -= MyPictureBox_MouseDown;
}
void ImageItem_Click(object sender, EventArgs e)
{
@@ -675,8 +671,8 @@ namespace Volian.Controls.Library
}
void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args)
{
- int sel = MyStepRTB.SelectionStart + args.ValText.Length;
- _IsDirty = true;
+ _ = MyStepRTB.SelectionStart + args.ValText.Length;
+ _IsDirty = true;
InsType = E_ImageSource.RoFigure;
MyStepRTB.UpdateStepRtb(args.LinkText, args.ValText);
HandleRoImage();
@@ -725,10 +721,12 @@ namespace Volian.Controls.Library
bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB);
if (success && _newSizeHt != 0)
{
- StepConfig sc = new StepConfig(MyItemInfo as StepInfo);
- sc.Step_ImageWidth = (int)(_newSizeWd / (MyStepPanel.DPI / 72f));
- sc.Step_ImageHeight = (int)(_newSizeHt / (MyStepPanel.DPI / 72f));
- using (Item item = MyItemInfo.Get())
+ StepConfig sc = new StepConfig(MyItemInfo as StepInfo)
+ {
+ Step_ImageWidth = (int)(_newSizeWd / (MyStepPanel.DPI / 72f)),
+ Step_ImageHeight = (int)(_newSizeHt / (MyStepPanel.DPI / 72f))
+ };
+ using (Item item = MyItemInfo.Get())
{
item.MyContent.Config = sc.ToString();
item.Save();
@@ -761,9 +759,11 @@ namespace Volian.Controls.Library
ImageConfig imgCfg = null;
if (_pastedNew && compressed)
{
- imgCfg = new ImageConfig();
- imgCfg.Image_DataSize = origLen;
- _MyItem.MyContent.MyImage.Config = imgCfg.ToString();
+ imgCfg = new ImageConfig
+ {
+ Image_DataSize = origLen
+ };
+ _MyItem.MyContent.MyImage.Config = imgCfg.ToString();
}
else if (_newSizeHt != 0)
{
@@ -800,10 +800,10 @@ namespace Volian.Controls.Library
// this should be saved for every piece of edited data. Note that the set of config
// item Step_MultipleChangeID has the save built in to it.
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds
- && !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange)
+ && !MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange)
{
if (sc == null) sc = new StepConfig();
- sc.Step_ChangeID = this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId;
+ sc.Step_ChangeID = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId;
}
// We saved changes. Reset the change bar override.
// IF there is a step config remove the change bar override by setting the CBOverride value to null
@@ -813,8 +813,8 @@ namespace Volian.Controls.Library
sc.Step_CBOverride = null; // clear the change bar override
MyStepRTB.ClearUndo();
}
- catch (Exception ex)
- {
+ catch (Exception)
+ {
FlexibleMessageBox.Show("The image could not be saved.", "Image Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
@@ -825,8 +825,10 @@ namespace Volian.Controls.Library
{
// get filename's extension to map to imageformat:
string ext = fname.Substring(fname.LastIndexOf(".") + 1).ToUpper();
- System.Drawing.Imaging.ImageFormat ifmt = System.Drawing.Imaging.ImageFormat.Gif;
- switch (ext)
+#pragma warning disable IDE0059 // Unnecessary assignment of a value
+ System.Drawing.Imaging.ImageFormat ifmt = System.Drawing.Imaging.ImageFormat.Gif;
+#pragma warning restore IDE0059 // Unnecessary assignment of a value
+ switch (ext)
{
case ("JPG"):
ifmt = System.Drawing.Imaging.ImageFormat.Jpeg;
@@ -891,12 +893,14 @@ namespace Volian.Controls.Library
}
if (img == null)
{
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.InitialDirectory = "c:\\";
- openFileDialog1.Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*";
- openFileDialog1.FilterIndex = 0;
- openFileDialog1.RestoreDirectory = true;
- DialogResult dr = openFileDialog1.ShowDialog();
+ OpenFileDialog openFileDialog1 = new OpenFileDialog
+ {
+ InitialDirectory = "c:\\",
+ Filter = "Image files (*.jpg;*.tif;*.bmp;*.png)|*.jpg;*.tif;*.bmp;*.png|All files (*.*)|*.*",
+ FilterIndex = 0,
+ RestoreDirectory = true
+ };
+ DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
// check that it is an image
@@ -904,8 +908,8 @@ namespace Volian.Controls.Library
{
img = System.Drawing.Image.FromFile(openFileDialog1.FileName);
}
- catch (Exception ex)
- {
+ catch (Exception)
+ {
img = null;
}
if (img != null) filename = openFileDialog1.FileName;
@@ -939,9 +943,11 @@ namespace Volian.Controls.Library
ImageConfig imgCfg = null;
if (compressed)
{
- imgCfg = new ImageConfig();
- imgCfg.Image_DataSize = origLen;
- _MyItem.MyContent.MyImage.Config = imgCfg.ToString();
+ imgCfg = new ImageConfig
+ {
+ Image_DataSize = origLen
+ };
+ _MyItem.MyContent.MyImage.Config = imgCfg.ToString();
}
_MyItem.MyContent.MyImage.Data = imgToByte;
_MyItem.MyContent.MyImage.FileName = filename;
@@ -956,13 +962,13 @@ namespace Volian.Controls.Library
public override void IdentifyMe(bool highlight)
{
if (highlight)
- this.BackColor = Color.Gray;
+ BackColor = Color.Gray;
else
{
- if (MyPictureBox.Focused || this.Focused) // If active Set BackColor to the active color
- this.BackColor = MyStepPanel.ActiveColor;
+ if (MyPictureBox.Focused || Focused) // If active Set BackColor to the active color
+ BackColor = MyStepPanel.ActiveColor;
else // note that the 'inactive' color is actually MyStepPanel.PanelColor
- this.BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.PanelColor : MyStepPanel.AnnotationColor;
+ BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.PanelColor : MyStepPanel.AnnotationColor;
}
}
#endregion
diff --git a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs
index 88d1f16c..d57d3a8f 100644
--- a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs
+++ b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs
@@ -16,15 +16,20 @@ namespace Volian.Controls.Library
private EPFields myEPFields;
private AnnotationConfig MyConfig;
- private StepTabRibbon _MyStepTabRibbon;
- private Dictionary _DicTB;
- private Dictionary _DicCheckBox;
- private Dictionary _DicComboBox;
- private Dictionary _DicSingleRO;
- private Dictionary _DicMultiRO;
+ private readonly StepTabRibbon _MyStepTabRibbon;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
+ private Dictionary _DicTB;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
+ private Dictionary _DicCheckBox;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
+ private Dictionary _DicComboBox;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
+ private Dictionary _DicSingleRO;
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
+ private Dictionary _DicMultiRO;
private TablePropertiesControl _TablePropControl;
- private string multiseparator = ",";
+ private readonly string multiseparator = ",";
public frmEPAnnotationDetails(AnnotationInfo currAnn)
{
@@ -58,13 +63,15 @@ namespace Volian.Controls.Library
if (EP.type.ToLower() != "tableinput")
{
- Label wlbl = new Label();
- wlbl.Text = EP.label;
- wlbl.Visible = true;
- wlbl.TextAlign = ContentAlignment.MiddleLeft;
- wlbl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
- wlbl.Width = (8 * MaxCharsInLabel) + 5;
- panelEP.Controls.Add(wlbl, 0, panelEP.RowCount - 1);
+ Label wlbl = new Label
+ {
+ Text = EP.label,
+ Visible = true,
+ TextAlign = ContentAlignment.MiddleLeft,
+ Anchor = AnchorStyles.Left | AnchorStyles.Top,
+ Width = (8 * MaxCharsInLabel) + 5
+ };
+ panelEP.Controls.Add(wlbl, 0, panelEP.RowCount - 1);
}
if (EP.type.ToLower() == "text")
@@ -99,9 +106,11 @@ namespace Volian.Controls.Library
}
if (EP.type.ToLower() == "logical")
{
- CheckBox cb = new CheckBox();
- cb.Text = EP.text;
- cb.Visible = true;
+ CheckBox cb = new CheckBox
+ {
+ Text = EP.text,
+ Visible = true
+ };
string val = MyConfig.GetValue("EP", EP.name);
cb.Checked = val != null && val != "" && val.ToUpper()[0] == 'Y';
_DicCheckBox.Add(EP.name, cb);
@@ -110,8 +119,10 @@ namespace Volian.Controls.Library
}
if (EP.type.ToLower() == "combo")
{
- ComboBox cmb = new ComboBox();
- cmb.Visible = true;
+ ComboBox cmb = new ComboBox
+ {
+ Visible = true
+ };
string tmp = EP.text;
string[] tmps = tmp.Split(",".ToCharArray());
foreach (string t in tmps) cmb.Items.Add(t.Trim());
@@ -124,10 +135,12 @@ namespace Volian.Controls.Library
}
if (EP.type.ToLower() == "rosingle")
{
- ComboBox cmb = new ComboBox();
- cmb.Visible = true;
+ ComboBox cmb = new ComboBox
+ {
+ Visible = true
+ };
- List tmps = EP.getROList(currAnn, true);
+ List tmps = EP.getROList(currAnn, true);
cmb.DisplayMember = "Text";
cmb.ValueMember = "Value";
cmb.DataSource = tmps;
@@ -156,9 +169,11 @@ namespace Volian.Controls.Library
if (EP.type.ToLower() == "tableinput" && _TablePropControl == null)
{
string val = MyConfig.GetValue("EP", EP.name);
- _TablePropControl = new TablePropertiesControl(EP.name, EP.label, val);
- _TablePropControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
- panelEP.Controls.Add(_TablePropControl, 1, panelEP.RowCount - 1);
+ _TablePropControl = new TablePropertiesControl(EP.name, EP.label, val)
+ {
+ Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
+ };
+ panelEP.Controls.Add(_TablePropControl, 1, panelEP.RowCount - 1);
}
diff --git a/PROMS/Volian.Controls.Library/frmImportWordContents.cs b/PROMS/Volian.Controls.Library/frmImportWordContents.cs
index ade8d997..abd47b56 100644
--- a/PROMS/Volian.Controls.Library/frmImportWordContents.cs
+++ b/PROMS/Volian.Controls.Library/frmImportWordContents.cs
@@ -13,7 +13,6 @@ namespace Volian.Controls.Library
public partial class frmImportWordContents : Form
{
LBApplicationClass _WordApp;
- bool _initializing = false;
private StepRTB _MyStepRTB = null;
public StepRTB MyStepRTB
@@ -23,12 +22,10 @@ namespace Volian.Controls.Library
}
public frmImportWordContents()
{
- _initializing = true;
InitializeComponent();
// C2019-021 Allow the Number field to be edited.
txbWordFile.Text = Properties.Settings.Default.ImportWordFilePath;
disableButtons();
- _initializing = false;
// B2019-108 Enable/disable buttons
btnOpen.Enabled = File.Exists(txbWordFile.Text) && _WordApp == null;
}
@@ -44,14 +41,9 @@ namespace Volian.Controls.Library
btnInsertNext.Enabled = false;
btnReplaceNext.Enabled = false;
}
- private void ofd_FileOk(object sender, CancelEventArgs e)
- {
- _initializing = true;
- txbWordFile.Text = ofd.FileName;
- _initializing = false;
- }
+ private void ofd_FileOk(object sender, CancelEventArgs e) => txbWordFile.Text = ofd.FileName;
- private void btnBrowse_Click(object sender, EventArgs e)
+ private void btnBrowse_Click(object sender, EventArgs e)
{
// if we have a word doc open, then close it and reset WordApp
if (_WordApp != null)
@@ -254,8 +246,8 @@ namespace Volian.Controls.Library
}
return retval.ToString();
}
- catch (Exception ex)
- {
+ catch (Exception)
+ {
return "12";
}
}
@@ -281,8 +273,7 @@ namespace Volian.Controls.Library
{
try
{
- if (_WordApp != null)
- _WordApp.Quit();
+ _WordApp?.Quit();
// B2019-108 Reset WordApp when closed.
_WordApp = null;
}
@@ -355,12 +346,11 @@ namespace Volian.Controls.Library
}
else
{
- EditItem ei = MyStepRTB.Parent as EditItem;
- if (ei != null)
- {
- ei.AddSiblingAfter();
- }
- }
+ if (MyStepRTB.Parent is EditItem ei)
+ {
+ ei.AddSiblingAfter();
+ }
+ }
}
}
@@ -380,10 +370,7 @@ namespace Volian.Controls.Library
ei = ei.MyParentEditItem;
else
ei = ei.MyPreviousEditItem;
- if (ei != null)
- {
- ei.AddSiblingAfter();
- }
+ ei?.AddSiblingAfter();
}
}
// C201-021 New Function Add a new High level step
@@ -402,10 +389,7 @@ namespace Volian.Controls.Library
ei = ei.MyParentEditItem;
else
ei = ei.MyPreviousEditItem;
- if (ei != null)
- {
- ei.AddSiblingAfter();
- }
+ ei?.AddSiblingAfter();
}
}
private EditItem GetEditItem(Control Ctrl)
@@ -556,7 +540,6 @@ namespace Volian.Controls.Library
return;
}
LoadTable2(xd.DocumentElement);
- int type = 20008;
if(MyStepRTB.MyItemInfo.IsTable)
{
using( Item itm = MyStepRTB.MyItemInfo.Get())
@@ -573,7 +556,7 @@ namespace Volian.Controls.Library
{
EditItem ei = MyStepRTB.Parent as EditItem;
ei.AddChild(E_FromType.Table, 20008, TblFlexGrid);
- if (ei != null) ei.SetAllTabs();
+ ei?.SetAllTabs();
}
}
@@ -624,7 +607,7 @@ namespace Volian.Controls.Library
int TableWidth = 0;
for (iC = 0; iC < tbl.Columns.Count; iC++)
{
- TableWidth = TableWidth + Wcol[iC];
+ TableWidth += Wcol[iC];
}
tend = DateTime.Now; Console.WriteLine("{0} before Rollup columns", TimeSpan.FromTicks(tend.Ticks - tstart.Ticks).TotalMilliseconds); tstart = tend;
// roll up columns
@@ -649,7 +632,7 @@ namespace Volian.Controls.Library
Wcell[iR, i] = Wcell[iR, i - 1];
Wcell[iR, i - 1] = 0;
}
- tmp = tmp - Wcol[iC + SpanC[iR, iC]];
+ tmp -= Wcol[iC + SpanC[iR, iC]];
SpanC[iR, iC]++;
}
iC = iC + SpanC[iR, iC] - 1;
diff --git a/PROMS/Volian.Controls.Library/frmSendErrorLog.cs b/PROMS/Volian.Controls.Library/frmSendErrorLog.cs
index e11323f3..f2e32407 100644
--- a/PROMS/Volian.Controls.Library/frmSendErrorLog.cs
+++ b/PROMS/Volian.Controls.Library/frmSendErrorLog.cs
@@ -13,7 +13,7 @@ namespace Volian.Controls.Library
{
public partial class frmSendErrorLog : Form
{
- private string _ErrorLogPath;
+ private readonly string _ErrorLogPath;
public bool OutlookEmail
{
get { return rbOutlook.Checked; }
@@ -75,17 +75,21 @@ namespace Volian.Controls.Library
FileStream fs = null;
try
{
- MailMessage mm = new MailMessage();
- mm.From = new MailAddress(SMTPUser);
- mm.To.Add("support@volian.com");
- mm.Subject = $"PROMS Error Log {DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")}";
+ MailMessage mm = new MailMessage
+ {
+ From = new MailAddress(SMTPUser)
+ };
+ mm.To.Add("support@volian.com");
+ mm.Subject = $"PROMS Error Log {DateTime.Now:MM/dd/yyyy hh:mm:ss}";
mm.Body = $"{Header}\r\n\r\n{tbContent.Text}";
fs = File.Open(_ErrorLogPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
mm.Attachments.Add(new Attachment(fs, "ErrorLog.txt"));
- SmtpClient sc = new SmtpClient(SMTPServer);
- sc.EnableSsl = true;
- sc.Credentials = new NetworkCredential(SMTPUser, tbPassword.Text);
- sc.Send(mm);
+ SmtpClient sc = new SmtpClient(SMTPServer)
+ {
+ EnableSsl = true,
+ Credentials = new NetworkCredential(SMTPUser, tbPassword.Text)
+ };
+ sc.Send(mm);
return true;
}
catch (Exception ex)
@@ -129,7 +133,7 @@ namespace Volian.Controls.Library
LBApplicationClass app = new LBApplicationClass();
LBMailItemClass msg = app.CreateMailItem();
msg.Recipients.Add("support@volian.com");
- msg.Subject = $"PROMS Error Log {DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")}";
+ msg.Subject = $"PROMS Error Log {DateTime.Now:MM/dd/yyyy hh:mm:ss}";
msg.BodyFormat = LBOlBodyFormat.olFormatPlain;
msg.Body = $"{Header}\r\n\r\n{tbContent.Text}";
msg.AddAttachment(_ErrorLogPath);
diff --git a/PROMS/Volian.Controls.Library/frmViewTextFile.cs b/PROMS/Volian.Controls.Library/frmViewTextFile.cs
index d1fe8eb8..c8b4a78e 100644
--- a/PROMS/Volian.Controls.Library/frmViewTextFile.cs
+++ b/PROMS/Volian.Controls.Library/frmViewTextFile.cs
@@ -6,8 +6,8 @@ namespace Volian.Controls.Library
{
public partial class frmViewTextFile : DevComponents.DotNetBar.Office2007Form //Form
{
- string _FileName;
- RichTextBoxStreamType _RTBType;
+ readonly string _FileName;
+ readonly RichTextBoxStreamType _RTBType;
public string ButtonText
{
get { return buttonX1.Text; }
diff --git a/PROMS/Volian.Pipe.Library/PipeClient.cs b/PROMS/Volian.Pipe.Library/PipeClient.cs
index 502badb0..b4e31394 100644
--- a/PROMS/Volian.Pipe.Library/PipeClient.cs
+++ b/PROMS/Volian.Pipe.Library/PipeClient.cs
@@ -3,31 +3,19 @@
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
*********************************************************************************************/
using System;
-using System.Collections.Generic;
using System.IO.Pipes;
-//using System.Linq;
using System.Text;
-//using System.Threading.Tasks;
namespace Volian.Pipe.Library
{
public class PipeClient
{
- private string _Name;
- public string Name
+ public string Name { get; set; }
+
+ public int TimeOut { get; set; } = 1000;
+ public PipeClient(string name)
{
- get { return _Name; }
- set { _Name = value; }
- }
- private int _TimeOut = 1000;
- public int TimeOut
- {
- get { return _TimeOut; }
- set { _TimeOut = value; }
- }
- public PipeClient(string name)
- {
- _Name = name;
+ Name = name;
}
public void Send(string msg)
{
diff --git a/PROMS/Volian.Pipe.Library/PipeServer.cs b/PROMS/Volian.Pipe.Library/PipeServer.cs
index 197d7a9d..15d3a63d 100644
--- a/PROMS/Volian.Pipe.Library/PipeServer.cs
+++ b/PROMS/Volian.Pipe.Library/PipeServer.cs
@@ -3,11 +3,8 @@
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
*********************************************************************************************/
using System;
-using System.Collections.Generic;
using System.IO.Pipes;
-using System.Linq;
using System.Text;
-//using System.Threading.Tasks;
namespace Volian.Pipe.Library
{
@@ -15,18 +12,12 @@ namespace Volian.Pipe.Library
public delegate void DelegateMessage(string Reply);
public class PipeServer
{
- private string _Name;
- public string Name
+ public string Name { get; set; }
+ public PipeServer(string name)
{
- get { return _Name; }
- set { _Name = value; }
- }
- public PipeServer(string name)
- {
- _Name = name;
+ Name = name;
}
public event DelegateMessage PipeMessage;
- string _pipeName;
public void Listen()
{
try
@@ -66,9 +57,7 @@ namespace Volian.Pipe.Library
// Kill original sever and create new wait server
pipeServer.Close();
pipeServer = null;
- //pipeServer = new NamedPipeServerStream(_pipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
- //// Recursively wait for the connection again and again....
- //pipeServer.BeginWaitForConnection(new AsyncCallback(WaitForConnectionCallBack), pipeServer);
+ // Recursively wait for the connection again and again....
Listen();
}
catch