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 { /// /// /// public class CustomizableObjectsForm : 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.UltraToolbarsManager ToolBarManager; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _CustomizableObjectsForm_Toolbars_Dock_Area_Left; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _CustomizableObjectsForm_Toolbars_Dock_Area_Right; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _CustomizableObjectsForm_Toolbars_Dock_Area_Top; private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _CustomizableObjectsForm_Toolbars_Dock_Area_Bottom; private System.Windows.Forms.HelpProvider helpProvider1; private System.ComponentModel.IContainer components; public CustomizableObjectsForm() { // // 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("CustomizableObjectsToolBar"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Toolbar.Refresh"); Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = 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(); this.Grid = new Infragistics.Win.UltraWinGrid.UltraGrid(); this.ToolBarManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components); this._CustomizableObjectsForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._CustomizableObjectsForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._CustomizableObjectsForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea(); this.helpProvider1 = new System.Windows.Forms.HelpProvider(); ((System.ComponentModel.ISupportInitialize)(this.Grid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).BeginInit(); this.SuspendLayout(); // // Grid // this.Grid.Cursor = System.Windows.Forms.Cursors.Hand; this.Grid.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns; 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 = "CustomizableObjects form"; this.Grid.ClickCellButton += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.Grid_ClickCellButton); // // 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[] { buttonTool1}); ultraToolbar1.Text = "CustomizableObjectsToolBar"; 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; buttonTool2.SharedPropsInternal.AppearancesLarge.Appearance = appearance1; appearance2.Image = global::AyaNova.Resource1.Refresh16; buttonTool2.SharedPropsInternal.AppearancesSmall.Appearance = appearance2; buttonTool2.SharedPropsInternal.Caption = "LT:UI.Toolbar.Refresh"; buttonTool2.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageAndText; this.ToolBarManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] { buttonTool2}); this.ToolBarManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.ToolBarManager_ToolClick); // // _CustomizableObjectsForm_Toolbars_Dock_Area_Left // this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control; this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left; this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText; this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 26); this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.Name = "_CustomizableObjectsForm_Toolbars_Dock_Area_Left"; this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 499); this._CustomizableObjectsForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.ToolBarManager; // // _CustomizableObjectsForm_Toolbars_Dock_Area_Right // this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control; this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right; this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText; this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(536, 26); this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.Name = "_CustomizableObjectsForm_Toolbars_Dock_Area_Right"; this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 499); this._CustomizableObjectsForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.ToolBarManager; // // _CustomizableObjectsForm_Toolbars_Dock_Area_Top // this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control; this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top; this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText; this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0); this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.Name = "_CustomizableObjectsForm_Toolbars_Dock_Area_Top"; this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(536, 26); this._CustomizableObjectsForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.ToolBarManager; // // _CustomizableObjectsForm_Toolbars_Dock_Area_Bottom // this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping; this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control; this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom; this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText; this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 525); this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.Name = "_CustomizableObjectsForm_Toolbars_Dock_Area_Bottom"; this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(536, 0); this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.ToolBarManager; // // CustomizableObjectsForm // 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._CustomizableObjectsForm_Toolbars_Dock_Area_Left); this.Controls.Add(this._CustomizableObjectsForm_Toolbars_Dock_Area_Right); this.Controls.Add(this._CustomizableObjectsForm_Toolbars_Dock_Area_Bottom); this.Controls.Add(this._CustomizableObjectsForm_Toolbars_Dock_Area_Top); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.helpProvider1.SetHelpKeyword(this, ""); this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic); this.Name = "CustomizableObjectsForm"; this.helpProvider1.SetShowHelp(this, true); this.Text = "CustomizableObjectsForm"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CustomizableObjectsForm_FormClosing); this.Load += new System.EventHandler(this.Form_Load); ((System.ComponentModel.ISupportInitialize)(this.Grid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ToolBarManager)).EndInit(); this.ResumeLayout(false); } #endregion // __ _ _ ___ ____ __ __ __ __ __ ___ ___ // / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _) // ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _) // \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___) // #region Grid Preparation, Display and Events //UIUserFormSetting mFormSetting; private void Form_Load(object sender, System.EventArgs e) { //case 1039 //log.Debug("Form_Load"); // // helpProvider1 // this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "Custom_Field_Designer.htm"; Util.LoadFormCustomization("CustomizableObjects", this, this.ToolBarManager, true); Grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.SortSingle; Grid.DisplayLayout.CaptionAppearance.TextHAlign=HAlign.Left; Util.Localize(this); BindGrid(false); Grid.DisplayLayout.Bands[0].Columns["LT_ObjectCustomField_Label_ObjectName"].Style=Infragistics.Win.UltraWinGrid.ColumnStyle.Button; Grid.DisplayLayout.Bands[0].Columns["Key"].Hidden=true; Util.LocalizeGrid(this.Grid); //case 2108 Util.GridStyler(Grid); } /// /// 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; Grid.DataSource=CustomizableObjectList.GetList(); Grid.Text="("+Grid.Rows.FilteredInRowCount.ToString()+")"; //Util.SetGridFilteredStyle(Grid,bFiltered); //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("BindGrid - finished (" + Grid.Text + ")"); Grid.EndUpdate(); Cursor.Current = Cursors.Default; } #endregion #region MenuMerging public Infragistics.Win.UltraWinToolbars.UltraToolbarsManager ToolBar { get { Util.Localize(ToolBarManager); return ToolBarManager; } } #endregion #region Menu tool items private void ToolBarManager_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.Toolbar.Refresh": // ButtonTool Grid.BeginUpdate(); BindGrid(false); break; } } #endregion private void Grid_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { // LocaleInfoForm lif=new LocaleInfoForm(); // lif.LocaleToEdit=LocalizedTexts.GetItemsForLocale(e.Cell.Value.ToString()); // lif.ShowDialog(); string sObjectName=e.Cell.Row.Cells["Key"].Value.ToString(); //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("Editing: "+sObjectName); //gridSetup.Text=((ComboBoxTool)tbManager.Tools["LT:UI.Label.Object"]).SelectedItem.ToString(); //Attempt to retrieve custom field record for the object selected ObjectCustomFields ocf=ObjectCustomFields.GetItems(sObjectName); if(ocf.Count==0)//not created yet? { ocf.Add(sObjectName,"Custom0"); ocf.Add(sObjectName,"Custom1"); ocf.Add(sObjectName,"Custom2"); ocf.Add(sObjectName,"Custom3"); ocf.Add(sObjectName,"Custom4"); ocf.Add(sObjectName,"Custom5"); ocf.Add(sObjectName,"Custom6"); ocf.Add(sObjectName,"Custom7"); ocf.Add(sObjectName,"Custom8"); ocf.Add(sObjectName,"Custom9"); } CustomizableObjectInfoForm cif=new CustomizableObjectInfoForm(); cif.ObjectCustomFieldsToEdit=ocf; cif.ObjectName=sObjectName; cif.ShowDialog(); BindGrid(false); } private void CustomizableObjectsForm_FormClosing(object sender, FormClosingEventArgs e) { Util.SaveFormCustomization("CustomizableObjects", this, ToolBarManager, true); } } }