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

448 lines
22 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 log4net;
namespace AyaNova
{
/// <summary>
/// Summary description for NotifySubscriptionDeliverySelector.
/// </summary>
public class NotifySubscriptionDeliverySelector : 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 NotifySubscriptionDeliverySelector_Fill_Panel;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom;
private Infragistics.Win.Misc.UltraButton btnNotifySubscriptionDeliveryID;
private GZTW.WinForm.Controls.GZUltraComboEditor cbNotifySubscriptionDeliveryID;
private System.ComponentModel.IContainer components;
public NotifySubscriptionDeliverySelector()
{
//
// 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.Toolbar.Refresh");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Cancel");
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.OK");
Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh");
Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
this.NotifySubscriptionDeliverySelector_Fill_Panel = new System.Windows.Forms.Panel();
this.cbNotifySubscriptionDeliveryID = new GZTW.WinForm.Controls.GZUltraComboEditor();
this.btnNotifySubscriptionDeliveryID = new Infragistics.Win.Misc.UltraButton();
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
this.NotifySubscriptionDeliverySelector_Fill_Panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cbNotifySubscriptionDeliveryID)).BeginInit();
this.SuspendLayout();
//
// tbManager
//
this.tbManager.DesignerFlags = 1;
this.tbManager.DockWithinContainer = this;
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
ultraToolbar1.DockedColumn = 0;
ultraToolbar1.DockedRow = 0;
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool1,
buttonTool2,
buttonTool3});
ultraToolbar1.Text = "NotifySubscriptionDeliverySelectorToolbar";
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;
appearance2.Image = global::AyaNova.Resource1.Cancel32;
buttonTool4.SharedPropsInternal.AppearancesLarge.Appearance = appearance2;
appearance3.Image = global::AyaNova.Resource1.Cancel16;
buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance3;
buttonTool4.SharedPropsInternal.Caption = "LT:UI.Command.Cancel";
appearance4.Image = global::AyaNova.Resource1.OK32;
buttonTool5.SharedPropsInternal.AppearancesLarge.Appearance = appearance4;
appearance5.Image = global::AyaNova.Resource1.OK16;
buttonTool5.SharedPropsInternal.AppearancesSmall.Appearance = appearance5;
buttonTool5.SharedPropsInternal.Caption = "LT:UI.Command.OK";
appearance6.Image = global::AyaNova.Resource1.Refresh32;
buttonTool6.SharedPropsInternal.AppearancesLarge.Appearance = appearance6;
appearance7.Image = global::AyaNova.Resource1.Refresh16;
buttonTool6.SharedPropsInternal.AppearancesSmall.Appearance = appearance7;
buttonTool6.SharedPropsInternal.Caption = "LT:UI.Toolbar.Refresh";
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool4,
buttonTool5,
buttonTool6});
this.tbManager.UseLargeImagesOnToolbar = true;
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
//
// NotifySubscriptionDeliverySelector_Fill_Panel
//
this.NotifySubscriptionDeliverySelector_Fill_Panel.Controls.Add(this.cbNotifySubscriptionDeliveryID);
this.NotifySubscriptionDeliverySelector_Fill_Panel.Controls.Add(this.btnNotifySubscriptionDeliveryID);
this.NotifySubscriptionDeliverySelector_Fill_Panel.Cursor = System.Windows.Forms.Cursors.Default;
this.NotifySubscriptionDeliverySelector_Fill_Panel.Dock = System.Windows.Forms.DockStyle.Fill;
this.NotifySubscriptionDeliverySelector_Fill_Panel.Location = new System.Drawing.Point(0, 43);
this.NotifySubscriptionDeliverySelector_Fill_Panel.Name = "NotifySubscriptionDeliverySelector_Fill_Panel";
this.NotifySubscriptionDeliverySelector_Fill_Panel.Size = new System.Drawing.Size(424, 60);
this.NotifySubscriptionDeliverySelector_Fill_Panel.TabIndex = 0;
//
// cbNotifySubscriptionDeliveryID
//
this.cbNotifySubscriptionDeliveryID.AllowEmptySelection = false;
this.cbNotifySubscriptionDeliveryID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbNotifySubscriptionDeliveryID.Location = new System.Drawing.Point(0, 28);
this.cbNotifySubscriptionDeliveryID.Name = "cbNotifySubscriptionDeliveryID";
this.cbNotifySubscriptionDeliveryID.Size = new System.Drawing.Size(424, 24);
this.cbNotifySubscriptionDeliveryID.TabIndex = 149;
this.cbNotifySubscriptionDeliveryID.ValueChanged += new System.EventHandler(this.cbNotifySubscriptionDeliveryID_ValueChanged);
//
// btnNotifySubscriptionDeliveryID
//
this.btnNotifySubscriptionDeliveryID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
appearance1.TextHAlignAsString = "Left";
this.btnNotifySubscriptionDeliveryID.Appearance = appearance1;
this.btnNotifySubscriptionDeliveryID.ButtonStyle = Infragistics.Win.UIElementButtonStyle.PopupBorderless;
this.btnNotifySubscriptionDeliveryID.Location = new System.Drawing.Point(0, 0);
this.btnNotifySubscriptionDeliveryID.Name = "btnNotifySubscriptionDeliveryID";
this.btnNotifySubscriptionDeliveryID.Size = new System.Drawing.Size(424, 28);
this.btnNotifySubscriptionDeliveryID.TabIndex = 148;
this.btnNotifySubscriptionDeliveryID.Tag = "";
this.btnNotifySubscriptionDeliveryID.Text = "LT:O.NotifySubscriptionDelivery";
this.btnNotifySubscriptionDeliveryID.UseHotTracking = Infragistics.Win.DefaultableBoolean.True;
this.btnNotifySubscriptionDeliveryID.Click += new System.EventHandler(this.btnNotifySubscriptionDeliveryID_Click);
//
// _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left
//
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.Name = "_NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left";
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 60);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
//
// _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right
//
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(424, 43);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.Name = "_NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right";
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 60);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
//
// _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top
//
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.Name = "_NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top";
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(424, 43);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
//
// _NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom
//
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 103);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.Name = "_NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom";
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(424, 0);
this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
//
// NotifySubscriptionDeliverySelector
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(424, 103);
this.Controls.Add(this.NotifySubscriptionDeliverySelector_Fill_Panel);
this.Controls.Add(this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Left);
this.Controls.Add(this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Right);
this.Controls.Add(this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Bottom);
this.Controls.Add(this._NotifySubscriptionDeliverySelector_Toolbars_Dock_Area_Top);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NotifySubscriptionDeliverySelector";
this.ShowInTaskbar = false;
this.Closing += new System.ComponentModel.CancelEventHandler(this.NotifySubscriptionDeliverySelector_Closing);
this.Load += new System.EventHandler(this.NotifySubscriptionDeliverySelector_Load);
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
this.NotifySubscriptionDeliverySelector_Fill_Panel.ResumeLayout(false);
this.NotifySubscriptionDeliverySelector_Fill_Panel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.cbNotifySubscriptionDeliveryID)).EndInit();
this.ResumeLayout(false);
}
#endregion
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
//
#region Global vars / Properties
private Guid mSelectedNotifySubscriptionDeliveryID=Guid.Empty;
public Guid SelectedNotifySubscriptionDeliveryID
{
get{ return mSelectedNotifySubscriptionDeliveryID;}
}
private NotifySubscription mSubscription;
public NotifySubscription Subscription
{
set{mSubscription=value;}
}
private bool _ListChanged=false;
public bool ListChanged
{
get{ return _ListChanged;}
}
#endregion
#region Load / close events
private void NotifySubscriptionDeliverySelector_Load(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("NotifySubscriptionDeliverySelector_Load");
Util.LoadFormCustomization("NotifySubscriptionDeliverySelector", this, tbManager, true);
this.Icon = Resource1.NotificationDeliveryMethod16icon;
Util.Localize(this);
LoadCombo();
Application.Idle+= new EventHandler(Application_Idle);
}
private void NotifySubscriptionDeliverySelector_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//case 1039 //log.Debug("NotifySubscriptionDeliverySelector_Closing");
Application.Idle-= new EventHandler(Application_Idle);
if(mSelectedNotifySubscriptionDeliveryID==Guid.Empty)
this.DialogResult=DialogResult.Cancel;
Util.SaveFormCustomization("NotifySubscriptionDeliverySelector", this, tbManager, true);
}
#endregion
#region Idle processing
private void Application_Idle(object sender, EventArgs e)
{
tbManager.Tools["LT:UI.Command.OK"].SharedProps.Enabled=mSelectedNotifySubscriptionDeliveryID!=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
mSelectedNotifySubscriptionDeliveryID=Guid.Empty;
this.DialogResult=DialogResult.Cancel;
this.Close();
break;
case "LT:UI.Command.OK": // ButtonTool
this.DialogResult=DialogResult.OK;
this.Close();
break;
case "LT:UI.Toolbar.Refresh": // ButtonTool
LoadCombo();
break;
}
}
/// <summary>
/// Load or create NotifySubscriptionDelivery
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnNotifySubscriptionDeliveryID_Click(object sender, System.EventArgs e)
{
//case 1039 //log.Debug("btnNotifySubscriptionDeliveryID_Click");
NotifyDeliverySettingsForm ndsf=new NotifyDeliverySettingsForm();
ndsf.ShowDialog();
if(ndsf.ChangesMade)
{
//Signal there is a new item
//so that subscription form can rebuild
//the grid combo box for display
_ListChanged=true;
LoadCombo();
if(mSelectedNotifySubscriptionDeliveryID!=Guid.Empty)
{
foreach(ValueListItem vi in cbNotifySubscriptionDeliveryID.Items)
{
if((Guid)vi.DataValue==mSelectedNotifySubscriptionDeliveryID)
{
cbNotifySubscriptionDeliveryID.SelectedItem=vi;
break;
}
}
}
}
}
#endregion
#region Combo box intialization / events
private void LoadCombo()
{
//case 1039 //log.Debug("LoadCombo");
cbNotifySubscriptionDeliveryID.Items.Clear();
NotifyDeliverySettingPickList l = NotifyDeliverySettingPickList.GetList(User.CurrentThreadUserID);
if(l.Count==0)
{
//Warn that there is no delivery settings and ask if want to create one now
if(Util.PromptYesNoFromLocaleKey("NotifySubscription.Label.WarningNoDeliveryMethod")!=DialogResult.Yes)
this.Close();//User selects no then close
else
{//User selects yes, so open form for adding one...
NotifyDeliverySettingsForm ndsf=new NotifyDeliverySettingsForm();
ndsf.ShowDialog();
if(!ndsf.ChangesMade) this.Close();//If no changes made then exit because user didn't add one
//changes made so attempt this again by calling recursively
LoadCombo();
//and simply return whatever the result.
return;
}
}
foreach(NotifyDeliverySettingPickList.NotifyDeliverySettingPickListInfo di in l)
{
//If the delivery setting is already present in the
//deliveries for this subscription then break and move on to
//next one
if(mSubscription.ContainsDelivery(di.ID)) continue;
//Not already selected so add it now
cbNotifySubscriptionDeliveryID.Items.Add(di.ID,di.Name);
}
if(cbNotifySubscriptionDeliveryID.Items.Count>0)
cbNotifySubscriptionDeliveryID.Enabled=true;
else
cbNotifySubscriptionDeliveryID.Enabled=false;
}
private void cbNotifySubscriptionDeliveryID_ValueChanged(object sender, System.EventArgs e)
{
mSelectedNotifySubscriptionDeliveryID=(Guid)cbNotifySubscriptionDeliveryID.SelectedItem.DataValue;
}
#endregion
//--------------------------------------------------------
}
}