Files
ayanova7/source/WinFormApp/MemoToSelector.cs
2018-06-29 19:47:36 +00:00

391 lines
18 KiB
C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using GZTW.AyaNova.BLL;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using log4net;
using System.Data;
namespace AyaNova
{
/// <summary>
/// Summary description for MemoToSelector.
/// </summary>
public class MemoToSelector : System.Windows.Forms.Form
{
// Create a logger for use in this class
//case 1039 private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
private System.Windows.Forms.Panel MemoToSelector_Fill_Panel;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoToSelector_Toolbars_Dock_Area_Left;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoToSelector_Toolbars_Dock_Area_Right;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoToSelector_Toolbars_Dock_Area_Top;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _MemoToSelector_Toolbars_Dock_Area_Bottom;
private Infragistics.Win.UltraWinGrid.UltraGrid Grid;
private System.ComponentModel.IContainer components;
public MemoToSelector()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
//
//
}
/// <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 Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("UltraToolbar1");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.OK");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Cancel");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Cancel");
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.OK");
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
this.MemoToSelector_Fill_Panel = new System.Windows.Forms.Panel();
this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
this._MemoToSelector_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._MemoToSelector_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._MemoToSelector_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._MemoToSelector_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
this.MemoToSelector_Fill_Panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit();
this.SuspendLayout();
//
// tbManager
//
this.tbManager.DesignerFlags = 1;
this.tbManager.DockWithinContainer = this;
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
this.tbManager.ShowFullMenusDelay = 500;
ultraToolbar1.DockedColumn = 0;
ultraToolbar1.DockedRow = 0;
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool1,
buttonTool2});
ultraToolbar1.Text = "MemoToSelectorToolbar";
this.tbManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
ultraToolbar1});
this.tbManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
this.tbManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False;
this.tbManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
appearance1.Image = global::AyaNova.Resource1.Cancel32;
buttonTool3.SharedPropsInternal.AppearancesLarge.Appearance = appearance1;
appearance2.Image = global::AyaNova.Resource1.Cancel16;
buttonTool3.SharedPropsInternal.AppearancesSmall.Appearance = appearance2;
buttonTool3.SharedPropsInternal.Caption = "LT:UI.Command.Cancel";
appearance3.Image = global::AyaNova.Resource1.OK32;
buttonTool4.SharedPropsInternal.AppearancesLarge.Appearance = appearance3;
appearance4.Image = global::AyaNova.Resource1.OK16;
buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance4;
buttonTool4.SharedPropsInternal.Caption = "LT:UI.Command.OK";
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool3,
buttonTool4});
this.tbManager.UseLargeImagesOnToolbar = true;
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
//
// MemoToSelector_Fill_Panel
//
this.MemoToSelector_Fill_Panel.Controls.Add(this.Grid);
this.MemoToSelector_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
this.MemoToSelector_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
this.MemoToSelector_Fill_Panel.Location = new System.Drawing.Point(0, 43);
this.MemoToSelector_Fill_Panel.Name = "MemoToSelector_Fill_Panel";
this.MemoToSelector_Fill_Panel.Size = new System.Drawing.Size(504, 146);
this.MemoToSelector_Fill_Panel.TabIndex = 0;
//
// Grid
//
this.Grid.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ExtendLastColumn;
this.Grid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
this.Grid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
this.Grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
this.Grid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
this.Grid.DisplayLayout.Override.ColumnAutoSizeMode = Infragistics.Win.UltraWinGrid.ColumnAutoSizeMode.AllRowsInBand;
this.Grid.DisplayLayout.Override.ColumnSizingArea = Infragistics.Win.UltraWinGrid.ColumnSizingArea.EntireColumn;
this.Grid.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
this.Grid.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.None;
this.Grid.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None;
this.Grid.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
this.Grid.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
this.Grid.DisplayLayout.TabNavigation = Infragistics.Win.UltraWinGrid.TabNavigation.NextControl;
this.Grid.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand;
this.Grid.Dock = System.Windows.Forms.DockStyle.Fill;
this.Grid.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Grid.Location = new System.Drawing.Point(0, 0);
this.Grid.Name = "Grid";
this.Grid.Size = new System.Drawing.Size(504, 146);
this.Grid.TabIndex = 0;
//
// _MemoToSelector_Toolbars_Dock_Area_Left
//
this._MemoToSelector_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._MemoToSelector_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
this._MemoToSelector_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
this._MemoToSelector_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
this._MemoToSelector_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43);
this._MemoToSelector_Toolbars_Dock_Area_Left.Name = "_MemoToSelector_Toolbars_Dock_Area_Left";
this._MemoToSelector_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 146);
this._MemoToSelector_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
//
// _MemoToSelector_Toolbars_Dock_Area_Right
//
this._MemoToSelector_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._MemoToSelector_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
this._MemoToSelector_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
this._MemoToSelector_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
this._MemoToSelector_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(504, 43);
this._MemoToSelector_Toolbars_Dock_Area_Right.Name = "_MemoToSelector_Toolbars_Dock_Area_Right";
this._MemoToSelector_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 146);
this._MemoToSelector_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
//
// _MemoToSelector_Toolbars_Dock_Area_Top
//
this._MemoToSelector_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._MemoToSelector_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
this._MemoToSelector_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
this._MemoToSelector_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
this._MemoToSelector_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
this._MemoToSelector_Toolbars_Dock_Area_Top.Name = "_MemoToSelector_Toolbars_Dock_Area_Top";
this._MemoToSelector_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(504, 43);
this._MemoToSelector_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
//
// _MemoToSelector_Toolbars_Dock_Area_Bottom
//
this._MemoToSelector_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._MemoToSelector_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
this._MemoToSelector_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
this._MemoToSelector_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
this._MemoToSelector_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 189);
this._MemoToSelector_Toolbars_Dock_Area_Bottom.Name = "_MemoToSelector_Toolbars_Dock_Area_Bottom";
this._MemoToSelector_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(504, 0);
this._MemoToSelector_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
//
// MemoToSelector
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(504, 189);
this.Controls.Add(this.MemoToSelector_Fill_Panel);
this.Controls.Add(this._MemoToSelector_Toolbars_Dock_Area_Left);
this.Controls.Add(this._MemoToSelector_Toolbars_Dock_Area_Right);
this.Controls.Add(this._MemoToSelector_Toolbars_Dock_Area_Bottom);
this.Controls.Add(this._MemoToSelector_Toolbars_Dock_Area_Top);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MemoToSelector";
this.ShowInTaskbar = false;
this.Closing += new System.ComponentModel.CancelEventHandler(this.MemoToSelector_Closing);
this.Load += new System.EventHandler(this.MemoToSelector_Load);
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
this.MemoToSelector_Fill_Panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit();
this.ResumeLayout(false);
}
#endregion
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
//
#region Global vars / Properties
private DataTable mSelectedRecipients=null;
public DataTable SelectedRecipients
{
get{ return mSelectedRecipients;}
set{ mSelectedRecipients=value;}
}
#endregion
#region Load / close events
//variable to hold user form settings
//UIUserFormSetting mFormSetting;
private void MemoToSelector_Load(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("MemoToSelector_Load");
this.Icon = Resource1.User16icon;
Grid.DataSource=this.mSelectedRecipients;
Util.FetchGridLayout("MemoToSelector","",Grid);
Grid.DisplayLayout.Bands[0].Columns["RECIPIENTID"].Hidden=true;
Grid.DisplayLayout.Bands[0].Columns["SELECTED"].Hidden=true;
Grid.DisplayLayout.Bands[0].ColHeadersVisible=true;
Grid.DisplayLayout.Bands[0].Columns["RECIPIENT"].Header.Caption=Util.LocaleText.GetLocalizedText("O.User");
Grid.DisplayLayout.Bands[0].Columns["RECIPIENTTYPE"].Header.Caption=Util.LocaleText.GetLocalizedText("User.Label.UserType");
Grid.DisplayLayout.Bands[0].Columns["SUBCONTRACTOR"].Header.Caption=Util.LocaleText.GetLocalizedText("User.Label.SubContractor");
Util.Localize(this);
SelectDataTableToGrid();
Util.LoadFormCustomization("MemoToSelector", this, tbManager, false);
Application.Idle+= new EventHandler(Application_Idle);
}
private void MemoToSelector_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//case 1039 //log.Debug("MemoToSelector_Closing");
Application.Idle-= new EventHandler(Application_Idle);
SelectGridToDataTable();
Util.SaveGridLayout("MemoToSelector","","",Grid);
Util.SaveFormCustomization("MemoToSelector", this, tbManager, false);
}
#endregion
#region Grid / DataTable synchronization
/// <summary>
/// xfer previously selected recipients in Datatable to grid
/// selected rows
/// </summary>
private void SelectDataTableToGrid()
{
foreach(DataRow dr in this.mSelectedRecipients.Rows)
{
if((bool)dr["SELECTED"]==true)
{
foreach(UltraGridRow r in Grid.Rows)
{
if((Guid)r.Cells["RECIPIENTID"].Value==(Guid)dr["RECIPIENTID"])
{
r.Selected=true;
break;
}
}
}
}
}
/// <summary>
/// Xfer grids selected rows to the DataTable passed back to the memocomposer form
/// </summary>
private void SelectGridToDataTable()
{
//first clear out the selections in the datatable completely
foreach(DataRow dr in this.mSelectedRecipients.Rows)
dr["SELECTED"]=false;
foreach(UltraGridRow r in Grid.Rows)
{
if(r.Selected)
{
foreach(DataRow dr in this.mSelectedRecipients.Rows)
{
if((Guid)r.Cells["RECIPIENTID"].Value==(Guid)dr["RECIPIENTID"])
{
dr["SELECTED"]=true;
break;
}
}
}
}
}
#endregion
#region Idle processing
private void Application_Idle(object sender, EventArgs e)
{
//tbManager.Tools["LT:UI.Command.OK"].SharedProps.Enabled=mSelectedClientID!=Guid.Empty;
}
#endregion
#region UI Commands
private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
//case 1039 //if(log.IsDebugEnabled)
//case 1039 //log.Debug("ToolClick: "+e.Tool.Key);
switch (e.Tool.Key)
{
case "LT:UI.Command.Cancel": // ButtonTool
//mSelectedClientID=Guid.Empty;
this.DialogResult=DialogResult.Cancel;
this.Close();
break;
case "LT:UI.Command.OK": // ButtonTool
this.DialogResult=DialogResult.OK;
this.Close();
break;
}
}
#endregion
//--------------------------------------------------------
}
}