Updates to DropDownPanel, Baseline, & Controls

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