Everything uses Common.Forms.ListViewEx, other LIstViewEx-es removed.

This commit is contained in:
Milan Hanajik 2022-01-23 13:58:54 +01:00
parent 61add6be07
commit a4a583c41a
93 changed files with 154 additions and 2503 deletions

View File

@ -43,14 +43,18 @@
<ItemGroup>
<Compile Include="BackgroundBeep.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Forms\ListViewEx.cs" />
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
<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.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ModelessForm.designer.cs">
<DependentUpon>ModelessForm.cs</DependentUpon>
</Compile>
@ -63,16 +67,9 @@
<Compile Include="UIControls\CoolButtonCtrl.Designer.cs">
<DependentUpon>CoolButtonCtrl.cs</DependentUpon>
</Compile>
<Compile Include="UIControls\LviDateTimeColumnComparer.cs" />
<Compile Include="UIControls\RoundedRectangle.cs" />
<Compile Include="Utils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UIControls\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UIControls\ListViewExtensions.cs" />
<Compile Include="UIControls\LviIntColumnComparer.cs" />
<Compile Include="UIControls\LviTextColumnComparer.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\ListViewEx.resx">

View File

@ -1,486 +0,0 @@
///
/// Copyright (c) 2013-2020 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.UIControls
{
/// <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
/// <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);
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
_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; }
}
}
}

View File

@ -1,42 +0,0 @@
<?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>

View File

@ -1,107 +0,0 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Common.UIControls
{
[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, SortOrder 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 != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
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();
}
}
}
}
}

View File

@ -1,46 +0,0 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Windows.Forms;
namespace Common.UIControls
{
public class LviDateTimeColumnComparer : IComparer
{
int column;
SortOrder order;
public LviDateTimeColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviDateTimeColumnComparer(int column, SortOrder 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 == SortOrder.Ascending)
{
return (valX > valY) ? 1 : -1;
}
else
{
return (valY > valX) ? 1 : -1;
}
}
}
}

View File

@ -1,34 +0,0 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Windows.Forms;
namespace Common.UIControls
{
public class LviIntColumnComparer : IComparer
{
int column;
SortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviIntColumnComparer(int column, SortOrder 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 == SortOrder.Descending) ? (valY - valX) : (valX - valY);
}
}
}

View File

@ -1,34 +0,0 @@
///
/// Copyright (c) 2019-2020 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Windows.Forms;
namespace Common.UIControls
{
public class LviTextColumnComparer : IComparer
{
private int column;
SortOrder order;
public LviTextColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviTextColumnComparer(int column, SortOrder 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 == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
}
}
}

View File

@ -35,7 +35,7 @@
this.unreadEventsRadioButton = new System.Windows.Forms.RadioButton();
this.allEventsRadioButton = new System.Windows.Forms.RadioButton();
this.settingsButton = new System.Windows.Forms.Button();
this.eventsListView = new Common.UIControls.ListViewEx();
this.eventsListView = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -176,7 +176,7 @@
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button settingsButton;
private Common.UIControls.ListViewEx eventsListView;
private Common.Forms.ListViewEx eventsListView;
private System.Windows.Forms.GroupBox eventsSelectionGroupBox;
private System.Windows.Forms.RadioButton unreadEventsRadioButton;
private System.Windows.Forms.RadioButton allEventsRadioButton;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Windows.Forms;
using NHibernate;
using Common;
using Common.UIControls;
using Common.Forms;
using Events;
using Events.Entities;
using EventViewer.Resources;
@ -33,7 +33,7 @@ namespace EventViewer
ISession session;
IList<Subscriber> subscribers;
IList<Event> events;
SortOrder sortOrder = SortOrder.Ascending;
MySortOrder sortOrder = MySortOrder.Ascending;
int sortColumn = -1; /// 0-based index of column to be used for sorting
EViewerOption eViewerOption;
@ -222,13 +222,13 @@ namespace EventViewer
{
if (e.Column == sortColumn)
{
sortOrder = (sortOrder == SortOrder.Ascending) ? SortOrder.Descending : SortOrder.Ascending;
sortOrder = (sortOrder == MySortOrder.Ascending) ? MySortOrder.Descending : MySortOrder.Ascending;
}
else
{
/// Clicked on another column header => set sortOrder to SortOrder.Ascending
sortColumn = e.Column;
sortOrder = SortOrder.Ascending;
sortOrder = MySortOrder.Ascending;
}
switch ((Column)sortColumn)

View File

@ -1,486 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Results.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
/// <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);
_editItem.SubItems[_editSubItem].Text = e.DisplayText;
_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; }
}
}
}

View File

@ -1,42 +0,0 @@
<?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>

View File

@ -1,104 +0,0 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Results.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, SortOrder 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 != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
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();
}
}
}
}
}

View File

@ -1,31 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace Results.Forms
{
public class LviIntColumnComparer : IComparer
{
int column;
SortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviIntColumnComparer(int column, SortOrder 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 == SortOrder.Descending) ? (valY - valX) : (valX - valY);
}
}
}

View File

@ -1,31 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace Results.Forms
{
public class LviTextColumnComparer : IComparer
{
private int column;
SortOrder order;
public LviTextColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviTextColumnComparer(int column, SortOrder 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 == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
}
}
}

View File

@ -37,7 +37,7 @@
this.availableAlphabeticTreeView = new System.Windows.Forms.TreeView();
this.downButton = new System.Windows.Forms.Button();
this.upButton = new System.Windows.Forms.Button();
this.selectedResultsListViewEx = new Results.Forms.ListViewEx();
this.selectedResultsListViewEx = new Common.Forms.ListViewEx();
this.removeAllButton = new System.Windows.Forms.Button();
this.removeButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button();
@ -247,7 +247,7 @@
private System.Windows.Forms.TreeView availableAlphabeticTreeView;
private System.Windows.Forms.Button downButton;
private System.Windows.Forms.Button upButton;
private ListViewEx selectedResultsListViewEx;
private Common.Forms.ListViewEx selectedResultsListViewEx;
private System.Windows.Forms.Button removeAllButton;
private System.Windows.Forms.Button removeButton;
private System.Windows.Forms.Button addButton;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Common;
using Common.Forms;
using Config.Entities;
using Results.Resources;

View File

@ -37,7 +37,7 @@
this.availableAlphabeticTreeView = new System.Windows.Forms.TreeView();
this.downButton = new System.Windows.Forms.Button();
this.upButton = new System.Windows.Forms.Button();
this.selectedResultsListViewEx = new Results.Forms.ListViewEx();
this.selectedResultsListViewEx = new Common.Forms.ListViewEx();
this.removeAllButton = new System.Windows.Forms.Button();
this.removeButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button();
@ -247,7 +247,7 @@
private System.Windows.Forms.TreeView availableAlphabeticTreeView;
private System.Windows.Forms.Button downButton;
private System.Windows.Forms.Button upButton;
private ListViewEx selectedResultsListViewEx;
private Common.Forms.ListViewEx selectedResultsListViewEx;
private System.Windows.Forms.Button removeAllButton;
private System.Windows.Forms.Button removeButton;
private System.Windows.Forms.Button addButton;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Common;
using Common.Forms;
using Results.Resources;
namespace Results.Forms

View File

@ -82,12 +82,6 @@
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\IOneWMResultsCtrl.cs" />
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Forms\ListViewExtensions.cs" />
<Compile Include="Forms\LviIntColumnComparer.cs" />
<Compile Include="Forms\LviTextColumnComparer.cs" />
<Compile Include="Forms\ManualEntryConfigCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
@ -225,9 +219,6 @@
<EmbeddedResource Include="Forms\BatchResultsDlg.resx">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ListViewEx.resx">
<DependentUpon>ListViewEx.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ManualEntryConfigCtrl.resx">
<DependentUpon>ManualEntryConfigCtrl.cs</DependentUpon>
</EmbeddedResource>

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Common;
using Common.Forms;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Resources;
@ -80,8 +81,8 @@ namespace TBF.Rig.Configs.ParamsProvider
flags = CfgUpdateFlags.None;
paramsListViewEx.SubItemClicked += new Results.Forms.SubItemEventHandler(paramsListViewEx_SubItemClicked);
paramsListViewEx.SubItemEndEditing += new Results.Forms.SubItemEndEditingEventHandler(paramsListViewEx_SubItemEndEditing);
paramsListViewEx.SubItemClicked += new SubItemEventHandler(paramsListViewEx_SubItemClicked);
paramsListViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(paramsListViewEx_SubItemEndEditing);
}
void Localize()
@ -172,14 +173,14 @@ namespace TBF.Rig.Configs.ParamsProvider
return f;
}
private void paramsListViewEx_SubItemClicked(object sender, Results.Forms.SubItemEventArgs e)
private void paramsListViewEx_SubItemClicked(object sender, SubItemEventArgs e)
{
if (e.SubItem != 1) return;
int itemNr = (int)e.Item.Tag;
paramsListViewEx.StartEditing(editors[itemNr], e.Item, e.SubItem);
}
private void paramsListViewEx_SubItemEndEditing(object sender, Results.Forms.SubItemEndEditingEventArgs e)
private void paramsListViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
{
if (e.SubItem != 1) return;
int itemNr = (int)e.Item.Tag;

View File

@ -38,7 +38,7 @@ namespace TBF.Rig.Configs.ParamsProvider
this.parentLabel = new System.Windows.Forms.Label();
this.componentClassLabel = new System.Windows.Forms.Label();
this.componentClassTextBox = new System.Windows.Forms.TextBox();
this.paramsListViewEx = new Results.Forms.ListViewEx();
this.paramsListViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -137,8 +137,8 @@ namespace TBF.Rig.Configs.ParamsProvider
this.paramsListViewEx.TabIndex = 0;
this.paramsListViewEx.UseCompatibleStateImageBehavior = false;
this.paramsListViewEx.View = System.Windows.Forms.View.Details;
this.paramsListViewEx.SubItemClicked += new Results.Forms.SubItemEventHandler(this.paramsListViewEx_SubItemClicked);
this.paramsListViewEx.SubItemEndEditing += new Results.Forms.SubItemEndEditingEventHandler(this.paramsListViewEx_SubItemEndEditing);
this.paramsListViewEx.SubItemClicked += new Common.Forms.SubItemEventHandler(this.paramsListViewEx_SubItemClicked);
this.paramsListViewEx.SubItemEndEditing += new Common.Forms.SubItemEndEditingEventHandler(this.paramsListViewEx_SubItemEndEditing);
//
// ComponentCfgCtrl
//
@ -166,6 +166,6 @@ namespace TBF.Rig.Configs.ParamsProvider
private System.Windows.Forms.Label parentLabel;
private System.Windows.Forms.Label componentClassLabel;
private System.Windows.Forms.TextBox componentClassTextBox;
private Results.Forms.ListViewEx paramsListViewEx;
private Common.Forms.ListViewEx paramsListViewEx;
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Common.Forms;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;
@ -115,7 +116,7 @@ namespace TBF.Rig.TestMethods.Endurance
void RefreshAllTabs()
{
if (seqStepsCtrl != null) (seqStepsCtrl as Results.Forms.ListViewEx).Refresh();
if (seqStepsCtrl != null) (seqStepsCtrl as ListViewEx).Refresh();
}
private void Unlocked(object sender, EventArgs e)
@ -237,7 +238,7 @@ namespace TBF.Rig.TestMethods.Endurance
/// <param name="listViewEx"></param>
void SelectedIndexChanged(object sender, EventArgs e)
{
Results.Forms.ListViewEx listViewEx = sender as Results.Forms.ListViewEx;
var listViewEx = sender as ListViewEx;
if (listViewEx.SelectedItems.Count != 1)
{
UpdateButtonStates(SharedButtons.SelectedItemPos.None);

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using log4net;
using Common.Forms;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;
@ -47,9 +48,9 @@ namespace TBF.Rig.TestMethods.Endurance
Name = "Dummy";
MyItems = sequence;
SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemRightClicked);
SubItemEndEditing += new Results.Forms.SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
SubItemRightClicked += new SubItemEventHandler(listViewEx_SubItemRightClicked);
SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
///
@ -97,14 +98,14 @@ namespace TBF.Rig.TestMethods.Endurance
}
void listViewEx_SubItemClicked(object sender, Results.Forms.SubItemEventArgs e)
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
{
if (!Unlocked || e.SubItem >= editors.Length) return;
StartEditing(editors[e.SubItem], e.Item, e.SubItem);
}
void listViewEx_SubItemRightClicked(object sender, Results.Forms.SubItemEventArgs e)
void listViewEx_SubItemRightClicked(object sender, SubItemEventArgs e)
{
if (!Unlocked || e.SubItem >= editors.Length) return;
@ -131,7 +132,7 @@ namespace TBF.Rig.TestMethods.Endurance
}
void listViewEx_SubItemEndEditing(object sender, Results.Forms.SubItemEndEditingEventArgs e)
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
{
if (e.SubItem == (int)Column.Duration)
{

View File

@ -2291,9 +2291,7 @@
<Compile Include="UI\Bench\Paths\PathsHeatMetersCtrl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Bench\Paths\PathsMetersCtrl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Bench\Paths\PathsMetersCtrl.cs" />
<Compile Include="UI\Bench\Paths\PathsOutputCtrl.cs">
<SubType>Component</SubType>
</Compile>

View File

@ -33,7 +33,7 @@ namespace TBF.UI.Bench.Components
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ComponentsManagerDlg));
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.sharedButtons = new TBF.UI.Shared.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
@ -68,7 +68,7 @@ namespace TBF.UI.Bench.Components
this.listViewEx.Name = "listViewEx";
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SubItemRightClicked += new Results.Forms.SubItemEventHandler(this.listViewEx_SubItemRightClicked);
this.listViewEx.SubItemRightClicked += new Common.Forms.SubItemEventHandler(this.listViewEx_SubItemRightClicked);
this.listViewEx.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewEx_ColumnClick);
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.componentsListView_SelectedIndexChanged);
this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick);
@ -96,7 +96,7 @@ namespace TBF.UI.Bench.Components
#endregion
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.SplitContainer splitContainer;
private TBF.UI.Shared.SharedButtons sharedButtons;
}

View File

@ -9,7 +9,7 @@ using log4net;
using NHibernate;
using Common;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.Generic;
using TBF.Resources;
@ -49,7 +49,7 @@ namespace TBF.UI.Bench.Components
ColumnsCount,
}
SortOrder sortOrder = SortOrder.Ascending;
MySortOrder sortOrder = MySortOrder.Ascending;
int sortColumn = -1; /// 0-based index of column to be used for sorting
/// Editors used by listViewEx
@ -785,13 +785,13 @@ namespace TBF.UI.Bench.Components
{
if (e.Column == sortColumn)
{
sortOrder = (sortOrder == SortOrder.Ascending) ? SortOrder.Descending : SortOrder.Ascending;
sortOrder = (sortOrder == MySortOrder.Ascending) ? MySortOrder.Descending : MySortOrder.Ascending;
}
else
{
/// Clicked on another column header => set sortOrder to SortOrder.Ascending
sortColumn = e.Column;
sortOrder = SortOrder.Ascending;
sortOrder = MySortOrder.Ascending;
}
if (sortColumn == (int)Column.Number)

View File

@ -57,7 +57,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredTextBox = new System.Windows.Forms.TextBox();
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -373,7 +373,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.Label cmpntNameLabel;
private System.Windows.Forms.SplitContainer splitContainer1;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.Label measuredLabel;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -46,7 +46,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredTextBox = new System.Windows.Forms.TextBox();
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -274,7 +274,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;
private System.Windows.Forms.TextBox measuredTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -46,7 +46,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredTextBox = new System.Windows.Forms.TextBox();
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -274,7 +274,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;
private System.Windows.Forms.TextBox measuredTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -46,7 +46,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredTextBox = new System.Windows.Forms.TextBox();
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -274,7 +274,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;
private System.Windows.Forms.TextBox measuredTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -46,7 +46,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredTextBox = new System.Windows.Forms.TextBox();
this.correctedLabel = new System.Windows.Forms.Label();
this.measuredLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -274,7 +274,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;
private System.Windows.Forms.TextBox measuredTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -44,7 +44,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredLabel = new System.Windows.Forms.Label();
this.componentLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -253,7 +253,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label componentLabel;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;
private System.Windows.Forms.TextBox measuredTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -44,7 +44,7 @@ namespace TBF.UI.Bench.Metrology
this.measuredLabel = new System.Windows.Forms.Label();
this.componentLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -253,7 +253,7 @@ namespace TBF.UI.Bench.Metrology
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label componentLabel;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.GroupBox testGroupBox;
private System.Windows.Forms.TextBox correctedTextBox;
private System.Windows.Forms.TextBox measuredTextBox;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -8,7 +8,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using NHibernate;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -8,7 +8,7 @@ using System.Windows.Forms;
using NHibernate;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -8,7 +8,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.GenericDevices;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -7,7 +7,7 @@ using System.Drawing;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -9,7 +9,7 @@ using System.Windows.Forms;
using log4net;
using Common;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -57,11 +57,11 @@ namespace TBF.UI.Bench.TestProfiles
this.procNameTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.metrologyTabPage = new System.Windows.Forms.TabPage();
this.metrologyListViewEx = new Results.Forms.ListViewEx();
this.metrologyListViewEx = new Common.Forms.ListViewEx();
this.errorFlagsTabPage = new System.Windows.Forms.TabPage();
this.errorFlagsListViewEx = new Results.Forms.ListViewEx();
this.errorFlagsListViewEx = new Common.Forms.ListViewEx();
this.errorFlags2TabPage = new System.Windows.Forms.TabPage();
this.errorFlags2ListViewEx = new Results.Forms.ListViewEx();
this.errorFlags2ListViewEx = new Common.Forms.ListViewEx();
this.sharedButtons = new TBF.UI.Shared.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
this.mainSplitContainer.Panel1.SuspendLayout();
@ -341,7 +341,7 @@ namespace TBF.UI.Bench.TestProfiles
private System.Windows.Forms.SplitContainer mainSplitContainer;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage metrologyTabPage;
private Results.Forms.ListViewEx metrologyListViewEx;
private Common.Forms.ListViewEx metrologyListViewEx;
private TBF.UI.Shared.SharedButtons sharedButtons;
private System.Windows.Forms.TabPage generalTabPage;
private System.Windows.Forms.TextBox lastChangedOnTextBox;
@ -359,7 +359,7 @@ namespace TBF.UI.Bench.TestProfiles
private System.Windows.Forms.RadioButton profileTypeRadioButton2;
private System.Windows.Forms.RadioButton profileTypeRadioButton1;
private System.Windows.Forms.TabPage errorFlagsTabPage;
private Results.Forms.ListViewEx errorFlagsListViewEx;
private Common.Forms.ListViewEx errorFlagsListViewEx;
private System.Windows.Forms.RadioButton profileTypeRadioButton3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton errorCalculationRadioButton2;
@ -368,6 +368,6 @@ namespace TBF.UI.Bench.TestProfiles
private System.Windows.Forms.RadioButton profileTypeRadioButton5;
private System.Windows.Forms.RadioButton profileTypeRadioButton4;
private System.Windows.Forms.TabPage errorFlags2TabPage;
private Results.Forms.ListViewEx errorFlags2ListViewEx;
private Common.Forms.ListViewEx errorFlags2ListViewEx;
}
}

View File

@ -10,7 +10,7 @@ using System.Windows.Forms;
using NHibernate;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;
@ -179,7 +180,7 @@ namespace TBF.UI.Bench.TestProfiles
/// <param name="listViewEx"></param>
void SelectedIndexChanged(object sender, EventArgs e)
{
Results.Forms.ListViewEx listViewEx = sender as Results.Forms.ListViewEx;
var listViewEx = sender as ListViewEx;
if (listViewEx.SelectedItems.Count != 1)
{
/// No item selected

View File

@ -6,7 +6,7 @@ using System.Drawing;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -9,7 +9,7 @@ using System.Windows.Forms;
using log4net;
using NHibernate;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -6,7 +6,7 @@ using System.Drawing;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -34,7 +34,7 @@ namespace TBF.UI.Bench.Uncertainties
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.cmpntLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -116,7 +116,7 @@ namespace TBF.UI.Bench.Uncertainties
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntLabel;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -34,7 +34,7 @@ namespace TBF.UI.Bench.Uncertainties
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.cmpntLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -116,7 +116,7 @@ namespace TBF.UI.Bench.Uncertainties
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntLabel;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -32,7 +32,7 @@ namespace TBF.UI.Bench.Uncertainties
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.cmpntLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -114,7 +114,7 @@ namespace TBF.UI.Bench.Uncertainties
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.Label cmpntLabel;
private System.Windows.Forms.Label cmpntNameLabel;
}

View File

@ -7,7 +7,7 @@ using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;

View File

@ -34,7 +34,7 @@ namespace TBF.UI.Bench.Uncertainties
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.cmpntLabel = new System.Windows.Forms.Label();
this.cmpntNameLabel = new System.Windows.Forms.Label();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -116,7 +116,7 @@ namespace TBF.UI.Bench.Uncertainties
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Label cmpntLabel;
private System.Windows.Forms.Label cmpntNameLabel;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -37,7 +37,7 @@ namespace TBF.UI.Calendar
this.calendarCtrl1 = new TBF.UI.Calendar.CalendarCtrl();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.newEventButton = new System.Windows.Forms.Button();
this.calendarEventsListViewEx = new Common.UIControls.ListViewEx();
this.calendarEventsListViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -152,6 +152,6 @@ namespace TBF.UI.Calendar
private CalendarCtrl calendarCtrl1;
private System.Windows.Forms.Button newEventButton;
private System.Windows.Forms.SplitContainer splitContainer2;
private Common.UIControls.ListViewEx calendarEventsListViewEx;
private Common.Forms.ListViewEx calendarEventsListViewEx;
}
}

View File

@ -5,7 +5,8 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Common.UIControls;
using Common;
using Common.Forms;
using Events.Entities;
using TBF.Resources;
using TBF.UiBridge;
@ -25,7 +26,7 @@ namespace TBF.UI.EventLogs
Count
}
SortOrder sortOrder = SortOrder.Ascending;
MySortOrder sortOrder = MySortOrder.Ascending;
int sortColumn = -1; /// 0-based index of column to be used for sorting
@ -80,13 +81,13 @@ namespace TBF.UI.EventLogs
{
if (e.Column == sortColumn)
{
sortOrder = (sortOrder == SortOrder.Ascending) ? SortOrder.Descending : SortOrder.Ascending;
sortOrder = (sortOrder == MySortOrder.Ascending) ? MySortOrder.Descending : MySortOrder.Ascending;
}
else
{
/// Clicked on another column header => set sortOrder to SortOrder.Ascending
sortColumn = e.Column;
sortOrder = SortOrder.Ascending;
sortOrder = MySortOrder.Ascending;
}
switch ((Column)sortColumn)

View File

@ -32,7 +32,7 @@ namespace TBF.UI.EventLogs
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EventLogsTabPageCtrl));
this.eventsListView = new Common.UIControls.ListViewEx();
this.eventsListView = new Common.Forms.ListViewEx();
this.SuspendLayout();
//
// eventsListView
@ -60,6 +60,6 @@ namespace TBF.UI.EventLogs
#endregion
private Common.UIControls.ListViewEx eventsListView;
private Common.Forms.ListViewEx eventsListView;
}
}

View File

@ -101,11 +101,11 @@ namespace TBF.UI.Procedures
this.metrology2TabPage = new System.Windows.Forms.TabPage();
this.processTabPage = new System.Windows.Forms.TabPage();
this.parametersTabPage = new System.Windows.Forms.TabPage();
this.historyListViewEx = new Results.Forms.ListViewEx();
this.metrology1ListViewEx = new Results.Forms.ListViewEx();
this.metrology2ListViewEx = new Results.Forms.ListViewEx();
this.processListViewEx = new Results.Forms.ListViewEx();
this.parametersListViewEx = new Results.Forms.ListViewEx();
this.historyListViewEx = new Common.Forms.ListViewEx();
this.metrology1ListViewEx = new Common.Forms.ListViewEx();
this.metrology2ListViewEx = new Common.Forms.ListViewEx();
this.processListViewEx = new Common.Forms.ListViewEx();
this.parametersListViewEx = new Common.Forms.ListViewEx();
this.sharedButtons = new TBF.UI.Shared.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.mainSplitContainer)).BeginInit();
this.mainSplitContainer.Panel1.SuspendLayout();
@ -708,13 +708,13 @@ namespace TBF.UI.Procedures
private System.Windows.Forms.SplitContainer mainSplitContainer;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage historyTabPage;
private Results.Forms.ListViewEx historyListViewEx;
private Common.Forms.ListViewEx historyListViewEx;
private System.Windows.Forms.TabPage metrology1TabPage;
private Results.Forms.ListViewEx metrology1ListViewEx;
private Common.Forms.ListViewEx metrology1ListViewEx;
private System.Windows.Forms.TabPage metrology2TabPage;
private Results.Forms.ListViewEx metrology2ListViewEx;
private Common.Forms.ListViewEx metrology2ListViewEx;
private System.Windows.Forms.TabPage processTabPage;
private Results.Forms.ListViewEx processListViewEx;
private Common.Forms.ListViewEx processListViewEx;
private TBF.UI.Shared.SharedButtons sharedButtons;
private System.Windows.Forms.TabPage generalTabPage;
private System.Windows.Forms.ComboBox fileWriter1ComboBox;
@ -746,7 +746,7 @@ namespace TBF.UI.Procedures
private System.Windows.Forms.RadioButton metersKindRadioButton2;
private System.Windows.Forms.RadioButton metersKindRadioButton1;
private System.Windows.Forms.TabPage parametersTabPage;
private Results.Forms.ListViewEx parametersListViewEx;
private Common.Forms.ListViewEx parametersListViewEx;
private System.Windows.Forms.ComboBox fileWriter2ComboBox;
private System.Windows.Forms.ComboBox fileWriter3ComboBox;
private System.Windows.Forms.ComboBox printer2ComboBox;

View File

@ -10,7 +10,7 @@ using log4net;
using Common;
using Config;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Resources;

View File

@ -31,7 +31,7 @@ namespace TBF.UI.Procedures
/// </summary>
private void InitializeComponent()
{
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.SuspendLayout();
//
// listViewEx
@ -60,6 +60,6 @@ namespace TBF.UI.Procedures
#endregion
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.Generic;
using TBF.Resources;

View File

@ -31,7 +31,7 @@ namespace TBF.UI.Procedures
/// </summary>
private void InitializeComponent()
{
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.SuspendLayout();
//
// listViewEx
@ -60,6 +60,6 @@ namespace TBF.UI.Procedures
#endregion
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.Generic;
using TBF.Resources;

View File

@ -37,7 +37,7 @@
this.mclassComboBox = new System.Windows.Forms.ComboBox();
this.q3ComboBox = new System.Windows.Forms.ComboBox();
this.dnComboBox = new System.Windows.Forms.ComboBox();
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
((System.ComponentModel.ISupportInitialize)(this.filtersSplitContainer)).BeginInit();
this.filtersSplitContainer.Panel1.SuspendLayout();
this.filtersSplitContainer.Panel2.SuspendLayout();
@ -190,6 +190,6 @@
private System.Windows.Forms.ComboBox mclassComboBox;
private System.Windows.Forms.ComboBox q3ComboBox;
private System.Windows.Forms.ComboBox dnComboBox;
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Windows.Forms;
using log4net;
using Common;
using Common.Forms;
using TBF.Resources;
using TBF.UI.Shared;
@ -190,7 +191,7 @@ namespace TBF.UI.Procedures
/// <param name="listViewEx"></param>
public void SelectedIndexChanged(ListView sender, bool isFilterAny)
{
Results.Forms.ListViewEx listViewEx = sender as Results.Forms.ListViewEx;
var listViewEx = sender as ListViewEx;
if (listViewEx.SelectedItems.Count != 1)
{
/// No item selected

View File

@ -31,7 +31,7 @@ namespace TBF.UI.Procedures
/// </summary>
private void InitializeComponent()
{
this.listViewEx = new Results.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.SuspendLayout();
//
// listViewEx
@ -60,6 +60,6 @@ namespace TBF.UI.Procedures
#endregion
private Results.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
}
}

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Windows.Forms;
using Common;
using Config.Entities;
using Results.Forms;
using Common.Forms;
using TBF.Rig.Generic;
using TBF.Resources;

View File

@ -55,7 +55,7 @@ namespace TBF.UI.Procedures.TestWizard
this.idWZTypTextBox = new System.Windows.Forms.TextBox();
this.materialCodeRadioButton = new System.Windows.Forms.RadioButton();
this.idWZTypRadioButton = new System.Windows.Forms.RadioButton();
this.listViewEx = new TracingDB.Forms.ListViewEx();
this.listViewEx = new Common.Forms.ListViewEx();
this.cancelButton = new System.Windows.Forms.Button();
this.nextButton = new System.Windows.Forms.Button();
this.backButton = new System.Windows.Forms.Button();
@ -340,8 +340,8 @@ namespace TBF.UI.Procedures.TestWizard
this.listViewEx.TabIndex = 0;
this.listViewEx.UseCompatibleStateImageBehavior = false;
this.listViewEx.View = System.Windows.Forms.View.Details;
this.listViewEx.SubItemClicked += new TracingDB.Forms.SubItemEventHandler(this.listViewEx_SubItemClicked);
this.listViewEx.SubItemEndEditing += new TracingDB.Forms.SubItemEndEditingEventHandler(this.listViewEx_SubItemEndEditing);
this.listViewEx.SubItemClicked += new Common.Forms.SubItemEventHandler(this.listViewEx_SubItemClicked);
this.listViewEx.SubItemEndEditing += new Common.Forms.SubItemEndEditingEventHandler(this.listViewEx_SubItemEndEditing);
//
// cancelButton
//
@ -411,7 +411,7 @@ namespace TBF.UI.Procedures.TestWizard
private System.Windows.Forms.RadioButton materialCodeRadioButton;
private System.Windows.Forms.RadioButton idWZTypRadioButton;
private System.Windows.Forms.Button searchButton;
private TracingDB.Forms.ListViewEx listViewEx;
private Common.Forms.ListViewEx listViewEx;
private System.Windows.Forms.Label remarkLabel;
private System.Windows.Forms.TextBox wzTypTextBox;
private System.Windows.Forms.Label wzTypLabel;

View File

@ -12,6 +12,7 @@ using Oracle.ManagedDataAccess.Client;
using Oracle.DataAccess.Client;
#endif
using Common;
using Common.Forms;
using Config.Entities;
using Results.Output;
using TBF.Rig.GenericDevices;
@ -302,7 +303,7 @@ namespace TBF.UI.Procedures.TestWizard
}
}
private void listViewEx_SubItemClicked(object sender, TracingDB.Forms.SubItemEventArgs e)
private void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
{
if (e.SubItem == listViewEx.Columns.Count - 2)
{
@ -316,7 +317,7 @@ namespace TBF.UI.Procedures.TestWizard
}
}
private void listViewEx_SubItemEndEditing(object sender, TracingDB.Forms.SubItemEndEditingEventArgs e)
private void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
{
if (e.SubItem == listViewEx.Columns.Count - 2)
{

View File

@ -8,6 +8,7 @@ using System.Windows.Forms;
using log4net;
using NHibernate;
using Common;
using Common.Forms;
using Results;
using Results.Forms;
using Results.Entities;

View File

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Config.Entities;
using Results.Forms;
using Common.Forms;
namespace TBF.UI.Shared
{

View File

@ -1,466 +0,0 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TracingDB.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 SortOrder SortOrder = SortOrder.None;
public int SortColumn = -1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public event SubItemEventHandler SubItemClicked;
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);
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));
}
}
#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);
}
/// <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; }
}
}
}

View File

@ -1,42 +0,0 @@
<?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>

View File

@ -1,104 +0,0 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace TracingDB.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, SortOrder 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 != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
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();
}
}
}
}
}

View File

@ -1,31 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace TracingDB.Forms
{
public class LviIntColumnComparer : IComparer
{
int column;
SortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviIntColumnComparer(int column, SortOrder 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 == SortOrder.Descending) ? (valY - valX) : (valX - valY);
}
}
}

View File

@ -1,31 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
namespace TracingDB.Forms
{
public class LviTextColumnComparer : IComparer
{
private int column;
SortOrder order;
public LviTextColumnComparer()
{
column = 0;
order = SortOrder.Ascending;
}
public LviTextColumnComparer(int column, SortOrder 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 == SortOrder.Descending) ? String.Compare(txtY, txtX) : String.Compare(txtX, txtY);
}
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Common.Forms;
using TracingDB.Entities;
using TracingDB.Resources;

View File

@ -39,7 +39,7 @@ namespace TracingDB.Forms
this.removeAllButton = new System.Windows.Forms.Button();
this.removeButton = new System.Windows.Forms.Button();
this.addButton = new System.Windows.Forms.Button();
this.selectedResultsListViewEx = new TracingDB.Forms.ListViewEx();
this.selectedResultsListViewEx = new Common.Forms.ListViewEx();
this.upButton = new System.Windows.Forms.Button();
this.downButton = new System.Windows.Forms.Button();
this.SuspendLayout();
@ -133,8 +133,8 @@ namespace TracingDB.Forms
this.selectedResultsListViewEx.TabIndex = 47;
this.selectedResultsListViewEx.UseCompatibleStateImageBehavior = false;
this.selectedResultsListViewEx.View = System.Windows.Forms.View.Details;
this.selectedResultsListViewEx.SubItemClicked += new TracingDB.Forms.SubItemEventHandler(this.selectedResultsListViewEx_SubItemClicked);
this.selectedResultsListViewEx.SubItemEndEditing += new TracingDB.Forms.SubItemEndEditingEventHandler(this.selectedResultsListViewEx_SubItemEndEditing);
this.selectedResultsListViewEx.SubItemClicked += new Common.Forms.SubItemEventHandler(this.selectedResultsListViewEx_SubItemClicked);
this.selectedResultsListViewEx.SubItemEndEditing += new Common.Forms.SubItemEndEditingEventHandler(this.selectedResultsListViewEx_SubItemEndEditing);
//
// upButton
//
@ -194,7 +194,7 @@ namespace TracingDB.Forms
private System.Windows.Forms.Button removeAllButton;
private System.Windows.Forms.Button removeButton;
private System.Windows.Forms.Button addButton;
private ListViewEx selectedResultsListViewEx;
private Common.Forms.ListViewEx selectedResultsListViewEx;
private System.Windows.Forms.Button upButton;
private System.Windows.Forms.Button downButton;
}

View File

@ -66,12 +66,6 @@
<ItemGroup>
<Compile Include="BatteryAndFlowtubeInfo.cs" />
<Compile Include="Entities\WorkplaceRegistration.cs" />
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Forms\ListViewExtensions.cs" />
<Compile Include="Forms\LviIntColumnComparer.cs" />
<Compile Include="Forms\LviTextColumnComparer.cs" />
<Compile Include="Forms\MessageEventArgs.cs" />
<Compile Include="Forms\ModelessForm.cs">
<SubType>Form</SubType>
@ -117,9 +111,6 @@
<Compile Include="WPlaceRegistrationMgmt.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\ListViewEx.resx">
<DependentUpon>ListViewEx.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ModelessForm.resx">
<DependentUpon>ModelessForm.cs</DependentUpon>
</EmbeddedResource>
@ -140,6 +131,12 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.

View File

@ -1,104 +0,0 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Common;
namespace Users.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 ListView 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;
}
}
else
{
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
}
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
}
}
}
}

View File

@ -1,32 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
using Common;
namespace Users.Forms
{
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);
}
}
}

View File

@ -1,55 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
using Common;
namespace Users.Forms
{
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;
}
}
}
}

View File

@ -1,32 +0,0 @@
using System;
using System.Collections;
using System.Windows.Forms;
using Common;
namespace Users.Forms
{
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);
}
}
}

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Windows.Forms;
using NHibernate;
using Common;
using Common.Forms;
using Users.Entities;
using Users.Resources;

View File

@ -32,7 +32,7 @@ namespace Users.Forms
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UserManagementDlg));
this.listViewUsers = new System.Windows.Forms.ListView();
this.listViewUsers = new Common.Forms.ListViewEx();
this.addButton = new System.Windows.Forms.Button();
this.editButton = new System.Windows.Forms.Button();
this.deleteButton = new System.Windows.Forms.Button();
@ -136,7 +136,7 @@ namespace Users.Forms
#endregion
private System.Windows.Forms.ListView listViewUsers;
private Common.Forms.ListViewEx listViewUsers;
private System.Windows.Forms.Button addButton;
private System.Windows.Forms.Button editButton;
private System.Windows.Forms.Button deleteButton;

View File

@ -61,10 +61,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DBSettings.cs" />
<Compile Include="Forms\ListViewExtensions.cs" />
<Compile Include="Forms\LviNameSurnameColumnComparer.cs" />
<Compile Include="Forms\LviIntColumnComparer.cs" />
<Compile Include="Forms\LviTextColumnComparer.cs" />
<Compile Include="Forms\PasswordChangeDlg.cs">
<SubType>Form</SubType>
</Compile>