Common.Forms with ListViewE and ModelessForm as in ver. 3.1
This commit is contained in:
parent
5a5f8493f2
commit
61add6be07
@ -43,6 +43,17 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BackgroundBeep.cs" />
|
<Compile Include="BackgroundBeep.cs" />
|
||||||
<Compile Include="Enums.cs" />
|
<Compile Include="Enums.cs" />
|
||||||
|
<Compile Include="Forms\ListViewEx.cs" />
|
||||||
|
<Compile Include="Forms\ListViewExtensions.cs" />
|
||||||
|
<Compile Include="Forms\LviDateTimeColumnComparer.cs" />
|
||||||
|
<Compile Include="Forms\LviIntColumnComparer.cs" />
|
||||||
|
<Compile Include="Forms\LviNameSurnameColumnComparer.cs" />
|
||||||
|
<Compile Include="Forms\LviTextColumnComparer.cs" />
|
||||||
|
<Compile Include="Forms\MessageEventArgs.cs" />
|
||||||
|
<Compile Include="Forms\ModelessForm.cs" />
|
||||||
|
<Compile Include="Forms\ModelessForm.designer.cs">
|
||||||
|
<DependentUpon>ModelessForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="StatisticalMetrics.cs" />
|
<Compile Include="StatisticalMetrics.cs" />
|
||||||
<Compile Include="Iperl\OptoTelegramRaw.cs" />
|
<Compile Include="Iperl\OptoTelegramRaw.cs" />
|
||||||
<Compile Include="SerializableDictionary.cs" />
|
<Compile Include="SerializableDictionary.cs" />
|
||||||
@ -63,7 +74,14 @@
|
|||||||
<Compile Include="UIControls\LviIntColumnComparer.cs" />
|
<Compile Include="UIControls\LviIntColumnComparer.cs" />
|
||||||
<Compile Include="UIControls\LviTextColumnComparer.cs" />
|
<Compile Include="UIControls\LviTextColumnComparer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Forms\ListViewEx.resx">
|
||||||
|
<DependentUpon>ListViewEx.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Forms\ModelessForm.resx">
|
||||||
|
<DependentUpon>ModelessForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
495
Common/Forms/ListViewEx.cs
Normal file
495
Common/Forms/ListViewEx.cs
Normal file
@ -0,0 +1,495 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event Handler for SubItem events
|
||||||
|
/// </summary>
|
||||||
|
public delegate void SubItemEventHandler(object sender, SubItemEventArgs e);
|
||||||
|
/// <summary>
|
||||||
|
/// Event Handler for SubItemEndEditing events
|
||||||
|
/// </summary>
|
||||||
|
public delegate void SubItemEndEditingEventHandler(object sender, SubItemEndEditingEventArgs e);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inherited ListView to allow in-place editing of subitems
|
||||||
|
/// </summary>
|
||||||
|
public class ListViewEx : System.Windows.Forms.ListView
|
||||||
|
{
|
||||||
|
#region Interop structs, imports and constants
|
||||||
|
/// <summary>
|
||||||
|
/// MessageHeader for WM_NOTIFY
|
||||||
|
/// </summary>
|
||||||
|
private struct NMHDR
|
||||||
|
{
|
||||||
|
#pragma warning disable
|
||||||
|
public IntPtr hwndFrom;
|
||||||
|
public Int32 idFrom;
|
||||||
|
public Int32 code;
|
||||||
|
#pragma warning restore
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar);
|
||||||
|
[DllImport("user32.dll", CharSet=CharSet.Ansi)]
|
||||||
|
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int len, ref int [] order);
|
||||||
|
|
||||||
|
// ListView messages
|
||||||
|
private const int LVM_FIRST = 0x1000;
|
||||||
|
private const int LVM_GETCOLUMNORDERARRAY = (LVM_FIRST + 59);
|
||||||
|
|
||||||
|
// Windows Messages that will abort editing
|
||||||
|
private const int WM_HSCROLL = 0x114;
|
||||||
|
private const int WM_VSCROLL = 0x115;
|
||||||
|
private const int WM_SIZE = 0x05;
|
||||||
|
private const int WM_NOTIFY = 0x4E;
|
||||||
|
|
||||||
|
private const int HDN_FIRST = -300;
|
||||||
|
private const int HDN_BEGINDRAG = (HDN_FIRST-10);
|
||||||
|
private const int HDN_ITEMCHANGINGA = (HDN_FIRST-0);
|
||||||
|
private const int HDN_ITEMCHANGINGW = (HDN_FIRST-20);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public MySortOrder SortOrder = MySortOrder.None;
|
||||||
|
public int SortColumn = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.Container components = null;
|
||||||
|
|
||||||
|
public event SubItemEventHandler SubItemClicked;
|
||||||
|
public event SubItemEventHandler SubItemRightClicked;
|
||||||
|
public event SubItemEventHandler SubItemBeginEditing;
|
||||||
|
public event SubItemEndEditingEventHandler SubItemEndEditing;
|
||||||
|
|
||||||
|
public ListViewEx()
|
||||||
|
{
|
||||||
|
// This call is required by the Windows.Forms Form Designer.
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
base.FullRowSelect = true;
|
||||||
|
base.View = View.Details;
|
||||||
|
base.AllowColumnReorder = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
protected override void Dispose( bool disposing )
|
||||||
|
{
|
||||||
|
if( disposing )
|
||||||
|
{
|
||||||
|
if( components != null )
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose( disposing );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private bool _doubleClickActivation = false;
|
||||||
|
/// <summary>
|
||||||
|
/// Is a double click required to start editing a cell?
|
||||||
|
/// </summary>
|
||||||
|
public bool DoubleClickActivation
|
||||||
|
{
|
||||||
|
get { return _doubleClickActivation; }
|
||||||
|
set { _doubleClickActivation = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve the order in which columns appear
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Current display order of column indices</returns>
|
||||||
|
public int[] GetColumnOrder()
|
||||||
|
{
|
||||||
|
IntPtr lPar = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * Columns.Count);
|
||||||
|
|
||||||
|
IntPtr res = SendMessage(Handle, LVM_GETCOLUMNORDERARRAY, new IntPtr(Columns.Count), lPar);
|
||||||
|
if (res.ToInt32() == 0) // Something went wrong
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(lPar);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int [] order = new int[Columns.Count];
|
||||||
|
Marshal.Copy(lPar, order, 0, Columns.Count);
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(lPar);
|
||||||
|
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find ListViewItem and SubItem Index at position (x,y)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">relative to ListView</param>
|
||||||
|
/// <param name="y">relative to ListView</param>
|
||||||
|
/// <param name="item">Item at position (x,y)</param>
|
||||||
|
/// <returns>SubItem index</returns>
|
||||||
|
public int GetSubItemAt(int x, int y, out ListViewItem item)
|
||||||
|
{
|
||||||
|
item = this.GetItemAt(x, y);
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
int[] order = GetColumnOrder();
|
||||||
|
Rectangle lviBounds;
|
||||||
|
int subItemX;
|
||||||
|
|
||||||
|
lviBounds = item.GetBounds(ItemBoundsPortion.Entire);
|
||||||
|
subItemX = lviBounds.Left;
|
||||||
|
for (int i=0; i<order.Length; i++)
|
||||||
|
{
|
||||||
|
ColumnHeader h = this.Columns[order[i]];
|
||||||
|
if (x < subItemX+h.Width)
|
||||||
|
{
|
||||||
|
return h.Index;
|
||||||
|
}
|
||||||
|
subItemX += h.Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get bounds for a SubItem
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Item">Target ListViewItem</param>
|
||||||
|
/// <param name="SubItem">Target SubItem index</param>
|
||||||
|
/// <returns>Bounds of SubItem (relative to ListView)</returns>
|
||||||
|
public Rectangle GetSubItemBounds(ListViewItem Item, int SubItem)
|
||||||
|
{
|
||||||
|
int[] order = GetColumnOrder();
|
||||||
|
|
||||||
|
Rectangle subItemRect = Rectangle.Empty;
|
||||||
|
if (SubItem >= order.Length)
|
||||||
|
throw new IndexOutOfRangeException("SubItem "+SubItem+" out of range");
|
||||||
|
|
||||||
|
if (Item == null)
|
||||||
|
throw new ArgumentNullException("Item");
|
||||||
|
|
||||||
|
Rectangle lviBounds = Item.GetBounds(ItemBoundsPortion.Entire);
|
||||||
|
int subItemX = lviBounds.Left;
|
||||||
|
|
||||||
|
ColumnHeader col;
|
||||||
|
int i;
|
||||||
|
for (i=0; i<order.Length; i++)
|
||||||
|
{
|
||||||
|
col = this.Columns[order[i]];
|
||||||
|
if (col.Index == SubItem)
|
||||||
|
break;
|
||||||
|
subItemX += col.Width;
|
||||||
|
}
|
||||||
|
subItemRect = new Rectangle(subItemX, lviBounds.Top, this.Columns[order[i]].Width, lviBounds.Height);
|
||||||
|
return subItemRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void WndProc(ref Message msg)
|
||||||
|
{
|
||||||
|
switch (msg.Msg)
|
||||||
|
{
|
||||||
|
// Look for WM_VSCROLL,WM_HSCROLL or WM_SIZE messages.
|
||||||
|
case WM_VSCROLL:
|
||||||
|
case WM_HSCROLL:
|
||||||
|
case WM_SIZE:
|
||||||
|
EndEditing(false);
|
||||||
|
break;
|
||||||
|
case WM_NOTIFY:
|
||||||
|
// Look for WM_NOTIFY of events that might also change the
|
||||||
|
// editor's position/size: Column reordering or resizing
|
||||||
|
NMHDR h = (NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(NMHDR));
|
||||||
|
if (h.code == HDN_BEGINDRAG ||
|
||||||
|
h.code == HDN_ITEMCHANGINGA ||
|
||||||
|
h.code == HDN_ITEMCHANGINGW)
|
||||||
|
EndEditing(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.WndProc(ref msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Initialize editing depending of DoubleClickActivation property
|
||||||
|
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
|
||||||
|
MouseEventArgs me = (MouseEventArgs)e;
|
||||||
|
if (me.Button == MouseButtons.Right)
|
||||||
|
{
|
||||||
|
/// Right mouse button click function
|
||||||
|
RightClickFunctionSubitemAt(new Point(e.X, e.Y));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/// Normal function (=edit item)
|
||||||
|
if (DoubleClickActivation)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditSubitemAt(new Point(e.X, e.Y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDoubleClick(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDoubleClick (e);
|
||||||
|
|
||||||
|
if (!DoubleClickActivation)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point pt = this.PointToClient(Cursor.Position);
|
||||||
|
|
||||||
|
EditSubitemAt(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Fire SubItemClicked
|
||||||
|
///</summary>
|
||||||
|
///<param name="p">Point of click/doubleclick</param>
|
||||||
|
private void EditSubitemAt(Point p)
|
||||||
|
{
|
||||||
|
ListViewItem item;
|
||||||
|
int idx = GetSubItemAt(p.X, p.Y, out item);
|
||||||
|
if (idx >= 0)
|
||||||
|
{
|
||||||
|
OnSubItemClicked(new SubItemEventArgs(item, idx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Fire SubItemRightClicked
|
||||||
|
///</summary>
|
||||||
|
///<param name="p">Point of click/doubleclick</param>
|
||||||
|
private void RightClickFunctionSubitemAt(Point p)
|
||||||
|
{
|
||||||
|
ListViewItem item;
|
||||||
|
int idx = GetSubItemAt(p.X, p.Y, out item);
|
||||||
|
if (idx >= 0)
|
||||||
|
{
|
||||||
|
OnSubItemRightClicked(new SubItemEventArgs(item, idx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region In-place editing functions
|
||||||
|
// The control performing the actual editing
|
||||||
|
private Control _editingControl;
|
||||||
|
// The LVI being edited
|
||||||
|
private ListViewItem _editItem;
|
||||||
|
// The SubItem being edited
|
||||||
|
private int _editSubItem;
|
||||||
|
|
||||||
|
protected void OnSubItemBeginEditing(SubItemEventArgs e)
|
||||||
|
{
|
||||||
|
if (SubItemBeginEditing != null) SubItemBeginEditing(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnSubItemEndEditing(SubItemEndEditingEventArgs e)
|
||||||
|
{
|
||||||
|
if (SubItemEndEditing != null) SubItemEndEditing(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnSubItemClicked(SubItemEventArgs e)
|
||||||
|
{
|
||||||
|
if (SubItemClicked != null) SubItemClicked(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnSubItemRightClicked(SubItemEventArgs e)
|
||||||
|
{
|
||||||
|
if (SubItemRightClicked != null) SubItemRightClicked(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Begin in-place editing of given cell
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c">Control used as cell editor</param>
|
||||||
|
/// <param name="Item">ListViewItem to edit</param>
|
||||||
|
/// <param name="SubItem">SubItem index to edit</param>
|
||||||
|
public void StartEditing(Control c, ListViewItem Item, int SubItem)
|
||||||
|
{
|
||||||
|
OnSubItemBeginEditing(new SubItemEventArgs(Item, SubItem));
|
||||||
|
|
||||||
|
Rectangle rcSubItem = GetSubItemBounds(Item, SubItem);
|
||||||
|
|
||||||
|
if (rcSubItem.X < 0)
|
||||||
|
{
|
||||||
|
// Left edge of SubItem not visible - adjust rectangle position and width
|
||||||
|
rcSubItem.Width += rcSubItem.X;
|
||||||
|
rcSubItem.X=0;
|
||||||
|
}
|
||||||
|
if (rcSubItem.X+rcSubItem.Width > this.Width)
|
||||||
|
{
|
||||||
|
// Right edge of SubItem not visible - adjust rectangle width
|
||||||
|
rcSubItem.Width = this.Width-rcSubItem.Left;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subitem bounds are relative to the location of the ListView!
|
||||||
|
rcSubItem.Offset(Left, Top);
|
||||||
|
|
||||||
|
// In case the editing control and the listview are on different parents,
|
||||||
|
// account for different origins
|
||||||
|
Point origin = new Point(0,0);
|
||||||
|
Point lvOrigin = this.Parent.PointToScreen(origin);
|
||||||
|
Point ctlOrigin = c.Parent.PointToScreen(origin);
|
||||||
|
|
||||||
|
rcSubItem.Offset(lvOrigin.X-ctlOrigin.X, lvOrigin.Y-ctlOrigin.Y);
|
||||||
|
|
||||||
|
// Position and show editor
|
||||||
|
c.Bounds = rcSubItem;
|
||||||
|
c.Text = Item.SubItems[SubItem].Text;
|
||||||
|
c.Visible = true;
|
||||||
|
c.BringToFront();
|
||||||
|
c.Focus();
|
||||||
|
|
||||||
|
_editingControl = c;
|
||||||
|
_editingControl.Leave += new EventHandler(_editControl_Leave);
|
||||||
|
_editingControl.KeyPress += new KeyPressEventHandler(_editControl_KeyPress);
|
||||||
|
|
||||||
|
_editItem = Item;
|
||||||
|
_editSubItem = SubItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void _editControl_Leave(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// cell editor losing focus
|
||||||
|
EndEditing(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _editControl_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.KeyChar)
|
||||||
|
{
|
||||||
|
case (char)(int)Keys.Escape:
|
||||||
|
{
|
||||||
|
EndEditing(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case (char)(int)Keys.Enter:
|
||||||
|
{
|
||||||
|
EndEditing(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Accept or discard current value of cell editor control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="AcceptChanges">Use the _editingControl's Text as new SubItem text or discard changes?</param>
|
||||||
|
public void EndEditing(bool AcceptChanges)
|
||||||
|
{
|
||||||
|
if (_editingControl == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SubItemEndEditingEventArgs e = new SubItemEndEditingEventArgs(
|
||||||
|
_editItem, // The item being edited
|
||||||
|
_editSubItem, // The subitem index being edited
|
||||||
|
AcceptChanges ?
|
||||||
|
_editingControl.Text : // Use editControl text if changes are accepted
|
||||||
|
_editItem.SubItems[_editSubItem].Text, // or the original subitem's text, if changes are discarded
|
||||||
|
!AcceptChanges // Cancel?
|
||||||
|
);
|
||||||
|
|
||||||
|
OnSubItemEndEditing(e);
|
||||||
|
|
||||||
|
if (_editSubItem >= 0 && _editSubItem < _editItem.SubItems.Count)
|
||||||
|
{
|
||||||
|
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_editingControl != null)
|
||||||
|
{
|
||||||
|
_editingControl.Leave -= new EventHandler(_editControl_Leave);
|
||||||
|
_editingControl.KeyPress -= new KeyPressEventHandler(_editControl_KeyPress);
|
||||||
|
|
||||||
|
_editingControl.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_editingControl = null;
|
||||||
|
_editItem = null;
|
||||||
|
_editSubItem = -1;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event Args for SubItemClicked event
|
||||||
|
/// </summary>
|
||||||
|
public class SubItemEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
int subItem = -1; /// Sub-item index
|
||||||
|
ListViewItem item = null;
|
||||||
|
|
||||||
|
public int SubItem { get { return subItem; } }
|
||||||
|
public ListViewItem Item { get { return item; } }
|
||||||
|
|
||||||
|
public SubItemEventArgs(ListViewItem item, int subItem)
|
||||||
|
{
|
||||||
|
this.subItem = subItem;
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event Args for SubItemEndEditingClicked event
|
||||||
|
/// </summary>
|
||||||
|
public class SubItemEndEditingEventArgs : SubItemEventArgs
|
||||||
|
{
|
||||||
|
string displayText = string.Empty;
|
||||||
|
bool cancel = true;
|
||||||
|
|
||||||
|
public SubItemEndEditingEventArgs(ListViewItem item, int subItem, string displayText, bool cancel) :
|
||||||
|
base(item, subItem)
|
||||||
|
{
|
||||||
|
this.displayText = displayText;
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
public string DisplayText
|
||||||
|
{
|
||||||
|
get { return displayText; }
|
||||||
|
set { displayText = value; }
|
||||||
|
}
|
||||||
|
public bool Cancel
|
||||||
|
{
|
||||||
|
get { return cancel; }
|
||||||
|
set { cancel = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Common/Forms/ListViewEx.resx
Normal file
42
Common/Forms/ListViewEx.resx
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="ResMimeType">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="Version">
|
||||||
|
<value>1.0.0.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="Reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="Writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
109
Common/Forms/ListViewExtensions.cs
Normal file
109
Common/Forms/ListViewExtensions.cs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public static class ListViewExtensions
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct HDITEM
|
||||||
|
{
|
||||||
|
public Mask mask;
|
||||||
|
public int cxy;
|
||||||
|
[MarshalAs(UnmanagedType.LPTStr)]
|
||||||
|
public string pszText;
|
||||||
|
public IntPtr hbm;
|
||||||
|
public int cchTextMax;
|
||||||
|
public Format fmt;
|
||||||
|
public IntPtr lParam;
|
||||||
|
// _WIN32_IE >= 0x0300
|
||||||
|
public int iImage;
|
||||||
|
public int iOrder;
|
||||||
|
// _WIN32_IE >= 0x0500
|
||||||
|
public uint type;
|
||||||
|
public IntPtr pvFilter;
|
||||||
|
// _WIN32_WINNT >= 0x0600
|
||||||
|
public uint state;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum Mask
|
||||||
|
{
|
||||||
|
Format = 0x4, // HDI_FORMAT
|
||||||
|
};
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum Format
|
||||||
|
{
|
||||||
|
SortDown = 0x200, // HDF_SORTDOWN
|
||||||
|
SortUp = 0x400, // HDF_SORTUP
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
public const int LVM_FIRST = 0x1000;
|
||||||
|
public const int LVM_GETHEADER = LVM_FIRST + 31;
|
||||||
|
|
||||||
|
public const int HDM_FIRST = 0x1200;
|
||||||
|
public const int HDM_GETITEM = HDM_FIRST + 11;
|
||||||
|
public const int HDM_SETITEM = HDM_FIRST + 12;
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
|
||||||
|
|
||||||
|
public static void SetSortIcon(this ListViewEx listViewControl, int columnIndex, MySortOrder order)
|
||||||
|
{
|
||||||
|
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
|
||||||
|
{
|
||||||
|
var columnPtr = new IntPtr(columnNumber);
|
||||||
|
var item = new HDITEM
|
||||||
|
{
|
||||||
|
mask = HDITEM.Mask.Format
|
||||||
|
};
|
||||||
|
|
||||||
|
if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order != MySortOrder.None && columnNumber == columnIndex)
|
||||||
|
{
|
||||||
|
switch (order)
|
||||||
|
{
|
||||||
|
case MySortOrder.Ascending:
|
||||||
|
case MySortOrder.Ascending2:
|
||||||
|
item.fmt &= ~HDITEM.Format.SortDown;
|
||||||
|
item.fmt |= HDITEM.Format.SortUp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MySortOrder.Descending:
|
||||||
|
case MySortOrder.Descending2:
|
||||||
|
item.fmt &= ~HDITEM.Format.SortUp;
|
||||||
|
item.fmt |= HDITEM.Format.SortDown;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
Common/Forms/LviDateTimeColumnComparer.cs
Normal file
46
Common/Forms/LviDateTimeColumnComparer.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
public class LviDateTimeColumnComparer : IComparer
|
||||||
|
{
|
||||||
|
int column;
|
||||||
|
MySortOrder order;
|
||||||
|
|
||||||
|
public LviDateTimeColumnComparer()
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
order = MySortOrder.Ascending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LviDateTimeColumnComparer(int column, MySortOrder order)
|
||||||
|
{
|
||||||
|
this.column = column;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(object x, object y)
|
||||||
|
{
|
||||||
|
DateTime valX = DateTime.Parse(((ListViewItem)x).SubItems[column].Text);
|
||||||
|
DateTime valY = DateTime.Parse(((ListViewItem)y).SubItems[column].Text);
|
||||||
|
|
||||||
|
if (valX == valY)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((order == MySortOrder.Descending || order == MySortOrder.Descending2))
|
||||||
|
{
|
||||||
|
return (valY > valX) ? 1 : -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (valX > valY) ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Common/Forms/LviIntColumnComparer.cs
Normal file
34
Common/Forms/LviIntColumnComparer.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
public class LviIntColumnComparer : IComparer
|
||||||
|
{
|
||||||
|
int column;
|
||||||
|
MySortOrder order;
|
||||||
|
|
||||||
|
public LviIntColumnComparer()
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
order = MySortOrder.Ascending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LviIntColumnComparer(int column, MySortOrder order)
|
||||||
|
{
|
||||||
|
this.column = column;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(object x, object y)
|
||||||
|
{
|
||||||
|
int valX = int.Parse(((ListViewItem)x).SubItems[column].Text);
|
||||||
|
int valY = int.Parse(((ListViewItem)y).SubItems[column].Text);
|
||||||
|
return (order == MySortOrder.Descending || order == MySortOrder.Descending2) ? (valY - valX) : (valX - valY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
Common/Forms/LviNameSurnameColumnComparer.cs
Normal file
54
Common/Forms/LviNameSurnameColumnComparer.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
public class LviNameSurnameColumnComparer : IComparer
|
||||||
|
{
|
||||||
|
private int column;
|
||||||
|
MySortOrder order;
|
||||||
|
|
||||||
|
public LviNameSurnameColumnComparer()
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
order = MySortOrder.Ascending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LviNameSurnameColumnComparer(int column, MySortOrder order)
|
||||||
|
{
|
||||||
|
this.column = column;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(object x, object y)
|
||||||
|
{
|
||||||
|
string nameX = ((ListViewItem)x).SubItems[column].Text;
|
||||||
|
string nameY = ((ListViewItem)y).SubItems[column].Text;
|
||||||
|
string surnameX;
|
||||||
|
string surnameY;
|
||||||
|
|
||||||
|
switch (order)
|
||||||
|
{
|
||||||
|
case MySortOrder.Ascending:
|
||||||
|
return String.Compare(nameX, nameY);
|
||||||
|
|
||||||
|
case MySortOrder.Descending:
|
||||||
|
return String.Compare(nameY, nameX);
|
||||||
|
|
||||||
|
case MySortOrder.Ascending2:
|
||||||
|
surnameX = (nameX.IndexOf(' ') > 0) ? nameX.Substring(nameX.IndexOf(' ') + 1) : nameX;
|
||||||
|
surnameY = (nameX.IndexOf(' ') > 0) ? nameY.Substring(nameY.IndexOf(' ') + 1) : nameY;
|
||||||
|
return String.Compare(surnameX, surnameY);
|
||||||
|
|
||||||
|
case MySortOrder.Descending2:
|
||||||
|
surnameX = (nameX.IndexOf(' ') > 0) ? nameX.Substring(nameX.IndexOf(' ') + 1) : nameX;
|
||||||
|
surnameY = (nameX.IndexOf(' ') > 0) ? nameY.Substring(nameY.IndexOf(' ') + 1) : nameY;
|
||||||
|
return String.Compare(surnameY, surnameX);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Common/Forms/LviTextColumnComparer.cs
Normal file
34
Common/Forms/LviTextColumnComparer.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
public class LviTextColumnComparer : IComparer
|
||||||
|
{
|
||||||
|
private int column;
|
||||||
|
MySortOrder order;
|
||||||
|
|
||||||
|
public LviTextColumnComparer()
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
order = MySortOrder.Ascending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LviTextColumnComparer(int column, MySortOrder order)
|
||||||
|
{
|
||||||
|
this.column = column;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(object x, object y)
|
||||||
|
{
|
||||||
|
string txtX = ((ListViewItem)x).SubItems[column].Text;
|
||||||
|
string txtY = ((ListViewItem)y).SubItems[column].Text;
|
||||||
|
return (order == MySortOrder.Descending || order == MySortOrder.Descending2) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Common/Forms/MessageEventArgs.cs
Normal file
10
Common/Forms/MessageEventArgs.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
public class MessageEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public string Message;
|
||||||
|
public MessageEventArgs(string message) { Message = message; }
|
||||||
|
}
|
||||||
|
}
|
||||||
63
Common/Forms/ModelessForm.Designer.cs
generated
Normal file
63
Common/Forms/ModelessForm.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
partial class ModelessForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(47, 29);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(35, 13);
|
||||||
|
this.label1.TabIndex = 0;
|
||||||
|
this.label1.Text = "label1";
|
||||||
|
//
|
||||||
|
// ModelessForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(191, 56);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
|
this.Name = "ModelessForm";
|
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "ModelessForm";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
}
|
||||||
|
}
|
||||||
76
Common/Forms/ModelessForm.cs
Normal file
76
Common/Forms/ModelessForm.cs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Common.Forms
|
||||||
|
{
|
||||||
|
public partial class ModelessForm : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to be used by the application
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">Window title</param>
|
||||||
|
/// <param name="message">Displayed message</param>
|
||||||
|
public ModelessForm(string message, int backArgb = 0, int textArgb = 0, Font textFont = null, string title = null)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
ControlBox = false;
|
||||||
|
|
||||||
|
label1.Text = (message != null) ? message : "Please wait";
|
||||||
|
BackColor = (backArgb != 0) ? Color.FromArgb(backArgb) : Color.LightGreen;
|
||||||
|
ForeColor = (textArgb != 0) ? Color.FromArgb(textArgb) : Color.Black;
|
||||||
|
label1.Font = (textFont != null) ? textFont : new Font("Arial", 14, FontStyle.Regular);
|
||||||
|
Text = (title != null) ? title : string.Empty;
|
||||||
|
|
||||||
|
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
|
||||||
|
float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
|
||||||
|
Width = (int)textWidth + 120; /// Form width calculated from the text width
|
||||||
|
Height += (int)textHeight; /// Form height calculated from the text height
|
||||||
|
|
||||||
|
UpdateMessageHandler += delegate(object sender, MessageEventArgs args)
|
||||||
|
{
|
||||||
|
if (InvokeRequired) { Invoke(new EventHandler<MessageEventArgs>(OnUpdateMessage), sender, args); }
|
||||||
|
else OnUpdateMessage(sender, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
CloseFormHandler += delegate(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args); }
|
||||||
|
else OnCloseForm(sender, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called from the state machine when an operation forces a modeless dialog close.
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateMessage(MessageEventArgs args)
|
||||||
|
{
|
||||||
|
if (UpdateMessageHandler == null) return;
|
||||||
|
try { UpdateMessageHandler(null, args); }
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
public event EventHandler<MessageEventArgs> UpdateMessageHandler;
|
||||||
|
void OnUpdateMessage(object sender, MessageEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Message != null) label1.Text = args.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called from the state machine when an operation forces a modeless dialog close.
|
||||||
|
/// </summary>
|
||||||
|
public static void CloseForm()
|
||||||
|
{
|
||||||
|
if (CloseFormHandler == null) return;
|
||||||
|
try { CloseFormHandler(null, null); }
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
static public event EventHandler<EventArgs> CloseFormHandler;
|
||||||
|
void OnCloseForm(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Common/Forms/ModelessForm.resx
Normal file
120
Common/Forms/ModelessForm.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
Loading…
Reference in New Issue
Block a user