using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using GZTW.AyaNova.BLL;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win;
using log4net;
namespace AyaNova
{
///
/// Summary description for NotifySubscriptionsForm.
///
public class NotifySubscriptionsForm : 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.UltraWinGrid.UltraGrid Grid;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptions_Toolbars_Dock_Area_Left;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptions_Toolbars_Dock_Area_Right;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptions_Toolbars_Dock_Area_Top;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _NotifySubscriptions_Toolbars_Dock_Area_Bottom;
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ToolBarManager;
private GZTW.WinForm.Controls.GZDateTimePicker GridCalendar;
private System.Windows.Forms.HelpProvider helpProvider1;
private System.ComponentModel.IContainer components;
public NotifySubscriptionsForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
//
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("SecurityGroupsToolBar");
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.New");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh");
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh");
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.Toolbar.New");
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
Infragistics.Win.UltraWinToolbars.ListTool listTool1 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST");
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("LT:UI.Toolbar.Print");
Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
Infragistics.Win.UltraWinToolbars.ListTool listTool2 = new Infragistics.Win.UltraWinToolbars.ListTool("REPORTLIST");
this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
this._NotifySubscriptions_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this.ToolBarManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
this._NotifySubscriptions_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._NotifySubscriptions_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
this.GridCalendar = new GZTW.WinForm.Controls.GZDateTimePicker();
this.helpProvider1 = new System.Windows.Forms.HelpProvider();
((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.GridCalendar)).BeginInit();
this.SuspendLayout();
//
// Grid
//
this.Grid.Cursor = System.Windows.Forms.Cursors.Default;
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.RowSelectors = Infragistics.Win.DefaultableBoolean.False;
this.Grid.Dock = System.Windows.Forms.DockStyle.Fill;
this.Grid.Location = new System.Drawing.Point(0, 26);
this.Grid.Name = "Grid";
this.Grid.Size = new System.Drawing.Size(536, 499);
this.Grid.TabIndex = 1;
this.Grid.Text = "LT:NotifySubscription.Label.List";
this.Grid.InitializeRow += new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler(this.Grid_InitializeRow);
this.Grid.DoubleClick += new System.EventHandler(this.Grid_DoubleClick);
this.Grid.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Grid_KeyUp);
this.Grid.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Grid_MouseDown);
//
// _NotifySubscriptions_Toolbars_Dock_Area_Left
//
this._NotifySubscriptions_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptions_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptions_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
this._NotifySubscriptions_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptions_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 26);
this._NotifySubscriptions_Toolbars_Dock_Area_Left.Name = "_NotifySubscriptions_Toolbars_Dock_Area_Left";
this._NotifySubscriptions_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 499);
this._NotifySubscriptions_Toolbars_Dock_Area_Left.ToolbarsManager = this.ToolBarManager;
//
// ToolBarManager
//
this.ToolBarManager.DesignerFlags = 1;
this.ToolBarManager.DockWithinContainer = this;
this.ToolBarManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
this.ToolBarManager.MdiMergeable = false;
this.ToolBarManager.ShowFullMenusDelay = 500;
ultraToolbar1.DockedColumn = 0;
ultraToolbar1.DockedRow = 0;
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
popupMenuTool1,
buttonTool1,
buttonTool2});
ultraToolbar1.Text = "SecurityGroupsToolBar";
this.ToolBarManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
ultraToolbar1});
this.ToolBarManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
this.ToolBarManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False;
this.ToolBarManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
appearance1.Image = global::AyaNova.Resource1.Refresh32;
buttonTool3.SharedPropsInternal.AppearancesLarge.Appearance = appearance1;
appearance2.Image = global::AyaNova.Resource1.Refresh16;
buttonTool3.SharedPropsInternal.AppearancesSmall.Appearance = appearance2;
buttonTool3.SharedPropsInternal.Caption = "LT:UI.Toolbar.Refresh";
buttonTool3.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageAndText;
appearance3.Image = global::AyaNova.Resource1.NotificationSubscription32;
buttonTool4.SharedPropsInternal.AppearancesLarge.Appearance = appearance3;
appearance4.Image = global::AyaNova.Resource1.NotificationSubscription16;
buttonTool4.SharedPropsInternal.AppearancesSmall.Appearance = appearance4;
buttonTool4.SharedPropsInternal.Caption = "LT:UI.Toolbar.New";
buttonTool4.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageAndText;
listTool1.DisplayCheckmark = false;
appearance5.Image = global::AyaNova.Resource1.Print32;
popupMenuTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance5;
appearance6.Image = global::AyaNova.Resource1.Print16;
popupMenuTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance6;
popupMenuTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Print";
popupMenuTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageOnlyOnToolbars;
popupMenuTool2.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
listTool2});
this.ToolBarManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
buttonTool3,
buttonTool4,
listTool1,
popupMenuTool2});
this.ToolBarManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.ToolBarManager_ToolClick);
//
// _NotifySubscriptions_Toolbars_Dock_Area_Right
//
this._NotifySubscriptions_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptions_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptions_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
this._NotifySubscriptions_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptions_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(536, 26);
this._NotifySubscriptions_Toolbars_Dock_Area_Right.Name = "_NotifySubscriptions_Toolbars_Dock_Area_Right";
this._NotifySubscriptions_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 499);
this._NotifySubscriptions_Toolbars_Dock_Area_Right.ToolbarsManager = this.ToolBarManager;
//
// _NotifySubscriptions_Toolbars_Dock_Area_Top
//
this._NotifySubscriptions_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptions_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptions_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
this._NotifySubscriptions_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptions_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
this._NotifySubscriptions_Toolbars_Dock_Area_Top.Name = "_NotifySubscriptions_Toolbars_Dock_Area_Top";
this._NotifySubscriptions_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(536, 26);
this._NotifySubscriptions_Toolbars_Dock_Area_Top.ToolbarsManager = this.ToolBarManager;
//
// _NotifySubscriptions_Toolbars_Dock_Area_Bottom
//
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 525);
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.Name = "_NotifySubscriptions_Toolbars_Dock_Area_Bottom";
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(536, 0);
this._NotifySubscriptions_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.ToolBarManager;
//
// GridCalendar
//
this.GridCalendar.GZEnabled = true;
this.GridCalendar.GZReadOnly = false;
this.GridCalendar.Location = new System.Drawing.Point(259, 291);
this.GridCalendar.Name = "GridCalendar";
this.GridCalendar.Size = new System.Drawing.Size(125, 24);
this.GridCalendar.TabIndex = 152;
this.GridCalendar.Visible = false;
//
// NotifySubscriptionsForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(536, 525);
this.ControlBox = false;
this.Controls.Add(this.Grid);
this.Controls.Add(this.GridCalendar);
this.Controls.Add(this._NotifySubscriptions_Toolbars_Dock_Area_Left);
this.Controls.Add(this._NotifySubscriptions_Toolbars_Dock_Area_Right);
this.Controls.Add(this._NotifySubscriptions_Toolbars_Dock_Area_Bottom);
this.Controls.Add(this._NotifySubscriptions_Toolbars_Dock_Area_Top);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
this.Name = "NotifySubscriptionsForm";
this.helpProvider1.SetShowHelp(this, true);
this.Text = "NotifySubscriptionsForm";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form_Closing);
this.Load += new System.EventHandler(this.Form_Load);
((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.GridCalendar)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
//
#region Grid Preparation, Display and Events
//variable to hold user form settings
//UIUserFormSetting mFormSetting;
private void Form_Load(object sender, System.EventArgs e)
{
//
// helpProvider1
//
this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "what_do_i_use_notifications_fo.htm";
//case 1039 //log.Debug("Form_Load");
Util.LoadFormCustomization("NotifySubscriptionsForm", this, ToolBarManager, true);
if(!Grid.DisplayLayout.Bands[0].Columns.Exists("EventDescription"))
Grid.DisplayLayout.Bands[0].Columns.Add("EventDescription");
BindGrid(false);
Util.FetchGridLayout("NotifySubscriptions","",Grid);
//GridCalendar.MaskInput=Util.LocaleDateTimeMask();
//Set the caption to be on the left side of the grid
Grid.DisplayLayout.CaptionAppearance.TextHAlign=HAlign.Left;
//internal (grid only) sorting
Grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.SortSingle;
Grid.DisplayLayout.Bands[0].Columns["ID"].Hidden=true;
Grid.DisplayLayout.Bands[0].Columns["GuidValue"].Hidden=true;
Grid.DisplayLayout.Bands[0].Columns["LT_NotifySubscription_Label_EventDescription"].Hidden=true;
Grid.DisplayLayout.Bands[0].Columns["LT_NotifySubscription_Label_Created"].EditorComponent=this.GridCalendar;
Grid.DisplayLayout.Bands[0].Columns["EventDescription"].Header.Caption=Util.LocaleText.GetLocalizedText("NotifySubscription.Label.EventDescription");
Grid.DisplayLayout.Override.AllowRowFiltering=DefaultableBoolean.False;
Util.Localize(this);
Util.LocalizeGrid(Grid);
Grid.DisplayLayout.Override.CellClickAction=CellClickAction.RowSelect;
foreach(UltraGridColumn c in Grid.DisplayLayout.Bands[0].Columns)
{
c.CellActivation=Activation.NoEdit;//.NoEdit;
}
if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly)
{
ToolBarManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = false;
}
else
{
ToolBarManager.Tools["LT:UI.Toolbar.Print"].SharedProps.Visible = true;
Util.ReportFillList(this.ToolBarManager.Tools["REPORTLIST"], NotifySubscriptionList.ReportKey, "");
}
}
///
/// When form closes it will save
/// (main form must call close on this form for this to work)
///
///
///
private void Form_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//case 1039 //log.Debug("Form_Closing");
Util.SaveGridLayout("NotifySubscriptions","","List of NotifySubscriptions",Grid);
Util.SaveFormCustomization("NotifySubscriptionsForm", this, ToolBarManager, true);
}
///
/// Rebind the control to the data source based on the latest
/// user filter and sort settings
///
private void BindGrid(bool bReverseSort)
{
//case 1039 //log.Debug("BindGrid - entering");
Cursor.Current=Cursors.WaitCursor;
//bool bFiltered=false;
//Grid.DataSource=NotifySubscriptionList.GetList(Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[0],bReverseSort,ref bFiltered));
//Grid.Text=Util.LocaleText.GetLocalizedText("NotifySubscription.Label.List")+" ("+Grid.Rows.FilteredInRowCount.ToString()+")";
NotifySubscriber ns=NotifySubscriber.GetItem(User.CurrentThreadUserID);
Grid.DataSource=NotifySubscriptionList.GetList(ns);
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("BindGrid - finished");
Grid.EndUpdate();
Cursor.Current = Cursors.Default;
}
private void Grid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
//convert description from localized text key to localized description
//Any text need to be added based on Guid value?
if((string)e.Row.Cells["LT_NotifySubscription_Label_EventDescription"].Value=="Workorder.Label.Event.Status")
{
e.Row.Cells["EventDescription"].Value=
Util.LocaleText.GetLocalizedText((string)e.Row.Cells["LT_NotifySubscription_Label_EventDescription"].Value) +
" (" + NameFetcher.GetItem("aWorkorderStatus","aName",(Guid)e.Row.Cells["GuidValue"].Value).RecordName + ")";
}
else
e.Row.Cells["EventDescription"].Value=
Util.LocaleText.GetLocalizedText((string)e.Row.Cells["LT_NotifySubscription_Label_EventDescription"].Value);
}
#endregion
#region Selection and Editing
Infragistics.Win.UIElement ElementLastClicked;
///
/// This is whacky Infragistics stuff, where normally we would
/// just do someting like override Row.OnDoubleClick we can't
/// do that with a grid because it's rows don't have a click event
///
/// To know which row is clicked on we need to always keep
/// track of what element of the grid was last clicked on
/// so that later on we can (in doubleclick) pre-know what was
/// clicked in the first click of the double click.
///
///
///
private void Grid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ElementLastClicked = Grid.DisplayLayout.UIElement.ElementFromPoint(new System.Drawing.Point(e.X, e.Y));
//Handle right click
if( e.Button == MouseButtons.Right)
{
GridNameValueCellItem nvb=Util.NameValueButtonRightClicked(Grid,e);
if(nvb!=null)
{
Util.DisplayObjectContextMenu(nvb.RootObjectType,nvb.Value,this);
}
else
{
UltraGridBand b=Util.BandRightClicked(Grid/*NAME OF GRID HERE, REST IS STOCK TO ANY FORM*/,e);
if(b!=null)
{
UtilGridColumnSelector c = new UtilGridColumnSelector();
c.HideColumns.Add("LT_NotifySubscription_Label_Viewed",0);
c.BandToEdit=b;
c.ShowDialog(this);
}
}
}
}
///
/// Ok, we already know roughly what was clicked
/// we just need to refine that a bit further
///
///
///
private void Grid_DoubleClick(object sender, System.EventArgs e)
{
UltraGridRow Row = (UltraGridRow)ElementLastClicked.GetContext(typeof(UltraGridRow));
//If row==null then something else was clicked on, maybe a header or something
if(Row!=null)
{
EditSubscription((Guid)Row.Cells["ID"].Value,Row.Index);
}
}
///
/// Handle a key down in addition to a mouse click
/// this allows user to hit enter to select from the grid
///
///
///
private void Grid_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==Keys.Enter)
{
UltraGridRow Row = Grid.ActiveRow;
//If row==null then something else was clicked on, maybe a header or something
if(Row!=null)
{
EditSubscription((Guid)Row.Cells["ID"].Value,Row.Index);
}
}
}
///
/// Open record for editing then update grid afterwards
///
///
///
private void EditSubscription(Guid SubscriptionID, int nRowToScrollTo)
{
NotifySubscription ns=NotifySubscription.GetItem(SubscriptionID);
NotifySubscriptionInfoForm nsif=new NotifySubscriptionInfoForm();
nsif.NotifySubscriptionToEdit=ns;
nsif.ShowDialog();
Grid.BeginUpdate();
BindGrid(false);
if(nRowToScrollTo