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 Infragistics.Win.UltraWinEditors; using log4net; namespace AyaNova { /// /// Summary description for PopUp. /// public class PopUp : 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 GZTW.WinForm.Controls.GZDateTimePicker GridCalendar; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; NotifyPopUpList _popList = null; public PopUp(NotifyPopUpList PopList) { _popList = PopList; // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// 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() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PopUp)); this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); this.GridCalendar = new GZTW.WinForm.Controls.GZDateTimePicker(); ((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.GridCalendar)).BeginInit(); this.SuspendLayout(); // // Grid // this.Grid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No; this.Grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False; this.Grid.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti; this.Grid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Single; this.Grid.Dock = System.Windows.Forms.DockStyle.Fill; this.Grid.Location = new System.Drawing.Point(0, 0); this.Grid.Name = "Grid"; this.Grid.Size = new System.Drawing.Size(756, 517); this.Grid.TabIndex = 0; this.Grid.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_ClickCellButton); this.Grid.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Grid_KeyUp); // // GridCalendar // this.GridCalendar.GZEnabled = true; this.GridCalendar.GZReadOnly = false; this.GridCalendar.Location = new System.Drawing.Point(113, 88); this.GridCalendar.Name = "GridCalendar"; this.GridCalendar.Size = new System.Drawing.Size(125, 24); this.GridCalendar.TabIndex = 153; this.GridCalendar.Visible = false; // // PopUp // this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.ClientSize = new System.Drawing.Size(756, 517); this.Controls.Add(this.Grid); this.Controls.Add(this.GridCalendar); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MinimumSize = new System.Drawing.Size(768, 554); this.Name = "PopUp"; this.Text = "(0)"; this.Closing += new System.ComponentModel.CancelEventHandler(this.PopUp_Closing); this.Load += new System.EventHandler(this.PopUp_Load); ((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.GridCalendar)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Load / Close //variable to hold user form settings //UIUserFormSetting mFormSetting; private void PopUp_Load(object sender, System.EventArgs e) { Grid.DataSource = _popList; //Setup column headers Util.FetchGridLayout("PopUpNotification","",Grid); //GridCalendar.MaskInput=Util.LocaleDateTimeMask(); Grid.DisplayLayout.Bands[0].Columns["ID"].Hidden=true; Grid.DisplayLayout.Bands[0].Columns["LT_Notify_Label_NotificationMessage"].CellMultiLine=DefaultableBoolean.True; Grid.DisplayLayout.Bands[0].Columns["LT_Notify_Label_NotificationMessage"].VertScrollBar=true; Grid.DisplayLayout.Bands[0].Columns["LT_Notify_Label_SourceOfEvent"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.Button; if(!Grid.DisplayLayout.Bands[0].Columns.Exists("REMOVE")) Grid.DisplayLayout.Bands[0].Columns.Add("REMOVE",""); Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Header.Caption=""; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.Button; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].CellButtonAppearance.Image = Resource1.Delete16; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].CellButtonAppearance.ImageHAlign=HAlign.Center; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].CellButtonAppearance.ImageVAlign=VAlign.Middle; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Header.Appearance.Image = Resource1.Delete16; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Header.Appearance.ImageHAlign=HAlign.Center; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Width=24; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].MinWidth=24; Grid.DisplayLayout.Bands[0].Columns["REMOVE"].MaxWidth=24; //case 1185 //Grid.DisplayLayout.Bands[0].Override.RowSelectors=DefaultableBoolean.False; Grid.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns; Util.Localize(this); Util.LoadFormCustomization("PopUpNotification", this, null, false); } private void PopUp_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Util.SaveGridLayout("PopUpNotification","","",Grid); Util.SaveFormCustomization("PopUpNotification", this, null, false); e.Cancel=true; this.Visible=false; } #endregion #region Set data source / refresh display private void Display() { Grid.DataSource=_popList; this.Text= "(" + _popList.Count + ")"; } private void RefreshView() { _popList=NotifyPopUpList.GetList(); Display(); } #endregion #region Editing private void Grid_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if(e.Cell.Column.Key=="REMOVE") { Cursor.Current=Cursors.WaitCursor; NotifyPopUp.DeleteItem((Guid)e.Cell.Row.Cells["ID"].Value); } else EditRecord((GridNameValueCellItem)e.Cell.Value,e.Cell.Row.Index); RefreshView(); } /// /// 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.Space || e.KeyCode==Keys.Enter) { UltraGridCell c = Grid.ActiveCell; if(c!=null) { if(c.Value.GetType().ToString()=="GZTW.AyaNova.BLL.GridNameValueCellItem") { e.Handled=true; EditRecord((GridNameValueCellItem)c.Value,c.Row.Index); } } } } /// /// Open record for editing then update grid afterwards /// /// /// private void EditRecord(GridNameValueCellItem i, int nRowToScrollTo) { //Make sure there is something to edit if(i==null || i.Value==Guid.Empty) return; Util.EditRecord(i.RootObjectType,i.Value); } #endregion //============================================================================== } }