diff --git a/source/WinFormApp/AssemblyInfo.cs b/source/WinFormApp/AssemblyInfo.cs index 9570d0c..9415497 100644 --- a/source/WinFormApp/AssemblyInfo.cs +++ b/source/WinFormApp/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; [assembly: log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config",Watch=true)] //[assembly: log4net.Config.XmlConfigurator(Watch=true)] [assembly: ComVisibleAttribute(false)] -[assembly: AssemblyFileVersionAttribute("7.6.5.0")] +[assembly: AssemblyFileVersionAttribute("7.6.6.0")] diff --git a/source/WinFormApp/Util.cs b/source/WinFormApp/Util.cs index a44cb7c..f9f28b8 100644 --- a/source/WinFormApp/Util.cs +++ b/source/WinFormApp/Util.cs @@ -30,32 +30,32 @@ using AyaNova.PlugIn; namespace AyaNova { - - //Namespace-Wide enums - /// - /// Used within sub forms to indicate what to do - /// with the current record - /// - public enum RecordActionType : int - { - SaveOnly = 1, - SaveAndExit = 2, - SaveAndNew = 3, - PromptToSave = 4, - DeleteAndExit = 5 + //Namespace-Wide enums - } + /// + /// Used within sub forms to indicate what to do + /// with the current record + /// + public enum RecordActionType : int + { + SaveOnly = 1, + SaveAndExit = 2, + SaveAndNew = 3, + PromptToSave = 4, + DeleteAndExit = 5 + + } //Case 37 - public enum HotKeyAction + public enum HotKeyAction { NoAction, CloseForm, NewWorkorder, NewPreventiveMaintenance, NewQuote, - NewClient, + NewClient, NewUnit, NewPart, Help, @@ -63,96 +63,96 @@ namespace AyaNova EmptyWorkingSet//case 1701 } - /// - /// Summary description for Util. - /// - public class Util - { - - // Create a logger for use in this class - private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Summary description for Util. + /// + public class Util + { + + // Create a logger for use in this class + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); internal static UIUserGridLastViews gGridLastViews; - internal static UIUserFormSettings gFormSettings; - internal static UIUserFormSettings gAdminFormSettings; - public static Hashtable PrivateColumns=null; - private static System.Drawing.Bitmap BrokenRuleErrorImage; + internal static UIUserFormSettings gFormSettings; + internal static UIUserFormSettings gAdminFormSettings; + public static Hashtable PrivateColumns = null; + private static System.Drawing.Bitmap BrokenRuleErrorImage; + + /// + /// Current thread security businessprinciple object + /// + //public static BusinessPrincipal BP; + + public static Global GlobalSettings = null; + public static GZTW.AyaNova.BLL.Region RegionalSettings = null; + - /// - /// Current thread security businessprinciple object - /// - //public static BusinessPrincipal BP; - - public static Global GlobalSettings=null; - public static GZTW.AyaNova.BLL.Region RegionalSettings=null; - - //Used by workorder form - public static Guid CurrentUserDefaultPartWarehouseID=Guid.Empty; + public static Guid CurrentUserDefaultPartWarehouseID = Guid.Empty; //case 939 public static bool CurrentUserIsAdminType = false; - //private static string DiagnosticConnectionInfo=null; + //private static string DiagnosticConnectionInfo=null; - internal static LocalizedTextTable LocaleText=null; - //set by config file value - //used to run generator from client winform background process - //internal static bool IAmAGenerator=false; + internal static LocalizedTextTable LocaleText = null; + //set by config file value + //used to run generator from client winform background process + //internal static bool IAmAGenerator=false; - //internal static bool UsingDataPortal=false; + //internal static bool UsingDataPortal=false; //Case 534 //Case 697 now also uses this internal static Form1 frmMain = null; - //case 73 + //case 73 public static string TempFolder = ""; //case 941 public static bool pluginsLoaded = false; - #region constructor - static Util() - { -// //ensure there is a logged in user before proceeding -// if(Thread.CurrentPrincipal.Identity.IsAuthenticated == false) -// return; -// -// -// //Get the error icon image used in grids -// BrokenRuleErrorImage= new System.Windows.Forms.ErrorProvider().Icon.ToBitmap(); -// -// -// //Get the businessprinciple which is the connection to the localized text -// //appropriate for this user (English/French etc) -// //BP = ((BusinessPrincipal)Thread.CurrentPrincipal); -// -// //A list of columns that should never be displayed to the user -// //used by many functions that alter the grid -// PrivateColumns=new Hashtable(); -// PrivateColumns.Add("IsDirty",0); -// PrivateColumns.Add("IsNew",0); -// PrivateColumns.Add("IsSavable",0); -// PrivateColumns.Add("Modifier",0); -// PrivateColumns.Add("Created",0); -// PrivateColumns.Add("Modified",0); -// PrivateColumns.Add("Creator",0); -// PrivateColumns.Add("IsDeleted",0); -// PrivateColumns.Add("IsValid",0); -// PrivateColumns.Add("BrokenRulesText",0); -// PrivateColumns.Add("CurrentUserID",0); -// PrivateColumns.Add("RootObjectID",0); -// PrivateColumns.Add("RootObjectType",0); -// PrivateColumns.Add("ID",0); -// PrivateColumns.Add("ContactID",0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? -// PrivateColumns.Add("HeadOfficeID",0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? -// + #region constructor + static Util() + { + // //ensure there is a logged in user before proceeding + // if(Thread.CurrentPrincipal.Identity.IsAuthenticated == false) + // return; + // + // + // //Get the error icon image used in grids + // BrokenRuleErrorImage= new System.Windows.Forms.ErrorProvider().Icon.ToBitmap(); + // + // + // //Get the businessprinciple which is the connection to the localized text + // //appropriate for this user (English/French etc) + // //BP = ((BusinessPrincipal)Thread.CurrentPrincipal); + // + // //A list of columns that should never be displayed to the user + // //used by many functions that alter the grid + // PrivateColumns=new Hashtable(); + // PrivateColumns.Add("IsDirty",0); + // PrivateColumns.Add("IsNew",0); + // PrivateColumns.Add("IsSavable",0); + // PrivateColumns.Add("Modifier",0); + // PrivateColumns.Add("Created",0); + // PrivateColumns.Add("Modified",0); + // PrivateColumns.Add("Creator",0); + // PrivateColumns.Add("IsDeleted",0); + // PrivateColumns.Add("IsValid",0); + // PrivateColumns.Add("BrokenRulesText",0); + // PrivateColumns.Add("CurrentUserID",0); + // PrivateColumns.Add("RootObjectID",0); + // PrivateColumns.Add("RootObjectType",0); + // PrivateColumns.Add("ID",0); + // PrivateColumns.Add("ContactID",0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? + // PrivateColumns.Add("HeadOfficeID",0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? + // - } + } - public static void InitUtil(Form1 form1) - { + public static void InitUtil(Form1 form1) + { //case 3112 fixFonts = true; string[] args = Environment.GetCommandLineArgs(); @@ -164,81 +164,81 @@ namespace AyaNova break; } } - - //check if already initialized... - if(PrivateColumns!=null) return; - //case 1039 //log.Debug("InitUtil"); + + //check if already initialized... + if (PrivateColumns != null) return; + //case 1039 //log.Debug("InitUtil"); frmMain = form1; - BrokenRuleErrorImage= new System.Windows.Forms.ErrorProvider().Icon.ToBitmap(); - - - //Get the businessprinciple which is the connection to the localized text - //appropriate for this user (English/French etc) - //BP = ((BusinessPrincipal)Thread.CurrentPrincipal); - - //A list of columns that should never be displayed to the user - //used by many functions that alter the grid - PrivateColumns=new Hashtable(); - PrivateColumns.Add("IsDirty",0); - PrivateColumns.Add("IsNew",0); - PrivateColumns.Add("IsSavable",0); - PrivateColumns.Add("Modifier",0); - PrivateColumns.Add("Created",0); - PrivateColumns.Add("Modified",0); - PrivateColumns.Add("Creator",0); - PrivateColumns.Add("IsDeleted",0); - PrivateColumns.Add("IsValid",0); - PrivateColumns.Add("BrokenRulesText",0); - PrivateColumns.Add("CurrentUserID",0); - PrivateColumns.Add("RootObjectID",0); - PrivateColumns.Add("RootObjectType",0); - PrivateColumns.Add("ID",0); - PrivateColumns.Add("ContactID",0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? - PrivateColumns.Add("HeadOfficeID",0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? - - - } - #endregion - - #region Form and toolbar end user layout / customization persistence - - /// - /// Returns a form setting object - /// for form specified. - /// - /// This includes the form position and layout as well - /// as the toolbar customization if any - /// - /// Adds to form settings collection if - /// doesn't prior exist - /// - /// - /// - static public UIUserFormSetting GetFormSettings(string FormName) - { - //case 1039 //log.Debug("GetFormSettings(" + FormName + ")"); - - if(gFormSettings.Contains(FormName)) - return gFormSettings[FormName]; - else - { - //Changed: 15-March-2005 to use admins setting if user has none for form - if(!User.IsAdmin) - { - if(gAdminFormSettings.Contains(FormName)) - return gFormSettings.Add(gAdminFormSettings[FormName]); - } - - return gFormSettings.Add(FormName); - } + BrokenRuleErrorImage = new System.Windows.Forms.ErrorProvider().Icon.ToBitmap(); - } + //Get the businessprinciple which is the connection to the localized text + //appropriate for this user (English/French etc) + //BP = ((BusinessPrincipal)Thread.CurrentPrincipal); + + //A list of columns that should never be displayed to the user + //used by many functions that alter the grid + PrivateColumns = new Hashtable(); + PrivateColumns.Add("IsDirty", 0); + PrivateColumns.Add("IsNew", 0); + PrivateColumns.Add("IsSavable", 0); + PrivateColumns.Add("Modifier", 0); + PrivateColumns.Add("Created", 0); + PrivateColumns.Add("Modified", 0); + PrivateColumns.Add("Creator", 0); + PrivateColumns.Add("IsDeleted", 0); + PrivateColumns.Add("IsValid", 0); + PrivateColumns.Add("BrokenRulesText", 0); + PrivateColumns.Add("CurrentUserID", 0); + PrivateColumns.Add("RootObjectID", 0); + PrivateColumns.Add("RootObjectType", 0); + PrivateColumns.Add("ID", 0); + PrivateColumns.Add("ContactID", 0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? + PrivateColumns.Add("HeadOfficeID", 0);//<--TODO: HACK will need to be done repeatedly? Might need alternative? + + + } + #endregion + + #region Form and toolbar end user layout / customization persistence + + /// + /// Returns a form setting object + /// for form specified. + /// + /// This includes the form position and layout as well + /// as the toolbar customization if any + /// + /// Adds to form settings collection if + /// doesn't prior exist + /// + /// + /// + static public UIUserFormSetting GetFormSettings(string FormName) + { + //case 1039 //log.Debug("GetFormSettings(" + FormName + ")"); + + if (gFormSettings.Contains(FormName)) + return gFormSettings[FormName]; + else + { + //Changed: 15-March-2005 to use admins setting if user has none for form + if (!User.IsAdmin) + { + if (gAdminFormSettings.Contains(FormName)) + return gFormSettings.Add(gAdminFormSettings[FormName]); + } + + return gFormSettings.Add(FormName); + } + + + } //case 1038 - ditch infragistics specific toolbar format and abstract away from it - + /// /// Load the form and toolbar customization as per the users last view /// @@ -252,11 +252,11 @@ namespace AyaNova LoadFormCustomization(FormName, TheForm, TheToolBarManager, ToolBarOnly, ref x, ref y); } - static public void LoadFormCustomization(string FormName, System.Windows.Forms.Form TheForm, + static public void LoadFormCustomization(string FormName, System.Windows.Forms.Form TheForm, UltraToolbarsManager TheToolBarManager, bool ToolBarOnly, ref int Split1) { int x = 0; - + LoadFormCustomization(FormName, TheForm, TheToolBarManager, ToolBarOnly, ref Split1, ref x); } @@ -277,13 +277,13 @@ namespace AyaNova if (!ToolBarOnly && ds.Tables.Contains("FORM") && ds.Tables["FORM"].Rows.Count > 0) { - + //load form settings //Only one row in a form table DataRow dr = ds.Tables["FORM"].Rows[0]; //case 1594 - int nWidth=int.Parse(dr["FormWidth"].ToString()); + int nWidth = int.Parse(dr["FormWidth"].ToString()); int nHeight = int.Parse(dr["FormHeight"].ToString()); if (nWidth == 0 || nHeight == 0) TheForm.WindowState = FormWindowState.Maximized; @@ -304,10 +304,10 @@ namespace AyaNova //maximize if it's the mainform if (FormName == "MainForm") TheForm.WindowState = FormWindowState.Maximized; - + } - if (TheToolBarManager!=null && ds.Tables.Contains("TOOLBAR") && ds.Tables["TOOLBAR"].Rows.Count>0) + if (TheToolBarManager != null && ds.Tables.Contains("TOOLBAR") && ds.Tables["TOOLBAR"].Rows.Count > 0) { foreach (DataRow dr in ds.Tables["TOOLBAR"].Rows) { @@ -343,38 +343,38 @@ namespace AyaNova } //else//for initial testing only // MessageBox.Show("LoadFormCustomization error: Form " + FormName + " toolbar manager does not contain toolbar: " + dr["Key"].ToString()); - } + } } TheForm.Width = TheForm.Width - 1; TheForm.Width = TheForm.Width + 1; EnsureFormVisible(TheForm); - - //case 1114 - if(TheToolBarManager!=null) - TheToolBarManager.BeforeDisplayCustomizeDialog += new Infragistics.Win.UltraWinToolbars.BeforeDisplayCustomizeDialogEventHandler(tb_BeforeDisplayCustomizeDialog); - + //case 1114 + if (TheToolBarManager != null) + TheToolBarManager.BeforeDisplayCustomizeDialog += new Infragistics.Win.UltraWinToolbars.BeforeDisplayCustomizeDialogEventHandler(tb_BeforeDisplayCustomizeDialog); + + } //case 1114 Hide customizer form keyboard shortcut command button public static void tb_BeforeDisplayCustomizeDialog(object sender, Infragistics.Win.UltraWinToolbars.BeforeDisplayCustomizeDialogEventArgs e) { - - //e.CustomizerForm.Controls["cmdKeyboard"].Visible = false;//case 1114 - //hide keyboard command and reset command + + //e.CustomizerForm.Controls["cmdKeyboard"].Visible = false;//case 1114 + //hide keyboard command and reset command //string s = GetControls(e.CustomizerForm); //case 1681 HideToolBarCustomizeUnusedControls(e.CustomizerForm); - + } private static string GetControls(Control c) { - System.Text.StringBuilder sb=new StringBuilder(); + System.Text.StringBuilder sb = new StringBuilder(); sb.Append("* " + c.Name + " - " + c.GetType().ToString() + "\r\n"); foreach (Control cc in c.Controls) { @@ -421,7 +421,7 @@ namespace AyaNova } return null; - + } @@ -476,13 +476,13 @@ At first I was happy to find your code that solved my problem, but I did not lik /// /// static public void SaveFormCustomization(string FormName, System.Windows.Forms.Form TheForm, UltraToolbarsManager TheToolBarManager, bool ToolBarOnly) - { + { SaveFormCustomization(FormName, TheForm, TheToolBarManager, ToolBarOnly, (int)0, (int)0); } static public void SaveFormCustomization(string FormName, System.Windows.Forms.Form TheForm, UltraToolbarsManager TheToolBarManager, bool ToolBarOnly, int Split1) - { + { SaveFormCustomization(FormName, TheForm, TheToolBarManager, ToolBarOnly, Split1, (int)0); } @@ -504,12 +504,12 @@ At first I was happy to find your code that solved my problem, but I did not lik //Don't save a minimized form as minimized if (TheForm.WindowState == FormWindowState.Minimized) - TheForm.WindowState=FormWindowState.Maximized; + TheForm.WindowState = FormWindowState.Maximized; w.WriteStartElement("FORM"); if (TheForm.WindowState == FormWindowState.Maximized)//case 1594 { - w.WriteAttributeString("FormWidth","0"); //zero means maximized + w.WriteAttributeString("FormWidth", "0"); //zero means maximized w.WriteAttributeString("FormHeight", "0"); } else @@ -520,14 +520,14 @@ At first I was happy to find your code that solved my problem, but I did not lik w.WriteAttributeString("LocationX", TheForm.Location.X.ToString()); w.WriteAttributeString("LocationY", TheForm.Location.Y.ToString()); w.WriteAttributeString("SplitPosition1", Split1.ToString()); - w.WriteAttributeString("SplitPosition2", Split2.ToString()); + w.WriteAttributeString("SplitPosition2", Split2.ToString()); w.WriteEndElement();//Form section } //toolbar //w.WriteStartElement("TOOLBARS"); if (TheToolBarManager != null) - { + { foreach (UltraToolbar tb in TheToolBarManager.Toolbars) { w.WriteStartElement("TOOLBAR"); @@ -542,155 +542,155 @@ At first I was happy to find your code that solved my problem, but I did not lik w.WriteEndElement(); } } - // w.WriteEndElement();//Toolbar section + // w.WriteEndElement();//Toolbar section w.WriteEndElement();//Layout w.WriteEndDocument(); sr.Close(); GetFormSettings(FormName).Layout = sr.ToString(); - + } - #endregion + #endregion - #region Localize + #region Localize - #region Grid - /// - /// Modify ui elements to display localized values - /// specific to a grid control because it's quirky when - /// on a tab control (invisible) - /// - /// - static public void LocalizeGrid(Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //log.Debug("LocalizeGrid(" + Grid.Name +"."+ Grid.Parent.Name + ")"); + #region Grid + /// + /// Modify ui elements to display localized values + /// specific to a grid control because it's quirky when + /// on a tab control (invisible) + /// + /// + static public void LocalizeGrid(Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //log.Debug("LocalizeGrid(" + Grid.Name +"."+ Grid.Parent.Name + ")"); - //replace UltraGrid header text with localized version - //this is a special case because the column headers are based on the read only collection - //business object's public properties, which means the system of using LT: and periods to - //denote and separate parts of locale text strings won't work - //so in this case only the text we're looking for is in the format of: - //LT_Object_Label_Item (underscores instead of colons and periods) + //replace UltraGrid header text with localized version + //this is a special case because the column headers are based on the read only collection + //business object's public properties, which means the system of using LT: and periods to + //denote and separate parts of locale text strings won't work + //so in this case only the text we're looking for is in the format of: + //LT_Object_Label_Item (underscores instead of colons and periods) //case 2108 - // Grid.DisplayLayout.ScrollBarLook.ViewStyle = Infragistics.Win.UltraWinScrollBar.ScrollBarViewStyle.Office2007; + // Grid.DisplayLayout.ScrollBarLook.ViewStyle = Infragistics.Win.UltraWinScrollBar.ScrollBarViewStyle.Office2007; Grid.DisplayLayout.ScrollBarLook.ViewStyle = defaultScrollBarViewStyle; - - //Loop through the columns in the grid's band(0) column collection - foreach(Infragistics.Win.UltraWinGrid.UltraGridBand band in Grid.DisplayLayout.Bands) - { - ////case 1039 //log.Debug("Processing " + band.Columns.Count.ToString() +" columns in band(" + band.Index.ToString() +")"); - - foreach(Infragistics.Win.UltraWinGrid.UltraGridColumn cm in band.Columns) - { - //check the header to see if it needs localizing... - if(cm.Header.Caption.StartsWith("LT_")) - { - //yes it does, so replace the LT_ with nothing to get rid of it - string s=cm.Header.Caption.Replace("LT_",""); - cm.Header.Caption=LocaleText.GetLocalizedText(s.Replace("_",".")); - } - } - } + //Loop through the columns in the grid's band(0) column collection + foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in Grid.DisplayLayout.Bands) + { + ////case 1039 //log.Debug("Processing " + band.Columns.Count.ToString() +" columns in band(" + band.Index.ToString() +")"); - } - /// - /// If a grid is bound to an editable collection - /// it's field names initially are our internal property names - /// this function converts the column captions back to localized text keys - /// so that the localize function later will set them correctly - /// - /// Name of business object band represents - /// band to be pre-localized - - public static void GridPreLocalize(string ObjectName,Infragistics.Win.UltraWinGrid.UltraGridBand Band) - { - //case 1039 //log.Debug("GridPreLocalize(" + ObjectName + ", " + Band.Key+ ")"); - foreach(Infragistics.Win.UltraWinGrid.UltraGridColumn c in Band.Columns) - { - if(!PrivateColumns.Contains(c.Header.Caption)) - { - c.Header.Caption="LT_" + ObjectName + "_Label_" + c.Header.Caption; - } - - } - - } - #endregion - - #region ToolBarManager - /// - /// Localize a toolbar manager on it's own - /// This is required for poup toolbar managers on some forms - /// that contain only popup items, therefore they are never - /// referenced from the form and don't get localized in the - /// general form localization - /// - /// - static public void Localize(Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbm) - { - ////case 1039 //log.Debug("Localize(toolbar in: "+ tbm.DockWithinContainer.Name + ")"); + foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn cm in band.Columns) + { + //check the header to see if it needs localizing... + if (cm.Header.Caption.StartsWith("LT_")) + { + //yes it does, so replace the LT_ with nothing to get rid of it + string s = cm.Header.Caption.Replace("LT_", ""); + cm.Header.Caption = LocaleText.GetLocalizedText(s.Replace("_", ".")); + } + } + } + + } + + /// + /// If a grid is bound to an editable collection + /// it's field names initially are our internal property names + /// this function converts the column captions back to localized text keys + /// so that the localize function later will set them correctly + /// + /// Name of business object band represents + /// band to be pre-localized + + public static void GridPreLocalize(string ObjectName, Infragistics.Win.UltraWinGrid.UltraGridBand Band) + { + //case 1039 //log.Debug("GridPreLocalize(" + ObjectName + ", " + Band.Key+ ")"); + foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn c in Band.Columns) + { + if (!PrivateColumns.Contains(c.Header.Caption)) + { + c.Header.Caption = "LT_" + ObjectName + "_Label_" + c.Header.Caption; + } + + } + + } + #endregion + + #region ToolBarManager + /// + /// Localize a toolbar manager on it's own + /// This is required for poup toolbar managers on some forms + /// that contain only popup items, therefore they are never + /// referenced from the form and don't get localized in the + /// general form localization + /// + /// + static public void Localize(Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbm) + { + ////case 1039 //log.Debug("Localize(toolbar in: "+ tbm.DockWithinContainer.Name + ")"); tbm.Style = defaultToolBarStyle; tbm.UseOsThemes = defaultUseOsThemes; - //Localize the toolbar descriptive names - //(necessary because they are shown when the user - //customizes the layout of the toolbar) - foreach(Infragistics.Win.UltraWinToolbars.UltraToolbar tb in tbm.Toolbars) - { - if(tb.Key.StartsWith("LT:")) - { - tb.Text=LocaleText.GetLocalizedText(tb.Key.Replace("LT:","")); - } - } + //Localize the toolbar descriptive names + //(necessary because they are shown when the user + //customizes the layout of the toolbar) + foreach (Infragistics.Win.UltraWinToolbars.UltraToolbar tb in tbm.Toolbars) + { + if (tb.Key.StartsWith("LT:")) + { + tb.Text = LocaleText.GetLocalizedText(tb.Key.Replace("LT:", "")); + } + } - //Localize individual tool items - foreach(Infragistics.Win.UltraWinToolbars.ToolBase tbase in tbm.Tools) - { - if(tbase.Key.StartsWith("LT:")) - { - tbase.SharedProps.Caption=LocaleText.GetLocalizedText(tbase.Key.Replace("LT:","")); - tbase.SharedProps.ToolTipText=LocaleText.GetLocalizedText(tbase.Key.Replace("LT:","")); - } - - if(tbase is Infragistics.Win.UltraWinToolbars.PopupMenuTool) - { - Infragistics.Win.UltraWinToolbars.PopupMenuTool pop =(Infragistics.Win.UltraWinToolbars.PopupMenuTool)tbase; - foreach(Infragistics.Win.UltraWinToolbars.ToolBase sub in pop.Tools) - { - if(sub is Infragistics.Win.UltraWinToolbars.LabelTool) - { - Infragistics.Win.UltraWinToolbars.LabelTool lbt=(Infragistics.Win.UltraWinToolbars.LabelTool)sub; - if(lbt.Key.StartsWith("LT:")) - lbt.SharedProps.Caption=LocaleText.GetLocalizedText(lbt.Key.Replace("LT:","")); - - } - else if(sub is Infragistics.Win.UltraWinToolbars.StateButtonTool) - { - Infragistics.Win.UltraWinToolbars.StateButtonTool lbt=(Infragistics.Win.UltraWinToolbars.StateButtonTool)sub; - if(lbt.Key.StartsWith("LT:")) - lbt.SharedProps.Caption=LocaleText.GetLocalizedText(lbt.Key.Replace("LT:","")); - - } - } - } - } - } - #endregion + //Localize individual tool items + foreach (Infragistics.Win.UltraWinToolbars.ToolBase tbase in tbm.Tools) + { + if (tbase.Key.StartsWith("LT:")) + { + tbase.SharedProps.Caption = LocaleText.GetLocalizedText(tbase.Key.Replace("LT:", "")); + tbase.SharedProps.ToolTipText = LocaleText.GetLocalizedText(tbase.Key.Replace("LT:", "")); + } + + if (tbase is Infragistics.Win.UltraWinToolbars.PopupMenuTool) + { + Infragistics.Win.UltraWinToolbars.PopupMenuTool pop = (Infragistics.Win.UltraWinToolbars.PopupMenuTool)tbase; + foreach (Infragistics.Win.UltraWinToolbars.ToolBase sub in pop.Tools) + { + if (sub is Infragistics.Win.UltraWinToolbars.LabelTool) + { + Infragistics.Win.UltraWinToolbars.LabelTool lbt = (Infragistics.Win.UltraWinToolbars.LabelTool)sub; + if (lbt.Key.StartsWith("LT:")) + lbt.SharedProps.Caption = LocaleText.GetLocalizedText(lbt.Key.Replace("LT:", "")); + + } + else if (sub is Infragistics.Win.UltraWinToolbars.StateButtonTool) + { + Infragistics.Win.UltraWinToolbars.StateButtonTool lbt = (Infragistics.Win.UltraWinToolbars.StateButtonTool)sub; + if (lbt.Key.StartsWith("LT:")) + lbt.SharedProps.Caption = LocaleText.GetLocalizedText(lbt.Key.Replace("LT:", "")); + + } + } + } + } + } + #endregion + + #region UltraTab + static public void Localize(Infragistics.Win.UltraWinTabControl.UltraTab t) + { + foreach (Control c2 in t.TabPage.Controls) + { + Localize(c2); + } + } + #endregion - #region UltraTab - static public void Localize(Infragistics.Win.UltraWinTabControl.UltraTab t) - { - foreach(Control c2 in t.TabPage.Controls) - { - Localize(c2); - } - } - #endregion - #region UltraDockManager static public void Localize(Infragistics.Win.UltraWinDock.UltraDockManager udm) { @@ -712,8 +712,8 @@ At first I was happy to find your code that solved my problem, but I did not lik #region UltraExplorerBar static public void Localize(Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Bar) { - Bar.ViewStyle= defaultExplorerBarViewStyle; - Bar.UseOsThemes=defaultUseOsThemes; + Bar.ViewStyle = defaultExplorerBarViewStyle; + Bar.UseOsThemes = defaultUseOsThemes; foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup BarGroup in Bar.Groups) { if (BarGroup.Key.StartsWith("LT:")) @@ -736,20 +736,20 @@ At first I was happy to find your code that solved my problem, but I did not lik } } #endregion - + #region TreeNodes (recursive) static public void Localize(Infragistics.Win.UltraWinTree.UltraTreeNode t) - { - foreach(Infragistics.Win.UltraWinTree.UltraTreeNode n in t.Nodes) - { - if(n.Text.StartsWith("LT:")) - n.Text=LocaleText.GetLocalizedText(n.Text.Replace("LT:","")); - Localize(n); - } - } - #endregion + { + foreach (Infragistics.Win.UltraWinTree.UltraTreeNode n in t.Nodes) + { + if (n.Text.StartsWith("LT:")) + n.Text = LocaleText.GetLocalizedText(n.Text.Replace("LT:", "")); + Localize(n); + } + } + #endregion - #region Form or any control that can host controls + #region Form or any control that can host controls #region STYLING OVERRIDES @@ -764,8 +764,8 @@ At first I was happy to find your code that solved my problem, but I did not lik //case 2108 testing new way... //Conclusion: Joyce and I both examined it and decided this is way better on modern OS (windows 10) and looks //fine on older ones so keeping this to default. - static Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarViewStyle defaultExplorerBarViewStyle = - Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarViewStyle.Default; + static Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarViewStyle defaultExplorerBarViewStyle = + Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarViewStyle.Default; static UIElementButtonStyle defaultButtonStyle = UIElementButtonStyle.Default; static DefaultableBoolean defaultUseOsThemes = DefaultableBoolean.True; @@ -774,30 +774,30 @@ At first I was happy to find your code that solved my problem, but I did not lik //case 2108 added static Infragistics.Win.UltraWinScrollBar.ScrollBarViewStyle defaultScrollBarViewStyle = Infragistics.Win.UltraWinScrollBar.ScrollBarViewStyle.Default; - + //case 3112 //this is set with the command line argument fixfonts public static bool fixFonts = true; #endregion styling overrides - + /// - /// Modify ui elements to display localized values + /// Modify ui elements to display localized values /// Style them as well - /// - static public void Localize(Control c) - { + /// + static public void Localize(Control c) + { //case 2108 stop fixing fonts, built in look better //case 3112 new fonts actually don't look better so default is to fix them if (c is Form && fixFonts) FormFontFixer.Fix((Form)c); - // System.Diagnostics.Debug.WriteLine("Localize: " + c.Name + " - " + c.GetType().ToString()); - //Style case 562 + // System.Diagnostics.Debug.WriteLine("Localize: " + c.Name + " - " + c.GetType().ToString()); + //Style case 562 if (c is GZTW.WinForm.Controls.GZUltraComboEditor) { ((GZTW.WinForm.Controls.GZUltraComboEditor)c).ButtonStyle = defaultButtonStyle; @@ -822,13 +822,13 @@ At first I was happy to find your code that solved my problem, but I did not lik //case 2108, before it was like this... //((Infragistics.Win.UltraWinEditors.UltraCheckEditor)c).GlyphInfo = Infragistics.Win.UIElementDrawParams.Office2007CheckBoxGlyphInfo; //this resulted in weird 3d checkboxes with internal styling etc, without it is much cleaner - + ((Infragistics.Win.UltraWinEditors.UltraCheckEditor)c).UseOsThemes = defaultUseOsThemes; } if (c is Infragistics.Win.UltraWinEditors.UltraTextEditor) { - + ((Infragistics.Win.UltraWinEditors.UltraTextEditor)c).DisplayStyle = defaultEmbeddableElementDisplayStyle; ((Infragistics.Win.UltraWinEditors.UltraTextEditor)c).UseOsThemes = defaultUseOsThemes; } @@ -841,51 +841,51 @@ At first I was happy to find your code that solved my problem, but I did not lik - //Localize the top level object itself if applicable - if(c.Text.StartsWith("LT:")) - c.Text=LocaleText.GetLocalizedText(c.Text.Replace("LT:","")); + //Localize the top level object itself if applicable + if (c.Text.StartsWith("LT:")) + c.Text = LocaleText.GetLocalizedText(c.Text.Replace("LT:", "")); - if(c is Infragistics.Win.UltraWinEditors.UltraOptionSet) - { - Infragistics.Win.UltraWinEditors.UltraOptionSet uos=(Infragistics.Win.UltraWinEditors.UltraOptionSet)c; + if (c is Infragistics.Win.UltraWinEditors.UltraOptionSet) + { + Infragistics.Win.UltraWinEditors.UltraOptionSet uos = (Infragistics.Win.UltraWinEditors.UltraOptionSet)c; //case 2108 leaving as is, ultraoptionset only used in two plugins I can't test now //pti and something else I forget which, not super relevant to leaving as is uos.GlyphInfo = Infragistics.Win.UIElementDrawParams.Office2007RadioButtonGlyphInfo; - + uos.UseOsThemes = defaultUseOsThemes; - foreach(Infragistics.Win.ValueListItem vi in uos.Items) - { - if(vi.DisplayText.StartsWith("LT:")) - vi.DisplayText=LocaleText.GetLocalizedText(vi.DisplayText.Replace("LT:","")); - - } - //An ultraoptionset doesn't contain any child controls so bump up a level now - return; + foreach (Infragistics.Win.ValueListItem vi in uos.Items) + { + if (vi.DisplayText.StartsWith("LT:")) + vi.DisplayText = LocaleText.GetLocalizedText(vi.DisplayText.Replace("LT:", "")); - } + } + //An ultraoptionset doesn't contain any child controls so bump up a level now + return; - if (c is Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar) - { - Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Bar = (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar)c; - Localize(Bar); } - if(c is Infragistics.Win.UltraWinTree.UltraTree) - { - #region Tree control (used for nav purposes not containing actual data) - Infragistics.Win.UltraWinTree.UltraTree t=(Infragistics.Win.UltraWinTree.UltraTree)c; - - foreach(Infragistics.Win.UltraWinTree.UltraTreeNode n in t.Nodes) - { - if(n.Text.StartsWith("LT:")) - n.Text=LocaleText.GetLocalizedText(n.Text.Replace("LT:","")); - Localize(n); - } - return; - #endregion - } + if (c is Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar) + { + Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Bar = (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar)c; + Localize(Bar); + } + + if (c is Infragistics.Win.UltraWinTree.UltraTree) + { + #region Tree control (used for nav purposes not containing actual data) + Infragistics.Win.UltraWinTree.UltraTree t = (Infragistics.Win.UltraWinTree.UltraTree)c; + + foreach (Infragistics.Win.UltraWinTree.UltraTreeNode n in t.Nodes) + { + if (n.Text.StartsWith("LT:")) + n.Text = LocaleText.GetLocalizedText(n.Text.Replace("LT:", "")); + Localize(n); + } + return; + #endregion + } if (c is Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea) { @@ -899,7 +899,7 @@ At first I was happy to find your code that solved my problem, but I did not lik if (c is Infragistics.Win.UltraWinTabControl.UltraTabControl) { - + foreach (Infragistics.Win.UltraWinTabControl.UltraTab ut in ((Infragistics.Win.UltraWinTabControl.UltraTabControl)c).Tabs) { if (ut.Text.StartsWith("LT:")) @@ -907,36 +907,36 @@ At first I was happy to find your code that solved my problem, but I did not lik Localize(ut); } - + } if (c is ToolStrip) { - foreach(ToolStripItem i in ((ToolStrip)c).Items) + foreach (ToolStripItem i in ((ToolStrip)c).Items) { - if (i.Text!=null && i.Text.StartsWith("LT:")) + if (i.Text != null && i.Text.StartsWith("LT:")) i.Text = LocaleText.GetLocalizedText(i.Text.Replace("LT:", "")); - if (i.ToolTipText!=null && i.ToolTipText.StartsWith("LT:")) + if (i.ToolTipText != null && i.ToolTipText.StartsWith("LT:")) i.ToolTipText = LocaleText.GetLocalizedText(i.ToolTipText.Replace("LT:", "")); - if (i is ToolStripDropDownButton) - { - ToolStripDropDownButton b = (ToolStripDropDownButton)i; - foreach (ToolStripItem di in b.DropDownItems) - { - if (di.Text != null && di.Text.StartsWith("LT:")) - di.Text = LocaleText.GetLocalizedText(di.Text.Replace("LT:", "")); + if (i is ToolStripDropDownButton) + { + ToolStripDropDownButton b = (ToolStripDropDownButton)i; + foreach (ToolStripItem di in b.DropDownItems) + { + if (di.Text != null && di.Text.StartsWith("LT:")) + di.Text = LocaleText.GetLocalizedText(di.Text.Replace("LT:", "")); - if (di.ToolTipText != null && di.ToolTipText.StartsWith("LT:")) - di.ToolTipText = LocaleText.GetLocalizedText(di.ToolTipText.Replace("LT:", "")); - } - } + if (di.ToolTipText != null && di.ToolTipText.StartsWith("LT:")) + di.ToolTipText = LocaleText.GetLocalizedText(di.ToolTipText.Replace("LT:", "")); + } + } } } - //Loop through the controls - - foreach(Control c2 in c.Controls) - { + //Loop through the controls + + foreach (Control c2 in c.Controls) + { Localize(c2); #region old crap //if( c2.Text.StartsWith("LT:")) @@ -946,11 +946,11 @@ At first I was happy to find your code that solved my problem, but I did not lik //else if(c2 is Infragistics.Win.UltraWinGrid.UltraGrid) //{ // LocalizeGrid((Infragistics.Win.UltraWinGrid.UltraGrid)c2); - - + + //} - - + + //else if(c2 is Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar) //{ // #region UltraExplorerBar @@ -984,7 +984,7 @@ At first I was happy to find your code that solved my problem, but I did not lik // tbase.SharedProps.Caption=LocaleText.GetLocalizedText(tbase.Key.Replace("LT:","")); // tbase.SharedProps.ToolTipText=LocaleText.GetLocalizedText(tbase.Key.Replace("LT:","")); // } - + // if(tbase is Infragistics.Win.UltraWinToolbars.PopupMenuTool) // { // Infragistics.Win.UltraWinToolbars.PopupMenuTool pop =(Infragistics.Win.UltraWinToolbars.PopupMenuTool)tbase; @@ -995,14 +995,14 @@ At first I was happy to find your code that solved my problem, but I did not lik // Infragistics.Win.UltraWinToolbars.LabelTool lbt=(Infragistics.Win.UltraWinToolbars.LabelTool)sub; // if(lbt.Key.StartsWith("LT:")) // lbt.SharedProps.Caption=LocaleText.GetLocalizedText(lbt.Key.Replace("LT:","")); - + // } // else if(sub is Infragistics.Win.UltraWinToolbars.StateButtonTool) // { // Infragistics.Win.UltraWinToolbars.StateButtonTool lbt=(Infragistics.Win.UltraWinToolbars.StateButtonTool)sub; // if(lbt.Key.StartsWith("LT:")) // lbt.SharedProps.Caption=LocaleText.GetLocalizedText(lbt.Key.Replace("LT:","")); - + // } // } // } @@ -1013,141 +1013,141 @@ At first I was happy to find your code that solved my problem, but I did not lik #endregion } - } - #endregion + } + #endregion - /// - /// Use reflection to find the locale key for a biz object - /// (if the biz object doesn't have a LocaleKey property it returns - /// the name of the biz object instead) - /// - /// - public static string GetBizObjectLocaleKey(object BizObject) - { - //case 1039 //log.Debug("GetBizObjectLocaleKey("+BizObject.ToString()+")"); - try - { - - PropertyInfo pi=BizObject.GetType().GetProperty("LocaleKey"); - if(pi==null) return BizObject.ToString(); + /// + /// Use reflection to find the locale key for a biz object + /// (if the biz object doesn't have a LocaleKey property it returns + /// the name of the biz object instead) + /// + /// + public static string GetBizObjectLocaleKey(object BizObject) + { + //case 1039 //log.Debug("GetBizObjectLocaleKey("+BizObject.ToString()+")"); + try + { - object propvalue = pi.GetValue(BizObject,null).ToString(); - if(propvalue!=null) - return propvalue.ToString(); - else - return BizObject.ToString(); + PropertyInfo pi = BizObject.GetType().GetProperty("LocaleKey"); + if (pi == null) return BizObject.ToString(); - } - catch(NullReferenceException e) - { - log.Error("GetBizObjectLocaleKey",e); - MessageBox.Show("GetBizObjectLocaleKey:" + e.Message); - } + object propvalue = pi.GetValue(BizObject, null).ToString(); + if (propvalue != null) + return propvalue.ToString(); + else + return BizObject.ToString(); + + } + catch (NullReferenceException e) + { + log.Error("GetBizObjectLocaleKey", e); + MessageBox.Show("GetBizObjectLocaleKey:" + e.Message); + } - return BizObject.ToString(); + return BizObject.ToString(); - } + } - #endregion + #endregion - #region Localize Infragistics message strings - /// - /// Localizes all infragistics built in messages - /// Call this once before UI displays to user and - /// it will remain set until the program closes and - /// apply to all Infragistics elements wherever they are - /// in the program - /// - static public void LocalizeInfragistics() - { - //case 1039 //log.Debug("LocalizeInfragistics"); - //Localize internal built in text - Infragistics.Shared.ResourceCustomizer rc; + #region Localize Infragistics message strings + /// + /// Localizes all infragistics built in messages + /// Call this once before UI displays to user and + /// it will remain set until the program closes and + /// apply to all Infragistics elements wherever they are + /// in the program + /// + static public void LocalizeInfragistics() + { + //case 1039 //log.Debug("LocalizeInfragistics"); + //Localize internal built in text + Infragistics.Shared.ResourceCustomizer rc; - //Localize all Grid related message strings - rc=Infragistics.Win.UltraWinGrid.Resources.Customizer; - rc.SetCustomizedString("FilterDialogAddConditionButtonText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogAddConditionButtonText")); - - rc.SetCustomizedString("FilterDialogAndRadioText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogAndRadioText")); - rc.SetCustomizedString("FilterDialogCancelButtonText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogCancelButtonText")); - rc.SetCustomizedString("FilterDialogDeleteButtonText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogDeleteButtonText")); - rc.SetCustomizedString("FilterDialogOkButtonNoFiltersText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogOkButtonNoFiltersText")); - rc.SetCustomizedString("FilterDialogOkButtonText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogOkButtonText")); - rc.SetCustomizedString("FilterDialogOrRadioText",LocaleText.GetLocalizedText("UI.Grid.FilterDialogOrRadioText")); - rc.SetCustomizedString("RowFilterDialogBlanksItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogBlanksItem")); - rc.SetCustomizedString("RowFilterDialogDBNullItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogDBNullItem")); - rc.SetCustomizedString("RowFilterDialogEmptyTextItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogEmptyTextItem")); - rc.SetCustomizedString("RowFilterDialogOperandHeaderCaption",LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogOperandHeaderCaption")); - rc.SetCustomizedString("RowFilterDialogOperatorHeaderCaption",LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogOperatorHeaderCaption")); - rc.SetCustomizedString("RowFilterDialogTitlePrefix",LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogTitlePrefix")); - rc.SetCustomizedString("RowFilterDropDownAllItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownAllItem")); - rc.SetCustomizedString("RowFilterDropDownBlanksItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownBlanksItem")); - rc.SetCustomizedString("RowFilterDropDownCustomItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownCustomItem")); - rc.SetCustomizedString("RowFilterDropDownEquals",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownEquals")); - rc.SetCustomizedString("RowFilterDropDownGreaterThan",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownGreaterThan")); - rc.SetCustomizedString("RowFilterDropDownGreaterThanOrEqualTo",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownGreaterThanOrEqualTo")); - rc.SetCustomizedString("RowFilterDropDownLessThan",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownLessThan")); - rc.SetCustomizedString("RowFilterDropDownLessThanOrEqualTo",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownLessThanOrEqualTo")); - rc.SetCustomizedString("RowFilterDropDownLike",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownLike")); - rc.SetCustomizedString("RowFilterDropDownMatch",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownMatch")); - rc.SetCustomizedString("RowFilterDropDownNonBlanksItem",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownNonBlanksItem")); - rc.SetCustomizedString("RowFilterDropDownNotEquals",LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownNotEquals")); - rc.SetCustomizedString("RowFilterRegexError",LocaleText.GetLocalizedText("UI.Grid.RowFilterRegexError")); - rc.SetCustomizedString("RowFilterRegexErrorCaption",LocaleText.GetLocalizedText("UI.Grid.RowFilterRegexErrorCaption")); + //Localize all Grid related message strings + rc = Infragistics.Win.UltraWinGrid.Resources.Customizer; + rc.SetCustomizedString("FilterDialogAddConditionButtonText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogAddConditionButtonText")); + + rc.SetCustomizedString("FilterDialogAndRadioText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogAndRadioText")); + rc.SetCustomizedString("FilterDialogCancelButtonText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogCancelButtonText")); + rc.SetCustomizedString("FilterDialogDeleteButtonText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogDeleteButtonText")); + rc.SetCustomizedString("FilterDialogOkButtonNoFiltersText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogOkButtonNoFiltersText")); + rc.SetCustomizedString("FilterDialogOkButtonText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogOkButtonText")); + rc.SetCustomizedString("FilterDialogOrRadioText", LocaleText.GetLocalizedText("UI.Grid.FilterDialogOrRadioText")); + rc.SetCustomizedString("RowFilterDialogBlanksItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogBlanksItem")); + rc.SetCustomizedString("RowFilterDialogDBNullItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogDBNullItem")); + rc.SetCustomizedString("RowFilterDialogEmptyTextItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogEmptyTextItem")); + rc.SetCustomizedString("RowFilterDialogOperandHeaderCaption", LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogOperandHeaderCaption")); + rc.SetCustomizedString("RowFilterDialogOperatorHeaderCaption", LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogOperatorHeaderCaption")); + rc.SetCustomizedString("RowFilterDialogTitlePrefix", LocaleText.GetLocalizedText("UI.Grid.RowFilterDialogTitlePrefix")); + rc.SetCustomizedString("RowFilterDropDownAllItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownAllItem")); + rc.SetCustomizedString("RowFilterDropDownBlanksItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownBlanksItem")); + rc.SetCustomizedString("RowFilterDropDownCustomItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownCustomItem")); + rc.SetCustomizedString("RowFilterDropDownEquals", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownEquals")); + rc.SetCustomizedString("RowFilterDropDownGreaterThan", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownGreaterThan")); + rc.SetCustomizedString("RowFilterDropDownGreaterThanOrEqualTo", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownGreaterThanOrEqualTo")); + rc.SetCustomizedString("RowFilterDropDownLessThan", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownLessThan")); + rc.SetCustomizedString("RowFilterDropDownLessThanOrEqualTo", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownLessThanOrEqualTo")); + rc.SetCustomizedString("RowFilterDropDownLike", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownLike")); + rc.SetCustomizedString("RowFilterDropDownMatch", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownMatch")); + rc.SetCustomizedString("RowFilterDropDownNonBlanksItem", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownNonBlanksItem")); + rc.SetCustomizedString("RowFilterDropDownNotEquals", LocaleText.GetLocalizedText("UI.Grid.RowFilterDropDownNotEquals")); + rc.SetCustomizedString("RowFilterRegexError", LocaleText.GetLocalizedText("UI.Grid.RowFilterRegexError")); + rc.SetCustomizedString("RowFilterRegexErrorCaption", LocaleText.GetLocalizedText("UI.Grid.RowFilterRegexErrorCaption")); //Added:3-oct-2006 //grid wasn't using localized strings for deletion warning rc.SetCustomizedString("DeleteSingleRowPrompt", LocaleText.GetLocalizedText("UI.Label.DeletePrompt")); rc.SetCustomizedString("DeleteMultipleRowsPrompt", LocaleText.GetLocalizedText("UI.Label.DeletePrompt")); - - //Toolbar - rc=Infragistics.Win.UltraWinToolbars.Resources.Customizer; - rc.SetCustomizedString("AddRemoveButtons",LocaleText.GetLocalizedText("UI.ToolBar.AddRemoveButtons")); - rc.SetCustomizedString("Customize",LocaleText.GetLocalizedText("UI.ToolBar.Customize")); - rc.SetCustomizedString("ResetToolbar",LocaleText.GetLocalizedText("UI.ToolBar.ResetToolbar")); - rc.SetCustomizedString("CustomizeDialog_New",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_New")); - rc.SetCustomizedString("CustomizeDialog_ResetAmp",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ResetAmp")); - rc.SetCustomizedString("CustomizeDialog_Rename",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_Rename")); - rc.SetCustomizedString("CustomizeDialog_KeyboardBeginAmp",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_KeyboardBeginAmp")); - rc.SetCustomizedString("CustomizeDialog_CloseNoAmp",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_CloseNoAmp")); - rc.SetCustomizedString("CustomizeDlgKbdCat",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDlgKbdCat")); - rc.SetCustomizedString("CustomizeDlgKbdCmd",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDlgKbdCmd")); - rc.SetCustomizedString("CustomizeDialog_SelectedCommand",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_SelectedCommand")); - rc.SetCustomizedString("CustomizeDialog_PersonalizedMenusAndToolbars",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_PersonalizedMenusAndToolbars")); - rc.SetCustomizedString("CustomizeDialog_AlwaysShowFullMenus",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_AlwaysShowFullMenus")); - rc.SetCustomizedString("CustomizeDialog_ShowFullMenusAfterAShortDelay",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ShowFullMenusAfterAShortDelay")); - rc.SetCustomizedString("CustomizeDialog_ResetMyUsageData",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ResetMyUsageData")); - rc.SetCustomizedString("CustomizeDialog_Other",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_Other")); - rc.SetCustomizedString("CustomizeDialog_LargeIconsOnMenus",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_LargeIconsOnMenus")); - rc.SetCustomizedString("CustomizeDialog_LargeIconsOnToolbars",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_LargeIconsOnToolbars")); - rc.SetCustomizedString("CustomizeDialog_ShowScreenTipsOnToolbars",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ShowScreenTipsOnToolbars")); - rc.SetCustomizedString("CustomizeDialog_ShowShortcutKeysInScreenTips",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ShowShortcutKeysInScreenTips")); - rc.SetCustomizedString("CustomizeDialog_FloatingToolbarFadeDelay",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_FloatingToolbarFadeDelay")); - rc.SetCustomizedString("CustomizeDialog_Milliseconds",LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_Milliseconds")); - //TODO: UltraToolBars and all other Infragistics elements that might display text to the user - //See ms-help://Infragistics.Win.UltraWinToolbars.v3/Infragistics.Win.UltraWinToolbars.v3/Message_Strings_Customization_UltraWinToolbars.html - //for starters - } + //Toolbar + rc = Infragistics.Win.UltraWinToolbars.Resources.Customizer; + rc.SetCustomizedString("AddRemoveButtons", LocaleText.GetLocalizedText("UI.ToolBar.AddRemoveButtons")); + rc.SetCustomizedString("Customize", LocaleText.GetLocalizedText("UI.ToolBar.Customize")); + rc.SetCustomizedString("ResetToolbar", LocaleText.GetLocalizedText("UI.ToolBar.ResetToolbar")); + rc.SetCustomizedString("CustomizeDialog_New", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_New")); + rc.SetCustomizedString("CustomizeDialog_ResetAmp", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ResetAmp")); + rc.SetCustomizedString("CustomizeDialog_Rename", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_Rename")); + rc.SetCustomizedString("CustomizeDialog_KeyboardBeginAmp", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_KeyboardBeginAmp")); + rc.SetCustomizedString("CustomizeDialog_CloseNoAmp", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_CloseNoAmp")); + rc.SetCustomizedString("CustomizeDlgKbdCat", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDlgKbdCat")); + rc.SetCustomizedString("CustomizeDlgKbdCmd", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDlgKbdCmd")); + rc.SetCustomizedString("CustomizeDialog_SelectedCommand", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_SelectedCommand")); + rc.SetCustomizedString("CustomizeDialog_PersonalizedMenusAndToolbars", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_PersonalizedMenusAndToolbars")); + rc.SetCustomizedString("CustomizeDialog_AlwaysShowFullMenus", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_AlwaysShowFullMenus")); + rc.SetCustomizedString("CustomizeDialog_ShowFullMenusAfterAShortDelay", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ShowFullMenusAfterAShortDelay")); + rc.SetCustomizedString("CustomizeDialog_ResetMyUsageData", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ResetMyUsageData")); + rc.SetCustomizedString("CustomizeDialog_Other", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_Other")); + rc.SetCustomizedString("CustomizeDialog_LargeIconsOnMenus", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_LargeIconsOnMenus")); + rc.SetCustomizedString("CustomizeDialog_LargeIconsOnToolbars", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_LargeIconsOnToolbars")); + rc.SetCustomizedString("CustomizeDialog_ShowScreenTipsOnToolbars", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ShowScreenTipsOnToolbars")); + rc.SetCustomizedString("CustomizeDialog_ShowShortcutKeysInScreenTips", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_ShowShortcutKeysInScreenTips")); + rc.SetCustomizedString("CustomizeDialog_FloatingToolbarFadeDelay", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_FloatingToolbarFadeDelay")); + rc.SetCustomizedString("CustomizeDialog_Milliseconds", LocaleText.GetLocalizedText("UI.ToolBar.CustomizeDialog_Milliseconds")); - #endregion + //TODO: UltraToolBars and all other Infragistics elements that might display text to the user + //See ms-help://Infragistics.Win.UltraWinToolbars.v3/Infragistics.Win.UltraWinToolbars.v3/Message_Strings_Customization_UltraWinToolbars.html + //for starters + } + + #endregion + + #region Localized DateTime mask for input + /// + /// Returns input mask to use in date and time editor for this locale + /// + /// + static public string LocaleDateTimeMask() + { - #region Localized DateTime mask for input - /// - /// Returns input mask to use in date and time editor for this locale - /// - /// - static public string LocaleDateTimeMask() - { - CultureInfo ciCurrent = System.Globalization.CultureInfo.CurrentCulture; - //Use date and time editor to calculate input mask - DateTimeEditor editor = new DateTimeEditor(); + //Use date and time editor to calculate input mask + DateTimeEditor editor = new DateTimeEditor(); - string dateMask = editor.CalcDefaultDateMask(ciCurrent ); + string dateMask = editor.CalcDefaultDateMask(ciCurrent); string timeMask = editor.CalcDefaultTimeMask(ciCurrent); //Case 137 @@ -1164,65 +1164,65 @@ At first I was happy to find your code that solved my problem, but I did not lik timeMask = "{longtime}"; } - - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("Detected LocaleDateTimeMask is: ["+dateMask + " " + timeMask+"]"); - return dateMask + " " + timeMask; - - //------------------------------------------- - } - #endregion + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("Detected LocaleDateTimeMask is: ["+dateMask + " " + timeMask+"]"); + + return dateMask + " " + timeMask; + + //------------------------------------------- + } + #endregion + + #region Load / save grid layout + /// + /// Save layout of grid + /// + static public void SaveGridLayout(string GridKey, string GridSubKey, string Description, Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("SaveGridLayout(" + GridKey + ", " + GridSubKey + ", " + Description + ", " + Grid.Name + "." + Grid.Parent.Name+ ")"); - #region Load / save grid layout - /// - /// Save layout of grid - /// - static public void SaveGridLayout(string GridKey, string GridSubKey, string Description, Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("SaveGridLayout(" + GridKey + ", " + GridSubKey + ", " + Description + ", " + Grid.Name + "." + Grid.Parent.Name+ ")"); - bool bFiltered = false; Util.gGridLastViews[GridKey].ViewXML = Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[0], false, ref bFiltered); - - } + + } - /// - /// Fetch and set the grid layout + /// + /// Fetch and set the grid layout /// public static void FetchGridLayout(string GridKey, string GridSubKey, Infragistics.Win.UltraWinGrid.UltraGrid Grid) { //if (log.IsDebugEnabled) - //case 1039 //log.Debug("FetchGridLayout(" + GridKey + ", " + GridSubKey + ", " + Grid.Name + "." + Grid.Parent.Name + ")"); - + //case 1039 //log.Debug("FetchGridLayout(" + GridKey + ", " + GridSubKey + ", " + Grid.Name + "." + Grid.Parent.Name + ")"); + if (gGridLastViews.Contains(GridKey)) { #region Use new UI agnostic method to load settings int nPosition = 0; Infragistics.Win.UltraWinGrid.UltraGridBand band = Grid.DisplayLayout.Bands[0]; - + foreach (UltraGridColumn cm in band.Columns) cm.Hidden = true; //show the columns that are in the order collection //And set their properties such as width, pinned, sort order etc foreach (DataRow TabRow in Util.gGridLastViews[GridKey].ViewOrder.Rows) { - string columnName=TabRow["UI"].ToString(); - UltraGridColumn c; - if (band.Columns.Exists(columnName)) - c = band.Columns[columnName]; - else - { - //it's a non-bound column that was added dynamically in the form - //so add it here to mimic original column layout saving and loading behaviour - //This works on the assumption that the forms will resetup the datatype and - //caption and any other customizations for a column that is added this way - //which is how they should be coded - c = band.Columns.Add(columnName); - } + string columnName = TabRow["UI"].ToString(); + UltraGridColumn c; + if (band.Columns.Exists(columnName)) + c = band.Columns[columnName]; + else + { + //it's a non-bound column that was added dynamically in the form + //so add it here to mimic original column layout saving and loading behaviour + //This works on the assumption that the forms will resetup the datatype and + //caption and any other customizations for a column that is added this way + //which is how they should be coded + c = band.Columns.Add(columnName); + } c.Hidden = false; //Set sort indicator for first visible column only if (nPosition == 0) @@ -1244,7 +1244,7 @@ At first I was happy to find your code that solved my problem, but I did not lik } //Turn back on the events for the grid - //Grid.EventManager.SetEnabled(Infragistics.Win.UltraWinGrid.EventGroups.AllEvents, true); + //Grid.EventManager.SetEnabled(Infragistics.Win.UltraWinGrid.EventGroups.AllEvents, true); #endregion new method } else @@ -1362,7 +1362,7 @@ At first I was happy to find your code that solved my problem, but I did not lik static public void SaveGridLayoutBAND1(string GridKey, string GridSubKey, string Description, Infragistics.Win.UltraWinGrid.UltraGrid Grid) { //if (log.IsDebugEnabled) - //case 1039 //log.Debug("SaveGridLayoutBAND1(" + GridKey + ", " + GridSubKey + ", " + Description + ", " + Grid.Name + "." + Grid.Parent.Name + ")"); + //case 1039 //log.Debug("SaveGridLayoutBAND1(" + GridKey + ", " + GridSubKey + ", " + Description + ", " + Grid.Name + "." + Grid.Parent.Name + ")"); bool bFiltered = false; Util.gGridLastViews[GridKey].ViewXML = Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[1], false, ref bFiltered); @@ -1376,7 +1376,7 @@ At first I was happy to find your code that solved my problem, but I did not lik public static void FetchGridLayoutBAND1(string GridKey, string GridSubKey, Infragistics.Win.UltraWinGrid.UltraGrid Grid) { //if (log.IsDebugEnabled) - //case 1039 //log.Debug("FetchGridLayoutBAND1(" + GridKey + ", " + GridSubKey + ", " + Grid.Name + "." + Grid.Parent.Name + ")"); + //case 1039 //log.Debug("FetchGridLayoutBAND1(" + GridKey + ", " + GridSubKey + ", " + Grid.Name + "." + Grid.Parent.Name + ")"); if (gGridLastViews.Contains(GridKey)) { @@ -1418,62 +1418,62 @@ At first I was happy to find your code that solved my problem, but I did not lik c.Header.VisiblePosition = nPosition++; c.Width = System.Convert.ToInt32(TabRow["WIDTH"]); - // c.Header.Fixed = (TabRow["PIN"].ToString() == "1") ? true : false; + // c.Header.Fixed = (TabRow["PIN"].ToString() == "1") ? true : false; } - + #endregion new method } - - + + } -#endregion band1 - #endregion + #endregion band1 + #endregion - #region Grid various event helper methods + #region Grid various event helper methods - public static void SetGridFilteredStyle(Infragistics.Win.UltraWinGrid.UltraGrid Grid, bool bFiltered) - { - if(bFiltered) - { - Grid.DisplayLayout.CaptionAppearance.FontData.Bold=Infragistics.Win.DefaultableBoolean.True; - Grid.DisplayLayout.CaptionAppearance.ForeColor=System.Drawing.SystemColors.HighlightText; - Grid.DisplayLayout.CaptionAppearance.BackColor=System.Drawing.SystemColors.Highlight; - Grid.Text=Grid.Text + " " + Util.LocaleText.GetLocalizedText("UI.Label.Filtered") ; - } - else - { - Grid.DisplayLayout.CaptionAppearance.FontData.Bold=Infragistics.Win.DefaultableBoolean.False; - Grid.DisplayLayout.CaptionAppearance.ForeColor=System.Drawing.SystemColors.ControlText; - Grid.DisplayLayout.CaptionAppearance.BackColor=System.Drawing.SystemColors.Control; - } + public static void SetGridFilteredStyle(Infragistics.Win.UltraWinGrid.UltraGrid Grid, bool bFiltered) + { + if (bFiltered) + { + Grid.DisplayLayout.CaptionAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True; + Grid.DisplayLayout.CaptionAppearance.ForeColor = System.Drawing.SystemColors.HighlightText; + Grid.DisplayLayout.CaptionAppearance.BackColor = System.Drawing.SystemColors.Highlight; + Grid.Text = Grid.Text + " " + Util.LocaleText.GetLocalizedText("UI.Label.Filtered"); + } + else + { + Grid.DisplayLayout.CaptionAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.False; + Grid.DisplayLayout.CaptionAppearance.ForeColor = System.Drawing.SystemColors.ControlText; + Grid.DisplayLayout.CaptionAppearance.BackColor = System.Drawing.SystemColors.Control; + } //case 2108 ? GridStyler(Grid); - } - public static UltraGridColumn GetLeftMostColumnInBand(Infragistics.Win.UltraWinGrid.UltraGridBand GridBand) - { - //case 1039 //log.Debug("GetLeftMostColumnInBand"); - //iterate through visible columns in grid - //as soon as we find the leftmost visible one, return it - for(int x=0;x @@ -1493,74 +1493,74 @@ At first I was happy to find your code that solved my problem, but I did not lik SortIndicator si = c.SortIndicator; c.SortIndicator = SortIndicator.None; c.SortIndicator = si; - } + } } - /// - /// ensures only leftmost column - /// has sort indicator after columns have been - /// repositioned and ensures that if the leftmost - /// column is a custom one, it can't be sorted on - /// - /// - public static void HandleColPosChanged(Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //log.Debug("HandleColPosChanged"); - Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange,false); + /// + /// ensures only leftmost column + /// has sort indicator after columns have been + /// repositioned and ensures that if the leftmost + /// column is a custom one, it can't be sorted on + /// + /// + public static void HandleColPosChanged(Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //log.Debug("HandleColPosChanged"); + Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange, false); - //Set all bands to no sort - foreach(Infragistics.Win.UltraWinGrid.UltraGridColumn c in Grid.DisplayLayout.Bands[0].Columns) - c.SortIndicator=SortIndicator.Disabled; - - //Set leftmost to sort enabled - UltraGridColumn cLeft=GetLeftMostColumnInBand(Grid.DisplayLayout.Bands[0]); - cLeft.SortIndicator=SortIndicator.Ascending; - Grid.DisplayLayout.Bands[0].ScrollTipField=cLeft.Key; + //Set all bands to no sort + foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn c in Grid.DisplayLayout.Bands[0].Columns) + c.SortIndicator = SortIndicator.Disabled; - Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange,true); + //Set leftmost to sort enabled + UltraGridColumn cLeft = GetLeftMostColumnInBand(Grid.DisplayLayout.Bands[0]); + cLeft.SortIndicator = SortIndicator.Ascending; + Grid.DisplayLayout.Bands[0].ScrollTipField = cLeft.Key; - } -#endregion + Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange, true); - #region Get grid sort and filter xml + } + #endregion - /// - /// checks for the SqlColumnNameAttribute and returns it if present - /// else retuns empty string - /// - /// A value of "grid" indicates not sql sortable / filterable - /// and grid should handle it - /// - /// - /// - public static string GetSqlColumnNameAttribute(UltraGridColumn c) - { - //Autofilter any custom fields as if they were set to "grid" - //SqlColumnNameAttribute to avoid filtering or sorting on them + #region Get grid sort and filter xml + + /// + /// checks for the SqlColumnNameAttribute and returns it if present + /// else retuns empty string + /// + /// A value of "grid" indicates not sql sortable / filterable + /// and grid should handle it + /// + /// + /// + public static string GetSqlColumnNameAttribute(UltraGridColumn c) + { + //Autofilter any custom fields as if they were set to "grid" + //SqlColumnNameAttribute to avoid filtering or sorting on them if (c.Key.IndexOf("_Label_Custom") != -1) { //woops! Make sure it's not simply //a field for the Customer object, i.e. _Label_CustomerReferenceNumber - if(c.Key.IndexOf("Customer")==-1) + if (c.Key.IndexOf("Customer") == -1) return "grid"; } if (c.PropertyDescriptor == null) return ""; - System.Reflection.PropertyInfo propInfo = c.PropertyDescriptor.ComponentType.GetProperty(c.Key); + System.Reflection.PropertyInfo propInfo = c.PropertyDescriptor.ComponentType.GetProperty(c.Key); //Added: 20-June-2006 when saving a grid format that contains not properties (all unbound) //was bombing because propInfo is null if (propInfo == null) return ""; - SqlColumnNameAttribute attr = (SqlColumnNameAttribute)Attribute.GetCustomAttribute(propInfo, typeof(SqlColumnNameAttribute)); - if(attr==null) return ""; - return attr.SqlColumnName; + SqlColumnNameAttribute attr = (SqlColumnNameAttribute)Attribute.GetCustomAttribute(propInfo, typeof(SqlColumnNameAttribute)); + if (attr == null) return ""; + return attr.SqlColumnName; - - } + + } /// /// checks for the SqlColumnNameAttribute and returns @@ -1602,13 +1602,13 @@ At first I was happy to find your code that solved my problem, but I did not lik - /// - /// Takes a grid band, returns a fragment of XML containing the column order - /// And filter conditions for that band - /// - /// - /// - /// + /// + /// Takes a grid band, returns a fragment of XML containing the column order + /// And filter conditions for that band + /// + /// + /// + /// public static string GetGridSortAndFilterXML(Infragistics.Win.UltraWinGrid.UltraGridBand GridBand, bool bReverseSort, ref bool bFiltered) { try @@ -1728,86 +1728,86 @@ At first I was happy to find your code that solved my problem, but I did not lik } #endregion sorting - #region Filtering + #region Filtering - - Hashtable ht = new Hashtable(); - string sFilter=""; - bool bAtLeastOneFilter=false; - //Create xml fragment containing filter columns and their conditions - //for building WHERE clause in read only collection - - //Loop through each column filter - foreach(Infragistics.Win.UltraWinGrid.ColumnFilter cf in GridBand.ColumnFilters) - { - if(cf.FilterConditions.Count==0) - continue; - w.WriteStartElement("WHEREITEMGROUP"); - w.WriteAttributeString("GROUPLOGICALOPERATOR",cf.LogicalOperator.ToString()); + Hashtable ht = new Hashtable(); + string sFilter = ""; + bool bAtLeastOneFilter = false; + + //Create xml fragment containing filter columns and their conditions + //for building WHERE clause in read only collection + + //Loop through each column filter + foreach (Infragistics.Win.UltraWinGrid.ColumnFilter cf in GridBand.ColumnFilters) + { + if (cf.FilterConditions.Count == 0) + continue; + w.WriteStartElement("WHEREITEMGROUP"); + w.WriteAttributeString("GROUPLOGICALOPERATOR", cf.LogicalOperator.ToString()); //Write out the UI column name for processing //by the ui when the UI grid has to be //reconstructed from this filter and order xml fragment w.WriteAttributeString("UI", cf.Column.Key); - #region Filter conditions within column filter loop - foreach(Infragistics.Win.UltraWinGrid.FilterCondition f in cf.FilterConditions) - { - if(f.CompareValue!=null && f.CompareValue.GetType()==typeof(Infragistics.Win.UltraWinGrid.UltraGridColumn)) - { - // - string sError=string.Format( - Util.LocaleText.GetLocalizedText("Error.Grid.FilterByOtherColumnNotSupported"), - ((Infragistics.Win.UltraWinGrid.UltraGridColumn)f.CompareValue).Header.Caption); - //case 1039 //log.Debug(sError); - MessageBox.Show(sError); - cf.FilterConditions.Remove(f); - continue; - } + #region Filter conditions within column filter loop + foreach (Infragistics.Win.UltraWinGrid.FilterCondition f in cf.FilterConditions) + { + if (f.CompareValue != null && f.CompareValue.GetType() == typeof(Infragistics.Win.UltraWinGrid.UltraGridColumn)) + { + // + string sError = string.Format( + Util.LocaleText.GetLocalizedText("Error.Grid.FilterByOtherColumnNotSupported"), + ((Infragistics.Win.UltraWinGrid.UltraGridColumn)f.CompareValue).Header.Caption); + //case 1039 //log.Debug(sError); + MessageBox.Show(sError); + cf.FilterConditions.Remove(f); + continue; + } - //If it's a regular expression then pop out of the loop - //as we don't handle them via sql - //Comparison operators for regex are called "Match" types by Infragistics - //there are two: match and don't match - if(f.ComparisionOperator==FilterComparisionOperator.Match || f.ComparisionOperator==FilterComparisionOperator.DoesNotMatch) - continue; - - sFilter=f.Column.Key.ToString()+f.ComparisionOperator.ToString(); - if(f.CompareValue!=null) - sFilter+=f.CompareValue; + //If it's a regular expression then pop out of the loop + //as we don't handle them via sql + //Comparison operators for regex are called "Match" types by Infragistics + //there are two: match and don't match + if (f.ComparisionOperator == FilterComparisionOperator.Match || f.ComparisionOperator == FilterComparisionOperator.DoesNotMatch) + continue; - //If it's already been processed or is not filterable - //then continue on to next filter condition - if(ht.ContainsKey(sFilter) || PrivateColumns.Contains(f.Column.Key.ToString())) - continue; - - //check to see if it's an internal grid filtering - //type only (i.e. sqlcolumnnameattribute = "grid") - if(GetSqlColumnNameAttribute(cf.Column)=="grid") continue; + sFilter = f.Column.Key.ToString() + f.ComparisionOperator.ToString(); + if (f.CompareValue != null) + sFilter += f.CompareValue; + + //If it's already been processed or is not filterable + //then continue on to next filter condition + if (ht.ContainsKey(sFilter) || PrivateColumns.Contains(f.Column.Key.ToString())) + continue; + + //check to see if it's an internal grid filtering + //type only (i.e. sqlcolumnnameattribute = "grid") + if (GetSqlColumnNameAttribute(cf.Column) == "grid") continue; - ht[sFilter]=1; + ht[sFilter] = 1; - - - w.WriteStartElement("WHEREITEM"); - bAtLeastOneFilter=true; - - w.WriteAttributeString("COMPAREOPERATOR",f.ComparisionOperator.ToString()); - //Is it a GridNameValueCellItem object in this column? - if(f.Column.DataType.ToString()=="GZTW.AyaNova.BLL.GridNameValueCellItem") - { - #region Filter a GridNameValueCellItem column + + w.WriteStartElement("WHEREITEM"); + bAtLeastOneFilter = true; + + w.WriteAttributeString("COMPAREOPERATOR", f.ComparisionOperator.ToString()); + + //Is it a GridNameValueCellItem object in this column? + if (f.Column.DataType.ToString() == "GZTW.AyaNova.BLL.GridNameValueCellItem") + { + #region Filter a GridNameValueCellItem column //Changed: 13-June-2006 added null filtering bit below and reorganized //for clarity //HOW THIS WORKS: - //Filtering is by underlying Guid value in namevaluegridcellitem objects - //or simply by the database field if not + //Filtering is by underlying Guid value in namevaluegridcellitem objects + //or simply by the database field if not - //there are three possible ways to filter a grid name value cell item field + //there are three possible ways to filter a grid name value cell item field //If the compare value is null then it should filter by a null guid //If the compare value is a gridnamevaluecellitem type then it should filter by @@ -1821,7 +1821,7 @@ At first I was happy to find your code that solved my problem, but I did not lik { #region Filter by null Guid - string sFieldName=GetSqlColumnNameAttribute(cf.Column); + string sFieldName = GetSqlColumnNameAttribute(cf.Column); //if there is a sql column name then change to //filter by an empty string if (sFieldName != "") @@ -1847,8 +1847,8 @@ At first I was happy to find your code that solved my problem, but I did not lik default: w.WriteAttributeString("TYPE", typeof(string).ToString()); break; - } - + } + w.WriteAttributeString("COMPAREVALUE", ""); } @@ -1869,8 +1869,8 @@ At first I was happy to find your code that solved my problem, but I did not lik #endregion filter by null guid } - else if(//If it's a guid match for or against an exact guid value, otherwise it's a match to the text or int value - f.CompareValue.GetType().ToString()=="GZTW.AyaNova.BLL.GridNameValueCellItem" && + else if (//If it's a guid match for or against an exact guid value, otherwise it's a match to the text or int value + f.CompareValue.GetType().ToString() == "GZTW.AyaNova.BLL.GridNameValueCellItem" && (f.ComparisionOperator == FilterComparisionOperator.Match || f.ComparisionOperator == FilterComparisionOperator.Equals || f.ComparisionOperator == FilterComparisionOperator.NotEquals) @@ -1879,19 +1879,19 @@ At first I was happy to find your code that solved my problem, but I did not lik #region Filter by specific Guid //It's a filter on the underlying GUID value - GridNameValueCellItem g=(GridNameValueCellItem)f.CompareValue; + GridNameValueCellItem g = (GridNameValueCellItem)f.CompareValue; - //get field name + //get field name string sFieldName = GetSqlValueColumnNameAttribute(cf.Column); - //is it in the GridNameValueCellItem object...? - if (sFieldName=="") + //is it in the GridNameValueCellItem object...? + if (sFieldName == "") { //get it from the column header tag name as normal //Get the text field to use in place of the Guid field sFieldName = f.Column.Key.ToString().Replace("LT_", "").Replace("_Label_", "."); - + if (!sFieldName.StartsWith("a")) sFieldName = "a" + sFieldName; @@ -1905,8 +1905,8 @@ At first I was happy to find your code that solved my problem, but I did not lik } - - + + } @@ -1926,114 +1926,114 @@ At first I was happy to find your code that solved my problem, but I did not lik w.WriteAttributeString("TYPE", "System.Guid"); w.WriteAttributeString("COMPAREVALUE", "{" + g.Value.ToString().ToUpper() + "}"); - + #endregion filter by guid } - else - { - #region Filter alphanumeric by name - - - //It's a filter on the display name (alphabetical) - //This is a result of the user filtering by selecting and - //alphabetcial range i.e. A-H instead of a particular item - //use the SqlColumnNameAttribute in the list object - //to retrieve the correct db column to use - string sFieldName=GetSqlColumnNameAttribute(cf.Column); - // - w.WriteAttributeString("CM",sFieldName); - - //Exceptions to datatype being a string: - switch(sFieldName) - { - case "aWorkorderQuote.aQuoteNumber": - w.WriteAttributeString("TYPE",typeof(int).ToString()); - break; - case "aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber": - w.WriteAttributeString("TYPE",typeof(int).ToString()); - break; - case "aWorkorderService.aServiceNumber": - w.WriteAttributeString("TYPE",typeof(int).ToString()); - break; + else + { + #region Filter alphanumeric by name + + + //It's a filter on the display name (alphabetical) + //This is a result of the user filtering by selecting and + //alphabetcial range i.e. A-H instead of a particular item + //use the SqlColumnNameAttribute in the list object + //to retrieve the correct db column to use + string sFieldName = GetSqlColumnNameAttribute(cf.Column); + // + w.WriteAttributeString("CM", sFieldName); + + //Exceptions to datatype being a string: + switch (sFieldName) + { + case "aWorkorderQuote.aQuoteNumber": + w.WriteAttributeString("TYPE", typeof(int).ToString()); + break; + case "aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber": + w.WriteAttributeString("TYPE", typeof(int).ToString()); + break; + case "aWorkorderService.aServiceNumber": + w.WriteAttributeString("TYPE", typeof(int).ToString()); + break; case "aPurchaseOrder.aPONumber": w.WriteAttributeString("TYPE", typeof(int).ToString()); break; - default: - w.WriteAttributeString("TYPE",typeof(string).ToString()); - break; - } + default: + w.WriteAttributeString("TYPE", typeof(string).ToString()); + break; + } //Placeholder, used for guid filtering only //This is the second of only two places where an actual value other than an empty string //needs to be written to the UICOMPAREVALUE TAG w.WriteAttributeString("UICOMPAREVALUE", f.CompareValue.ToString()); - - if(f.CompareValue==null|| f.CompareValue==System.DBNull.Value || f.CompareValue.ToString()=="") - w.WriteAttributeString("COMPAREVALUE",""); - else - { - w.WriteAttributeString("COMPAREVALUE",f.CompareValue.ToString()); + if (f.CompareValue == null || f.CompareValue == System.DBNull.Value || f.CompareValue.ToString() == "") + w.WriteAttributeString("COMPAREVALUE", ""); + else + { + + w.WriteAttributeString("COMPAREVALUE", f.CompareValue.ToString()); } #endregion filter by name } - #endregion - } - else - { - #region Filter a NON GridNameValueCellItem column + #endregion + } + else + { + #region Filter a NON GridNameValueCellItem column - //First: check to see if it has the SqlColumnNameAttribute, if not - //then contrive the sql field name - string sFieldName=GetSqlColumnNameAttribute(f.Column); + //First: check to see if it has the SqlColumnNameAttribute, if not + //then contrive the sql field name + string sFieldName = GetSqlColumnNameAttribute(f.Column); - if(sFieldName=="") - {//Nope, no SqlColumnNameAttribute present - sFieldName=f.Column.Key.ToString().Replace("LT_","").Replace("_Label_","."); + if (sFieldName == "") + {//Nope, no SqlColumnNameAttribute present + sFieldName = f.Column.Key.ToString().Replace("LT_", "").Replace("_Label_", "."); - //Added Jan 30 05 to correspond to above but is not exactly the same - switch(sFieldName) - { - case"Common.Creator": - sFieldName="aCreatorInitials"; - break; - case"Common.Modifier": - sFieldName="aModifierInitials"; - break; - case"Common.Created": - sFieldName="aCreatedDate"; - break; - case"Common.Modified": - sFieldName="aModifiedDate"; - break; - } + //Added Jan 30 05 to correspond to above but is not exactly the same + switch (sFieldName) + { + case "Common.Creator": + sFieldName = "aCreatorInitials"; + break; + case "Common.Modifier": + sFieldName = "aModifierInitials"; + break; + case "Common.Created": + sFieldName = "aCreatedDate"; + break; + case "Common.Modified": + sFieldName = "aModifiedDate"; + break; + } - //-------------------- + //-------------------- - //If User field then change name to - //sql's aUser version instead - if(sFieldName.IndexOf("User.")==0) - sFieldName=sFieldName.Replace("User.","aUser."); + //If User field then change name to + //sql's aUser version instead + if (sFieldName.IndexOf("User.") == 0) + sFieldName = sFieldName.Replace("User.", "aUser."); - //sFieldName=sFieldName.Replace("_Common",""); - if(!sFieldName.StartsWith("a")) - sFieldName="a"+sFieldName; + //sFieldName=sFieldName.Replace("_Common",""); + if (!sFieldName.StartsWith("a")) + sFieldName = "a" + sFieldName; - int nPeriod=sFieldName.IndexOf("."); - if(nPeriod!=-1) - { - if(sFieldName[nPeriod+1]!='a') - { - sFieldName=sFieldName.Replace(".",".a"); - } - } - } + int nPeriod = sFieldName.IndexOf("."); + if (nPeriod != -1) + { + if (sFieldName[nPeriod + 1] != 'a') + { + sFieldName = sFieldName.Replace(".", ".a"); + } + } + } - //tags contain our underlying field key - w.WriteAttributeString("CM",sFieldName);//); + //tags contain our underlying field key + w.WriteAttributeString("CM", sFieldName);//); //Write out the UI column name for processing //by the ui when the UI grid has to be //reconstructed from this filter and order xml fragment @@ -2047,10 +2047,10 @@ At first I was happy to find your code that solved my problem, but I did not lik //Placeholder, used for guid filtering only w.WriteAttributeString("UICOMPAREVALUE", ""); - if(f.CompareValue==null|| f.CompareValue==System.DBNull.Value || f.CompareValue.ToString()=="") - w.WriteAttributeString("COMPAREVALUE",""); - else - { + if (f.CompareValue == null || f.CompareValue == System.DBNull.Value || f.CompareValue.ToString() == "") + w.WriteAttributeString("COMPAREVALUE", ""); + else + { //AyaNova Enumerated list? if (f.Column.DataType.BaseType == typeof(Enum)) @@ -2087,36 +2087,36 @@ At first I was happy to find your code that solved my problem, but I did not lik //so far this line is being left unchanged and I'll try to fix it at the back end during query build w.WriteAttributeString("COMPAREVALUE", f.CompareValue.ToString()); } - } - #endregion - } + } + #endregion + } - w.WriteEndElement(); + w.WriteEndElement(); - }//End filter conditions loop - #endregion filter conditions loop - - w.WriteEndElement(); - }//End column filter loop - #endregion filtering + }//End filter conditions loop + #endregion filter conditions loop - - w.WriteEndElement(); - w.WriteEndDocument(); - sr.Close(); + w.WriteEndElement(); + }//End column filter loop + #endregion filtering - bFiltered=bAtLeastOneFilter; - return sr.ToString(); - } - catch(Exception ex) - { - log.Error("GetGridSortAndFilterXML",ex); - throw new System.Exception("Error @ Util.GetGridSortAndFilterXML:\r\n" + ex.Message) ; - - } - } - #endregion + w.WriteEndElement(); + w.WriteEndDocument(); + sr.Close(); + + bFiltered = bAtLeastOneFilter; + return sr.ToString(); + } + catch (Exception ex) + { + log.Error("GetGridSortAndFilterXML", ex); + throw new System.Exception("Error @ Util.GetGridSortAndFilterXML:\r\n" + ex.Message); + + } + } + + #endregion #region All grids common styling /// @@ -2136,11 +2136,11 @@ At first I was happy to find your code that solved my problem, but I did not lik //case 2108 changed from whitesmoke to honeydew looks better // Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor = Color.WhiteSmoke; Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor = Color.Honeydew; - + Grid.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.Default; - + //case 2108 caption area blends into column headers in win 10 - + //STEP 1: suppress OS themes that can take over from our specified ones (windows 10, not 7 for some reason, fucking infragistics, always overcomplicated) Grid.DisplayLayout.CaptionAppearance.ThemedElementAlpha = Alpha.Transparent; @@ -2149,7 +2149,7 @@ At first I was happy to find your code that solved my problem, but I did not lik Grid.DisplayLayout.CaptionAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True; Grid.DisplayLayout.CaptionAppearance.ForeColor = System.Drawing.SystemColors.ControlText; Grid.DisplayLayout.CaptionAppearance.BackColor = System.Drawing.SystemColors.Control; - + //Color the background of the caption area to make it stand out from the grid column headers Grid.DisplayLayout.CaptionAppearance.BackColor = Color.Honeydew; @@ -2161,84 +2161,84 @@ At first I was happy to find your code that solved my problem, but I did not lik Grid.DisplayLayout.Override.HeaderAppearance.ThemedElementAlpha = Alpha.Transparent; Grid.DisplayLayout.Override.HeaderAppearance.BorderAlpha = Alpha.Opaque; Grid.DisplayLayout.Override.HeaderAppearance.BorderColor = Color.Black; - + } #endregion #region GridPreparation /// - /// Prepares grid to settings compatible with our own filtering / sorting etc - /// called once by any form containing a grid when it's first loaded - /// to set the grid up properly - /// - /// This seems to be only called from read only grids so any settings - /// affecting data entry are not useful here - /// - /// - static public void PrepareGrid(Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //log.Debug("PrepareGrid"); - //Turn off internal sorting but - //still use the sort arrows - Grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.ExternalSortSingle; - - //Set the caption to be on the left side of the grid - Grid.DisplayLayout.CaptionAppearance.TextHAlign=HAlign.Left; + /// Prepares grid to settings compatible with our own filtering / sorting etc + /// called once by any form containing a grid when it's first loaded + /// to set the grid up properly + /// + /// This seems to be only called from read only grids so any settings + /// affecting data entry are not useful here + /// + /// + static public void PrepareGrid(Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //log.Debug("PrepareGrid"); + //Turn off internal sorting but + //still use the sort arrows + Grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.ExternalSortSingle; - + //Set the caption to be on the left side of the grid + Grid.DisplayLayout.CaptionAppearance.TextHAlign = HAlign.Left; - } - /// - /// setup string bound columns in editable grids to allow user - /// to enter nothing in them by wiping out all text. This then - /// causes the data bound object to have an empty string value stored. - /// - /// Without this an error is thrown whenver a user attempts to clear a previously - /// entered text field in a grid - /// - /// - static public void SetTextColumnsNullable(Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //log.Debug("SetTextColumnsNullable"); - foreach(UltraGridBand b in Grid.DisplayLayout.Bands) - { - foreach(Infragistics.Win.UltraWinGrid.UltraGridColumn c in b.Columns) - { - if(c.DataType==typeof(string)) - c.Nullable=Infragistics.Win.UltraWinGrid.Nullable.EmptyString; - - } - } - - - - } - - #endregion - - #region Grid custom filters - static public void SetCustomFilters(Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventArgs e) - { - //case 1039 //log.Debug("SetCustomFilters"); - //How to remove a stock one - // for(int x=0;x + /// setup string bound columns in editable grids to allow user + /// to enter nothing in them by wiping out all text. This then + /// causes the data bound object to have an empty string value stored. + /// + /// Without this an error is thrown whenver a user attempts to clear a previously + /// entered text field in a grid + /// + /// + static public void SetTextColumnsNullable(Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //log.Debug("SetTextColumnsNullable"); + foreach (UltraGridBand b in Grid.DisplayLayout.Bands) + { + foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn c in b.Columns) + { + if (c.DataType == typeof(string)) + c.Nullable = Infragistics.Win.UltraWinGrid.Nullable.EmptyString; + + } + } + + + + } + + #endregion + + #region Grid custom filters + static public void SetCustomFilters(Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventArgs e) + { + //case 1039 //log.Debug("SetCustomFilters"); + //How to remove a stock one + // for(int x=0;x0 - filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And); - filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThan,0); - e.ValueList.ValueListItems.Insert(2,filterMulti,"[>0]"); + //>0 + filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And); + filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThan, 0); + e.ValueList.ValueListItems.Insert(2, filterMulti, "[>0]"); - } - } + } + } - #endregion + #endregion - #region Business object data binding and broken rule feedback - /// - /// Take care of binding form controls to business object properties - /// - /// - /// - /// - /// - public static void BindField(Control control, string propertyName, object dataSource, string dataMember) - { + #region Business object data binding and broken rule feedback + /// + /// Take care of binding form controls to business object properties + /// + /// + /// + /// + /// + public static void BindField(Control control, string propertyName, object dataSource, string dataMember) + { //if (log.IsDebugEnabled) // //case 1039 //log.Debug("BindField(" + control.Name + ", " + propertyName + ", " + dataSource.ToString() + ", " + dataMember + ")"); - Binding bd; - int index; + Binding bd; + int index; - index = control.DataBindings.Count - 1; - while (index >= 0) - { - bd = control.DataBindings[index]; - if (bd.PropertyName==propertyName) - control.DataBindings.Remove(bd); - index--; - } - control.DataBindings.Add(propertyName, dataSource, dataMember); - } + index = control.DataBindings.Count - 1; + while (index >= 0) + { + bd = control.DataBindings[index]; + if (bd.PropertyName == propertyName) + control.DataBindings.Remove(bd); + index--; + } + control.DataBindings.Add(propertyName, dataSource, dataMember); + } - /// - /// Display errorProvider icons beside any fields that have broken rules - /// on the form - /// - /// Form containing business object - /// Business object instance variable - /// instance variable of ErrorProvider object on form - public static void BrokenRuleFeedback(Control ctl,CSLA.BusinessBase Obj,ErrorProvider EP ) - { -// //case 1039 //if(log.IsDebugEnabled) -// //case 1039 //log.Debug("BrokenRuleFeedback("+ctl.Name+", " + Obj.ToString()+ ")"); - //Loop through all databindings for control (if any) - foreach(Binding b in ctl.DataBindings) - { - - string sErr=BrokenRuleLocalizer(Obj.GetBrokenRulesCollection().get_RuleForProperty(b.BindingMemberInfo.BindingField).Description); - EP.SetError(ctl,sErr); - } - - //recurse through all controls inside passed in control - foreach(Control c in ctl.Controls) - { - BrokenRuleFeedback(c,Obj,EP); - - } + /// + /// Display errorProvider icons beside any fields that have broken rules + /// on the form + /// + /// Form containing business object + /// Business object instance variable + /// instance variable of ErrorProvider object on form + public static void BrokenRuleFeedback(Control ctl, CSLA.BusinessBase Obj, ErrorProvider EP) + { + // //case 1039 //if(log.IsDebugEnabled) + // //case 1039 //log.Debug("BrokenRuleFeedback("+ctl.Name+", " + Obj.ToString()+ ")"); + //Loop through all databindings for control (if any) + foreach (Binding b in ctl.DataBindings) + { - } + string sErr = BrokenRuleLocalizer(Obj.GetBrokenRulesCollection().get_RuleForProperty(b.BindingMemberInfo.BindingField).Description); + EP.SetError(ctl, sErr); + } + + //recurse through all controls inside passed in control + foreach (Control c in ctl.Controls) + { + BrokenRuleFeedback(c, Obj, EP); + + } + + } - /// - /// Takes a broken rule text and xforms it into the localized version - /// applying all formatting as required - /// - /// - /// - private static string BrokenRuleLocalizer(string BrokenRuleString) - { - if(BrokenRuleString==null) return null; - if(BrokenRuleString=="") return ""; - - - //Localize and format the string - //this string comes to us as a set of comma delimited localized text key strings - //i.e. "Error.Object.RequiredFieldEmpty,Client.Label.Name" - //the first key translates often to a string with format characters in it such as - //"{0} is not a valid value for the {1} field - //The second and following keys are the values to be inserted in those format positions - - //This code makes an object array of all the second and following localized text strings - //and then passes that to the string.format function along with the first string - string[] sarray=BrokenRuleString.Split(','); - object[] sitems=new object[sarray.GetLength(0)-1]; - for(int x=1;x - /// cracks a broken rule collection into separate errors - /// then processes them - /// - /// A brokenrulestext property of a biz object contains one or more - /// broken rules as in the brokenrulelocalizer method above, but - /// separated by pipe characters | - /// - /// - /// - public static string BrokenRuleCollectionLocalizer(string BrokenRuleCollection) - { - StringBuilder sb=new StringBuilder(); - string[] sarray=BrokenRuleCollection.Split('|'); - foreach(string s in sarray) - { - sb.Append(BrokenRuleLocalizer(s)); - sb.Append("\r\n"); - } - return sb.ToString(); - } - #endregion - - #region Grid Hide standard child collection fields - - /// - /// Hide fields from the biz object layer that are internal and not for viewing - /// - /// (Stuff in BusinessBase framework layer such as IsDirty, IsSavable etc is - /// flagged with Browseable(false) instead - /// of using this method, much cleaner.) - /// - /// - /// - static public void GridHideEditableBizObjectInternalFields(Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("GridHideEditableBizObjectInternalFields("+Grid.Name+"."+Grid.Parent.Name+")"); - foreach(Infragistics.Win.UltraWinGrid.UltraGridBand b in Grid.DisplayLayout.Bands) - { - b.Columns["Modified"].Hidden =true; - b.Columns["Modifier"].Hidden =true; - b.Columns["Created"].Hidden =true; - b.Columns["Creator"].Hidden =true; + /// + /// Takes a broken rule text and xforms it into the localized version + /// applying all formatting as required + /// + /// + /// + private static string BrokenRuleLocalizer(string BrokenRuleString) + { + if (BrokenRuleString == null) return null; + if (BrokenRuleString == "") return ""; - if(b.Columns.Exists("RootObjectID")) - { - b.Columns["RootObjectID"].Hidden =true; - } + //Localize and format the string + //this string comes to us as a set of comma delimited localized text key strings + //i.e. "Error.Object.RequiredFieldEmpty,Client.Label.Name" + //the first key translates often to a string with format characters in it such as + //"{0} is not a valid value for the {1} field + //The second and following keys are the values to be inserted in those format positions - if(b.Columns.Exists("RootObjectType")) - { - b.Columns["RootObjectType"].Hidden =true; - } + //This code makes an object array of all the second and following localized text strings + //and then passes that to the string.format function along with the first string + string[] sarray = BrokenRuleString.Split(','); + object[] sitems = new object[sarray.GetLength(0) - 1]; + for (int x = 1; x < sarray.GetLength(0); x++) + { + sitems[x - 1] = LocaleText.GetLocalizedText(sarray[x]); + } - if(b.Columns.Exists("ID")) - { - b.Columns["ID"].Hidden =true; - } - - - } + return string.Format(LocaleText.GetLocalizedText(sarray[0]), sitems); - //----------- + } + + /// + /// cracks a broken rule collection into separate errors + /// then processes them + /// + /// A brokenrulestext property of a biz object contains one or more + /// broken rules as in the brokenrulelocalizer method above, but + /// separated by pipe characters | + /// + /// + /// + public static string BrokenRuleCollectionLocalizer(string BrokenRuleCollection) + { + StringBuilder sb = new StringBuilder(); + string[] sarray = BrokenRuleCollection.Split('|'); + foreach (string s in sarray) + { + sb.Append(BrokenRuleLocalizer(s)); + sb.Append("\r\n"); + } + return sb.ToString(); + } + #endregion + + #region Grid Hide standard child collection fields + + /// + /// Hide fields from the biz object layer that are internal and not for viewing + /// + /// (Stuff in BusinessBase framework layer such as IsDirty, IsSavable etc is + /// flagged with Browseable(false) instead + /// of using this method, much cleaner.) + /// + /// + /// + static public void GridHideEditableBizObjectInternalFields(Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("GridHideEditableBizObjectInternalFields("+Grid.Name+"."+Grid.Parent.Name+")"); + foreach (Infragistics.Win.UltraWinGrid.UltraGridBand b in Grid.DisplayLayout.Bands) + { + b.Columns["Modified"].Hidden = true; + b.Columns["Modifier"].Hidden = true; + b.Columns["Created"].Hidden = true; + b.Columns["Creator"].Hidden = true; + + + if (b.Columns.Exists("RootObjectID")) + { + b.Columns["RootObjectID"].Hidden = true; + } + + if (b.Columns.Exists("RootObjectType")) + { + b.Columns["RootObjectType"].Hidden = true; + } + + if (b.Columns.Exists("ID")) + { + b.Columns["ID"].Hidden = true; + } + + + } + + + //----------- - } + } - #endregion - - #region Grid Click handler functions + #endregion - /// - /// Find which band user right clicked on in grid - /// - /// Grid in question - /// MouseEvent argument from click event - /// Band that was right clicked on - static public UltraGridBand BandRightClicked(Infragistics.Win.UltraWinGrid.UltraGrid Grid, System.Windows.Forms.MouseEventArgs e) - { - //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("BandRightClicked("+Grid.Name+"."+Grid.Parent.Name+"," +e.Button.ToString()+ ")"); + #region Grid Click handler functions - //redundant: every time this is called it's already been pre-screened for right button -// if ( e.Button == MouseButtons.Right ) -// { -// - UIElement oUIElement; - System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y); + /// + /// Find which band user right clicked on in grid + /// + /// Grid in question + /// MouseEvent argument from click event + /// Band that was right clicked on + static public UltraGridBand BandRightClicked(Infragistics.Win.UltraWinGrid.UltraGrid Grid, System.Windows.Forms.MouseEventArgs e) + { + //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("BandRightClicked("+Grid.Name+"."+Grid.Parent.Name+"," +e.Button.ToString()+ ")"); - oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point); - if ( oUIElement == null ) { return null; } + //redundant: every time this is called it's already been pre-screened for right button + // if ( e.Button == MouseButtons.Right ) + // { + // + UIElement oUIElement; + System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y); - oUIElement = oUIElement.GetAncestor(typeof(HeaderUIElement)); - if(null == oUIElement) - return null; - if ( oUIElement.GetType() != typeof(HeaderUIElement) ) - return null; + oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point); + if (oUIElement == null) { return null; } - //HeaderUIElement oHeaderUI=(HeaderUIElement)oUIElement; - - - return ((Infragistics.Win.UltraWinGrid.ColumnHeader)((HeaderUIElement)oUIElement).SelectableItem).Band; + oUIElement = oUIElement.GetAncestor(typeof(HeaderUIElement)); + if (null == oUIElement) + return null; + if (oUIElement.GetType() != typeof(HeaderUIElement)) + return null; - - -// } -// else -// return null; - - } + //HeaderUIElement oHeaderUI=(HeaderUIElement)oUIElement; - /// - /// Check if user left clicked on a column header and return column key if so - /// - /// Grid in question - /// MouseEvent argument from click event - /// Key of column header if clicked else null - static public string HeaderClicked(Infragistics.Win.UltraWinGrid.UltraGrid Grid, System.Windows.Forms.MouseEventArgs e) - { - //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("HeaderClicked("+Grid.Name+"."+Grid.Parent.Name+"," +e.Button.ToString()+ ")"); + return ((Infragistics.Win.UltraWinGrid.ColumnHeader)((HeaderUIElement)oUIElement).SelectableItem).Band; - if ( e.Button == MouseButtons.Left ) - { - - UIElement oUIElement; - System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y); - oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point); - if ( oUIElement == null ) { return null; } - oUIElement = oUIElement.GetAncestor(typeof(HeaderUIElement)); - if(null == oUIElement) - return null; - if ( oUIElement.GetType() != typeof(HeaderUIElement) ) - return null; + // } + // else + // return null; - //HeaderUIElement oHeaderUI=(HeaderUIElement)oUIElement; - - - return ((Infragistics.Win.UltraWinGrid.ColumnHeader)((HeaderUIElement)oUIElement).SelectableItem).Column.Key; + } - - } - else - return null; + /// + /// Check if user left clicked on a column header and return column key if so + /// + /// Grid in question + /// MouseEvent argument from click event + /// Key of column header if clicked else null + static public string HeaderClicked(Infragistics.Win.UltraWinGrid.UltraGrid Grid, System.Windows.Forms.MouseEventArgs e) + { + //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("HeaderClicked("+Grid.Name+"."+Grid.Parent.Name+"," +e.Button.ToString()+ ")"); - } + if (e.Button == MouseButtons.Left) + { + + UIElement oUIElement; + System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y); + + oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point); + if (oUIElement == null) { return null; } + + oUIElement = oUIElement.GetAncestor(typeof(HeaderUIElement)); + if (null == oUIElement) + return null; + if (oUIElement.GetType() != typeof(HeaderUIElement)) + return null; + + //HeaderUIElement oHeaderUI=(HeaderUIElement)oUIElement; + + + return ((Infragistics.Win.UltraWinGrid.ColumnHeader)((HeaderUIElement)oUIElement).SelectableItem).Column.Key; + + + + } + else + return null; + + } - /// - /// Check if user right clicked on a nameValuebutton - /// and return if so - /// - /// Grid in question - /// MouseEvent argument from click event - /// GridNameValueCellItem if that's what was clicked - static public GridNameValueCellItem NameValueButtonRightClicked(Infragistics.Win.UltraWinGrid.UltraGrid Grid, System.Windows.Forms.MouseEventArgs e) - { - //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("NameValueButtonRightClicked("+Grid.Name+"."+Grid.Parent.Name+"," +e.Button.ToString()+ ")"); + /// + /// Check if user right clicked on a nameValuebutton + /// and return if so + /// + /// Grid in question + /// MouseEvent argument from click event + /// GridNameValueCellItem if that's what was clicked + static public GridNameValueCellItem NameValueButtonRightClicked(Infragistics.Win.UltraWinGrid.UltraGrid Grid, System.Windows.Forms.MouseEventArgs e) + { + //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("NameValueButtonRightClicked("+Grid.Name+"."+Grid.Parent.Name+"," +e.Button.ToString()+ ")"); - if ( e.Button == MouseButtons.Right ) - { - - UIElement oUIElement; - System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y); + if (e.Button == MouseButtons.Right) + { - oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point); - if ( oUIElement == null ) { return null; } + UIElement oUIElement; + System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y); - oUIElement=oUIElement.GetAncestor(typeof(CellButtonUIElement)); - if(null == oUIElement) - return null; + oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point); + if (oUIElement == null) { return null; } - if ( oUIElement.GetType() != typeof(CellButtonUIElement) ) - return null; + oUIElement = oUIElement.GetAncestor(typeof(CellButtonUIElement)); + if (null == oUIElement) + return null; - //Make sure it's one of *our* buttons, not just any button - if(((UltraGridCell)oUIElement.SelectableItem).Value.GetType() != typeof(GridNameValueCellItem)) - return null; - - return (GridNameValueCellItem)((UltraGridCell)oUIElement.SelectableItem).Value; + if (oUIElement.GetType() != typeof(CellButtonUIElement)) + return null; - + //Make sure it's one of *our* buttons, not just any button + if (((UltraGridCell)oUIElement.SelectableItem).Value.GetType() != typeof(GridNameValueCellItem)) + return null; - } - else - return null; + return (GridNameValueCellItem)((UltraGridCell)oUIElement.SelectableItem).Value; - } - #endregion - #region Common Prompting messageboxes localized - // - public static DialogResult PromptForSave() - { - DialogResult dr= MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.SavePrompt"),"",MessageBoxButtons.YesNoCancel, - MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button3); - //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("PromptForSave (user selected " + dr.ToString()+")"); - return dr; - } - public static DialogResult PromptForBrokenRulesCancelSave() - { - DialogResult dr= MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.UnsaveableDueToBrokenRulesPrompt"),"",MessageBoxButtons.YesNo, - MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button2); - //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("PromptForBrokenRulesCancelSave (proceed without saving?) (user selected " + dr.ToString()+")"); - return dr; - } + } + else + return null; - public static DialogResult PromptForDelete() - { - DialogResult dr= MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.DeletePrompt"),"",MessageBoxButtons.YesNoCancel, - MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button3); - //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("PromptForDelete (user selected " + dr.ToString()+")"); - return dr; - } + } + #endregion + + #region Common Prompting messageboxes localized + // + public static DialogResult PromptForSave() + { + DialogResult dr = MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.SavePrompt"), "", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3); + //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("PromptForSave (user selected " + dr.ToString()+")"); + return dr; + } + + public static DialogResult PromptForBrokenRulesCancelSave() + { + DialogResult dr = MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.UnsaveableDueToBrokenRulesPrompt"), "", MessageBoxButtons.YesNo, + MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); + //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("PromptForBrokenRulesCancelSave (proceed without saving?) (user selected " + dr.ToString()+")"); + return dr; + } + + public static DialogResult PromptForDelete() + { + DialogResult dr = MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.DeletePrompt"), "", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3); + //case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("PromptForDelete (user selected " + dr.ToString()+")"); + return dr; + } public static DialogResult PromptForDeleteWorkorder() { @@ -2757,67 +2757,67 @@ At first I was happy to find your code that solved my problem, but I did not lik return dr; } - public static DialogResult PromptYesNoCancelFromLocaleKey(string LocaleKey) - { - - DialogResult dr= MessageBox.Show(LocaleText.GetLocalizedText(LocaleKey),"",MessageBoxButtons.YesNoCancel, - MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button3); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PromptYesNoCancelFromLocaleKey("+LocaleKey+" (user selected " + dr.ToString()+")"); - return dr; - } + public static DialogResult PromptYesNoCancelFromLocaleKey(string LocaleKey) + { - public static DialogResult PromptYesNoFromLocaleKey(string LocaleKey) - { - - - DialogResult dr= MessageBox.Show(LocaleText.GetLocalizedText(LocaleKey),"",MessageBoxButtons.YesNo, - MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button2); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PromptYesNoFromLocaleKey("+LocaleKey+" (user selected " + dr.ToString()+")"); - return dr; - } + DialogResult dr = MessageBox.Show(LocaleText.GetLocalizedText(LocaleKey), "", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PromptYesNoCancelFromLocaleKey("+LocaleKey+" (user selected " + dr.ToString()+")"); + return dr; + } - public static void PromptWithIconOKOnlyFromLocaleKey(string LocaleKey, MessageBoxIcon ic) - { - - MessageBox.Show(LocaleText.GetLocalizedText(LocaleKey),"",MessageBoxButtons.OK,ic); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PromptWithIconOKOnlyFromLocaleKey("+LocaleKey+")"); - return ; - } + public static DialogResult PromptYesNoFromLocaleKey(string LocaleKey) + { - public static void PromptWithIconOKOnlyFromLocaleKey(string LocaleKey,string sExtraInfo, MessageBoxIcon ic) - { - - - MessageBox.Show(string.Format(LocaleText.GetLocalizedText(LocaleKey),sExtraInfo),"",MessageBoxButtons.OK,ic); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PromptWithIconOKOnlyFromLocaleKey("+LocaleKey+")"); - return ; - } - //show a standard administrator only function message box with an OK key - public static void PromptAdministratorOnly() - { - - - MessageBox.Show(LocaleText.GetLocalizedText("Error.Security.AdministratorOnlyMessage"),"",MessageBoxButtons.OK,MessageBoxIcon.Hand); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PromptAdministratorOnly()"); - return ; - } + DialogResult dr = MessageBox.Show(LocaleText.GetLocalizedText(LocaleKey), "", MessageBoxButtons.YesNo, + MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PromptYesNoFromLocaleKey("+LocaleKey+" (user selected " + dr.ToString()+")"); + return dr; + } - public static void PromptRestricted() - { - - MessageBox.Show(LocaleText.GetLocalizedText("Error.Trial.Restricted"),"",MessageBoxButtons.OK,MessageBoxIcon.Information); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PromptRestricted()"); - return ; - } + public static void PromptWithIconOKOnlyFromLocaleKey(string LocaleKey, MessageBoxIcon ic) + { - //case 1140 + MessageBox.Show(LocaleText.GetLocalizedText(LocaleKey), "", MessageBoxButtons.OK, ic); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PromptWithIconOKOnlyFromLocaleKey("+LocaleKey+")"); + return; + } + + public static void PromptWithIconOKOnlyFromLocaleKey(string LocaleKey, string sExtraInfo, MessageBoxIcon ic) + { + + + MessageBox.Show(string.Format(LocaleText.GetLocalizedText(LocaleKey), sExtraInfo), "", MessageBoxButtons.OK, ic); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PromptWithIconOKOnlyFromLocaleKey("+LocaleKey+")"); + return; + } + + //show a standard administrator only function message box with an OK key + public static void PromptAdministratorOnly() + { + + + MessageBox.Show(LocaleText.GetLocalizedText("Error.Security.AdministratorOnlyMessage"), "", MessageBoxButtons.OK, MessageBoxIcon.Hand); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PromptAdministratorOnly()"); + return; + } + + public static void PromptRestricted() + { + + MessageBox.Show(LocaleText.GetLocalizedText("Error.Trial.Restricted"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PromptRestricted()"); + return; + } + + //case 1140 //User outside client region warning message, put it here because it's called from both schedule form and workorder form public static void ShowSchedTechOutsideRegionWarning(Guid UserID, Guid ClientID) { @@ -2825,15 +2825,15 @@ At first I was happy to find your code that solved my problem, but I did not lik if (UserID == Guid.Empty) return; if (ClientID == Guid.Empty) return; - if(!AyaBizUtils.InClientRegion(ClientID,UserID)) + if (!AyaBizUtils.InClientRegion(ClientID, UserID)) { PromptWithIconOKOnlyFromLocaleKey("WorkorderItemScheduledUser.Label.Warn.OutOfRegion", MessageBoxIcon.Warning); } } - #endregion + #endregion - #region ComboBox helpers + #region ComboBox helpers #region combo performance enhancement when loading //These methods added 19-July-2006 and changed @@ -2845,11 +2845,11 @@ At first I was happy to find your code that solved my problem, but I did not lik static public void ComboBeginUpdate(GZTW.WinForm.Controls.GZUltraComboEditor cb) { - + //Added: 19-July-2006 Huge performance increase with large lists cb.BeginUpdate(); cb.SortStyle = ValueListSortStyle.None; - + } @@ -2879,25 +2879,25 @@ At first I was happy to find your code that solved my problem, but I did not lik #endregion /// - /// Select the value list item in the combo that - /// matches the ID passed in with it - /// - /// - /// - /// - /// - static public void ComboSelectGuid(UltraComboEditor cb, Guid SelectRecord) - { - //case 1039 //log.Debug("ComboSelectGuid"); - foreach(ValueListItem vi in cb.Items) - { - if((Guid)vi.DataValue==SelectRecord) - { - cb.SelectedItem=vi; - break; - } - } - } + /// Select the value list item in the combo that + /// matches the ID passed in with it + /// + /// + /// + /// + /// + static public void ComboSelectGuid(UltraComboEditor cb, Guid SelectRecord) + { + //case 1039 //log.Debug("ComboSelectGuid"); + foreach (ValueListItem vi in cb.Items) + { + if ((Guid)vi.DataValue == SelectRecord) + { + cb.SelectedItem = vi; + break; + } + } + } /// /// Check if guid present in combo @@ -2930,7 +2930,7 @@ At first I was happy to find your code that solved my problem, but I did not lik static public void ComboRemoveFromListGuid(UltraComboEditor cb, Guid SelectRecord) { ////case 1039 //log.Debug("ComboRemoveFromListGuid"); - ValueListItem viRemove=null; + ValueListItem viRemove = null; foreach (ValueListItem vi in cb.Items) { if ((Guid)vi.DataValue == SelectRecord) @@ -2940,137 +2940,137 @@ At first I was happy to find your code that solved my problem, but I did not lik } } - if(viRemove!=null) + if (viRemove != null) cb.Items.Remove(viRemove); } - /// - /// - /// - /// - /// - /// - /// - static public void FillGZComboBoxWithNameIDList(string ObjectName, GZTW.WinForm.Controls.GZUltraComboEditor cb, bool SelectMode, Guid SelectRecord, bool Regional )//case 58 - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("FillGZComboBoxWithNameIDList("+ObjectName+", " + cb.Name + ", " +SelectMode.ToString() + ", " + SelectRecord.ToString() + ")" ); - //Save the current combo box selection if any - //in case we need to manually put it back in the - //case of an inactive item being pre-selected - Guid gCurrentlySelectedID=Guid.Empty; - if(cb.Value!=null && cb.Value.ToString() != Util.NoSelectionString)//case 1261 - { - try - { - gCurrentlySelectedID=(Guid)cb.Value; - } - catch(System.InvalidCastException ex) - { - log.Error("FillGZComboBoxWithNameIDList: error casting value of selected combo box item to a guid, Guid.Empty will be used instead",ex); - gCurrentlySelectedID=Guid.Empty; - } - } - - cb.BeginUpdate(); - + /// + /// + /// + /// + /// + /// + /// + static public void FillGZComboBoxWithNameIDList(string ObjectName, GZTW.WinForm.Controls.GZUltraComboEditor cb, bool SelectMode, Guid SelectRecord, bool Regional)//case 58 + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("FillGZComboBoxWithNameIDList("+ObjectName+", " + cb.Name + ", " +SelectMode.ToString() + ", " + SelectRecord.ToString() + ")" ); + //Save the current combo box selection if any + //in case we need to manually put it back in the + //case of an inactive item being pre-selected + Guid gCurrentlySelectedID = Guid.Empty; + if (cb.Value != null && cb.Value.ToString() != Util.NoSelectionString)//case 1261 + { + try + { + gCurrentlySelectedID = (Guid)cb.Value; + } + catch (System.InvalidCastException ex) + { + log.Error("FillGZComboBoxWithNameIDList: error casting value of selected combo box item to a guid, Guid.Empty will be used instead", ex); + gCurrentlySelectedID = Guid.Empty; + } + } - //wipe any previous list - ////case 1039 //log.Debug("Before clear list item count:" + cb.Items.Count.ToString()); - cb.ClearList(); - + cb.BeginUpdate(); - ////case 1039 //log.Debug("After clear list item count:" + cb.Items.Count.ToString()); - ValueListItem viSelected=cb.EmptyValueListItem; - if(SelectMode) - { - - //Fetch selected record and add to list so it's displayed - if(SelectRecord!=Guid.Empty) - { - NameFetcher nf=null; - try - { - nf = NameFetcher.GetItem(ObjectName,"Name",SelectRecord); - cb.Items.Add(SelectRecord,nf.RecordName); - } - catch(Exception ex) - { - log.Error("FillGZComboBoxWithNameIDList: error fetching name of selected item (Object=" + ObjectName + " ID=" + SelectRecord.ToString()+") Name will not be fetched.",ex); - } - - } - } - else - { - //NVCHANGED - GenericNVList l=GenericNVList.GetList("a"+ObjectName,"aID","aName",true,true,Regional); - - //ensure that non-active record - //still appears in list - bool bSelectedRecordIsInList=false; + //wipe any previous list + ////case 1039 //log.Debug("Before clear list item count:" + cb.Items.Count.ToString()); + cb.ClearList(); + + + ////case 1039 //log.Debug("After clear list item count:" + cb.Items.Count.ToString()); + ValueListItem viSelected = cb.EmptyValueListItem; + + if (SelectMode) + { + + //Fetch selected record and add to list so it's displayed + if (SelectRecord != Guid.Empty) + { + NameFetcher nf = null; + try + { + nf = NameFetcher.GetItem(ObjectName, "Name", SelectRecord); + cb.Items.Add(SelectRecord, nf.RecordName); + } + catch (Exception ex) + { + log.Error("FillGZComboBoxWithNameIDList: error fetching name of selected item (Object=" + ObjectName + " ID=" + SelectRecord.ToString() + ") Name will not be fetched.", ex); + } + + } + } + else + { + //NVCHANGED + GenericNVList l = GenericNVList.GetList("a" + ObjectName, "aID", "aName", true, true, Regional); + + //ensure that non-active record + //still appears in list + bool bSelectedRecordIsInList = false; //Added: 19-July-2006 for performance improvement cb.SortStyle = ValueListSortStyle.None; - foreach(DictionaryEntry d in l.BindableList) - { - Guid gValue=new Guid(d.Key.ToString()); - if(gValue == gCurrentlySelectedID) - { - bSelectedRecordIsInList=true; - viSelected=cb.Items.Add(gValue,d.Value.ToString()); - - } - else - { - cb.Items.Add(gValue,d.Value.ToString()); - - } - - } + foreach (DictionaryEntry d in l.BindableList) + { + Guid gValue = new Guid(d.Key.ToString()); + if (gValue == gCurrentlySelectedID) + { + bSelectedRecordIsInList = true; + viSelected = cb.Items.Add(gValue, d.Value.ToString()); + + } + else + { + cb.Items.Add(gValue, d.Value.ToString()); + + } + + } //Added: 19-July-2006 for performance improvement cb.SortStyle = ValueListSortStyle.Ascending; - //manually add non-active item? - if(gCurrentlySelectedID!=Guid.Empty && !bSelectedRecordIsInList) - { - //retrieve manually non-active item - try - { - NameFetcher nf = NameFetcher.GetItem(ObjectName,"Name",gCurrentlySelectedID); - viSelected=cb.Items.Add(gCurrentlySelectedID,nf.RecordName); - viSelected.Appearance.ForeColor=System.Drawing.SystemColors.GrayText; - - } - catch - { - } - - } - cb.SelectedItem=viSelected; - + //manually add non-active item? + if (gCurrentlySelectedID != Guid.Empty && !bSelectedRecordIsInList) + { + //retrieve manually non-active item + try + { + NameFetcher nf = NameFetcher.GetItem(ObjectName, "Name", gCurrentlySelectedID); + viSelected = cb.Items.Add(gCurrentlySelectedID, nf.RecordName); + viSelected.Appearance.ForeColor = System.Drawing.SystemColors.GrayText; - } + } + catch + { + } - - cb.EndUpdate(); - - } + } + cb.SelectedItem = viSelected; - + } - - - #endregion + cb.EndUpdate(); - #region Custom Fields + } + + + + + + + + #endregion + + #region Custom Fields /// /// case 1317 check if custom fields are available to be shown /// @@ -3083,27 +3083,27 @@ At first I was happy to find your code that solved my problem, but I did not lik { return false; } - + foreach (ObjectCustomField f in ocf) { if (f.Visible) - return true; + return true; } - return false; + return false; } - /// - /// Prepares grid passed in with custom field rows - /// sets each to the correct data editor chosen - /// shows localized text for each field (row) name correctly - /// - /// - /// AyaNova business object name (i.e. "Client") - /// Grid to customize - /// true if there are custom fields to show, false if not - static public bool PrepareCustomFieldsGrid(string sObject,Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - + /// + /// Prepares grid passed in with custom field rows + /// sets each to the correct data editor chosen + /// shows localized text for each field (row) name correctly + /// + /// + /// AyaNova business object name (i.e. "Client") + /// Grid to customize + /// true if there are custom fields to show, false if not + static public bool PrepareCustomFieldsGrid(string sObject, Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 2108 Grid.DisplayLayout.CaptionAppearance.TextHAlign = HAlign.Left; Grid.DisplayLayout.CaptionAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True; @@ -3111,235 +3111,235 @@ At first I was happy to find your code that solved my problem, but I did not lik Grid.DisplayLayout.CaptionAppearance.BackColor = System.Drawing.SystemColors.Control; GridStyler(Grid); - ObjectCustomFields ocf=ObjectCustomFields.GetItems(sObject); - if(ocf.Count==0) - { - //case 1039 //log.Debug("PrepareCustomFieldsGrid: zero ObjectCustomFields fetched returning false"); - return false; - } - bool bAtLeastOneFieldIsVisible=false; - foreach(ObjectCustomField f in ocf) - { - if(f.Visible) - { - bAtLeastOneFieldIsVisible=true; - break; - } + ObjectCustomFields ocf = ObjectCustomFields.GetItems(sObject); + if (ocf.Count == 0) + { + //case 1039 //log.Debug("PrepareCustomFieldsGrid: zero ObjectCustomFields fetched returning false"); + return false; + } + bool bAtLeastOneFieldIsVisible = false; + foreach (ObjectCustomField f in ocf) + { + if (f.Visible) + { + bAtLeastOneFieldIsVisible = true; + break; + } - } - if(!bAtLeastOneFieldIsVisible) - { - //case 1039 //log.Debug("PrepareCustomFieldsGrid: zero ObjectCustomFields are set visible returning false"); - return false; - } + } + if (!bAtLeastOneFieldIsVisible) + { + //case 1039 //log.Debug("PrepareCustomFieldsGrid: zero ObjectCustomFields are set visible returning false"); + return false; + } - //OK, we have fields to show, let's get showing... + //OK, we have fields to show, let's get showing... - //Setup the grid properly - Grid.DisplayLayout.AutoFitStyle=AutoFitStyle.ExtendLastColumn; - - - - - DataTable dt = new DataTable( ); - //original column value (i.e. "Custom0" "Custom1" etc, won't be visible) - dt.Columns.Add( "ID",typeof(string)); - //what type of editor to use, won't be visible - dt.Columns.Add( "Editor",typeof(FormFieldDataTypes)); - - //Field name (is visible) - dt.Columns.Add( "Field",typeof(string)); - //Field value (is visible and only editable field) - dt.Columns.Add( "FieldValue",typeof(object)); - - foreach(ObjectCustomField f in ocf) - { - if(f.Visible) - { - dt.Rows.Add(new object[] {f.FieldName,f.FieldType,LocaleText.GetLocalizedText(sObject+".Label."+f.FieldName),null}); - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PrepareCustomFieldsGrid: Adding field=" + f.FieldName + ", Type=" + f.FieldType.ToString()+ ",Localized="+LocaleText.GetLocalizedText(sObject+".Label."+f.FieldName) +")"); - - } - else - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PrepareCustomFieldsGrid: Not adding field " + f.FieldName + " (set to invisible)"); - } - } - - - // Set the data source of the grid to the table we created. - Grid.DataSource = dt; - - //Set the editor for each row's custom field to the editor type selected - - Grid.DisplayLayout.Bands[0].Columns["ID"].Hidden=true; - Grid.DisplayLayout.Bands[0].Columns["Editor"].Hidden=true; - Grid.DisplayLayout.Bands[0].Columns["Field"].CellActivation=Activation.NoEdit; - - - //case 1039 //log.Debug("PrepareCustomFieldsGrid: Setting editors for each custom field based on type..."); - - //Pre-compute a date and time editor mask for this current culture - EditorWithMask em=new EditorWithMask(); - - string sDateOnlyMask=em.CalcDefaultDateMask(CultureInfo.CurrentCulture); - string sTimeOnlyMask =em.CalcDefaultTimeMask(CultureInfo.CurrentCulture); - - string sDateTimeMask=sDateOnlyMask + " " + sTimeOnlyMask; - - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PrepareCustomFieldsGrid: CurrentCulture Date/time mask is [" + sDateTimeMask+"]"); - - DefaultEditorOwnerSettings editorSettings = null; - foreach(UltraGridRow r in Grid.Rows) - { - - FormFieldDataTypes ff=(FormFieldDataTypes)r.Cells["Editor"].Value; - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("PrepareCustomFieldsGrid: setting an editor of type " + ff.ToString() + " for field " + r.Cells["Field"]); - switch(ff) - { - case FormFieldDataTypes.Currency: - // Add an item for editing currency. - editorSettings = new DefaultEditorOwnerSettings( ); - editorSettings.DataType = typeof( decimal ); - r.Cells["FieldValue"].Editor= new EditorWithMask( new DefaultEditorOwner( editorSettings ) ); - - break; - case FormFieldDataTypes.DateOnly: - // Add an item for editing date. - editorSettings = new DefaultEditorOwnerSettings( ); - editorSettings.DataType = typeof( DateTime ); - editorSettings.MaskInput=sDateOnlyMask; - r.Cells["FieldValue"].Editor = new DateTimeEditor( new DefaultEditorOwner( editorSettings ) ); - - break; - case FormFieldDataTypes.DateTime: - - // Add an item for editing both date and time. - editorSettings = new DefaultEditorOwnerSettings( ); - editorSettings.DataType = typeof( DateTime ); - editorSettings.MaskInput = sDateTimeMask; - r.Cells["FieldValue"].Editor = new DateTimeEditor( new DefaultEditorOwner( editorSettings ) ); - - break; - case FormFieldDataTypes.Number: - // Add an item for editing doubles. - editorSettings = new DefaultEditorOwnerSettings( ); - editorSettings.DataType = typeof( double ); - r.Cells["FieldValue"].Editor = new EditorWithMask( new DefaultEditorOwner( editorSettings ) ); - break; - case FormFieldDataTypes.Text: - break; - case FormFieldDataTypes.TimeOnly: - // Add an item for editing time. - editorSettings = new DefaultEditorOwnerSettings( ); - editorSettings.DataType = typeof( DateTime ); - editorSettings.MaskInput = sTimeOnlyMask; - r.Cells["FieldValue"].Editor = new EditorWithMask( new DefaultEditorOwner( editorSettings ) ); - - break; - case FormFieldDataTypes.TrueFalse: - // Add an item that uses checkbox. - editorSettings = new DefaultEditorOwnerSettings( ); - editorSettings.DataType = typeof( bool ); - r.Cells["FieldValue"].Editor = new CheckEditor( new DefaultEditorOwner( editorSettings ) ); - break; - - - - } - - - } - - return true; - - - } + //Setup the grid properly + Grid.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn; - /// + DataTable dt = new DataTable(); + //original column value (i.e. "Custom0" "Custom1" etc, won't be visible) + dt.Columns.Add("ID", typeof(string)); + //what type of editor to use, won't be visible + dt.Columns.Add("Editor", typeof(FormFieldDataTypes)); + + //Field name (is visible) + dt.Columns.Add("Field", typeof(string)); + //Field value (is visible and only editable field) + dt.Columns.Add("FieldValue", typeof(object)); + + foreach (ObjectCustomField f in ocf) + { + if (f.Visible) + { + dt.Rows.Add(new object[] { f.FieldName, f.FieldType, LocaleText.GetLocalizedText(sObject + ".Label." + f.FieldName), null }); + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PrepareCustomFieldsGrid: Adding field=" + f.FieldName + ", Type=" + f.FieldType.ToString()+ ",Localized="+LocaleText.GetLocalizedText(sObject+".Label."+f.FieldName) +")"); + + } + else + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PrepareCustomFieldsGrid: Not adding field " + f.FieldName + " (set to invisible)"); + } + } + + + // Set the data source of the grid to the table we created. + Grid.DataSource = dt; + + //Set the editor for each row's custom field to the editor type selected + + Grid.DisplayLayout.Bands[0].Columns["ID"].Hidden = true; + Grid.DisplayLayout.Bands[0].Columns["Editor"].Hidden = true; + Grid.DisplayLayout.Bands[0].Columns["Field"].CellActivation = Activation.NoEdit; + + + //case 1039 //log.Debug("PrepareCustomFieldsGrid: Setting editors for each custom field based on type..."); + + //Pre-compute a date and time editor mask for this current culture + EditorWithMask em = new EditorWithMask(); + + string sDateOnlyMask = em.CalcDefaultDateMask(CultureInfo.CurrentCulture); + string sTimeOnlyMask = em.CalcDefaultTimeMask(CultureInfo.CurrentCulture); + + string sDateTimeMask = sDateOnlyMask + " " + sTimeOnlyMask; + + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PrepareCustomFieldsGrid: CurrentCulture Date/time mask is [" + sDateTimeMask+"]"); + + DefaultEditorOwnerSettings editorSettings = null; + foreach (UltraGridRow r in Grid.Rows) + { + + FormFieldDataTypes ff = (FormFieldDataTypes)r.Cells["Editor"].Value; + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("PrepareCustomFieldsGrid: setting an editor of type " + ff.ToString() + " for field " + r.Cells["Field"]); + switch (ff) + { + case FormFieldDataTypes.Currency: + // Add an item for editing currency. + editorSettings = new DefaultEditorOwnerSettings(); + editorSettings.DataType = typeof(decimal); + r.Cells["FieldValue"].Editor = new EditorWithMask(new DefaultEditorOwner(editorSettings)); + + break; + case FormFieldDataTypes.DateOnly: + // Add an item for editing date. + editorSettings = new DefaultEditorOwnerSettings(); + editorSettings.DataType = typeof(DateTime); + editorSettings.MaskInput = sDateOnlyMask; + r.Cells["FieldValue"].Editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings)); + + break; + case FormFieldDataTypes.DateTime: + + // Add an item for editing both date and time. + editorSettings = new DefaultEditorOwnerSettings(); + editorSettings.DataType = typeof(DateTime); + editorSettings.MaskInput = sDateTimeMask; + r.Cells["FieldValue"].Editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings)); + + break; + case FormFieldDataTypes.Number: + // Add an item for editing doubles. + editorSettings = new DefaultEditorOwnerSettings(); + editorSettings.DataType = typeof(double); + r.Cells["FieldValue"].Editor = new EditorWithMask(new DefaultEditorOwner(editorSettings)); + break; + case FormFieldDataTypes.Text: + break; + case FormFieldDataTypes.TimeOnly: + // Add an item for editing time. + editorSettings = new DefaultEditorOwnerSettings(); + editorSettings.DataType = typeof(DateTime); + editorSettings.MaskInput = sTimeOnlyMask; + r.Cells["FieldValue"].Editor = new EditorWithMask(new DefaultEditorOwner(editorSettings)); + + break; + case FormFieldDataTypes.TrueFalse: + // Add an item that uses checkbox. + editorSettings = new DefaultEditorOwnerSettings(); + editorSettings.DataType = typeof(bool); + r.Cells["FieldValue"].Editor = new CheckEditor(new DefaultEditorOwner(editorSettings)); + break; + + + + } + + + } + + return true; + + + } + + + + + /// /// Set the biz object values from the custom grid fields /// - /// Use reflection to find the custom fields on the custom grid and - /// set their BizObject values to the value in the grid - /// - /// - /// - public static void GridToCustomFields(object BizObject,Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("GridToCustomFields(" + BizObject.ToString() + ", " + Grid.Name+"."+Grid.Parent.Name+")"); - - try - { - foreach(UltraGridRow r in Grid.Rows) - { - //Set the biz objects field from the custom grid - //the "ID" cell contains the string name of which custom property to fill in - //and the "FieldValue" cell contains the actual data to put in that property - //this function uses reflection so it can find and fill the property by variable name - //Note that this could be used for other properties as well, not just the custom ones - //and because it's by name were not restricted to the 10 specific custom properties but can - //add at will - string sData=r.Cells["FieldValue"].Value.ToString(); - if(sData.Length>500) sData=sData.Substring(0,500); - BizObject.GetType().GetProperty(r.Cells["ID"].Value.ToString()).SetValue(BizObject,sData,null); - - } + /// Use reflection to find the custom fields on the custom grid and + /// set their BizObject values to the value in the grid + /// + /// + /// + public static void GridToCustomFields(object BizObject, Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("GridToCustomFields(" + BizObject.ToString() + ", " + Grid.Name+"."+Grid.Parent.Name+")"); - } - catch(NullReferenceException e) - { - log.Error("GridToCustomFields",e); - MessageBox.Show("GridToCustomFields:" + e.Message); - } + try + { + foreach (UltraGridRow r in Grid.Rows) + { + //Set the biz objects field from the custom grid + //the "ID" cell contains the string name of which custom property to fill in + //and the "FieldValue" cell contains the actual data to put in that property + //this function uses reflection so it can find and fill the property by variable name + //Note that this could be used for other properties as well, not just the custom ones + //and because it's by name were not restricted to the 10 specific custom properties but can + //add at will + string sData = r.Cells["FieldValue"].Value.ToString(); + if (sData.Length > 500) sData = sData.Substring(0, 500); + BizObject.GetType().GetProperty(r.Cells["ID"].Value.ToString()).SetValue(BizObject, sData, null); + + } + + } + catch (NullReferenceException e) + { + log.Error("GridToCustomFields", e); + MessageBox.Show("GridToCustomFields:" + e.Message); + } - - - } - - /// - /// Set grid from Custom field values - /// - /// - /// - public static void GridFromCustomFields(object BizObject,Infragistics.Win.UltraWinGrid.UltraGrid Grid) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("GridFromCustomFields(" + BizObject.ToString() + ", " + Grid.Name+"."+Grid.Parent.Name+")"); - - - try - { - DataTable dt=(DataTable)Grid.DataSource; - foreach(DataRow dr in dt.Rows) - {//v3.0.2 change - object o=(object)BizObject.GetType().GetProperty(dr["ID"].ToString()).GetValue(BizObject,null); - if(o==null) o=DBNull.Value; - dr["FieldValue"]=o; - } + } + + /// + /// Set grid from Custom field values + /// + /// + /// + public static void GridFromCustomFields(object BizObject, Infragistics.Win.UltraWinGrid.UltraGrid Grid) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("GridFromCustomFields(" + BizObject.ToString() + ", " + Grid.Name+"."+Grid.Parent.Name+")"); - } - catch(NullReferenceException e) - { - log.Error("GridFromCustomFields",e); - MessageBox.Show("GridFromCustomFields:"+ e.Message); - } + try + { + DataTable dt = (DataTable)Grid.DataSource; + foreach (DataRow dr in dt.Rows) + {//v3.0.2 change + object o = (object)BizObject.GetType().GetProperty(dr["ID"].ToString()).GetValue(BizObject, null); + if (o == null) o = DBNull.Value; + dr["FieldValue"] = o; - } - #endregion - #region Business object editing handler + } + + + } + catch (NullReferenceException e) + { + log.Error("GridFromCustomFields", e); + MessageBox.Show("GridFromCustomFields:" + e.Message); + } + + } + #endregion + + #region Business object editing handler /// /// Stub method to avoid having to re-edit all the existing code for EditRecord callers @@ -3353,7 +3353,7 @@ At first I was happy to find your code that solved my problem, but I did not lik static public bool EditRecord(RootObjectTypes ObjectType, Guid ID) { //call version with optional id as optional id empty - return EditRecord(ObjectType, ID, null); + return EditRecord(ObjectType, ID, null); } //case 227 @@ -3386,13 +3386,13 @@ At first I was happy to find your code that solved my problem, but I did not lik /// /// /// - static public bool EditRecord(RootObjectTypes ObjectType, Guid ID, TypeAndID subTypeIdToOpen=null) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("EditRecord(" + ObjectType.ToString()+", " + ID.ToString()); - //Make sure there is something to edit - if(ID==Guid.Empty) - return false; + static public bool EditRecord(RootObjectTypes ObjectType, Guid ID, TypeAndID subTypeIdToOpen = null) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("EditRecord(" + ObjectType.ToString()+", " + ID.ToString()); + //Make sure there is something to edit + if (ID == Guid.Empty) + return false; //If the special new object ID is used then it's //a flag that the object needs to be created here @@ -3402,400 +3402,376 @@ At first I was happy to find your code that solved my problem, but I did not lik //in their getitem code so there is no special handling below //with the exception of workorders and like objects //that require info to be set on creation or passed to newitem - bool createThenEdit=false; + bool createThenEdit = false; if (ID == AyaBizUtils.NewObjectGuid) createThenEdit = true; - bool bObjectEdited=false; - try - { - - #region switch and open record for editing - //Open the appropriate form for editing... - switch(ObjectType) - { - - case RootObjectTypes.Client: - { - ClientInfoForm f=new ClientInfoForm(); + bool bObjectEdited = false; + try + { + #region switch and open record for editing + //Open the appropriate form for editing... + switch (ObjectType) + { - //case 3823 - if (subTypeIdToOpen != null) { - //for the time being subtype is only going to be a client note so we only need the ID - f.ClientNoteIdToDisplay = subTypeIdToOpen.ID; - } - - Client o=Client.GetItem(ID); - - f.ClientToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - case RootObjectTypes.Contract: - { - ContractInfoForm f=new ContractInfoForm(); - Contract o=Contract.GetItem(ID); - f.ContractToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - case RootObjectTypes.UnitModel: - { - UnitModelInfoForm f=new UnitModelInfoForm(); - UnitModel o=UnitModel.GetItem(ID); - f.UnitModelToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - case RootObjectTypes.Unit: - { - UnitInfoForm f=new UnitInfoForm(); - Unit o=Unit.GetItem(ID); - f.UnitToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - - case RootObjectTypes.HeadOffice: - { - HeadOfficeInfoForm f=new HeadOfficeInfoForm(); - HeadOffice o=HeadOffice.GetItem(ID); - f.HeadOfficeToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.Vendor: - { - VendorInfoForm f=new VendorInfoForm(VendorTypes.All); - Vendor o=Vendor.GetItem(ID); - f.VendorToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.LoanItem: - { - LoanItemInfoForm f = new LoanItemInfoForm(); - f.LoanItemToEdit= LoanItem.GetItem(ID); - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - case RootObjectTypes.Project: - { - ProjectInfoForm f=new ProjectInfoForm(); - Project o=Project.GetItem(ID); - f.ProjectToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - case RootObjectTypes.Part: - { - PartInfoForm f=new PartInfoForm(); - Part o=Part.GetItem(ID); - f.PartToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.PurchaseOrder: - { - PurchaseOrderInfoForm f=new PurchaseOrderInfoForm(); - PurchaseOrder o=PurchaseOrder.GetItem(ID); - f.PurchaseOrderToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - - } - break; - - - case RootObjectTypes.Region: - { - - RegionInfoForm f=new RegionInfoForm(); - GZTW.AyaNova.BLL.Region o=GZTW.AyaNova.BLL.Region.GetItem(ID); - f.RegionToEdit=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - - } - break; - case RootObjectTypes.Workorder: - { - if (AyaBizUtils.Lite)//case 1172 + case RootObjectTypes.Client: { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = Workorder.GetItem(ID); - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); - } - else - { - //Case 677 - WorkorderForm w = GetWorkorderForm(ID); - if (w.WorkorderToEdit == null) + ClientInfoForm f = new ClientInfoForm(); + + + //case 3823 + if (subTypeIdToOpen != null) { - Workorder o = Workorder.GetItem(ID); - w.WorkorderToEdit = o; - w.Visible = false; + //for the time being subtype is only going to be a client note so we only need the ID + f.ClientNoteIdToDisplay = subTypeIdToOpen.ID; } - w.Show(); + + Client o = Client.GetItem(ID); + + f.ClientToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); + break; + case RootObjectTypes.Contract: + { + ContractInfoForm f = new ContractInfoForm(); + Contract o = Contract.GetItem(ID); + f.ContractToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + case RootObjectTypes.UnitModel: + { + UnitModelInfoForm f = new UnitModelInfoForm(); + UnitModel o = UnitModel.GetItem(ID); + f.UnitModelToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + case RootObjectTypes.Unit: + { + UnitInfoForm f = new UnitInfoForm(); + Unit o = Unit.GetItem(ID); + f.UnitToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; - } - break; - case RootObjectTypes.WorkorderItem: - { - - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItem,ID); - if (AyaBizUtils.Lite)//case 1172 + case RootObjectTypes.HeadOffice: { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.GoTo = RootObjectTypes.WorkorderItem; - wfl.GoToWorkorderItemID = ID; - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); + HeadOfficeInfoForm f = new HeadOfficeInfoForm(); + HeadOffice o = HeadOffice.GetItem(ID); + f.HeadOfficeToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); } - else + break; + + case RootObjectTypes.Vendor: { + VendorInfoForm f = new VendorInfoForm(VendorTypes.All); + Vendor o = Vendor.GetItem(ID); + f.VendorToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.LoanItem: + { + LoanItemInfoForm f = new LoanItemInfoForm(); + f.LoanItemToEdit = LoanItem.GetItem(ID); + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + case RootObjectTypes.Project: + { + ProjectInfoForm f = new ProjectInfoForm(); + Project o = Project.GetItem(ID); + f.ProjectToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + case RootObjectTypes.Part: + { + PartInfoForm f = new PartInfoForm(); + Part o = Part.GetItem(ID); + f.PartToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.PurchaseOrder: + { + PurchaseOrderInfoForm f = new PurchaseOrderInfoForm(); + PurchaseOrder o = PurchaseOrder.GetItem(ID); + f.PurchaseOrderToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + + } + break; + + + case RootObjectTypes.Region: + { + + RegionInfoForm f = new RegionInfoForm(); + GZTW.AyaNova.BLL.Region o = GZTW.AyaNova.BLL.Region.GetItem(ID); + f.RegionToEdit = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + + } + break; + case RootObjectTypes.Workorder: + { + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = Workorder.GetItem(ID); + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(ID); + if (w.WorkorderToEdit == null) + { + Workorder o = Workorder.GetItem(ID); + w.WorkorderToEdit = o; + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + + + } + break; + case RootObjectTypes.WorkorderItem: + { + + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItem, ID); + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.GoTo = RootObjectTypes.WorkorderItem; + wfl.GoToWorkorderItemID = ID; + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItem; + w.GoToWorkorderItemID = ID; + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + + } + break; + case RootObjectTypes.WorkorderItemLabor: + { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLabor, ID); + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.GoTo = RootObjectTypes.WorkorderItemLabor; + wfl.GoToWorkorderItemSubItemID = ID; + wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemLabor, ID); + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItemLabor; + w.GoToWorkorderItemSubItemID = ID; + w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemLabor, ID); + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + + } + break; + case RootObjectTypes.WorkorderItemTravel: + { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemTravel, ID); + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.GoTo = RootObjectTypes.WorkorderItemTravel; + wfl.GoToWorkorderItemSubItemID = ID; + wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemTravel, ID); + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItemTravel; + w.GoToWorkorderItemSubItemID = ID; + w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemTravel, ID); + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + + } + break; + case RootObjectTypes.WorkorderItemScheduledUser: + { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemScheduledUser, ID); + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.GoTo = RootObjectTypes.WorkorderItemScheduledUser; + wfl.GoToWorkorderItemSubItemID = ID; + wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemScheduledUser, ID); + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItemScheduledUser; + w.GoToWorkorderItemSubItemID = ID; + w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemScheduledUser, ID); + w.Visible = false; + } + w.Show(); + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + } + + } + break; + case RootObjectTypes.WorkorderItemOutsideService: + { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemOutsideService, ID); + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.GoTo = RootObjectTypes.WorkorderItemOutsideService; + wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemOutsideService, ID); + + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItemOutsideService; + w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemOutsideService, ID); + //w.GoToWorkorderItemSubItemID=ID; + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + + } + break; + case RootObjectTypes.WorkorderPreventiveMaintenance: + { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderPreventiveMaintenance, ID); //Case 677 WorkorderForm w = GetWorkorderForm(o.ID); if (w.WorkorderToEdit == null) { w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItem; - w.GoToWorkorderItemID = ID; - w.Visible = false; - } - w.Show(); - } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; - case RootObjectTypes.WorkorderItemLabor: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLabor,ID); - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.GoTo = RootObjectTypes.WorkorderItemLabor; - wfl.GoToWorkorderItemSubItemID = ID; - wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemLabor, ID); - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); - } - else - { - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) - { - w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItemLabor; - w.GoToWorkorderItemSubItemID = ID; - w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemLabor, ID); - w.Visible = false; - } - w.Show(); - } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; - case RootObjectTypes.WorkorderItemTravel: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemTravel,ID); - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.GoTo = RootObjectTypes.WorkorderItemTravel; - wfl.GoToWorkorderItemSubItemID = ID; - wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemTravel, ID); - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); - } - else - { - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) - { - w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItemTravel; - w.GoToWorkorderItemSubItemID = ID; - w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemTravel, ID); - w.Visible = false; - } - w.Show(); - } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; - case RootObjectTypes.WorkorderItemScheduledUser: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemScheduledUser,ID); - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.GoTo = RootObjectTypes.WorkorderItemScheduledUser; - wfl.GoToWorkorderItemSubItemID = ID; - wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemScheduledUser, ID); - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); - } - else - { - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) - { - w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItemScheduledUser; - w.GoToWorkorderItemSubItemID = ID; - w.GoToWorkorderItemID =o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemScheduledUser, ID) ; + //w.GoTo=RootObjectTypes.WorkorderItemOutsideService; + //w.GoToWorkorderItemID=o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemOutsideService,ID); + //w.GoToWorkorderItemSubItemID=ID; w.Visible = false; } w.Show(); //bObjectEdited=w.ChangesMade; //w.Dispose(); - } - } - break; - case RootObjectTypes.WorkorderItemOutsideService: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemOutsideService,ID); - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.GoTo = RootObjectTypes.WorkorderItemOutsideService; - wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemOutsideService, ID); - - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); } - else - { - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) - { - w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItemOutsideService; - w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemOutsideService, ID); - //w.GoToWorkorderItemSubItemID=ID; - w.Visible = false; - } - w.Show(); - } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; - case RootObjectTypes.WorkorderPreventiveMaintenance: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderPreventiveMaintenance,ID); - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) - { - w.WorkorderToEdit = o; - //w.GoTo=RootObjectTypes.WorkorderItemOutsideService; - //w.GoToWorkorderItemID=o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemOutsideService,ID); - //w.GoToWorkorderItemSubItemID=ID; - w.Visible = false; - } - w.Show(); - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; - case RootObjectTypes.WorkorderQuote: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderQuote,ID); - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) - { - w.WorkorderToEdit = o; - w.Visible = false; - } - w.Show(); - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; - case RootObjectTypes.WorkorderService: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderService,ID); - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.ShowDialog(); - wfl.Dispose(); - } - else + break; + case RootObjectTypes.WorkorderQuote: { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderQuote, ID); //Case 677 WorkorderForm w = GetWorkorderForm(o.ID); if (w.WorkorderToEdit == null) @@ -3804,46 +3780,71 @@ At first I was happy to find your code that solved my problem, but I did not lik w.Visible = false; } w.Show(); - } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); + //bObjectEdited=w.ChangesMade; + //w.Dispose(); - } - break; - case RootObjectTypes.WorkorderItemPartRequest: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPartRequest,ID); - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = o; - wfl.GoTo = RootObjectTypes.WorkorderItemPartRequest; - wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemPartRequest, ID); - - wfl.ShowDialog(); - bObjectEdited = wfl.ChangesMade; - wfl.Dispose(); } - else + break; + case RootObjectTypes.WorkorderService: { - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderService, ID); + if (AyaBizUtils.Lite)//case 1172 { - w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItemPartRequest; - w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemPartRequest, ID); - //w.GoToWorkorderItemSubItemID=ID; - w.Visible = false; + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.ShowDialog(); + wfl.Dispose(); } - w.Show(); - } - //bObjectEdited=w.ChangesMade; - //w.Dispose(); + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); - } - break; - //Changed: 16-June-2006 Added this + } + break; + case RootObjectTypes.WorkorderItemPartRequest: + { + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPartRequest, ID); + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = o; + wfl.GoTo = RootObjectTypes.WorkorderItemPartRequest; + wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemPartRequest, ID); + + wfl.ShowDialog(); + bObjectEdited = wfl.ChangesMade; + wfl.Dispose(); + } + else + { + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItemPartRequest; + w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemPartRequest, ID); + //w.GoToWorkorderItemSubItemID=ID; + w.Visible = false; + } + w.Show(); + } + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + + } + break; + //Changed: 16-June-2006 Added this case RootObjectTypes.WorkorderItemPart: { Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPart, ID); @@ -3877,296 +3878,296 @@ At first I was happy to find your code that solved my problem, but I did not lik } break; - case RootObjectTypes.WorkorderItemLoan: - { - Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLoan,ID); - //Case 677 - WorkorderForm w = GetWorkorderForm(o.ID); - if (w.WorkorderToEdit == null) + case RootObjectTypes.WorkorderItemLoan: { - w.WorkorderToEdit = o; - w.GoTo = RootObjectTypes.WorkorderItemLoan; - w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemLoan, ID); - //w.GoToWorkorderItemSubItemID=ID; - w.Visible = false; + Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLoan, ID); + //Case 677 + WorkorderForm w = GetWorkorderForm(o.ID); + if (w.WorkorderToEdit == null) + { + w.WorkorderToEdit = o; + w.GoTo = RootObjectTypes.WorkorderItemLoan; + w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemLoan, ID); + //w.GoToWorkorderItemSubItemID=ID; + w.Visible = false; + } + w.Show(); + //bObjectEdited=w.ChangesMade; + //w.Dispose(); + } - w.Show(); - //bObjectEdited=w.ChangesMade; - //w.Dispose(); - - } - break; + break; - case RootObjectTypes.TaxCode: - { - TaxCodesForm f=new TaxCodesForm(); - f.SelectedRecordID=ID; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - //Generic forms - - case RootObjectTypes.ClientGroup: - { - GenericListForm f=new GenericListForm(); - ClientGroups o=ClientGroups.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.DispatchZone: - { - GenericListForm f=new GenericListForm(); - DispatchZones o=DispatchZones.GetItems(true); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - - case RootObjectTypes.PartCategory: - { - GenericListForm f=new GenericListForm(); - PartCategories o=PartCategories.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.UnitOfMeasure: - { - GenericListForm f=new GenericListForm(); - UnitOfMeasures o=UnitOfMeasures.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - case RootObjectTypes.PartAssembly: - { - GenericListForm f=new GenericListForm(); - PartAssemblies o=PartAssemblies.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.PartWarehouse: - { - GenericListForm f=new GenericListForm(); - PartWarehouses o=PartWarehouses.GetItems(true); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - case RootObjectTypes.UnitModelCategory: - { - GenericListForm f=new GenericListForm(); - UnitModelCategories o=UnitModelCategories.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - case RootObjectTypes.WorkorderItemType: - { - GenericListForm f=new GenericListForm(); - WorkorderItemTypes o=WorkorderItemTypes.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - case RootObjectTypes.WorkorderCategory: - { - GenericListForm f=new GenericListForm(); - WorkorderCategories o=WorkorderCategories.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - - - case RootObjectTypes.WorkorderStatus: - { - GenericListForm f=new GenericListForm(); - WorkorderStatuses o=WorkorderStatuses.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - case RootObjectTypes.Priority: - { - GenericListForm f=new GenericListForm(); - Priorities o=Priorities.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - case RootObjectTypes.UserSkill: - { - GenericListForm f=new GenericListForm(); - UserSkills o=UserSkills.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - case RootObjectTypes.UserCertification: - { - GenericListForm f=new GenericListForm(); - UserCertifications o=UserCertifications.GetItems(); - f.SelectedRecordID=ID; - f.GridDataSource=o; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - - } - break; - - - case RootObjectTypes.PartInventoryAdjustment: - { - //always view only (true in constructor) - PartInventoryAdjustmentInfoForm f = new PartInventoryAdjustmentInfoForm(!createThenEdit); - PartInventoryAdjustment o=PartInventoryAdjustment.GetItem(ID); - f.PartInventoryAdjustmentToEdit=o; - - f.ShowDialog(); - bObjectEdited = createThenEdit; - f.Dispose(); - - } - break; - - case RootObjectTypes.User: - { - UserInfoForm f=new UserInfoForm(); - User u=User.GetItem(ID); - f.UserToEdit=u; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.SecurityGroup: - { - SecurityGroupInfoForm f=new SecurityGroupInfoForm(); - SecurityGroup u=SecurityGroup.GetItem(ID); - f.SecurityGroupToEdit=u; - f.Visible=false; - f.ShowDialog(); - bObjectEdited=f.ChangesMade; - f.Dispose(); - } - break; - - case RootObjectTypes.Memo: - { - if (createThenEdit) + case RootObjectTypes.TaxCode: { - MemoComposerForm mcf = new MemoComposerForm(); - mcf.MemoToEdit = GZTW.AyaNova.BLL.Memo.NewItem(); - mcf.Visible = false; - mcf.ShowDialog(); - mcf.Dispose(); - bObjectEdited = true; + TaxCodesForm f = new TaxCodesForm(); + f.SelectedRecordID = ID; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); } - else - { - //Case 136 - added current user language bit - MemoFetcher memo = MemoFetcher.GetItem(ID,User.CurrentUserLanguage); - MemoReaderForm mrf = new MemoReaderForm(); - mrf.MemoToRead = memo; - mrf.ShowDialog(); - bObjectEdited = mrf.ChangesMade;//case 1880 - mrf.Dispose(); - - } - - } - break; + break; - case RootObjectTypes.Report: - { - Report r = Report.GetItem(ID); - ReportInfoForm rif = new ReportInfoForm(); - rif.ReportToEdit=r; - rif.Visible=false; - rif.ShowDialog(); - bObjectEdited=rif.ChangesMade; - rif.Dispose(); - - } - break; + //Generic forms + + case RootObjectTypes.ClientGroup: + { + GenericListForm f = new GenericListForm(); + ClientGroups o = ClientGroups.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.DispatchZone: + { + GenericListForm f = new GenericListForm(); + DispatchZones o = DispatchZones.GetItems(true); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + + case RootObjectTypes.PartCategory: + { + GenericListForm f = new GenericListForm(); + PartCategories o = PartCategories.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.UnitOfMeasure: + { + GenericListForm f = new GenericListForm(); + UnitOfMeasures o = UnitOfMeasures.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + case RootObjectTypes.PartAssembly: + { + GenericListForm f = new GenericListForm(); + PartAssemblies o = PartAssemblies.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.PartWarehouse: + { + GenericListForm f = new GenericListForm(); + PartWarehouses o = PartWarehouses.GetItems(true); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + case RootObjectTypes.UnitModelCategory: + { + GenericListForm f = new GenericListForm(); + UnitModelCategories o = UnitModelCategories.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + case RootObjectTypes.WorkorderItemType: + { + GenericListForm f = new GenericListForm(); + WorkorderItemTypes o = WorkorderItemTypes.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + case RootObjectTypes.WorkorderCategory: + { + GenericListForm f = new GenericListForm(); + WorkorderCategories o = WorkorderCategories.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + + + case RootObjectTypes.WorkorderStatus: + { + GenericListForm f = new GenericListForm(); + WorkorderStatuses o = WorkorderStatuses.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + case RootObjectTypes.Priority: + { + GenericListForm f = new GenericListForm(); + Priorities o = Priorities.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + case RootObjectTypes.UserSkill: + { + GenericListForm f = new GenericListForm(); + UserSkills o = UserSkills.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + case RootObjectTypes.UserCertification: + { + GenericListForm f = new GenericListForm(); + UserCertifications o = UserCertifications.GetItems(); + f.SelectedRecordID = ID; + f.GridDataSource = o; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + + } + break; + + + case RootObjectTypes.PartInventoryAdjustment: + { + //always view only (true in constructor) + PartInventoryAdjustmentInfoForm f = new PartInventoryAdjustmentInfoForm(!createThenEdit); + PartInventoryAdjustment o = PartInventoryAdjustment.GetItem(ID); + f.PartInventoryAdjustmentToEdit = o; + + f.ShowDialog(); + bObjectEdited = createThenEdit; + f.Dispose(); + + } + break; + + case RootObjectTypes.User: + { + UserInfoForm f = new UserInfoForm(); + User u = User.GetItem(ID); + f.UserToEdit = u; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.SecurityGroup: + { + SecurityGroupInfoForm f = new SecurityGroupInfoForm(); + SecurityGroup u = SecurityGroup.GetItem(ID); + f.SecurityGroupToEdit = u; + f.Visible = false; + f.ShowDialog(); + bObjectEdited = f.ChangesMade; + f.Dispose(); + } + break; + + case RootObjectTypes.Memo: + { + if (createThenEdit) + { + MemoComposerForm mcf = new MemoComposerForm(); + mcf.MemoToEdit = GZTW.AyaNova.BLL.Memo.NewItem(); + mcf.Visible = false; + mcf.ShowDialog(); + mcf.Dispose(); + bObjectEdited = true; + } + else + { + //Case 136 - added current user language bit + MemoFetcher memo = MemoFetcher.GetItem(ID, User.CurrentUserLanguage); + MemoReaderForm mrf = new MemoReaderForm(); + mrf.MemoToRead = memo; + mrf.ShowDialog(); + bObjectEdited = mrf.ChangesMade;//case 1880 + mrf.Dispose(); + + } + + } + break; + + case RootObjectTypes.Report: + { + Report r = Report.GetItem(ID); + ReportInfoForm rif = new ReportInfoForm(); + rif.ReportToEdit = r; + rif.Visible = false; + rif.ShowDialog(); + bObjectEdited = rif.ChangesMade; + rif.Dispose(); + + } + break; case RootObjectTypes.PurchaseOrderReceiptItem: { @@ -4180,7 +4181,7 @@ At first I was happy to find your code that solved my problem, but I did not lik } break; - //Added:4-Sept-2006 + //Added:4-Sept-2006 case RootObjectTypes.ServiceBank: { ServiceBank s = ServiceBank.GetItem(ID); @@ -4202,7 +4203,7 @@ At first I was happy to find your code that solved my problem, but I did not lik ScheduleMarkerForm f = new ScheduleMarkerForm(); f.ScheduleMarkerToEdit = s; //f.AppointmentToEdit=mActiveCalendarAppointment; - // f.Info = ultraCalendarInfo1; + // f.Info = ultraCalendarInfo1; f.ShowDialog(); bObjectEdited = f.ChangesMade; f.Dispose(); @@ -4211,13 +4212,13 @@ At first I was happy to find your code that solved my problem, but I did not lik break; - //Added: 2-Oct-2006 + //Added: 2-Oct-2006 case RootObjectTypes.Rate: { RatesForm f = new RatesForm(); Rates o = Rates.GetItems(true); f.SelectedRecordID = ID; - + f.Visible = false; f.ShowDialog(); bObjectEdited = f.ChangesMade; @@ -4294,7 +4295,7 @@ At first I was happy to find your code that solved my problem, but I did not lik { ScheduleableUserGroup s = ScheduleableUserGroup.GetItem(ID); ScheduleableUserGroupsForm f = new ScheduleableUserGroupsForm(); - f.ScheduleableUserGroupToEdit = s; + f.ScheduleableUserGroupToEdit = s; f.ShowDialog(); bObjectEdited = f.ChangesMade; f.Dispose(); @@ -4315,7 +4316,7 @@ At first I was happy to find your code that solved my problem, but I did not lik } break; - //Added:11-Nov-2006 + //Added:11-Nov-2006 case RootObjectTypes.ClientServiceRequest: { ClientServiceRequestInfoForm f = new ClientServiceRequestInfoForm(); @@ -4328,7 +4329,7 @@ At first I was happy to find your code that solved my problem, but I did not lik } break; - //case 750 + //case 750 case RootObjectTypes.WorkorderServiceTemplate: { Workorder o = Workorder.GetItem(ID); @@ -4340,14 +4341,14 @@ At first I was happy to find your code that solved my problem, but I did not lik w.WorkorderToEdit = o; w.Visible = false; } - w.Show(); + w.Show(); } break; //case 750 case RootObjectTypes.WorkorderQuoteTemplate: { - // Workorder o = Workorder.GetItem(ID); + // Workorder o = Workorder.GetItem(ID); Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderQuote, ID); //Case 677 WorkorderForm w = GetWorkorderForm(o.ID); @@ -4375,11 +4376,11 @@ At first I was happy to find your code that solved my problem, but I did not lik w.Show(); } break; - //case 73 + //case 73 case RootObjectTypes.AyaFile: { - AyaFileList l=AyaFileList.GetListOfOne(ID); - if(l.Count==0) return false; + AyaFileList l = AyaFileList.GetListOfOne(ID); + if (l.Count == 0) return false; AyaFileList.AyaFileListInfo i = l[0]; WikiFileOpenSave d = new WikiFileOpenSave(i); @@ -4409,7 +4410,7 @@ At first I was happy to find your code that solved my problem, but I did not lik } } break; - //case 73 + //case 73 case RootObjectTypes.WikiPage: { Cursor.Current = Cursors.WaitCursor; @@ -4419,28 +4420,28 @@ At first I was happy to find your code that solved my problem, but I did not lik wi.Show(); } break; - default: - { - log.Error("MISSING: editor for - " + ObjectType.ToString()); - throw new System.ApplicationException("MISSING: editor for - " + ObjectType.ToString()) ; - } - - } - #endregion switch and open item for editing - } - catch(Exception ex) - { - if(ex.InnerException!=null) - ex=ex.InnerException; - if(ex is FetchException) - { - - MessageBox.Show(ex.Message,"",MessageBoxButtons.OK,MessageBoxIcon.Information); - - log.Warn("Edit record fetch exception "+ObjectType.ToString() + ", " + ID.ToString(),ex); - return false ; - } - //Added: 31-Aug-2006 so user doesn't get harsh exception when attempting to open an item that they don't have rights to + default: + { + log.Error("MISSING: editor for - " + ObjectType.ToString()); + throw new System.ApplicationException("MISSING: editor for - " + ObjectType.ToString()); + } + + } + #endregion switch and open item for editing + } + catch (Exception ex) + { + if (ex.InnerException != null) + ex = ex.InnerException; + if (ex is FetchException) + { + + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information); + + log.Warn("Edit record fetch exception " + ObjectType.ToString() + ", " + ID.ToString(), ex); + return false; + } + //Added: 31-Aug-2006 so user doesn't get harsh exception when attempting to open an item that they don't have rights to else if (ex is System.Security.SecurityException) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -4448,92 +4449,92 @@ At first I was happy to find your code that solved my problem, but I did not lik return false; } else - throw; - } - - //if(bObjectEdited) - //case 1039 //log.Debug("EditRecord: Object *Was* edited"); - //else - //case 1039 //log.Debug("EditRecord: Object was *NOT* edited"); - return bObjectEdited; - } + throw; + } - - + //if(bObjectEdited) + //case 1039 //log.Debug("EditRecord: Object *Was* edited"); + //else + //case 1039 //log.Debug("EditRecord: Object was *NOT* edited"); + return bObjectEdited; + } - - #endregion - #region Grid broken rules display - /// - /// If the current row's underlying list object - /// has broken rules, then show a broken rule error icon in the row selector - /// - /// - static public void GridShowBrokenRulesErrorIcons(Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) - { - //removed item below, too wordy in log - ////case 1039 //log.Debug("GridShowBrokenRulesErrorIcons"); - if(e.Row.ListObject != null) - { - //If it's not valid (has broken rules) then - //put an error icon in the row selector - //otherwise clear any previous one that might be there - if(!((CSLA.BusinessBase)e.Row.ListObject).IsValid) - e.Row.RowSelectorAppearance.Image=BrokenRuleErrorImage; - else - e.Row.RowSelectorAppearance.Image=null; - } - } + #endregion - /// - /// Show tool tip containing all broken rules if mouse over a - /// broken rule icon in the row selector - /// - /// - /// - static public void GridShowBrokenRulesToolTip(Infragistics.Win.UIElementEventArgs e, System.Windows.Forms.ToolTip tipError) - { //too wordy to include this - ////case 1039 //log.Debug("GridShowBrokenRulesToolTip"); - tipError.RemoveAll(); - if(e.Element is RowSelectorUIElement) - { - RowSelectorUIElement UIElement=(RowSelectorUIElement)e.Element; + #region Grid broken rules display - if(UIElement.Row.ListObject !=null) - { - //If it's not valid (has broken rules) then - //put an error icon in the row selector - //otherwise clear any previous one that might be there - if(!((CSLA.BusinessBase)UIElement.Row.ListObject).IsValid) - { - tipError.InitialDelay=0; - StringBuilder sbLocalizedBrokenRules=new StringBuilder(); -// - //Because there could be more than one broken rule in the collection - //we need to first split them out as they come with the pipe character separating each - //broken rule which in turn is a comma delimited array suitable for the - //BrokenRuleLocalizer method to work with - string[] rulesarray=((CSLA.BusinessBase)UIElement.Row.ListObject).BrokenRulesText.Split('|'); - foreach(string PreLocalizedSingleBrokenRule in rulesarray) - { - sbLocalizedBrokenRules.Append(BrokenRuleLocalizer(PreLocalizedSingleBrokenRule)); - } - tipError.SetToolTip(UIElement.Control,sbLocalizedBrokenRules.ToString()); - - - //Originally... - //tipError.SetToolTip(UIElement.Control,((CSLA.BusinessBase)UIElement.Row.ListObject).BrokenRulesText); - - } - } - } - } + /// + /// If the current row's underlying list object + /// has broken rules, then show a broken rule error icon in the row selector + /// + /// + static public void GridShowBrokenRulesErrorIcons(Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) + { + //removed item below, too wordy in log + ////case 1039 //log.Debug("GridShowBrokenRulesErrorIcons"); + if (e.Row.ListObject != null) + { + //If it's not valid (has broken rules) then + //put an error icon in the row selector + //otherwise clear any previous one that might be there + if (!((CSLA.BusinessBase)e.Row.ListObject).IsValid) + e.Row.RowSelectorAppearance.Image = BrokenRuleErrorImage; + else + e.Row.RowSelectorAppearance.Image = null; - #endregion + } + + } + + /// + /// Show tool tip containing all broken rules if mouse over a + /// broken rule icon in the row selector + /// + /// + /// + static public void GridShowBrokenRulesToolTip(Infragistics.Win.UIElementEventArgs e, System.Windows.Forms.ToolTip tipError) + { //too wordy to include this + ////case 1039 //log.Debug("GridShowBrokenRulesToolTip"); + tipError.RemoveAll(); + if (e.Element is RowSelectorUIElement) + { + RowSelectorUIElement UIElement = (RowSelectorUIElement)e.Element; + + if (UIElement.Row.ListObject != null) + { + //If it's not valid (has broken rules) then + //put an error icon in the row selector + //otherwise clear any previous one that might be there + if (!((CSLA.BusinessBase)UIElement.Row.ListObject).IsValid) + { + tipError.InitialDelay = 0; + StringBuilder sbLocalizedBrokenRules = new StringBuilder(); + // + //Because there could be more than one broken rule in the collection + //we need to first split them out as they come with the pipe character separating each + //broken rule which in turn is a comma delimited array suitable for the + //BrokenRuleLocalizer method to work with + string[] rulesarray = ((CSLA.BusinessBase)UIElement.Row.ListObject).BrokenRulesText.Split('|'); + foreach (string PreLocalizedSingleBrokenRule in rulesarray) + { + sbLocalizedBrokenRules.Append(BrokenRuleLocalizer(PreLocalizedSingleBrokenRule)); + } + tipError.SetToolTip(UIElement.Control, sbLocalizedBrokenRules.ToString()); + + + //Originally... + //tipError.SetToolTip(UIElement.Control,((CSLA.BusinessBase)UIElement.Row.ListObject).BrokenRulesText); + + } + } + } + } + + #endregion #region Menu helpers /// @@ -4546,7 +4547,7 @@ At first I was happy to find your code that solved my problem, but I did not lik {//Part of case 918 to refactor out duplicate code in many info forms t.BeginUpdate(); - + if (!HasDocs) { t.Tools["LT:AssignedDoc.Label.List"].SharedProps.AppearancesLarge.Appearance.Image = Util.ImageIncomplete(Resource1.Documents32); @@ -4562,77 +4563,77 @@ At first I was happy to find your code that solved my problem, but I did not lik t.EndUpdate(); } #endregion - + #region Icons and Priority flags /// - /// Give an ARGB value, returns a flag bitmpa in that color - /// - /// - /// - static public Bitmap Flag(int ARGB) - { + /// Give an ARGB value, returns a flag bitmpa in that color + /// + /// + /// + static public Bitmap Flag(int ARGB) + { - //starting image (all black flag) + //starting image (all black flag) Bitmap flag = Resource1.FlagBlack16; - Color NewColor=Color.FromArgb(ARGB); - - //Skip some work if they want an all black flag... - if(NewColor==Color.Black) - return flag; + Color NewColor = Color.FromArgb(ARGB); - int width = flag.Width; - int height = flag.Height; + //Skip some work if they want an all black flag... + if (NewColor == Color.Black) + return flag; - int i, j; - for (i = 0; i< width; i++) - { - for (j=0; j -// /// Gets icon image from assembly -// /// -// /// -// /// -// static public Bitmap Image(string ImageName) -// { -//// //case 1039 //if(log.IsDebugEnabled) -//// //case 1039 //log.Debug("Image(" + ImageName + ")"); -// //string [] s=Assembly.GetExecutingAssembly().GetManifestResourceNames(); -// return new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("AyaNova."+ImageName)); -// } + // /// + // /// Gets icon image from assembly + // /// + // /// + // /// + // static public Bitmap Image(string ImageName) + // { + //// //case 1039 //if(log.IsDebugEnabled) + //// //case 1039 //log.Debug("Image(" + ImageName + ")"); + // //string [] s=Assembly.GetExecutingAssembly().GetManifestResourceNames(); + // return new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("AyaNova."+ImageName)); + // } -// /// -// ///DEPRECATED. REMOVE ONCE CASE 918 has been completed -// /// -// /// -// /// -// static public Bitmap ImageIncomplete(string ImageName) -// { -// Bitmap b=new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("AyaNova."+ImageName)); -// Graphics g = Graphics.FromImage(b); -// Pen p = new Pen(Color.FromArgb(128,255,255,255),5); -// g.DrawLine(p,0,0,b.Width,b.Height); -// return b; -// } + // /// + // ///DEPRECATED. REMOVE ONCE CASE 918 has been completed + // /// + // /// + // /// + // static public Bitmap ImageIncomplete(string ImageName) + // { + // Bitmap b=new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("AyaNova."+ImageName)); + // Graphics g = Graphics.FromImage(b); + // Pen p = new Pen(Color.FromArgb(128,255,255,255),5); + // g.DrawLine(p,0,0,b.Width,b.Height); + // return b; + // } /// /// Returns bitmap with line drawn through it to indicate incompleteness @@ -4685,78 +4686,78 @@ At first I was happy to find your code that solved my problem, but I did not lik g.Dispose(); return newBitmap; } - #endregion + #endregion - #region Form access restrictions helpers - - /// - /// Set all form controls to read only or read/write - /// - /// - /// - /// Parent control - /// Don't allow delete on grids - static public void SetAccess(bool ReadOnly, Control c, bool bNoDelete) - { -// //case 1039 //if(log.IsDebugEnabled) -// //case 1039 //log.Debug("SetAccess(Readonly=" +ReadOnly.ToString()+", Host Control=" + c.Name+", GridNoDelete=" + bNoDelete.ToString()+")"); -// - //Loop through the controls - //Setting access as required for each type of control - foreach(Control c2 in c.Controls) - { - //If it's a panel then need to recurse into it - if(c2 is Panel) - {SetAccess(ReadOnly,c2,bNoDelete); continue;} + #region Form access restrictions helpers - if(c2 is Infragistics.Win.UltraWinEditors.UltraTextEditor) - {((Infragistics.Win.UltraWinEditors.UltraTextEditor)c2).ReadOnly=ReadOnly;continue;} + /// + /// Set all form controls to read only or read/write + /// + /// + /// + /// Parent control + /// Don't allow delete on grids + static public void SetAccess(bool ReadOnly, Control c, bool bNoDelete) + { + // //case 1039 //if(log.IsDebugEnabled) + // //case 1039 //log.Debug("SetAccess(Readonly=" +ReadOnly.ToString()+", Host Control=" + c.Name+", GridNoDelete=" + bNoDelete.ToString()+")"); + // + //Loop through the controls + //Setting access as required for each type of control + foreach (Control c2 in c.Controls) + { + //If it's a panel then need to recurse into it + if (c2 is Panel) + { SetAccess(ReadOnly, c2, bNoDelete); continue; } - if(c2 is Infragistics.Win.UltraWinEditors.UltraCurrencyEditor) - {((Infragistics.Win.UltraWinEditors.UltraCurrencyEditor)c2).ReadOnly=ReadOnly;continue;} + if (c2 is Infragistics.Win.UltraWinEditors.UltraTextEditor) + { ((Infragistics.Win.UltraWinEditors.UltraTextEditor)c2).ReadOnly = ReadOnly; continue; } + + if (c2 is Infragistics.Win.UltraWinEditors.UltraCurrencyEditor) + { ((Infragistics.Win.UltraWinEditors.UltraCurrencyEditor)c2).ReadOnly = ReadOnly; continue; } if (c2 is GZTW.WinForm.Controls.GZDateTimePicker) { ((GZTW.WinForm.Controls.GZDateTimePicker)c2).GZReadOnly = ReadOnly; continue; } - if(c2 is Infragistics.Win.UltraWinEditors.UltraComboEditor) - {((Infragistics.Win.UltraWinEditors.UltraComboEditor)c2).ReadOnly=ReadOnly;continue;} + if (c2 is Infragistics.Win.UltraWinEditors.UltraComboEditor) + { ((Infragistics.Win.UltraWinEditors.UltraComboEditor)c2).ReadOnly = ReadOnly; continue; } - if(c2 is Infragistics.Win.UltraWinEditors.UltraCheckEditor) - {((Infragistics.Win.UltraWinEditors.UltraCheckEditor)c2).Enabled=!ReadOnly;continue;} + if (c2 is Infragistics.Win.UltraWinEditors.UltraCheckEditor) + { ((Infragistics.Win.UltraWinEditors.UltraCheckEditor)c2).Enabled = !ReadOnly; continue; } - if(c2 is Infragistics.Win.UltraWinGrid.UltraGrid) - { - Infragistics.Win.UltraWinGrid.UltraGrid Grid=(Infragistics.Win.UltraWinGrid.UltraGrid)c2; + if (c2 is Infragistics.Win.UltraWinGrid.UltraGrid) + { + Infragistics.Win.UltraWinGrid.UltraGrid Grid = (Infragistics.Win.UltraWinGrid.UltraGrid)c2; - if(ReadOnly) - { - Grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.No; - Grid.DisplayLayout.Override.AllowDelete=DefaultableBoolean.False; - Grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.False; - } - else - { - if(Grid.Name!="gridCustom") - { - Grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.TemplateOnBottom; - - if(!bNoDelete) - Grid.DisplayLayout.Override.AllowDelete=DefaultableBoolean.True; - else - Grid.DisplayLayout.Override.AllowDelete=DefaultableBoolean.False; - } - Grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.True; - + if (ReadOnly) + { + Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.No; + Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False; + Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False; + } + else + { + if (Grid.Name != "gridCustom") + { + Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom; + + if (!bNoDelete) + Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.True; + else + Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False; + } + Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True; - } - - } + } - } - } + } + + } + + } ///// @@ -4816,180 +4817,180 @@ At first I was happy to find your code that solved my problem, but I did not lik } - + } - #endregion + #endregion - #region Object right click popup menu and handler - static public bool DisplayObjectContextMenu(RootObjectTypes ObjectType, Guid ID, System.Windows.Forms.Control InsideForm) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("DisplayObjectContextMenu(RootObjectType=" + ObjectType.ToString()+", ID=" + ID.ToString()+"Insideform=" + InsideForm.Name+")"); + #region Object right click popup menu and handler + static public bool DisplayObjectContextMenu(RootObjectTypes ObjectType, Guid ID, System.Windows.Forms.Control InsideForm) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("DisplayObjectContextMenu(RootObjectType=" + ObjectType.ToString()+", ID=" + ID.ToString()+"Insideform=" + InsideForm.Name+")"); if (ID == Guid.Empty) return false; //create manager - UltraToolbarsManager tbManager = new UltraToolbarsManager(); - tbManager.DockWithinContainer=InsideForm; - tbManager.UseLargeImagesOnMenu=true; - - //create popup - PopupMenuTool pop = new PopupMenuTool("POPKEY"); - - //add to tbmanager - tbManager.Tools.Add(pop); + UltraToolbarsManager tbManager = new UltraToolbarsManager(); + tbManager.DockWithinContainer = InsideForm; + tbManager.UseLargeImagesOnMenu = true; - + //create popup + PopupMenuTool pop = new PopupMenuTool("POPKEY"); - switch(ObjectType) - { + //add to tbmanager + tbManager.Tools.Add(pop); - case RootObjectTypes.Client: - { - //add some "flash" - pop.Settings.SideStripText = LocaleText.GetLocalizedText("O.Client"); - pop.Settings.SideStripWidth = 12; - pop.Settings.IsSideStripVisible = DefaultableBoolean.True; - - ButtonTool b1 = new ButtonTool("NEW_WO"); - b1.SharedProps.AppearancesLarge.Appearance.Image = Resource1.ServiceWorkorder32; - b1.SharedProps.Caption=LocaleText.GetLocalizedText("O.WorkorderService"); - b1.SharedProps.Tag=new TypeAndID(ObjectType,ID); - - ButtonTool b2 = new ButtonTool("NEW_QUOTE"); - b2.SharedProps.AppearancesLarge.Appearance.Image = Resource1.Quote32; - b2.SharedProps.Caption=LocaleText.GetLocalizedText("O.WorkorderQuote"); - b2.SharedProps.Tag=new TypeAndID(ObjectType,ID); - ButtonTool b3 = new ButtonTool("NEW_PM"); - b3.SharedProps.AppearancesLarge.Appearance.Image = Resource1.PreventiveMaintenance32; - b3.SharedProps.Caption=LocaleText.GetLocalizedText("O.WorkorderPreventiveMaintenance"); - b3.SharedProps.Tag=new TypeAndID(ObjectType,ID); + switch (ObjectType) + { - //Case 284 - ButtonTool b4 = new ButtonTool("NEW_NOTE"); - b4.SharedProps.AppearancesLarge.Appearance.Image = Resource1.ClientNotes32; - b4.SharedProps.Caption = LocaleText.GetLocalizedText("O.ClientNote"); - b4.SharedProps.Tag = new TypeAndID(ObjectType, ID); - - //Case 534 - ButtonTool b5 = new ButtonTool("VIEW_WOLIST"); - b5.SharedProps.Caption = LocaleText.GetLocalizedText("Workorder.Label.ListAll"); - b5.SharedProps.Tag = new TypeAndID(ObjectType, ID); - - tbManager.Tools.Add(b1); - if (!AyaBizUtils.Lite) + case RootObjectTypes.Client: { - tbManager.Tools.Add(b2); - tbManager.Tools.Add(b3); - } - //Case 284 - tbManager.Tools.Add(b4); + //add some "flash" + pop.Settings.SideStripText = LocaleText.GetLocalizedText("O.Client"); + pop.Settings.SideStripWidth = 12; + pop.Settings.IsSideStripVisible = DefaultableBoolean.True; + + ButtonTool b1 = new ButtonTool("NEW_WO"); + b1.SharedProps.AppearancesLarge.Appearance.Image = Resource1.ServiceWorkorder32; + b1.SharedProps.Caption = LocaleText.GetLocalizedText("O.WorkorderService"); + b1.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + + ButtonTool b2 = new ButtonTool("NEW_QUOTE"); + b2.SharedProps.AppearancesLarge.Appearance.Image = Resource1.Quote32; + b2.SharedProps.Caption = LocaleText.GetLocalizedText("O.WorkorderQuote"); + b2.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + ButtonTool b3 = new ButtonTool("NEW_PM"); + b3.SharedProps.AppearancesLarge.Appearance.Image = Resource1.PreventiveMaintenance32; + b3.SharedProps.Caption = LocaleText.GetLocalizedText("O.WorkorderPreventiveMaintenance"); + b3.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + //Case 284 + ButtonTool b4 = new ButtonTool("NEW_NOTE"); + b4.SharedProps.AppearancesLarge.Appearance.Image = Resource1.ClientNotes32; + b4.SharedProps.Caption = LocaleText.GetLocalizedText("O.ClientNote"); + b4.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + //Case 534 + ButtonTool b5 = new ButtonTool("VIEW_WOLIST"); + b5.SharedProps.Caption = LocaleText.GetLocalizedText("Workorder.Label.ListAll"); + b5.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + tbManager.Tools.Add(b1); + if (!AyaBizUtils.Lite) + { + tbManager.Tools.Add(b2); + tbManager.Tools.Add(b3); + } + //Case 284 + tbManager.Tools.Add(b4); + + //Case 534 - //Case 534 - tbManager.Tools.Add(b5); - pop.Tools.AddTool("NEW_WO"); - if (!AyaBizUtils.Lite) pop.Tools.AddTool("NEW_QUOTE"); - if (!AyaBizUtils.Lite) pop.Tools.AddTool("NEW_PM"); + pop.Tools.AddTool("NEW_WO"); + if (!AyaBizUtils.Lite) pop.Tools.AddTool("NEW_QUOTE"); + if (!AyaBizUtils.Lite) pop.Tools.AddTool("NEW_PM"); - //Case 284 - pop.Tools.AddTool("NEW_NOTE"); + //Case 284 + pop.Tools.AddTool("NEW_NOTE"); - //Case 534 - pop.Tools.AddTool("VIEW_WOLIST"); + //Case 534 + pop.Tools.AddTool("VIEW_WOLIST"); - //case 1308 - //need a factory item for this instead - if (AyaBizUtils.Right(ObjectType) > (int)SecurityLevelTypes.NoAccess) - { - Client c = Client.GetItem(ID); - PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, ObjectType, c, null)); + //case 1308 + //need a factory item for this instead + if (AyaBizUtils.Right(ObjectType) > (int)SecurityLevelTypes.NoAccess) + { + Client c = Client.GetItem(ID); + PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, ObjectType, c, null)); + } } - } - break; + break; - case RootObjectTypes.Unit: - { - //add some "flash" - pop.Settings.SideStripText = LocaleText.GetLocalizedText("O.Unit"); - pop.Settings.SideStripWidth = 24; - pop.Settings.IsSideStripVisible = DefaultableBoolean.True; - - - ButtonTool b1 = new ButtonTool("NEW_WO"); - b1.SharedProps.AppearancesLarge.Appearance.Image = Resource1.ServiceWorkorder32; - b1.SharedProps.Caption=LocaleText.GetLocalizedText("O.WorkorderService"); - b1.SharedProps.Tag=new TypeAndID(ObjectType,ID); - - ButtonTool b3 = new ButtonTool("NEW_PM"); - b3.SharedProps.AppearancesLarge.Appearance.Image = Resource1.PreventiveMaintenance32; - b3.SharedProps.Caption=LocaleText.GetLocalizedText("O.WorkorderPreventiveMaintenance"); - b3.SharedProps.Tag=new TypeAndID(ObjectType,ID); - - //Case 534 - ButtonTool b5 = new ButtonTool("VIEW_WOLIST"); - b5.SharedProps.Caption = LocaleText.GetLocalizedText("Workorder.Label.ListAll"); - b5.SharedProps.Tag = new TypeAndID(ObjectType, ID); - - - tbManager.Tools.Add(b1); - //tbManager.Tools.Add(b2); - tbManager.Tools.Add(b3); - - //Case 534 - tbManager.Tools.Add(b5); - - pop.Tools.AddTool("NEW_WO"); - //pop.Tools.AddTool("NEW_QUOTE"); - pop.Tools.AddTool("NEW_PM"); - - //Case 534 - pop.Tools.AddTool("VIEW_WOLIST"); - - //case 1308 - //This really should be a factory method instead in the biz utils - if (AyaBizUtils.Right(ObjectType) > (int)SecurityLevelTypes.NoAccess) + case RootObjectTypes.Unit: { - Unit u = Unit.GetItem(ID); - PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, ObjectType, u, null)); - } - } - break; + //add some "flash" + pop.Settings.SideStripText = LocaleText.GetLocalizedText("O.Unit"); + pop.Settings.SideStripWidth = 24; + pop.Settings.IsSideStripVisible = DefaultableBoolean.True; - //case 3158 + + ButtonTool b1 = new ButtonTool("NEW_WO"); + b1.SharedProps.AppearancesLarge.Appearance.Image = Resource1.ServiceWorkorder32; + b1.SharedProps.Caption = LocaleText.GetLocalizedText("O.WorkorderService"); + b1.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + ButtonTool b3 = new ButtonTool("NEW_PM"); + b3.SharedProps.AppearancesLarge.Appearance.Image = Resource1.PreventiveMaintenance32; + b3.SharedProps.Caption = LocaleText.GetLocalizedText("O.WorkorderPreventiveMaintenance"); + b3.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + //Case 534 + ButtonTool b5 = new ButtonTool("VIEW_WOLIST"); + b5.SharedProps.Caption = LocaleText.GetLocalizedText("Workorder.Label.ListAll"); + b5.SharedProps.Tag = new TypeAndID(ObjectType, ID); + + + tbManager.Tools.Add(b1); + //tbManager.Tools.Add(b2); + tbManager.Tools.Add(b3); + + //Case 534 + tbManager.Tools.Add(b5); + + pop.Tools.AddTool("NEW_WO"); + //pop.Tools.AddTool("NEW_QUOTE"); + pop.Tools.AddTool("NEW_PM"); + + //Case 534 + pop.Tools.AddTool("VIEW_WOLIST"); + + //case 1308 + //This really should be a factory method instead in the biz utils + if (AyaBizUtils.Right(ObjectType) > (int)SecurityLevelTypes.NoAccess) + { + Unit u = Unit.GetItem(ID); + PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, ObjectType, u, null)); + } + } + break; + + //case 3158 case RootObjectTypes.LoanItem: { //add some "flash" pop.Settings.SideStripText = LocaleText.GetLocalizedText("O.LoanItem"); pop.Settings.SideStripWidth = 24; pop.Settings.IsSideStripVisible = DefaultableBoolean.True; - + //Case 534 ButtonTool b5 = new ButtonTool("VIEW_WOLIST"); b5.SharedProps.Caption = LocaleText.GetLocalizedText("Workorder.Label.ListAll"); b5.SharedProps.Tag = new TypeAndID(ObjectType, ID); //Case 534 - tbManager.Tools.Add(b5); + tbManager.Tools.Add(b5); //Case 534 pop.Tools.AddTool("VIEW_WOLIST"); - + } break; - default: - return false; + default: + return false; - } + } //case 73 wikilink if (!AyaBizUtils.Lite) @@ -5003,44 +5004,44 @@ At first I was happy to find your code that solved my problem, but I did not lik } - tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(ObjectContextMenu_ToolClick); - tbManager.ShowPopup("POPKEY",InsideForm); - - - - return true; - - } + tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(ObjectContextMenu_ToolClick); + tbManager.ShowPopup("POPKEY", InsideForm); - /// - /// Handle popup menu clicks - /// - /// - /// - static private void ObjectContextMenu_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) - { + return true; - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("ObjectContextMenu_ToolClick(Key="+e.Tool.Key + ")"); + } - switch (e.Tool.Key) - { - case "NEW_WO": - if(e.Tool.SharedProps.Tag!=null) - NewWorkorder((TypeAndID)e.Tool.SharedProps.Tag); - break; - case "NEW_QUOTE": - if(e.Tool.SharedProps.Tag!=null) - NewQuote((TypeAndID)e.Tool.SharedProps.Tag); - break; - case "NEW_PM": - if(e.Tool.SharedProps.Tag!=null) - NewPM((TypeAndID)e.Tool.SharedProps.Tag); - break; - //Case 284 + + /// + /// Handle popup menu clicks + /// + /// + /// + static private void ObjectContextMenu_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) + { + + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("ObjectContextMenu_ToolClick(Key="+e.Tool.Key + ")"); + + switch (e.Tool.Key) + { + case "NEW_WO": + if (e.Tool.SharedProps.Tag != null) + NewWorkorder((TypeAndID)e.Tool.SharedProps.Tag); + break; + case "NEW_QUOTE": + if (e.Tool.SharedProps.Tag != null) + NewQuote((TypeAndID)e.Tool.SharedProps.Tag); + break; + case "NEW_PM": + if (e.Tool.SharedProps.Tag != null) + NewPM((TypeAndID)e.Tool.SharedProps.Tag); + break; + + //Case 284 case "NEW_NOTE": if (e.Tool.SharedProps.Tag != null) { @@ -5050,11 +5051,11 @@ At first I was happy to find your code that solved my problem, but I did not lik } break; - //Case 534 + //Case 534 case "VIEW_WOLIST": if (e.Tool.SharedProps.Tag != null) { - TypeAndID t=(TypeAndID)e.Tool.SharedProps.Tag; + TypeAndID t = (TypeAndID)e.Tool.SharedProps.Tag; switch (t.RootObjectType) { case RootObjectTypes.Client: @@ -5063,7 +5064,7 @@ At first I was happy to find your code that solved my problem, but I did not lik sb.Append(""); sb.Append("\r\n"); sb.Append("\t\r\n"); @@ -5072,12 +5073,12 @@ At first I was happy to find your code that solved my problem, but I did not lik frmMain.ShowForm("LT:UI.Go.Service", "LT:WorkorderService.Label.List", true); frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Service"]; frmMain.MainServiceTree.Nodes["LT:WorkorderService.Label.List"].Selected = true; - + } break; case RootObjectTypes.Unit: { - + StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append("\r\n"); @@ -5090,21 +5091,21 @@ At first I was happy to find your code that solved my problem, but I did not lik gGridLastViews["WorkorderServiceItemList"].SubstituteCriteria = sb.ToString(); frmMain.ShowForm("LT:UI.Go.Service", "LT:WorkorderItem.Label.List", true); frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Service"]; - frmMain.MainServiceTree.Nodes["LT:WorkorderService.Label.List"].Nodes["LT:WorkorderItem.Label.List"].Selected=true; + frmMain.MainServiceTree.Nodes["LT:WorkorderService.Label.List"].Nodes["LT:WorkorderItem.Label.List"].Selected = true; } break; - //case 3158 + //case 3158 case RootObjectTypes.LoanItem: { StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append("\r\n"); sb.Append("\t\r\n"); @@ -5117,74 +5118,74 @@ At first I was happy to find your code that solved my problem, but I did not lik } break; } - + } break; case "WIKILINK": { CopyAyaNovaUrl((TypeAndID)e.Tool.SharedProps.Tag); - + } break; - } + } - } + } - /// - /// Create and open for editing a new workorder based off the indicated - /// object passed in. - /// - /// TypeAndID object to create workorder from - static public void NewWorkorder(TypeAndID From) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("NewWorkorder(FromObject="+From.RootObjectType.ToString() + ", FromID=" + From.ID.ToString() + ")"); + /// + /// Create and open for editing a new workorder based off the indicated + /// object passed in. + /// + /// TypeAndID object to create workorder from + static public void NewWorkorder(TypeAndID From) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("NewWorkorder(FromObject="+From.RootObjectType.ToString() + ", FromID=" + From.ID.ToString() + ")"); - switch(From.RootObjectType) - { - case RootObjectTypes.Client: - { - Workorder w=null; - try - { - ClientSelector c = new ClientSelector(WorkorderTypes.TemplateService); - c.SelectedClientID = From.ID; - DialogResult result = c.ShowDialog(); - if (result == DialogResult.Cancel) return; + switch (From.RootObjectType) + { + case RootObjectTypes.Client: + { + Workorder w = null; + try + { + ClientSelector c = new ClientSelector(WorkorderTypes.TemplateService); + c.SelectedClientID = From.ID; + DialogResult result = c.ShowDialog(); + if (result == DialogResult.Cancel) return; - if (c.SelectedTemplateID != Guid.Empty) - w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); + if (c.SelectedTemplateID != Guid.Empty) + w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); + else + w = Workorder.NewItem(WorkorderTypes.Service); + } + catch (TrialException ex) + { + ex.ToString();//Just to suppress the compiler warning + Util.PromptRestricted(); + return; + } + w.ClientID = From.ID; + if (AyaBizUtils.Lite)//case 1172 + { + WorkorderFormLite wfl = new WorkorderFormLite(); + wfl.WorkorderToEdit = w; + wfl.GoTo = RootObjectTypes.WorkorderItemLabor; + wfl.ShowDialog(); + wfl.Dispose(); + } else - w = Workorder.NewItem(WorkorderTypes.Service); - } - catch(TrialException ex) - { - ex.ToString();//Just to suppress the compiler warning - Util.PromptRestricted(); - return; - } - w.ClientID=From.ID; - if (AyaBizUtils.Lite)//case 1172 - { - WorkorderFormLite wfl = new WorkorderFormLite(); - wfl.WorkorderToEdit = w; - wfl.GoTo = RootObjectTypes.WorkorderItemLabor; - wfl.ShowDialog(); - wfl.Dispose(); + { + WorkorderForm wf = new WorkorderForm(); + wf.WorkorderToEdit = w; + wf.GoTo = RootObjectTypes.WorkorderItemLabor; + //Case 677 + wf.Show(); + } + } - else - { - WorkorderForm wf = new WorkorderForm(); - wf.WorkorderToEdit = w; - wf.GoTo = RootObjectTypes.WorkorderItemLabor; - //Case 677 - wf.Show(); - } - - } - break; + break; case RootObjectTypes.Unit: { @@ -5209,7 +5210,7 @@ At first I was happy to find your code that solved my problem, but I did not lik Util.PromptRestricted(); return; } - + WorkorderItem wi = w.WorkorderItems[0]; @@ -5226,184 +5227,184 @@ At first I was happy to find your code that solved my problem, but I did not lik wf.GoTo = RootObjectTypes.WorkorderItemLabor; //Case 677 wf.Show(); - + } - break; - } - } + break; + } + } - /// - /// Create and open for editing a new quote based off the indicated - /// object passed in. - /// - /// TypeAndID object to create quote from - static public void NewQuote(TypeAndID From) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("NewQuote(FromObject="+From.RootObjectType.ToString() + ", FromID=" + From.ID.ToString() + ")"); + /// + /// Create and open for editing a new quote based off the indicated + /// object passed in. + /// + /// TypeAndID object to create quote from + static public void NewQuote(TypeAndID From) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("NewQuote(FromObject="+From.RootObjectType.ToString() + ", FromID=" + From.ID.ToString() + ")"); - switch(From.RootObjectType) - { - case RootObjectTypes.Client: - { - Workorder w=null; - try - { - ClientSelector c = new ClientSelector(WorkorderTypes.TemplateQuote); - c.SelectedClientID = From.ID; - DialogResult result = c.ShowDialog(); - if (result == DialogResult.Cancel) return; + switch (From.RootObjectType) + { + case RootObjectTypes.Client: + { + Workorder w = null; + try + { + ClientSelector c = new ClientSelector(WorkorderTypes.TemplateQuote); + c.SelectedClientID = From.ID; + DialogResult result = c.ShowDialog(); + if (result == DialogResult.Cancel) return; - if (c.SelectedTemplateID != Guid.Empty) - w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); - else - w = Workorder.NewItem(WorkorderTypes.Quote); + if (c.SelectedTemplateID != Guid.Empty) + w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); + else + w = Workorder.NewItem(WorkorderTypes.Quote); - } - catch(TrialException ex) - { - ex.ToString();//Just to suppress the compiler warning - Util.PromptRestricted(); - return; - } - w.ClientID=From.ID; - WorkorderForm wf= new WorkorderForm(); - wf.WorkorderToEdit=w; - //Case 677 - wf.Show(); - - } - break; + } + catch (TrialException ex) + { + ex.ToString();//Just to suppress the compiler warning + Util.PromptRestricted(); + return; + } + w.ClientID = From.ID; + WorkorderForm wf = new WorkorderForm(); + wf.WorkorderToEdit = w; + //Case 677 + wf.Show(); + + } + break; - } - } + } + } - - /// - /// Create and open for editing a new PM based off the indicated - /// object passed in. - /// - /// TypeAndID object to create PM from - static public void NewPM(TypeAndID From) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("NewPM(FromObject="+From.RootObjectType.ToString() + ", FromID=" + From.ID.ToString() + ")"); - switch(From.RootObjectType) - { - case RootObjectTypes.Client: - { - Workorder w=null; - try - { - ClientSelector c = new ClientSelector(WorkorderTypes.TemplatePreventiveMaintenance); - c.SelectedClientID = From.ID; - DialogResult result = c.ShowDialog(); - if (result == DialogResult.Cancel) return; + /// + /// Create and open for editing a new PM based off the indicated + /// object passed in. + /// + /// TypeAndID object to create PM from + static public void NewPM(TypeAndID From) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("NewPM(FromObject="+From.RootObjectType.ToString() + ", FromID=" + From.ID.ToString() + ")"); - if (c.SelectedTemplateID != Guid.Empty) - w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); - else - w = Workorder.NewItem(WorkorderTypes.PreventiveMaintenance); + switch (From.RootObjectType) + { + case RootObjectTypes.Client: + { + Workorder w = null; + try + { + ClientSelector c = new ClientSelector(WorkorderTypes.TemplatePreventiveMaintenance); + c.SelectedClientID = From.ID; + DialogResult result = c.ShowDialog(); + if (result == DialogResult.Cancel) return; - } - catch(TrialException ex) - { - ex.ToString();//Just to suppress the compiler warning - Util.PromptRestricted(); - return; - } - w.ClientID=From.ID; - WorkorderForm wf= new WorkorderForm(); - wf.WorkorderToEdit=w; - wf.GoTo=RootObjectTypes.WorkorderItemLabor; - //Case 677 - wf.Show(); - - } - break; + if (c.SelectedTemplateID != Guid.Empty) + w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); + else + w = Workorder.NewItem(WorkorderTypes.PreventiveMaintenance); - case RootObjectTypes.Unit: - { - - Unit u=Unit.GetItemMRU(From.ID,false); - Workorder w=null; - try - { + } + catch (TrialException ex) + { + ex.ToString();//Just to suppress the compiler warning + Util.PromptRestricted(); + return; + } + w.ClientID = From.ID; + WorkorderForm wf = new WorkorderForm(); + wf.WorkorderToEdit = w; + wf.GoTo = RootObjectTypes.WorkorderItemLabor; + //Case 677 + wf.Show(); - ClientSelector c = new ClientSelector(WorkorderTypes.TemplatePreventiveMaintenance); - c.SelectedClientID = u.ClientID; - DialogResult result = c.ShowDialog(); - if (result == DialogResult.Cancel) return; + } + break; - if (c.SelectedTemplateID != Guid.Empty) - w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); - else - w = Workorder.NewItem(WorkorderTypes.PreventiveMaintenance); - - } - catch(TrialException ex) - { - ex.ToString();//Just to suppress the compiler warning - Util.PromptRestricted(); - return; - } - - + case RootObjectTypes.Unit: + { - WorkorderItem wi=w.WorkorderItems[0]; - wi.UnitID=From.ID; - //indicate client - w.ClientID=u.ClientID; + Unit u = Unit.GetItemMRU(From.ID, false); + Workorder w = null; + try + { - - WorkorderForm wf= new WorkorderForm(); - wf.WorkorderToEdit=w; - wf.GoTo=RootObjectTypes.WorkorderItemLabor; - //Case 677 - wf.Show(); - - } - break; - } - } + ClientSelector c = new ClientSelector(WorkorderTypes.TemplatePreventiveMaintenance); + c.SelectedClientID = u.ClientID; + DialogResult result = c.ShowDialog(); + if (result == DialogResult.Cancel) return; + + if (c.SelectedTemplateID != Guid.Empty) + w = Workorder.NewItem(c.SelectedTemplateID, c.SelectedClientID); + else + w = Workorder.NewItem(WorkorderTypes.PreventiveMaintenance); + + } + catch (TrialException ex) + { + ex.ToString();//Just to suppress the compiler warning + Util.PromptRestricted(); + return; + } + + + + WorkorderItem wi = w.WorkorderItems[0]; + wi.UnitID = From.ID; + //indicate client + w.ClientID = u.ClientID; + + + WorkorderForm wf = new WorkorderForm(); + wf.WorkorderToEdit = w; + wf.GoTo = RootObjectTypes.WorkorderItemLabor; + //Case 677 + wf.Show(); + + } + break; + } + } - #endregion + #endregion - #region Error and warning reporting - - static public void Error(string Where, string What) - { + #region Error and warning reporting + + static public void Error(string Where, string What) + { string Message = Where + " @ " + DBUtil.CurrentWorkingDateTime.ToString() + "\r\n-----------\r\n" + What; - log.Error("Error (reported to user) \r\n" + Where +": " + What); - CopyableMessageBox m = new CopyableMessageBox(Message); - m.ShowDialog(); - m.Dispose(); - - } + log.Error("Error (reported to user) \r\n" + Where + ": " + What); + CopyableMessageBox m = new CopyableMessageBox(Message); + m.ShowDialog(); + m.Dispose(); - /// - /// translates obscure sql errors into human readable form, - /// logs and reports them to user - /// - /// - static public void ReportSQLError(Exception ex) - { - if(ex.InnerException==null) throw ex; - string sErrorMessage=""; - - if(ex.InnerException is FirebirdSql.Data.FirebirdClient.FbException) - {//TODO: this is forcing a dependancy on the firebird sql driver - //Move this down to the database level + } + + /// + /// translates obscure sql errors into human readable form, + /// logs and reports them to user + /// + /// + static public void ReportSQLError(Exception ex) + { + if (ex.InnerException == null) throw ex; + string sErrorMessage = ""; + + if (ex.InnerException is FirebirdSql.Data.FirebirdClient.FbException) + {//TODO: this is forcing a dependancy on the firebird sql driver + //Move this down to the database level FirebirdSql.Data.FirebirdClient.FbException fex = (FirebirdSql.Data.FirebirdClient.FbException)ex.InnerException; bool bHandled = false; foreach (FirebirdSql.Data.FirebirdClient.FbError err in fex.Errors) @@ -5421,108 +5422,108 @@ At first I was happy to find your code that solved my problem, but I did not lik //something unusual so rethrow it here. if (!bHandled) throw fex; - - } - else if(ex.InnerException is System.Data.SqlClient.SqlException) - { - System.Data.SqlClient.SqlException sex=(System.Data.SqlClient.SqlException)ex.InnerException; - - switch(sex.Number) - { - case 547: + + } + else if (ex.InnerException is System.Data.SqlClient.SqlException) + { + System.Data.SqlClient.SqlException sex = (System.Data.SqlClient.SqlException)ex.InnerException; + + switch (sex.Number) + { + case 547: log.Warn("SqlException", sex); - sErrorMessage=LocaleText.GetLocalizedText("Error.DB.ForeignKeyViolation")+"\r\n\r\n----------------------------------------\r\n" + sex.Message; - break; - default://rethrow it, it's nothing we can handle here - throw sex; - } - } - else - throw ex.InnerException; - - MessageBox.Show(sErrorMessage,"",MessageBoxButtons.OK,MessageBoxIcon.Error); - - - } + sErrorMessage = LocaleText.GetLocalizedText("Error.DB.ForeignKeyViolation") + "\r\n\r\n----------------------------------------\r\n" + sex.Message; + break; + default://rethrow it, it's nothing we can handle here + throw sex; + } + } + else + throw ex.InnerException; - #endregion - - #region Graphic helpers - static public Color InvertColor(Color col) - { -// //case 1039 //if(log.IsDebugEnabled) -// //case 1039 //log.Debug("InvertColor("+col.ToString()+")"); - - int nSourceColor=col.R + col.G + col.B; - - int r = 255 - col.R; - int g = 255 - col.G; - int b = 255 - col.B; - - int nInvertColor=r+g+b; - - Color invert; - if(nSourceColor-nInvertColor< 28) - invert=Color.White; - else - invert = Color.FromArgb(r,g,b); - return invert; - } - #endregion - - #region URL Openers - static public void OpenEmailURL(object oUrl) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("OpenEmailURL(" +oUrl.ToString()+")"); - if(oUrl==null) return; - string sUrl=oUrl.ToString(); - if(sUrl=="") return; - try - { - if(sUrl.ToLower().StartsWith("mailto:")) - System.Diagnostics.Process.Start(sUrl); - else - System.Diagnostics.Process.Start("mailto:" + sUrl); - - } - catch(Exception ex) - { - log.Error("OpenEmailURL",ex); - Error("Util.OpenEmailUrl",Util.LocaleText.GetLocalizedText("Error.UnableToOpenEmailUrl")+"\r\nException:\r\n"+ex.Message+"\r\n"+ex.Source); - - } + MessageBox.Show(sErrorMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + } - static public void OpenWebURL(object oUrl) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("OpenWebURL(" +oUrl.ToString()+")"); - if(oUrl==null) return; - string sUrl=oUrl.ToString(); - if(sUrl=="") return; - - try - { + #endregion + + #region Graphic helpers + static public Color InvertColor(Color col) + { + // //case 1039 //if(log.IsDebugEnabled) + // //case 1039 //log.Debug("InvertColor("+col.ToString()+")"); + + int nSourceColor = col.R + col.G + col.B; + + int r = 255 - col.R; + int g = 255 - col.G; + int b = 255 - col.B; + + int nInvertColor = r + g + b; + + Color invert; + if (nSourceColor - nInvertColor < 28) + invert = Color.White; + else + invert = Color.FromArgb(r, g, b); + return invert; + } + #endregion + + #region URL Openers + static public void OpenEmailURL(object oUrl) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("OpenEmailURL(" +oUrl.ToString()+")"); + if (oUrl == null) return; + string sUrl = oUrl.ToString(); + if (sUrl == "") return; + try + { + if (sUrl.ToLower().StartsWith("mailto:")) + System.Diagnostics.Process.Start(sUrl); + else + System.Diagnostics.Process.Start("mailto:" + sUrl); + + } + catch (Exception ex) + { + log.Error("OpenEmailURL", ex); + Error("Util.OpenEmailUrl", Util.LocaleText.GetLocalizedText("Error.UnableToOpenEmailUrl") + "\r\nException:\r\n" + ex.Message + "\r\n" + ex.Source); + + } + + + } + + static public void OpenWebURL(object oUrl) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("OpenWebURL(" +oUrl.ToString()+")"); + if (oUrl == null) return; + string sUrl = oUrl.ToString(); + if (sUrl == "") return; + + try + { //case 3649 changed this block to handle https urls if (sUrl.ToLower().StartsWith("https://")) System.Diagnostics.Process.Start(sUrl); - else if(sUrl.ToLower().StartsWith("http://")) - System.Diagnostics.Process.Start(sUrl); - else - System.Diagnostics.Process.Start("https://" + sUrl);//was http before case 3649 + else if (sUrl.ToLower().StartsWith("http://")) + System.Diagnostics.Process.Start(sUrl); + else + System.Diagnostics.Process.Start("https://" + sUrl);//was http before case 3649 - } - catch(Exception ex) - { - log.Error("OpenWebUrl",ex); - Error("Util.OpenWebUrl",Util.LocaleText.GetLocalizedText("Error.UnableToOpenWebUrl")+"\r\nException:\r\n"+ex.Message+"\r\n"+ex.Source); + } + catch (Exception ex) + { + log.Error("OpenWebUrl", ex); + Error("Util.OpenWebUrl", Util.LocaleText.GetLocalizedText("Error.UnableToOpenWebUrl") + "\r\nException:\r\n" + ex.Message + "\r\n" + ex.Source); - } + } - } + } /// /// Save the file to a temp location, start a process to edit it @@ -5532,7 +5533,7 @@ At first I was happy to find your code that solved my problem, but I did not lik static public void OpenAyaFileAndUpdateWhenClosed(Guid AyaFileID) { AyaFile f = AyaFile.GetItem(AyaFileID); - string sFullPath=TempFolder + Path.DirectorySeparatorChar + f.Name; + string sFullPath = TempFolder + Path.DirectorySeparatorChar + f.Name; //1st Write the file to disk f.WriteToDisk(TempFolder, f.Name); @@ -5560,142 +5561,142 @@ At first I was happy to find your code that solved my problem, but I did not lik { File.Delete(sFullPath); } - catch{};//Might not be able to delete here, if still open in calling app, that's ok, will get it on the application exit instead + catch { };//Might not be able to delete here, if still open in calling app, that's ok, will get it on the application exit instead } - static public void OpenDocumentURL(object oUrl) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("OpenDocumentURL(" +oUrl.ToString()+")"); - if(oUrl==null) return; - string sUrl=oUrl.ToString(); - if(sUrl=="") return; - - try - { - - System.Diagnostics.Process.Start(sUrl); - + static public void OpenDocumentURL(object oUrl) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("OpenDocumentURL(" +oUrl.ToString()+")"); + if (oUrl == null) return; + string sUrl = oUrl.ToString(); + if (sUrl == "") return; - } - catch(Exception ex) - { - log.Error("OpenDocumentURL",ex); - MessageBox.Show(ex.Message,Util.LocaleText.GetLocalizedText("Error.UnableToOpenDocumentUrl")); - //Error("Util.OpenDocumentUrl",Util.LocaleText.GetLocalizedText("Error.UnableToOpenDocumentUrl")+"\r\nException:\r\n"+ex.Message+"\r\n"+ex.Source); + try + { - } + System.Diagnostics.Process.Start(sUrl); - } - #endregion + } + catch (Exception ex) + { + log.Error("OpenDocumentURL", ex); + MessageBox.Show(ex.Message, Util.LocaleText.GetLocalizedText("Error.UnableToOpenDocumentUrl")); + //Error("Util.OpenDocumentUrl",Util.LocaleText.GetLocalizedText("Error.UnableToOpenDocumentUrl")+"\r\nException:\r\n"+ex.Message+"\r\n"+ex.Source); - #region Reporting helpers + } - static internal void WatermarkReport(XtraReport rpt, bool Insert ) - { - if(Insert) - { - rpt.Watermark.Text="TRIAL SAMPLE"; - rpt.Watermark.Font=new Font("Tahoma",72,FontStyle.Bold); - //Case 232 + } + + #endregion + + #region Reporting helpers + + static internal void WatermarkReport(XtraReport rpt, bool Insert) + { + if (Insert) + { + rpt.Watermark.Text = "TRIAL SAMPLE"; + rpt.Watermark.Font = new Font("Tahoma", 72, FontStyle.Bold); + //Case 232 //rpt.Watermark.Transparency=128; rpt.Watermark.TextTransparency = 128; - rpt.Watermark.ShowBehind=false; - } - else - { - rpt.Watermark.Text=""; - } - } - - - /// - /// Fill an infragistics list tool - /// with all reports for given key - /// - /// - static public void ReportFillList(Infragistics.Win.UltraWinToolbars.ToolBase lTool, string ReportKeySummary,string ReportKeyDetailed) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("ReportFillList(Tool=" +lTool.Key +", ReportKeySummary=" + ReportKeySummary+", ReportKeyDetailed=" + ReportKeyDetailed+")"); - Infragistics.Win.UltraWinToolbars.ListTool ListTool; - ListTool = (Infragistics.Win.UltraWinToolbars.ListTool)lTool; - ListTool.ListToolItems.Clear(); + rpt.Watermark.ShowBehind = false; + } + else + { + rpt.Watermark.Text = ""; + } + } + + + /// + /// Fill an infragistics list tool + /// with all reports for given key + /// + /// + static public void ReportFillList(Infragistics.Win.UltraWinToolbars.ToolBase lTool, string ReportKeySummary, string ReportKeyDetailed) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("ReportFillList(Tool=" +lTool.Key +", ReportKeySummary=" + ReportKeySummary+", ReportKeyDetailed=" + ReportKeyDetailed+")"); + Infragistics.Win.UltraWinToolbars.ListTool ListTool; + ListTool = (Infragistics.Win.UltraWinToolbars.ListTool)lTool; + ListTool.ListToolItems.Clear(); //Case 245 - Missed an item with a checkmark and for some reason //the visual designer despite being set to no checkmark still results in a checkmark so //put it centralized in code here to be sure ListTool.DisplayCheckmark = false; - ReportPickList rpl=ReportPickList.GetList(ReportKeySummary,ReportKeyDetailed,true); - - foreach(ReportPickList.ReportPickListInfo i in rpl) - { - if(i.Active) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("ReportFillList: Adding " + i.Name + ", ID=" + i.ID.ToString()+ ", IsSummary=" + i.ToString() ); - Infragistics.Win.UltraWinToolbars.ListToolItem li=ListTool.ListToolItems.Insert(ListTool.ListToolItems.Count,i.ID.ToString(),i.Name); - if(i.IsSummary) - li.Tag=1; + ReportPickList rpl = ReportPickList.GetList(ReportKeySummary, ReportKeyDetailed, true); - - } - } - - //Add NEW option if user is allowed - if(AyaBizUtils.Right("Object.Report")> (int)SecurityLevelTypes.ReadOnly) - { - //Can do summaries? - if(ReportKeySummary!="") - { - Infragistics.Win.UltraWinToolbars.ListToolItem li=ListTool.ListToolItems.Insert(ListTool.ListToolItems.Count,"NEWSUMMARY",LocaleText.GetLocalizedText("Report.Label.NewSummaryReport")); - li.Appearance.FontData.Italic=DefaultableBoolean.True; - li.Tag=1; - } - - //Can do Detailed reports? - if(ReportKeyDetailed!="") - { - Infragistics.Win.UltraWinToolbars.ListToolItem li=ListTool.ListToolItems.Insert(ListTool.ListToolItems.Count,"NEWDETAILED",LocaleText.GetLocalizedText("Report.Label.NewDetailedReport")); - li.Appearance.FontData.Italic=DefaultableBoolean.True; - } - } + foreach (ReportPickList.ReportPickListInfo i in rpl) + { + if (i.Active) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("ReportFillList: Adding " + i.Name + ", ID=" + i.ID.ToString()+ ", IsSummary=" + i.ToString() ); + Infragistics.Win.UltraWinToolbars.ListToolItem li = ListTool.ListToolItems.Insert(ListTool.ListToolItems.Count, i.ID.ToString(), i.Name); + if (i.IsSummary) + li.Tag = 1; - } - - /// - /// Works in conjunction with the fill report tool list - /// which sets the tag of the tool list item to 1 for summary type - /// reports. - /// - /// This is checked when a user clicks on print / design report so that the - /// biz object knows whether to supply the detail or summary version of the biz - /// object list to the ReportHandleToolClick method below - /// - /// - /// - static public bool ReportHandleToolClickIsSummary(Infragistics.Win.UltraWinToolbars.ToolBase lTool) - { - //User clicked an item on the report List tool. - Infragistics.Win.UltraWinToolbars.ListTool aListTool; - Infragistics.Win.UltraWinToolbars.ListToolItem aListToolItem; - - //Cast e.Tool (which is a ToolBase) into a List too, so we can access tool-specific properties - aListTool = (Infragistics.Win.UltraWinToolbars.ListTool)lTool; - //Get the ListToolItem which was clicked - aListToolItem = aListTool.SelectedItem; - if(aListToolItem.Tag==null) return false; + } + } - return true; + //Add NEW option if user is allowed + if (AyaBizUtils.Right("Object.Report") > (int)SecurityLevelTypes.ReadOnly) + { + //Can do summaries? + if (ReportKeySummary != "") + { + Infragistics.Win.UltraWinToolbars.ListToolItem li = ListTool.ListToolItems.Insert(ListTool.ListToolItems.Count, "NEWSUMMARY", LocaleText.GetLocalizedText("Report.Label.NewSummaryReport")); + li.Appearance.FontData.Italic = DefaultableBoolean.True; + li.Tag = 1; + } + + //Can do Detailed reports? + if (ReportKeyDetailed != "") + { + Infragistics.Win.UltraWinToolbars.ListToolItem li = ListTool.ListToolItems.Insert(ListTool.ListToolItems.Count, "NEWDETAILED", LocaleText.GetLocalizedText("Report.Label.NewDetailedReport")); + li.Appearance.FontData.Italic = DefaultableBoolean.True; + } + } + + + } + + /// + /// Works in conjunction with the fill report tool list + /// which sets the tag of the tool list item to 1 for summary type + /// reports. + /// + /// This is checked when a user clicks on print / design report so that the + /// biz object knows whether to supply the detail or summary version of the biz + /// object list to the ReportHandleToolClick method below + /// + /// + /// + static public bool ReportHandleToolClickIsSummary(Infragistics.Win.UltraWinToolbars.ToolBase lTool) + { + //User clicked an item on the report List tool. + Infragistics.Win.UltraWinToolbars.ListTool aListTool; + Infragistics.Win.UltraWinToolbars.ListToolItem aListToolItem; + + //Cast e.Tool (which is a ToolBase) into a List too, so we can access tool-specific properties + aListTool = (Infragistics.Win.UltraWinToolbars.ListTool)lTool; + //Get the ListToolItem which was clicked + aListToolItem = aListTool.SelectedItem; + if (aListToolItem.Tag == null) return false; + + return true; } - + /// /// Handle report and take optional email address to set /// for report so it can be prefilled when export to email selected @@ -5707,80 +5708,80 @@ At first I was happy to find your code that solved my problem, but I did not lik /// static public bool ReportHandleToolClick(Infragistics.Win.UltraWinToolbars.ToolBase lTool, string ReportKey, object DataSource) { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("ReportHandleToolClick(Tool=" + lTool.Key + ", ReportKey=" + ReportKey + ")"); - - Cursor.Current=Cursors.WaitCursor; - - ReportDataSet source=null; - if(DataSource is ReportDataSet) - source=(ReportDataSet) DataSource; - else - { - ReportDataSetAdapter rdsa=new ReportDataSetAdapter(); - source=new ReportDataSet(); - rdsa.Fill(source,DataSource); - } -//#if (DEBUG) + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("ReportHandleToolClick(Tool=" + lTool.Key + ", ReportKey=" + ReportKey + ")"); -// source.WriteXml("c:\\temp\\" + ReportKey + ".xsd", XmlWriteMode.WriteSchema); -//#endif - + Cursor.Current = Cursors.WaitCursor; - //Add localized text and display name to reportdataset - source.LocaleTextTable=LocaleText; - source.DisplayName=ReportKey; + ReportDataSet source = null; + if (DataSource is ReportDataSet) + source = (ReportDataSet)DataSource; + else + { + ReportDataSetAdapter rdsa = new ReportDataSetAdapter(); + source = new ReportDataSet(); + rdsa.Fill(source, DataSource); + } + //#if (DEBUG) - bool bDesign=false; - if(((Control.ModifierKeys & Keys.Shift)!=0) /*Shift key held down*/) - bDesign=true; + // source.WriteXml("c:\\temp\\" + ReportKey + ".xsd", XmlWriteMode.WriteSchema); + //#endif - - //User clicked an item on the report List tool. - Infragistics.Win.UltraWinToolbars.ListTool aListTool; - Infragistics.Win.UltraWinToolbars.ListToolItem aListToolItem; - - //Cast e.Tool (which is a ToolBase) into a List too, so we can access tool-specific properties - aListTool = (Infragistics.Win.UltraWinToolbars.ListTool)lTool; - //Get the ListToolItem which was clicked - aListToolItem = aListTool.SelectedItem; - Report r=null; - if(aListToolItem.Key.StartsWith("NEW")) - { - ReportDesignerSaveAsDialog d = new ReportDesignerSaveAsDialog(); - d.SelectedName=Util.LocaleText.GetLocalizedText("O.Report"); - d.ReportKey=ReportKey; - DialogResult result=d.ShowDialog(); - - if(result==DialogResult.Cancel) - { - d.Dispose(); - return false; - } - bDesign=true; - r=Report.NewItem(); - r.Name=d.SelectedName; - r.ReportKey=ReportKey; - d.Dispose(); - } - else - r=Report.GetItem(new Guid(aListToolItem.Key)); - - // - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("ReportHandleToolClick: ReportKey=" + r.ReportKey); - - - if(!bDesign) - { + //Add localized text and display name to reportdataset + source.LocaleTextTable = LocaleText; + source.DisplayName = ReportKey; - //case 1039 //log.Debug("ReportHandleToolClick: Viewing report"); - - XtraReport x = new XtraReport(); + bool bDesign = false; + if (((Control.ModifierKeys & Keys.Shift) != 0) /*Shift key held down*/) + bDesign = true; + + + //User clicked an item on the report List tool. + Infragistics.Win.UltraWinToolbars.ListTool aListTool; + Infragistics.Win.UltraWinToolbars.ListToolItem aListToolItem; + + //Cast e.Tool (which is a ToolBase) into a List too, so we can access tool-specific properties + aListTool = (Infragistics.Win.UltraWinToolbars.ListTool)lTool; + //Get the ListToolItem which was clicked + aListToolItem = aListTool.SelectedItem; + Report r = null; + if (aListToolItem.Key.StartsWith("NEW")) + { + ReportDesignerSaveAsDialog d = new ReportDesignerSaveAsDialog(); + d.SelectedName = Util.LocaleText.GetLocalizedText("O.Report"); + d.ReportKey = ReportKey; + DialogResult result = d.ShowDialog(); + + if (result == DialogResult.Cancel) + { + d.Dispose(); + return false; + } + + bDesign = true; + r = Report.NewItem(); + r.Name = d.SelectedName; + r.ReportKey = ReportKey; + d.Dispose(); + } + else + r = Report.GetItem(new Guid(aListToolItem.Key)); + + // + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("ReportHandleToolClick: ReportKey=" + r.ReportKey); + + + if (!bDesign) + { + + //case 1039 //log.Debug("ReportHandleToolClick: Viewing report"); + + XtraReport x = new XtraReport(); //old 1.12.5 xtrareports way - // x.LoadState(r.GetReportContent()); + // x.LoadState(r.GetReportContent()); //case 1039 //log.Debug("ReportHandleToolClick: Calling LoadLayout on report content from db"); @@ -5790,7 +5791,7 @@ At first I was happy to find your code that solved my problem, but I did not lik //case 1039 //log.Debug("ReportHandleToolClick: LoadLayout completed"); LocalizeReport(x); - + //Case 232 change block: //x.DataSource=source; @@ -5823,1146 +5824,1146 @@ At first I was happy to find your code that solved my problem, but I did not lik //case 1039 //log.Debug("ReportHandleToolClick: Initialization complete, displaying report"); - - //x.ExportOptions.Email.RecipientAddress = email; - + + //x.ExportOptions.Email.RecipientAddress = email; + //Case 880 x.PrintingSystem.SetCommandVisibility(DevExpress.XtraPrinting.PrintingSystemCommand.ClosePreview, DevExpress.XtraPrinting.CommandVisibility.None); //case 1468 x.ScriptReferences = AyaBizUtils.GetBizObjectLibraryDllPaths(); - - x.ShowPreviewDialog(); - - } - else - { - //case 1039 //log.Debug("ReportHandleToolClick: Designing report"); - - ////ReportEditor re=new ReportEditor(r,source); + x.ShowPreviewDialog(); + + + } + else + { + //case 1039 //log.Debug("ReportHandleToolClick: Designing report"); + + ////ReportEditor re=new ReportEditor(r,source); ReportEditor2 re = new ReportEditor2(r, source); - re.ShowDialog(); - return re.ChangesMade; - - } - - return false; + re.ShowDialog(); + return re.ChangesMade; - } + } + + return false; + + } - #region Report localization - static public void LocalizeReport(XtraReport r) - { - foreach(Band b in r.Bands) - { - LocalizeReportControl(b); - } - - - } - - /// - /// Localize the text on the report if it starts with LT - /// - /// - static public void LocalizeReportControl(XRControl c) - { - if(c.Text.StartsWith("LT")) - c.Text=LocaleText.GetLocalizedText(c.Text.Replace("LT:","")); - - foreach(XRControl d in c.Controls) - LocalizeReportControl(d); - - - } - #endregion reportlocalization + #region Report localization + static public void LocalizeReport(XtraReport r) + { + foreach (Band b in r.Bands) + { + LocalizeReportControl(b); + } - #endregion - - #region PropertyBag -// /// -// /// Represents a single property in a PropertySpec. -// /// -// public class PropertySpec -// { -// private Attribute[] attributes; -// private string category; -// private object defaultValue; -// private string description; -// private string editor; -// private string name; -// private string type; -// private string typeConverter; -// private string key; -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// The fully qualified name of the type of the property. -// public PropertySpec(string key, string name, string type) : this(key, name, type, null, null, null) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// A Type that represents the type of the property. -// public PropertySpec(string key, string name, Type type) : -// this(key, name, type.AssemblyQualifiedName, null, null, null) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// The fully qualified name of the type of the property. -// /// The category under which the property is displayed in the -// /// property grid. -// public PropertySpec(string key,string name, string type, string category) : this(key, name, type, category, null, null) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// A Type that represents the type of the property. -// /// -// public PropertySpec(string key,string name, Type type, string category) : -// this(key, name, type.AssemblyQualifiedName, category, null, null) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// The fully qualified name of the type of the property. -// /// The category under which the property is displayed in the -// /// property grid. -// /// A string that is displayed in the help area of the -// /// property grid. -// public PropertySpec(string key,string name, string type, string category, string description) : -// this(key, name, type, category, description, null) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// A Type that represents the type of the property. -// /// The category under which the property is displayed in the -// /// property grid. -// /// A string that is displayed in the help area of the -// /// property grid. -// public PropertySpec(string name, Type type, string category, string description) : -// this(name, type.AssemblyQualifiedName, category, description, null) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// The fully qualified name of the type of the property. -// /// The category under which the property is displayed in the -// /// property grid. -// /// A string that is displayed in the help area of the -// /// property grid. -// /// The default value of the property, or null if there is -// /// no default value. -// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue) -// { -// this.key=key; -// this.name = name; -// this.type = type; -// this.category = category; -// this.description = description; -// this.defaultValue = defaultValue; -// this.attributes = null; -// } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// A Type that represents the type of the property. -// /// The category under which the property is displayed in the -// /// property grid. -// /// A string that is displayed in the help area of the -// /// property grid. -// /// The default value of the property, or null if there is -// /// no default value. -// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue) : -// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue) { } -// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// The fully qualified name of the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The fully qualified name of the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The fully qualified name of the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue, -//// string editor, string typeConverter) : this(key, name, type, category, description, defaultValue) -//// { -//// this.editor = editor; -//// this.typeConverter = typeConverter; -//// } -//// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// A Type that represents the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The fully qualified name of the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The fully qualified name of the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue, -//// string editor, string typeConverter) : -//// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue, editor, typeConverter) { } -// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// The fully qualified name of the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The Type that represents the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The fully qualified name of the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue, -//// Type editor, string typeConverter) : -//// this(key, name, type, category, description, defaultValue, editor.AssemblyQualifiedName, -//// typeConverter) { } -// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// A Type that represents the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The Type that represents the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The fully qualified name of the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue, -//// Type editor, string typeConverter) : -//// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue, -//// editor.AssemblyQualifiedName, typeConverter) { } -// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// The fully qualified name of the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The fully qualified name of the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The Type that represents the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue, -//// string editor, Type typeConverter) : -//// this(key, name, type, category, description, defaultValue, editor, typeConverter.AssemblyQualifiedName) { } -//// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// A Type that represents the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The fully qualified name of the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The Type that represents the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key, string name, Type type, string category, string description, object defaultValue, -//// string editor, Type typeConverter) : -//// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue, editor, -//// typeConverter.AssemblyQualifiedName) { } -// -//// /// -//// /// Initializes a new instance of the PropertySpec class. -//// /// -//// /// The name of the property displayed in the property grid. -//// /// The fully qualified name of the type of the property. -//// /// The category under which the property is displayed in the -//// /// property grid. -//// /// A string that is displayed in the help area of the -//// /// property grid. -//// /// The default value of the property, or null if there is -//// /// no default value. -//// /// The Type that represents the type of the editor for this -//// /// property. This type must derive from UITypeEditor. -//// /// The Type that represents the type of the type -//// /// converter for this property. This type must derive from TypeConverter. -//// public PropertySpec(string key, string name, string type, string category, string description, object defaultValue, -//// Type editor, Type typeConverter) : -//// this(key, name, type, category, description, defaultValue, editor.AssemblyQualifiedName, -//// typeConverter.AssemblyQualifiedName) { } -// -// /// -// /// Initializes a new instance of the PropertySpec class. -// /// -// /// The name of the property displayed in the property grid. -// /// A Type that represents the type of the property. -// /// The category under which the property is displayed in the -// /// property grid. -// /// A string that is displayed in the help area of the -// /// property grid. -// /// The default value of the property, or null if there is -// /// no default value. -// /// The Type that represents the type of the editor for this -// /// property. This type must derive from UITypeEditor. -// /// The Type that represents the type of the type -// /// converter for this property. This type must derive from TypeConverter. -// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue, -// Type editor, Type typeConverter) -// { -// this.key=key; -// this.name = name; -// this.type = type.AssemblyQualifiedName; -// this.category = category; -// this.description = description; -// this.defaultValue = defaultValue; -// this.attributes = null; -// -// if(editor!=null) -// this.editor=editor.AssemblyQualifiedName; -// -// if(typeConverter!=null) -// this.typeConverter=typeConverter.AssemblyQualifiedName; -// -// -// } -// -// -// -// -// /// -// /// Gets or sets a collection of additional Attributes for this property. This can -// /// be used to specify attributes beyond those supported intrinsically by the -// /// PropertySpec class, such as ReadOnly and Browsable. -// /// -// public Attribute[] Attributes -// { -// get { return attributes; } -// set { attributes = value; } -// } -// -// /// -// /// Gets or sets the key of this property. -// /// -// public string Key -// { -// get { return key; } -// set { key = value; } -// } -// -// /// -// /// Gets or sets the category name of this property. -// /// -// public string Category -// { -// get { return category; } -// set { category = value; } -// } -// -// /// -// /// Gets or sets the fully qualified name of the type converter -// /// type for this property. -// /// -// public string ConverterTypeName -// { -// get { return typeConverter; } -// set { typeConverter = value; } -// } -// -// /// -// /// Gets or sets the default value of this property. -// /// -// public object DefaultValue -// { -// get { return defaultValue; } -// set { defaultValue = value; } -// } -// -// /// -// /// Gets or sets the help text description of this property. -// /// -// public string Description -// { -// get { return description; } -// set { description = value; } -// } -// -// /// -// /// Gets or sets the fully qualified name of the editor type for -// /// this property. -// /// -// public string EditorTypeName -// { -// get { return editor; } -// set { editor = value; } -// } -// -// /// -// /// Gets or sets the name of this property. -// /// -// public string Name -// { -// get { return name; } -// set { name = value; } -// } -// -// /// -// /// Gets or sets the fully qualfied name of the type of this -// /// property. -// /// -// public string TypeName -// { -// get { return type; } -// set { type = value; } -// } -// } -// -// /// -// /// Provides data for the GetValue and SetValue events of the PropertyBag class. -// /// -// public class PropertySpecEventArgs : EventArgs -// { -// private PropertySpec property; -// private object val; -// -// /// -// /// Initializes a new instance of the PropertySpecEventArgs class. -// /// -// /// The PropertySpec that represents the property whose -// /// value is being requested or set. -// /// The current value of the property. -// public PropertySpecEventArgs(PropertySpec property, object val) -// { -// this.property = property; -// this.val = val; -// } -// -// /// -// /// Gets the PropertySpec that represents the property whose value is being -// /// requested or set. -// /// -// public PropertySpec Property -// { -// get { return property; } -// } -// -// /// -// /// Gets or sets the current value of the property. -// /// -// public object Value -// { -// get { return val; } -// set { val = value; } -// } -// } -// -// /// -// /// Represents the method that will handle the GetValue and SetValue events of the -// /// PropertyBag class. -// /// -// public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e); -// -// /// -// /// Represents a collection of custom properties that can be selected into a -// /// PropertyGrid to provide functionality beyond that of the simple reflection -// /// normally used to query an object's properties. -// /// -// public class PropertyBag : ICustomTypeDescriptor -// { -// #region PropertySpecCollection class definition -// /// -// /// Encapsulates a collection of PropertySpec objects. -// /// -// [Serializable] -// public class PropertySpecCollection : IList -// { -// private ArrayList innerArray; -// -// /// -// /// Initializes a new instance of the PropertySpecCollection class. -// /// -// public PropertySpecCollection() -// { -// innerArray = new ArrayList(); -// } -// -// /// -// /// Gets the number of elements in the PropertySpecCollection. -// /// -// /// -// /// The number of elements contained in the PropertySpecCollection. -// /// -// public int Count -// { -// get { return innerArray.Count; } -// } -// -// /// -// /// Gets a value indicating whether the PropertySpecCollection has a fixed size. -// /// -// /// -// /// true if the PropertySpecCollection has a fixed size; otherwise, false. -// /// -// public bool IsFixedSize -// { -// get { return false; } -// } -// -// /// -// /// Gets a value indicating whether the PropertySpecCollection is read-only. -// /// -// public bool IsReadOnly -// { -// get { return false; } -// } -// -// /// -// /// Gets a value indicating whether access to the collection is synchronized (thread-safe). -// /// -// /// -// /// true if access to the PropertySpecCollection is synchronized (thread-safe); otherwise, false. -// /// -// public bool IsSynchronized -// { -// get { return false; } -// } -// -// /// -// /// Gets an object that can be used to synchronize access to the collection. -// /// -// /// -// /// An object that can be used to synchronize access to the collection. -// /// -// object ICollection.SyncRoot -// { -// get { return null; } -// } -// -// /// -// /// Gets or sets the element at the specified index. -// /// In C#, this property is the indexer for the PropertySpecCollection class. -// /// -// /// The zero-based index of the element to get or set. -// /// -// /// The element at the specified index. -// /// -// public PropertySpec this[int index] -// { -// get { return (PropertySpec)innerArray[index]; } -// set { innerArray[index] = value; } -// } -// -// /// -// /// Adds a PropertySpec to the end of the PropertySpecCollection. -// /// -// /// The PropertySpec to be added to the end of the PropertySpecCollection. -// /// The PropertySpecCollection index at which the value has been added. -// public int Add(PropertySpec value) -// { -// int index = innerArray.Add(value); -// -// return index; -// } -// -// /// -// /// Adds the elements of an array of PropertySpec objects to the end of the PropertySpecCollection. -// /// -// /// The PropertySpec array whose elements should be added to the end of the -// /// PropertySpecCollection. -// public void AddRange(PropertySpec[] array) -// { -// innerArray.AddRange(array); -// } -// -// /// -// /// Removes all elements from the PropertySpecCollection. -// /// -// public void Clear() -// { -// innerArray.Clear(); -// } -// -// /// -// /// Determines whether a PropertySpec is in the PropertySpecCollection. -// /// -// /// The PropertySpec to locate in the PropertySpecCollection. The element to locate -// /// can be a null reference (Nothing in Visual Basic). -// /// true if item is found in the PropertySpecCollection; otherwise, false. -// public bool Contains(PropertySpec item) -// { -// return innerArray.Contains(item); -// } -// -// /// -// /// Determines whether a PropertySpec with the specified name is in the PropertySpecCollection. -// /// -// /// The name of the PropertySpec to locate in the PropertySpecCollection. -// /// true if item is found in the PropertySpecCollection; otherwise, false. -// public bool Contains(string name) -// { -// foreach(PropertySpec spec in innerArray) -// if(spec.Name == name) -// return true; -// -// return false; -// } -// -// /// -// /// Copies the entire PropertySpecCollection to a compatible one-dimensional Array, starting at the -// /// beginning of the target array. -// /// -// /// The one-dimensional Array that is the destination of the elements copied -// /// from PropertySpecCollection. The Array must have zero-based indexing. -// public void CopyTo(PropertySpec[] array) -// { -// innerArray.CopyTo(array); -// } -// -// /// -// /// Copies the PropertySpecCollection or a portion of it to a one-dimensional array. -// /// -// /// The one-dimensional Array that is the destination of the elements copied -// /// from the collection. -// /// The zero-based index in array at which copying begins. -// public void CopyTo(PropertySpec[] array, int index) -// { -// innerArray.CopyTo(array, index); -// } -// -// /// -// /// Returns an enumerator that can iterate through the PropertySpecCollection. -// /// -// /// An IEnumerator for the entire PropertySpecCollection. -// public IEnumerator GetEnumerator() -// { -// return innerArray.GetEnumerator(); -// } -// -// /// -// /// Searches for the specified PropertySpec and returns the zero-based index of the first -// /// occurrence within the entire PropertySpecCollection. -// /// -// /// The PropertySpec to locate in the PropertySpecCollection. -// /// The zero-based index of the first occurrence of value within the entire PropertySpecCollection, -// /// if found; otherwise, -1. -// public int IndexOf(PropertySpec value) -// { -// return innerArray.IndexOf(value); -// } -// -// /// -// /// Searches for the PropertySpec with the specified name and returns the zero-based index of -// /// the first occurrence within the entire PropertySpecCollection. -// /// -// /// The name of the PropertySpec to locate in the PropertySpecCollection. -// /// The zero-based index of the first occurrence of value within the entire PropertySpecCollection, -// /// if found; otherwise, -1. -// public int IndexOf(string name) -// { -// int i = 0; -// -// foreach(PropertySpec spec in innerArray) -// { -// if(spec.Name == name) -// return i; -// -// i++; -// } -// -// return -1; -// } -// -// /// -// /// Inserts a PropertySpec object into the PropertySpecCollection at the specified index. -// /// -// /// The zero-based index at which value should be inserted. -// /// The PropertySpec to insert. -// public void Insert(int index, PropertySpec value) -// { -// innerArray.Insert(index, value); -// } -// -// /// -// /// Removes the first occurrence of a specific object from the PropertySpecCollection. -// /// -// /// The PropertySpec to remove from the PropertySpecCollection. -// public void Remove(PropertySpec obj) -// { -// innerArray.Remove(obj); -// } -// -// /// -// /// Removes the property with the specified name from the PropertySpecCollection. -// /// -// /// The name of the PropertySpec to remove from the PropertySpecCollection. -// public void Remove(string name) -// { -// int index = IndexOf(name); -// RemoveAt(index); -// } -// -// /// -// /// Removes the object at the specified index of the PropertySpecCollection. -// /// -// /// The zero-based index of the element to remove. -// public void RemoveAt(int index) -// { -// innerArray.RemoveAt(index); -// } -// -// /// -// /// Copies the elements of the PropertySpecCollection to a new PropertySpec array. -// /// -// /// A PropertySpec array containing copies of the elements of the PropertySpecCollection. -// public PropertySpec[] ToArray() -// { -// return (PropertySpec[])innerArray.ToArray(typeof(PropertySpec)); -// } -// -// #region Explicit interface implementations for ICollection and IList -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// void ICollection.CopyTo(Array array, int index) -// { -// CopyTo((PropertySpec[])array, index); -// } -// -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// int IList.Add(object value) -// { -// return Add((PropertySpec)value); -// } -// -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// bool IList.Contains(object obj) -// { -// return Contains((PropertySpec)obj); -// } -// -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// object IList.this[int index] -// { -// get -// { -// return ((PropertySpecCollection)this)[index]; -// } -// set -// { -// ((PropertySpecCollection)this)[index] = (PropertySpec)value; -// } -// } -// -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// int IList.IndexOf(object obj) -// { -// return IndexOf((PropertySpec)obj); -// } -// -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// void IList.Insert(int index, object value) -// { -// Insert(index, (PropertySpec)value); -// } -// -// /// -// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. -// /// -// void IList.Remove(object value) -// { -// Remove((PropertySpec)value); -// } -// #endregion -// } -// #endregion -// #region PropertySpecDescriptor class definition -// private class PropertySpecDescriptor : PropertyDescriptor -// { -// private PropertyBag bag; -// private PropertySpec item; -// -// public PropertySpecDescriptor(PropertySpec item, PropertyBag bag, string name, Attribute[] attrs) : -// base(name, attrs) -// { -// this.bag = bag; -// this.item = item; -// } -// -// public override Type ComponentType -// { -// get { return item.GetType(); } -// } -// -// public override bool IsReadOnly -// { -// get { return (Attributes.Matches(ReadOnlyAttribute.Yes)); } -// } -// -// public override Type PropertyType -// { -// get { return Type.GetType(item.TypeName); } -// } -// -// public override bool CanResetValue(object component) -// { -// if(item.DefaultValue == null) -// return false; -// else -// return !this.GetValue(component).Equals(item.DefaultValue); -// } -// -// public override object GetValue(object component) -// { -// // Have the property bag raise an event to get the current value -// // of the property. -// -// PropertySpecEventArgs e = new PropertySpecEventArgs(item, null); -// bag.OnGetValue(e); -// return e.Value; -// } -// -// public override void ResetValue(object component) -// { -// SetValue(component, item.DefaultValue); -// } -// -// public override void SetValue(object component, object value) -// { -// // Have the property bag raise an event to set the current value -// // of the property. -// -// PropertySpecEventArgs e = new PropertySpecEventArgs(item, value); -// bag.OnSetValue(e); -// } -// -// public override bool ShouldSerializeValue(object component) -// { -// object val = this.GetValue(component); -// -// if(item.DefaultValue == null && val == null) -// return false; -// else -// return !val.Equals(item.DefaultValue); -// } -// } -// #endregion -// -// private string defaultProperty; -// private PropertySpecCollection properties; -// -// /// -// /// Initializes a new instance of the PropertyBag class. -// /// -// public PropertyBag() -// { -// defaultProperty = null; -// properties = new PropertySpecCollection(); -// } -// -// /// -// /// Gets or sets the name of the default property in the collection. -// /// -// public string DefaultProperty -// { -// get { return defaultProperty; } -// set { defaultProperty = value; } -// } -// -// /// -// /// Gets the collection of properties contained within this PropertyBag. -// /// -// public PropertySpecCollection Properties -// { -// get { return properties; } -// } -// -// /// -// /// Occurs when a PropertyGrid requests the value of a property. -// /// -// public event PropertySpecEventHandler GetValue; -// -// /// -// /// Occurs when the user changes the value of a property in a PropertyGrid. -// /// -// public event PropertySpecEventHandler SetValue; -// -// /// -// /// Raises the GetValue event. -// /// -// /// A PropertySpecEventArgs that contains the event data. -// protected virtual void OnGetValue(PropertySpecEventArgs e) -// { -// if(GetValue != null) -// GetValue(this, e); -// } -// -// /// -// /// Raises the SetValue event. -// /// -// /// A PropertySpecEventArgs that contains the event data. -// protected virtual void OnSetValue(PropertySpecEventArgs e) -// { -// if(SetValue != null) -// SetValue(this, e); -// } -// -// #region ICustomTypeDescriptor explicit interface definitions -// // Most of the functions required by the ICustomTypeDescriptor are -// // merely pssed on to the default TypeDescriptor for this type, -// // which will do something appropriate. The exceptions are noted -// // below. -// AttributeCollection ICustomTypeDescriptor.GetAttributes() -// { -// return TypeDescriptor.GetAttributes(this, true); -// } -// -// string ICustomTypeDescriptor.GetClassName() -// { -// return TypeDescriptor.GetClassName(this, true); -// } -// -// string ICustomTypeDescriptor.GetComponentName() -// { -// return TypeDescriptor.GetComponentName(this, true); -// } -// -// TypeConverter ICustomTypeDescriptor.GetConverter() -// { -// return TypeDescriptor.GetConverter(this, true); -// } -// -// EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() -// { -// return TypeDescriptor.GetDefaultEvent(this, true); -// } -// -// PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() -// { -// // This function searches the property list for the property -// // with the same name as the DefaultProperty specified, and -// // returns a property descriptor for it. If no property is -// // found that matches DefaultProperty, a null reference is -// // returned instead. -// -// PropertySpec propertySpec = null; -// if(defaultProperty != null) -// { -// int index = properties.IndexOf(defaultProperty); -// propertySpec = properties[index]; -// } -// -// if(propertySpec != null) -// return new PropertySpecDescriptor(propertySpec, this, propertySpec.Name, null); -// else -// return null; -// } -// -// object ICustomTypeDescriptor.GetEditor(Type editorBaseType) -// { -// return TypeDescriptor.GetEditor(this, editorBaseType, true); -// } -// -// EventDescriptorCollection ICustomTypeDescriptor.GetEvents() -// { -// return TypeDescriptor.GetEvents(this, true); -// } -// -// EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) -// { -// return TypeDescriptor.GetEvents(this, attributes, true); -// } -// -// PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() -// { -// return ((ICustomTypeDescriptor)this).GetProperties(new Attribute[0]); -// } -// -// PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) -// { -// // Rather than passing this function on to the default TypeDescriptor, -// // which would return the actual properties of PropertyBag, I construct -// // a list here that contains property descriptors for the elements of the -// // Properties list in the bag. -// -// ArrayList props = new ArrayList(); -// -// foreach(PropertySpec property in properties) -// { -// ArrayList attrs = new ArrayList(); -// -// // If a category, description, editor, or type converter are specified -// // in the PropertySpec, create attributes to define that relationship. -// if(property.Category != null) -// attrs.Add(new CategoryAttribute(property.Category)); -// -// if(property.Description != null) -// attrs.Add(new DescriptionAttribute(property.Description)); -// -// if(property.EditorTypeName != null) -// attrs.Add(new EditorAttribute(property.EditorTypeName, typeof(UITypeEditor))); -// -// if(property.ConverterTypeName != null) -// attrs.Add(new TypeConverterAttribute(property.ConverterTypeName)); -// -// // Additionally, append the custom attributes associated with the -// // PropertySpec, if any. -// if(property.Attributes != null) -// attrs.AddRange(property.Attributes); -// -// Attribute[] attrArray = (Attribute[])attrs.ToArray(typeof(Attribute)); -// -// // Create a new property descriptor for the property item, and add -// // it to the list. -// PropertySpecDescriptor pd = new PropertySpecDescriptor(property, -// this, property.Name, attrArray); -// props.Add(pd); -// } -// -// // Convert the list of PropertyDescriptors to a collection that the -// // ICustomTypeDescriptor can use, and return it. -// PropertyDescriptor[] propArray = (PropertyDescriptor[])props.ToArray( -// typeof(PropertyDescriptor)); -// return new PropertyDescriptorCollection(propArray); -// } -// -// object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) -// { -// return this; -// } -// #endregion -// } -// -// /// -// /// An extension of PropertyBag that manages a table of property values, in -// /// addition to firing events when property values are requested or set. -// /// -// public class PropertyTable : PropertyBag -// { -// private Hashtable propValues; -// -// /// -// /// Initializes a new instance of the PropertyTable class. -// /// -// public PropertyTable() -// { -// propValues = new Hashtable(); -// } -// -// /// -// /// Gets or sets the value of the property with the specified name. -// ///

In C#, this property is the indexer of the PropertyTable class.

-// ///
-// public object this[string key] -// { -// get { return propValues[key]; } -// set { propValues[key] = value; } -// } -// -// /// -// /// This member overrides PropertyBag.OnGetValue. -// /// -// protected override void OnGetValue(PropertySpecEventArgs e) -// { -// e.Value = propValues[e.Property.Name]; -// base.OnGetValue(e); -// } -// -// /// -// /// This member overrides PropertyBag.OnSetValue. -// /// -// protected override void OnSetValue(PropertySpecEventArgs e) -// { -// propValues[e.Property.Name] = e.Value; -// base.OnSetValue(e); -// } -// } -// + } - #endregion + /// + /// Localize the text on the report if it starts with LT + /// + /// + static public void LocalizeReportControl(XRControl c) + { + if (c.Text.StartsWith("LT")) + c.Text = LocaleText.GetLocalizedText(c.Text.Replace("LT:", "")); - #region WorkorderTemplatePropertyGridEditor - public class WorkorderTemplateEditor : UITypeEditor - { - public override UITypeEditorEditStyle - GetEditStyle(ITypeDescriptorContext context) - { - return UITypeEditorEditStyle.DropDown; - } - - public override object EditValue(ITypeDescriptorContext context, - IServiceProvider provider, object value) - { - IWindowsFormsEditorService wfes = - provider.GetService(typeof(IWindowsFormsEditorService)) as - IWindowsFormsEditorService; - - if (wfes != null) - { - WorkorderSummaryTemplate f = new WorkorderSummaryTemplate(); - f.WorkorderSummaryTemplateToEdit = (string) value; - f._wfes = wfes; - - wfes.DropDownControl(f); - value = f.WorkorderSummaryTemplateToEdit; - } - return value; - } - } + foreach (XRControl d in c.Controls) + LocalizeReportControl(d); - #endregion + } + #endregion reportlocalization - #region Form Drag and drop helpers + + #endregion + + #region PropertyBag + // /// + // /// Represents a single property in a PropertySpec. + // /// + // public class PropertySpec + // { + // private Attribute[] attributes; + // private string category; + // private object defaultValue; + // private string description; + // private string editor; + // private string name; + // private string type; + // private string typeConverter; + // private string key; + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// The fully qualified name of the type of the property. + // public PropertySpec(string key, string name, string type) : this(key, name, type, null, null, null) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// A Type that represents the type of the property. + // public PropertySpec(string key, string name, Type type) : + // this(key, name, type.AssemblyQualifiedName, null, null, null) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// The fully qualified name of the type of the property. + // /// The category under which the property is displayed in the + // /// property grid. + // public PropertySpec(string key,string name, string type, string category) : this(key, name, type, category, null, null) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// A Type that represents the type of the property. + // /// + // public PropertySpec(string key,string name, Type type, string category) : + // this(key, name, type.AssemblyQualifiedName, category, null, null) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// The fully qualified name of the type of the property. + // /// The category under which the property is displayed in the + // /// property grid. + // /// A string that is displayed in the help area of the + // /// property grid. + // public PropertySpec(string key,string name, string type, string category, string description) : + // this(key, name, type, category, description, null) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// A Type that represents the type of the property. + // /// The category under which the property is displayed in the + // /// property grid. + // /// A string that is displayed in the help area of the + // /// property grid. + // public PropertySpec(string name, Type type, string category, string description) : + // this(name, type.AssemblyQualifiedName, category, description, null) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// The fully qualified name of the type of the property. + // /// The category under which the property is displayed in the + // /// property grid. + // /// A string that is displayed in the help area of the + // /// property grid. + // /// The default value of the property, or null if there is + // /// no default value. + // public PropertySpec(string key,string name, string type, string category, string description, object defaultValue) + // { + // this.key=key; + // this.name = name; + // this.type = type; + // this.category = category; + // this.description = description; + // this.defaultValue = defaultValue; + // this.attributes = null; + // } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// A Type that represents the type of the property. + // /// The category under which the property is displayed in the + // /// property grid. + // /// A string that is displayed in the help area of the + // /// property grid. + // /// The default value of the property, or null if there is + // /// no default value. + // public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue) : + // this(key, name, type.AssemblyQualifiedName, category, description, defaultValue) { } + // + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// The fully qualified name of the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The fully qualified name of the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The fully qualified name of the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue, + //// string editor, string typeConverter) : this(key, name, type, category, description, defaultValue) + //// { + //// this.editor = editor; + //// this.typeConverter = typeConverter; + //// } + //// + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// A Type that represents the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The fully qualified name of the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The fully qualified name of the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue, + //// string editor, string typeConverter) : + //// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue, editor, typeConverter) { } + // + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// The fully qualified name of the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The Type that represents the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The fully qualified name of the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue, + //// Type editor, string typeConverter) : + //// this(key, name, type, category, description, defaultValue, editor.AssemblyQualifiedName, + //// typeConverter) { } + // + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// A Type that represents the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The Type that represents the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The fully qualified name of the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue, + //// Type editor, string typeConverter) : + //// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue, + //// editor.AssemblyQualifiedName, typeConverter) { } + // + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// The fully qualified name of the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The fully qualified name of the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The Type that represents the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key,string name, string type, string category, string description, object defaultValue, + //// string editor, Type typeConverter) : + //// this(key, name, type, category, description, defaultValue, editor, typeConverter.AssemblyQualifiedName) { } + //// + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// A Type that represents the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The fully qualified name of the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The Type that represents the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key, string name, Type type, string category, string description, object defaultValue, + //// string editor, Type typeConverter) : + //// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue, editor, + //// typeConverter.AssemblyQualifiedName) { } + // + //// /// + //// /// Initializes a new instance of the PropertySpec class. + //// /// + //// /// The name of the property displayed in the property grid. + //// /// The fully qualified name of the type of the property. + //// /// The category under which the property is displayed in the + //// /// property grid. + //// /// A string that is displayed in the help area of the + //// /// property grid. + //// /// The default value of the property, or null if there is + //// /// no default value. + //// /// The Type that represents the type of the editor for this + //// /// property. This type must derive from UITypeEditor. + //// /// The Type that represents the type of the type + //// /// converter for this property. This type must derive from TypeConverter. + //// public PropertySpec(string key, string name, string type, string category, string description, object defaultValue, + //// Type editor, Type typeConverter) : + //// this(key, name, type, category, description, defaultValue, editor.AssemblyQualifiedName, + //// typeConverter.AssemblyQualifiedName) { } + // + // /// + // /// Initializes a new instance of the PropertySpec class. + // /// + // /// The name of the property displayed in the property grid. + // /// A Type that represents the type of the property. + // /// The category under which the property is displayed in the + // /// property grid. + // /// A string that is displayed in the help area of the + // /// property grid. + // /// The default value of the property, or null if there is + // /// no default value. + // /// The Type that represents the type of the editor for this + // /// property. This type must derive from UITypeEditor. + // /// The Type that represents the type of the type + // /// converter for this property. This type must derive from TypeConverter. + // public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue, + // Type editor, Type typeConverter) + // { + // this.key=key; + // this.name = name; + // this.type = type.AssemblyQualifiedName; + // this.category = category; + // this.description = description; + // this.defaultValue = defaultValue; + // this.attributes = null; + // + // if(editor!=null) + // this.editor=editor.AssemblyQualifiedName; + // + // if(typeConverter!=null) + // this.typeConverter=typeConverter.AssemblyQualifiedName; + // + // + // } + // + // + // + // + // /// + // /// Gets or sets a collection of additional Attributes for this property. This can + // /// be used to specify attributes beyond those supported intrinsically by the + // /// PropertySpec class, such as ReadOnly and Browsable. + // /// + // public Attribute[] Attributes + // { + // get { return attributes; } + // set { attributes = value; } + // } + // + // /// + // /// Gets or sets the key of this property. + // /// + // public string Key + // { + // get { return key; } + // set { key = value; } + // } + // + // /// + // /// Gets or sets the category name of this property. + // /// + // public string Category + // { + // get { return category; } + // set { category = value; } + // } + // + // /// + // /// Gets or sets the fully qualified name of the type converter + // /// type for this property. + // /// + // public string ConverterTypeName + // { + // get { return typeConverter; } + // set { typeConverter = value; } + // } + // + // /// + // /// Gets or sets the default value of this property. + // /// + // public object DefaultValue + // { + // get { return defaultValue; } + // set { defaultValue = value; } + // } + // + // /// + // /// Gets or sets the help text description of this property. + // /// + // public string Description + // { + // get { return description; } + // set { description = value; } + // } + // + // /// + // /// Gets or sets the fully qualified name of the editor type for + // /// this property. + // /// + // public string EditorTypeName + // { + // get { return editor; } + // set { editor = value; } + // } + // + // /// + // /// Gets or sets the name of this property. + // /// + // public string Name + // { + // get { return name; } + // set { name = value; } + // } + // + // /// + // /// Gets or sets the fully qualfied name of the type of this + // /// property. + // /// + // public string TypeName + // { + // get { return type; } + // set { type = value; } + // } + // } + // + // /// + // /// Provides data for the GetValue and SetValue events of the PropertyBag class. + // /// + // public class PropertySpecEventArgs : EventArgs + // { + // private PropertySpec property; + // private object val; + // + // /// + // /// Initializes a new instance of the PropertySpecEventArgs class. + // /// + // /// The PropertySpec that represents the property whose + // /// value is being requested or set. + // /// The current value of the property. + // public PropertySpecEventArgs(PropertySpec property, object val) + // { + // this.property = property; + // this.val = val; + // } + // + // /// + // /// Gets the PropertySpec that represents the property whose value is being + // /// requested or set. + // /// + // public PropertySpec Property + // { + // get { return property; } + // } + // + // /// + // /// Gets or sets the current value of the property. + // /// + // public object Value + // { + // get { return val; } + // set { val = value; } + // } + // } + // + // /// + // /// Represents the method that will handle the GetValue and SetValue events of the + // /// PropertyBag class. + // /// + // public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e); + // + // /// + // /// Represents a collection of custom properties that can be selected into a + // /// PropertyGrid to provide functionality beyond that of the simple reflection + // /// normally used to query an object's properties. + // /// + // public class PropertyBag : ICustomTypeDescriptor + // { + // #region PropertySpecCollection class definition + // /// + // /// Encapsulates a collection of PropertySpec objects. + // /// + // [Serializable] + // public class PropertySpecCollection : IList + // { + // private ArrayList innerArray; + // + // /// + // /// Initializes a new instance of the PropertySpecCollection class. + // /// + // public PropertySpecCollection() + // { + // innerArray = new ArrayList(); + // } + // + // /// + // /// Gets the number of elements in the PropertySpecCollection. + // /// + // /// + // /// The number of elements contained in the PropertySpecCollection. + // /// + // public int Count + // { + // get { return innerArray.Count; } + // } + // + // /// + // /// Gets a value indicating whether the PropertySpecCollection has a fixed size. + // /// + // /// + // /// true if the PropertySpecCollection has a fixed size; otherwise, false. + // /// + // public bool IsFixedSize + // { + // get { return false; } + // } + // + // /// + // /// Gets a value indicating whether the PropertySpecCollection is read-only. + // /// + // public bool IsReadOnly + // { + // get { return false; } + // } + // + // /// + // /// Gets a value indicating whether access to the collection is synchronized (thread-safe). + // /// + // /// + // /// true if access to the PropertySpecCollection is synchronized (thread-safe); otherwise, false. + // /// + // public bool IsSynchronized + // { + // get { return false; } + // } + // + // /// + // /// Gets an object that can be used to synchronize access to the collection. + // /// + // /// + // /// An object that can be used to synchronize access to the collection. + // /// + // object ICollection.SyncRoot + // { + // get { return null; } + // } + // + // /// + // /// Gets or sets the element at the specified index. + // /// In C#, this property is the indexer for the PropertySpecCollection class. + // /// + // /// The zero-based index of the element to get or set. + // /// + // /// The element at the specified index. + // /// + // public PropertySpec this[int index] + // { + // get { return (PropertySpec)innerArray[index]; } + // set { innerArray[index] = value; } + // } + // + // /// + // /// Adds a PropertySpec to the end of the PropertySpecCollection. + // /// + // /// The PropertySpec to be added to the end of the PropertySpecCollection. + // /// The PropertySpecCollection index at which the value has been added. + // public int Add(PropertySpec value) + // { + // int index = innerArray.Add(value); + // + // return index; + // } + // + // /// + // /// Adds the elements of an array of PropertySpec objects to the end of the PropertySpecCollection. + // /// + // /// The PropertySpec array whose elements should be added to the end of the + // /// PropertySpecCollection. + // public void AddRange(PropertySpec[] array) + // { + // innerArray.AddRange(array); + // } + // + // /// + // /// Removes all elements from the PropertySpecCollection. + // /// + // public void Clear() + // { + // innerArray.Clear(); + // } + // + // /// + // /// Determines whether a PropertySpec is in the PropertySpecCollection. + // /// + // /// The PropertySpec to locate in the PropertySpecCollection. The element to locate + // /// can be a null reference (Nothing in Visual Basic). + // /// true if item is found in the PropertySpecCollection; otherwise, false. + // public bool Contains(PropertySpec item) + // { + // return innerArray.Contains(item); + // } + // + // /// + // /// Determines whether a PropertySpec with the specified name is in the PropertySpecCollection. + // /// + // /// The name of the PropertySpec to locate in the PropertySpecCollection. + // /// true if item is found in the PropertySpecCollection; otherwise, false. + // public bool Contains(string name) + // { + // foreach(PropertySpec spec in innerArray) + // if(spec.Name == name) + // return true; + // + // return false; + // } + // + // /// + // /// Copies the entire PropertySpecCollection to a compatible one-dimensional Array, starting at the + // /// beginning of the target array. + // /// + // /// The one-dimensional Array that is the destination of the elements copied + // /// from PropertySpecCollection. The Array must have zero-based indexing. + // public void CopyTo(PropertySpec[] array) + // { + // innerArray.CopyTo(array); + // } + // + // /// + // /// Copies the PropertySpecCollection or a portion of it to a one-dimensional array. + // /// + // /// The one-dimensional Array that is the destination of the elements copied + // /// from the collection. + // /// The zero-based index in array at which copying begins. + // public void CopyTo(PropertySpec[] array, int index) + // { + // innerArray.CopyTo(array, index); + // } + // + // /// + // /// Returns an enumerator that can iterate through the PropertySpecCollection. + // /// + // /// An IEnumerator for the entire PropertySpecCollection. + // public IEnumerator GetEnumerator() + // { + // return innerArray.GetEnumerator(); + // } + // + // /// + // /// Searches for the specified PropertySpec and returns the zero-based index of the first + // /// occurrence within the entire PropertySpecCollection. + // /// + // /// The PropertySpec to locate in the PropertySpecCollection. + // /// The zero-based index of the first occurrence of value within the entire PropertySpecCollection, + // /// if found; otherwise, -1. + // public int IndexOf(PropertySpec value) + // { + // return innerArray.IndexOf(value); + // } + // + // /// + // /// Searches for the PropertySpec with the specified name and returns the zero-based index of + // /// the first occurrence within the entire PropertySpecCollection. + // /// + // /// The name of the PropertySpec to locate in the PropertySpecCollection. + // /// The zero-based index of the first occurrence of value within the entire PropertySpecCollection, + // /// if found; otherwise, -1. + // public int IndexOf(string name) + // { + // int i = 0; + // + // foreach(PropertySpec spec in innerArray) + // { + // if(spec.Name == name) + // return i; + // + // i++; + // } + // + // return -1; + // } + // + // /// + // /// Inserts a PropertySpec object into the PropertySpecCollection at the specified index. + // /// + // /// The zero-based index at which value should be inserted. + // /// The PropertySpec to insert. + // public void Insert(int index, PropertySpec value) + // { + // innerArray.Insert(index, value); + // } + // + // /// + // /// Removes the first occurrence of a specific object from the PropertySpecCollection. + // /// + // /// The PropertySpec to remove from the PropertySpecCollection. + // public void Remove(PropertySpec obj) + // { + // innerArray.Remove(obj); + // } + // + // /// + // /// Removes the property with the specified name from the PropertySpecCollection. + // /// + // /// The name of the PropertySpec to remove from the PropertySpecCollection. + // public void Remove(string name) + // { + // int index = IndexOf(name); + // RemoveAt(index); + // } + // + // /// + // /// Removes the object at the specified index of the PropertySpecCollection. + // /// + // /// The zero-based index of the element to remove. + // public void RemoveAt(int index) + // { + // innerArray.RemoveAt(index); + // } + // + // /// + // /// Copies the elements of the PropertySpecCollection to a new PropertySpec array. + // /// + // /// A PropertySpec array containing copies of the elements of the PropertySpecCollection. + // public PropertySpec[] ToArray() + // { + // return (PropertySpec[])innerArray.ToArray(typeof(PropertySpec)); + // } + // + // #region Explicit interface implementations for ICollection and IList + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // void ICollection.CopyTo(Array array, int index) + // { + // CopyTo((PropertySpec[])array, index); + // } + // + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // int IList.Add(object value) + // { + // return Add((PropertySpec)value); + // } + // + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // bool IList.Contains(object obj) + // { + // return Contains((PropertySpec)obj); + // } + // + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // object IList.this[int index] + // { + // get + // { + // return ((PropertySpecCollection)this)[index]; + // } + // set + // { + // ((PropertySpecCollection)this)[index] = (PropertySpec)value; + // } + // } + // + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // int IList.IndexOf(object obj) + // { + // return IndexOf((PropertySpec)obj); + // } + // + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // void IList.Insert(int index, object value) + // { + // Insert(index, (PropertySpec)value); + // } + // + // /// + // /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code. + // /// + // void IList.Remove(object value) + // { + // Remove((PropertySpec)value); + // } + // #endregion + // } + // #endregion + // #region PropertySpecDescriptor class definition + // private class PropertySpecDescriptor : PropertyDescriptor + // { + // private PropertyBag bag; + // private PropertySpec item; + // + // public PropertySpecDescriptor(PropertySpec item, PropertyBag bag, string name, Attribute[] attrs) : + // base(name, attrs) + // { + // this.bag = bag; + // this.item = item; + // } + // + // public override Type ComponentType + // { + // get { return item.GetType(); } + // } + // + // public override bool IsReadOnly + // { + // get { return (Attributes.Matches(ReadOnlyAttribute.Yes)); } + // } + // + // public override Type PropertyType + // { + // get { return Type.GetType(item.TypeName); } + // } + // + // public override bool CanResetValue(object component) + // { + // if(item.DefaultValue == null) + // return false; + // else + // return !this.GetValue(component).Equals(item.DefaultValue); + // } + // + // public override object GetValue(object component) + // { + // // Have the property bag raise an event to get the current value + // // of the property. + // + // PropertySpecEventArgs e = new PropertySpecEventArgs(item, null); + // bag.OnGetValue(e); + // return e.Value; + // } + // + // public override void ResetValue(object component) + // { + // SetValue(component, item.DefaultValue); + // } + // + // public override void SetValue(object component, object value) + // { + // // Have the property bag raise an event to set the current value + // // of the property. + // + // PropertySpecEventArgs e = new PropertySpecEventArgs(item, value); + // bag.OnSetValue(e); + // } + // + // public override bool ShouldSerializeValue(object component) + // { + // object val = this.GetValue(component); + // + // if(item.DefaultValue == null && val == null) + // return false; + // else + // return !val.Equals(item.DefaultValue); + // } + // } + // #endregion + // + // private string defaultProperty; + // private PropertySpecCollection properties; + // + // /// + // /// Initializes a new instance of the PropertyBag class. + // /// + // public PropertyBag() + // { + // defaultProperty = null; + // properties = new PropertySpecCollection(); + // } + // + // /// + // /// Gets or sets the name of the default property in the collection. + // /// + // public string DefaultProperty + // { + // get { return defaultProperty; } + // set { defaultProperty = value; } + // } + // + // /// + // /// Gets the collection of properties contained within this PropertyBag. + // /// + // public PropertySpecCollection Properties + // { + // get { return properties; } + // } + // + // /// + // /// Occurs when a PropertyGrid requests the value of a property. + // /// + // public event PropertySpecEventHandler GetValue; + // + // /// + // /// Occurs when the user changes the value of a property in a PropertyGrid. + // /// + // public event PropertySpecEventHandler SetValue; + // + // /// + // /// Raises the GetValue event. + // /// + // /// A PropertySpecEventArgs that contains the event data. + // protected virtual void OnGetValue(PropertySpecEventArgs e) + // { + // if(GetValue != null) + // GetValue(this, e); + // } + // + // /// + // /// Raises the SetValue event. + // /// + // /// A PropertySpecEventArgs that contains the event data. + // protected virtual void OnSetValue(PropertySpecEventArgs e) + // { + // if(SetValue != null) + // SetValue(this, e); + // } + // + // #region ICustomTypeDescriptor explicit interface definitions + // // Most of the functions required by the ICustomTypeDescriptor are + // // merely pssed on to the default TypeDescriptor for this type, + // // which will do something appropriate. The exceptions are noted + // // below. + // AttributeCollection ICustomTypeDescriptor.GetAttributes() + // { + // return TypeDescriptor.GetAttributes(this, true); + // } + // + // string ICustomTypeDescriptor.GetClassName() + // { + // return TypeDescriptor.GetClassName(this, true); + // } + // + // string ICustomTypeDescriptor.GetComponentName() + // { + // return TypeDescriptor.GetComponentName(this, true); + // } + // + // TypeConverter ICustomTypeDescriptor.GetConverter() + // { + // return TypeDescriptor.GetConverter(this, true); + // } + // + // EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() + // { + // return TypeDescriptor.GetDefaultEvent(this, true); + // } + // + // PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() + // { + // // This function searches the property list for the property + // // with the same name as the DefaultProperty specified, and + // // returns a property descriptor for it. If no property is + // // found that matches DefaultProperty, a null reference is + // // returned instead. + // + // PropertySpec propertySpec = null; + // if(defaultProperty != null) + // { + // int index = properties.IndexOf(defaultProperty); + // propertySpec = properties[index]; + // } + // + // if(propertySpec != null) + // return new PropertySpecDescriptor(propertySpec, this, propertySpec.Name, null); + // else + // return null; + // } + // + // object ICustomTypeDescriptor.GetEditor(Type editorBaseType) + // { + // return TypeDescriptor.GetEditor(this, editorBaseType, true); + // } + // + // EventDescriptorCollection ICustomTypeDescriptor.GetEvents() + // { + // return TypeDescriptor.GetEvents(this, true); + // } + // + // EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) + // { + // return TypeDescriptor.GetEvents(this, attributes, true); + // } + // + // PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() + // { + // return ((ICustomTypeDescriptor)this).GetProperties(new Attribute[0]); + // } + // + // PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) + // { + // // Rather than passing this function on to the default TypeDescriptor, + // // which would return the actual properties of PropertyBag, I construct + // // a list here that contains property descriptors for the elements of the + // // Properties list in the bag. + // + // ArrayList props = new ArrayList(); + // + // foreach(PropertySpec property in properties) + // { + // ArrayList attrs = new ArrayList(); + // + // // If a category, description, editor, or type converter are specified + // // in the PropertySpec, create attributes to define that relationship. + // if(property.Category != null) + // attrs.Add(new CategoryAttribute(property.Category)); + // + // if(property.Description != null) + // attrs.Add(new DescriptionAttribute(property.Description)); + // + // if(property.EditorTypeName != null) + // attrs.Add(new EditorAttribute(property.EditorTypeName, typeof(UITypeEditor))); + // + // if(property.ConverterTypeName != null) + // attrs.Add(new TypeConverterAttribute(property.ConverterTypeName)); + // + // // Additionally, append the custom attributes associated with the + // // PropertySpec, if any. + // if(property.Attributes != null) + // attrs.AddRange(property.Attributes); + // + // Attribute[] attrArray = (Attribute[])attrs.ToArray(typeof(Attribute)); + // + // // Create a new property descriptor for the property item, and add + // // it to the list. + // PropertySpecDescriptor pd = new PropertySpecDescriptor(property, + // this, property.Name, attrArray); + // props.Add(pd); + // } + // + // // Convert the list of PropertyDescriptors to a collection that the + // // ICustomTypeDescriptor can use, and return it. + // PropertyDescriptor[] propArray = (PropertyDescriptor[])props.ToArray( + // typeof(PropertyDescriptor)); + // return new PropertyDescriptorCollection(propArray); + // } + // + // object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) + // { + // return this; + // } + // #endregion + // } + // + // /// + // /// An extension of PropertyBag that manages a table of property values, in + // /// addition to firing events when property values are requested or set. + // /// + // public class PropertyTable : PropertyBag + // { + // private Hashtable propValues; + // + // /// + // /// Initializes a new instance of the PropertyTable class. + // /// + // public PropertyTable() + // { + // propValues = new Hashtable(); + // } + // + // /// + // /// Gets or sets the value of the property with the specified name. + // ///

In C#, this property is the indexer of the PropertyTable class.

+ // ///
+ // public object this[string key] + // { + // get { return propValues[key]; } + // set { propValues[key] = value; } + // } + // + // /// + // /// This member overrides PropertyBag.OnGetValue. + // /// + // protected override void OnGetValue(PropertySpecEventArgs e) + // { + // e.Value = propValues[e.Property.Name]; + // base.OnGetValue(e); + // } + // + // /// + // /// This member overrides PropertyBag.OnSetValue. + // /// + // protected override void OnSetValue(PropertySpecEventArgs e) + // { + // propValues[e.Property.Name] = e.Value; + // base.OnSetValue(e); + // } + // } + // + + #endregion + + #region WorkorderTemplatePropertyGridEditor + public class WorkorderTemplateEditor : UITypeEditor + { + public override UITypeEditorEditStyle + GetEditStyle(ITypeDescriptorContext context) + { + return UITypeEditorEditStyle.DropDown; + } + + public override object EditValue(ITypeDescriptorContext context, + IServiceProvider provider, object value) + { + IWindowsFormsEditorService wfes = + provider.GetService(typeof(IWindowsFormsEditorService)) as + IWindowsFormsEditorService; + + if (wfes != null) + { + WorkorderSummaryTemplate f = new WorkorderSummaryTemplate(); + f.WorkorderSummaryTemplateToEdit = (string)value; + f._wfes = wfes; + + wfes.DropDownControl(f); + value = f.WorkorderSummaryTemplateToEdit; + } + return value; + } + } + + + #endregion + + #region Form Drag and drop helpers #region WikiForm @@ -6973,7 +6974,7 @@ At first I was happy to find your code that solved my problem, but I did not lik /// to insert in it's place in the document if applicable /// ///
- public static string WikiDragDrop(System.Windows.Forms.DragEventArgs e, Guid RootObjectID) + public static string WikiDragDrop(System.Windows.Forms.DragEventArgs e, Guid RootObjectID) { //case 1039 //log.Debug("WikiDragDrop"); @@ -6993,7 +6994,7 @@ At first I was happy to find your code that solved my problem, but I did not lik foreach (string file in files) { //if (log.IsDebugEnabled) - //case 1039 //log.Debug("WikiDragDrop: dropping file [" + file + "] to WikiPage ID=" + RootObjectID.ToString()); + //case 1039 //log.Debug("WikiDragDrop: dropping file [" + file + "] to WikiPage ID=" + RootObjectID.ToString()); //AssignedDoc doc = docs.Add(RootObjectType, RootObjectID); //doc.Description = System.IO.Path.GetFileName(file); //doc.URL = file; @@ -7003,12 +7004,12 @@ At first I was happy to find your code that solved my problem, but I did not lik } return "";//no link, it's a file that will sit in the files grid below the rtf control } - //Handle URLS being dropped + //Handle URLS being dropped else if (e.Data.GetDataPresent("UniformResourceLocator")) { - string sUrl=e.Data.GetData(DataFormats.Text).ToString(); + string sUrl = e.Data.GetData(DataFormats.Text).ToString(); //if (log.IsDebugEnabled) - //case 1039 //log.Debug("WikiDragDrop: dropping URL [" + sUrl + "] to WikiPage ID=" + RootObjectID.ToString()); + //case 1039 //log.Debug("WikiDragDrop: dropping URL [" + sUrl + "] to WikiPage ID=" + RootObjectID.ToString()); //AssignedDoc doc = docs.Add(RootObjectType, RootObjectID); //doc.Description = "URL"; @@ -7018,7 +7019,7 @@ At first I was happy to find your code that solved my problem, but I did not lik //nothing to store in the db return sUrl; } - + ////ok, it's something else, let's figure it out @@ -7034,11 +7035,11 @@ At first I was happy to find your code that solved my problem, but I did not lik } - //provide visual feedback if object being dragged is allowed - public static void WikiDragEnter(System.Windows.Forms.DragEventArgs e) - { + //provide visual feedback if object being dragged is allowed + public static void WikiDragEnter(System.Windows.Forms.DragEventArgs e) + { if (e.Data.GetDataPresent(DataFormats.FileDrop) || - e.Data.GetDataPresent(DataFormats.UnicodeText)|| + e.Data.GetDataPresent(DataFormats.UnicodeText) || e.Data.GetDataPresent("UniformResourceLocator") ) { @@ -7047,7 +7048,7 @@ At first I was happy to find your code that solved my problem, but I did not lik else { e.Effect = DragDropEffects.None; - + } } @@ -7075,49 +7076,49 @@ At first I was happy to find your code that solved my problem, but I did not lik } - /// - /// Handle a drop by putting the object dropped into the docs - /// collection of the object - /// - public static void DragDrop(System.Windows.Forms.DragEventArgs e,AssignedDocs docs, RootObjectTypes RootObjectType, Guid RootObjectID, RootObjectTypes ExactObjectType ) - { - //case 1039 //log.Debug("DragDrop"); + /// + /// Handle a drop by putting the object dropped into the docs + /// collection of the object + /// + public static void DragDrop(System.Windows.Forms.DragEventArgs e, AssignedDocs docs, RootObjectTypes RootObjectType, Guid RootObjectID, RootObjectTypes ExactObjectType) + { + //case 1039 //log.Debug("DragDrop"); - //Handle files being dropped - //which means put them in the assigned docs collection - if(e.Data.GetDataPresent(DataFormats.FileDrop)) - { - string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + //Handle files being dropped + //which means put them in the assigned docs collection + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); - if ( files != null ) - { - - // Extract string from first array element - // (ignore all files except first if number of files are dropped). - //string s = a.GetValue(0).ToString(); - - foreach(string file in files) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("DragDrop: dropping file ["+file+"] to object " + RootObjectType.ToString() + " ID=" + RootObjectID.ToString()); - AssignedDoc doc=docs.Add(RootObjectType,RootObjectID,ExactObjectType); - doc.Description=System.IO.Path.GetFileName(file); - doc.URL=file; + if (files != null) + { - } - - } - } - else if(e.Data.GetDataPresent("UniformResourceLocator")) - { - //case 1039 //if(log.IsDebugEnabled) - //case 1039 //log.Debug("DragDrop: dropping URL ["+e.Data.GetData(DataFormats.Text).ToString()+"] to object " + RootObjectType.ToString() + " ID=" + RootObjectID.ToString()); - - AssignedDoc doc=docs.Add(RootObjectType,RootObjectID,ExactObjectType); - doc.Description="URL"; - doc.URL=e.Data.GetData(DataFormats.Text).ToString(); - - } + // Extract string from first array element + // (ignore all files except first if number of files are dropped). + //string s = a.GetValue(0).ToString(); + + foreach (string file in files) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("DragDrop: dropping file ["+file+"] to object " + RootObjectType.ToString() + " ID=" + RootObjectID.ToString()); + AssignedDoc doc = docs.Add(RootObjectType, RootObjectID, ExactObjectType); + doc.Description = System.IO.Path.GetFileName(file); + doc.URL = file; + + } + + } + } + else if (e.Data.GetDataPresent("UniformResourceLocator")) + { + //case 1039 //if(log.IsDebugEnabled) + //case 1039 //log.Debug("DragDrop: dropping URL ["+e.Data.GetData(DataFormats.Text).ToString()+"] to object " + RootObjectType.ToString() + " ID=" + RootObjectID.ToString()); + + AssignedDoc doc = docs.Add(RootObjectType, RootObjectID, ExactObjectType); + doc.Description = "URL"; + doc.URL = e.Data.GetData(DataFormats.Text).ToString(); + + } } #endregion documents form @@ -7228,9 +7229,9 @@ At first I was happy to find your code that solved my problem, but I did not lik return null; } } - #endregion + #endregion - #region Custom Grid SortComparers + #region Custom Grid SortComparers /// /// Compare two dates that are strings /// @@ -7292,31 +7293,31 @@ At first I was happy to find your code that solved my problem, but I did not lik } } - #endregion + #endregion - #region LetSQLDoItFilterCondition class + #region LetSQLDoItFilterCondition class - /// - /// This filter condition is used in grids to replace the built in filter conditions - /// to avoid overhead of double filtering: The sql server filters via the query anyway - /// so this filtercondition always returns true so that the grid doesn't - /// try to filter again in the display unnecessarily - /// - [Serializable] - public class LetSQLDoItFilterCondition : FilterCondition - { - #region Constructors - public LetSQLDoItFilterCondition(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base (info, context) {} + /// + /// This filter condition is used in grids to replace the built in filter conditions + /// to avoid overhead of double filtering: The sql server filters via the query anyway + /// so this filtercondition always returns true so that the grid doesn't + /// try to filter again in the display unnecessarily + /// + [Serializable] + public class LetSQLDoItFilterCondition : FilterCondition + { + #region Constructors + public LetSQLDoItFilterCondition(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } - public LetSQLDoItFilterCondition(UltraGridColumn column, FilterComparisionOperator comparisionOperator, object compareValue ): base(column ,comparisionOperator, compareValue) {} - #endregion Constructors - - public override bool MeetsCriteria(Infragistics.Win.UltraWinGrid.UltraGridRow row) - {return true;} - } - #endregion LetSQLDoItFilterCondition class + public LetSQLDoItFilterCondition(UltraGridColumn column, FilterComparisionOperator comparisionOperator, object compareValue) : base(column, comparisionOperator, compareValue) { } + #endregion Constructors - #region Support info + public override bool MeetsCriteria(Infragistics.Win.UltraWinGrid.UltraGridRow row) + { return true; } + } + #endregion LetSQLDoItFilterCondition class + + #region Support info static public string FullSupportInfo() { log.Debug("FullSupportInfo"); @@ -7339,55 +7340,55 @@ At first I was happy to find your code that solved my problem, but I did not lik "\tLogical drives: "); foreach (string s in System.Environment.GetLogicalDrives()) sb.Append(s + " "); - - sb.Append( "\r\n"); - sb.Append( - "\tWorking set: " + System.Environment.WorkingSet.ToString() + "\r\n" + - "\tPrimary monitor size: " + SystemInformation.PrimaryMonitorSize.ToString() + "\r\n" + - - "\tLocale current culture: " + System.Threading.Thread.CurrentThread.CurrentCulture.EnglishName + "\r\n" + - "\tLocale currency symbol: " + System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol + "\r\n" + - "\tLocale short date pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + "\r\n" + - "\tLocale short time pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern + "\r\n" ); - - Assembly a=Assembly.GetExecutingAssembly(); - AssemblyName an=a.GetName(); + sb.Append("\r\n"); + sb.Append( + "\tWorking set: " + System.Environment.WorkingSet.ToString() + "\r\n" + + "\tPrimary monitor size: " + SystemInformation.PrimaryMonitorSize.ToString() + "\r\n" + + + "\tLocale current culture: " + System.Threading.Thread.CurrentThread.CurrentCulture.EnglishName + "\r\n" + + "\tLocale currency symbol: " + System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol + "\r\n" + + "\tLocale short date pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + "\r\n" + + "\tLocale short time pattern: " + System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern + "\r\n"); + + + Assembly a = Assembly.GetExecutingAssembly(); + AssemblyName an = a.GetName(); System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location); sb.Append("\tPrimary assembly: " + System.IO.Path.GetFileName(fileVersion.FileName) + " " + AyaBizUtils.DisplayVersion(an.Version)); int nHotFix = fileVersion.FileBuildPart;//case 2003 if (nHotFix > 0) sb.Append(" (Patch " + nHotFix.ToString() + ")"); - sb.Append("\r\n"); - sb.Append("\tPrimary assembly location: "+an.CodeBase +"\r\n"); + sb.Append("\r\n"); + sb.Append("\tPrimary assembly location: " + an.CodeBase + "\r\n"); sb.Append("\tPrimary assembly built: " + AyaNova.Timestamp.BuildAt.ToString() + "\r\n"); ////Sub release version if any sb.Append(AyaBizUtils.SubVersion); - sb.Append("\t\tReferences:\r\n"); - foreach(AssemblyName arn in a.GetReferencedAssemblies()) - { - sb.Append("\t\t" + arn.Name + " " + arn.Version.ToString()+"\r\n"); - } + sb.Append("\t\tReferences:\r\n"); + foreach (AssemblyName arn in a.GetReferencedAssemblies()) + { + sb.Append("\t\t" + arn.Name + " " + arn.Version.ToString() + "\r\n"); + } if (AyaBizUtils.AyaNovaConnectionSetting.UsingDataPortal && AyaBizUtils.PortalDiagnostics != "") - { - sb.Append("DataPortal diagnostics:\r\n"); - sb.Append(AyaBizUtils.PortalDiagnostics); - } + { + sb.Append("DataPortal diagnostics:\r\n"); + sb.Append(AyaBizUtils.PortalDiagnostics); + } //case 2094 //add plugin info and dates if available sb.Append(PluginsList()); - -// sb.Append("Options:\r\n"); -// sb.Append(AyaBizUtils.View()); - return sb.ToString(); - } + + // sb.Append("Options:\r\n"); + // sb.Append(AyaBizUtils.View()); + return sb.ToString(); + } //case 3663 @@ -7400,19 +7401,19 @@ At first I was happy to find your code that solved my problem, but I did not lik } - static public string BriefSupportInfo() - { - log.Debug("BriefSupportInfo"); - StringBuilder sb = new StringBuilder(); - sb.Append( - "\tMachine name: " + System.Environment.MachineName + "\r\n" + + static public string BriefSupportInfo() + { + log.Debug("BriefSupportInfo"); + StringBuilder sb = new StringBuilder(); + sb.Append( + "\tMachine name: " + System.Environment.MachineName + "\r\n" + //case 3589 RedactPasswords(AyaBizUtils.AyaNovaConnectionSetting.ToString()) + "\r\n" + - // "\tDBServer version: " + DBInfo.DBVersion() + "\r\n" + - //"\tOS version: " + System.Environment.OSVersion.ToString() + "\r\n" + - OSVersionInfo.FullOperatingSystemInformationForDisplay + "\r\n" + - "\tCLR version: " + System.Environment.Version.ToString() + "\r\n" ); - + // "\tDBServer version: " + DBInfo.DBVersion() + "\r\n" + + //"\tOS version: " + System.Environment.OSVersion.ToString() + "\r\n" + + OSVersionInfo.FullOperatingSystemInformationForDisplay + "\r\n" + + "\tCLR version: " + System.Environment.Version.ToString() + "\r\n"); + Assembly a = Assembly.GetExecutingAssembly(); AssemblyName an = a.GetName(); @@ -7423,212 +7424,213 @@ At first I was happy to find your code that solved my problem, but I did not lik if (nHotFix > 0) sb.Append(" (Patch " + nHotFix.ToString() + ")"); sb.Append("\r\n"); - sb.Append("\tPrimary assembly location: "+an.CodeBase + "\r\n"); + sb.Append("\tPrimary assembly location: " + an.CodeBase + "\r\n"); sb.Append("\tPrimary assembly build timestamp: " + AyaNova.Timestamp.BuildAt.ToString() + "\r\n"); ////Sub release version if any sb.Append(AyaBizUtils.SubVersion); - -// sb.Append("Options:\r\n"); -// sb.Append(AyaBizUtils.View()); - - return sb.ToString(); - } + // sb.Append("Options:\r\n"); + // sb.Append(AyaBizUtils.View()); - #endregion - #region Settings info - static public string FullSettingsInfo(User uCurrent) - { - log.Debug("FullSettingsInfo"); - StringBuilder sb = new StringBuilder(); - BusinessPrincipal p = ((BusinessPrincipal)Thread.CurrentPrincipal); + return sb.ToString(); + } + + #endregion + + #region Settings info + static public string FullSettingsInfo(User uCurrent) + { + log.Debug("FullSettingsInfo"); + StringBuilder sb = new StringBuilder(); + BusinessPrincipal p = ((BusinessPrincipal)Thread.CurrentPrincipal); DBInfo dbi = DBInfo.GetInfo(); sb.Append("\tDBServer: " + dbi.DBServerType.ToString() + "\r\n"); sb.Append("\tDBServer version: " + dbi.Version + "\r\n"); - sb.Append("\tUser settings\r\n"); - sb.Append("\t\tUser: " + uCurrent.Name(ScheduleableUserNameDisplayFormats.FirstLast)+"\r\n"); - sb.Append("\t\tLanguage: " + uCurrent.DefaultLanguage+"\r\n"); - sb.Append("\t\tTimeZone: " + System.TimeZoneInfo.Local.DisplayName+"\r\n"); - + sb.Append("\tUser settings\r\n"); + sb.Append("\t\tUser: " + uCurrent.Name(ScheduleableUserNameDisplayFormats.FirstLast) + "\r\n"); + sb.Append("\t\tLanguage: " + uCurrent.DefaultLanguage + "\r\n"); + sb.Append("\t\tTimeZone: " + System.TimeZoneInfo.Local.DisplayName + "\r\n"); + sb.Append("\t\tTimeZone override: " + (uCurrent.TimeZoneOffset == null ? "None" : (uCurrent.TimeZoneOffset.ToString() + " hours GMT")) + "\r\n"); - sb.Append("\t\tUserType: " + uCurrent.UserType.ToString()+"\r\n"); - sb.Append("\t\tSubContractor: " + uCurrent.SubContractor.ToString()+"\r\n"); - sb.Append("\t\tRegion: " + RegionalSettings.Name+"\r\n"); - + sb.Append("\t\tUserType: " + uCurrent.UserType.ToString() + "\r\n"); + sb.Append("\t\tSubContractor: " + uCurrent.SubContractor.ToString() + "\r\n"); + sb.Append("\t\tRegion: " + RegionalSettings.Name + "\r\n"); - sb.Append("\tGlobal settings\r\n"); - sb.Append("\t\tLanguage: " + GlobalSettings.DefaultLanguage+"\r\n"); - sb.Append("\t\tUse Notification services: " + GlobalSettings.UseNotification.ToString()+"\r\n"); - sb.Append("\t\tCJK Index: " + GlobalSettings.CJKIndex.ToString()+"\r\n"); - sb.Append("\t\tUse inventory: " + GlobalSettings.UseInventory.ToString()+"\r\n"); - //sb.Append("\t\tUse regions: " + GlobalSettings.UseRegions.ToString()+"\r\n"); - - - return sb.ToString(); + + sb.Append("\tGlobal settings\r\n"); + sb.Append("\t\tLanguage: " + GlobalSettings.DefaultLanguage + "\r\n"); + sb.Append("\t\tUse Notification services: " + GlobalSettings.UseNotification.ToString() + "\r\n"); + sb.Append("\t\tCJK Index: " + GlobalSettings.CJKIndex.ToString() + "\r\n"); + sb.Append("\t\tUse inventory: " + GlobalSettings.UseInventory.ToString() + "\r\n"); + //sb.Append("\t\tUse regions: " + GlobalSettings.UseRegions.ToString()+"\r\n"); + + + return sb.ToString(); - - } - - - #endregion - - #region Enum TYPE converter - - /// - /// EnumConverter supporting System.ComponentModel.DescriptionAttribute - /// - public class EnumDescConverter : System.ComponentModel.EnumConverter - { - protected System.Type myVal; - - /// - /// Gets Enum Value's Description Attribute - /// This can be called directly from anywhere to return - /// the localized text value of an enumeration. - /// - /// The value you want the description attribute for - /// The description, if any, else it's .ToString() - public static string GetEnumDescription(Enum value) - { - FieldInfo fi= value.GetType().GetField(value.ToString()); - DescriptionAttribute[] attributes = - (DescriptionAttribute[] )fi.GetCustomAttributes( - typeof(DescriptionAttribute), false); - - if(! (attributes.Length>0)) - return value.ToString(); + } - if(attributes[0].Description.StartsWith("LT:")) - { - //case 1801 - //BusinessPrincipal p = ((BusinessPrincipal)Thread.CurrentPrincipal); - return LocaleText.GetLocalizedText(attributes[0].Description.Replace("LT:","")); - } - else - return attributes[0].Description; + #endregion - } - - /// - /// Gets the description for certain named value in an Enumeration - /// - /// The type of the Enumeration - /// The name of the Enumeration value - /// The description, if any, else the passed name - public static string GetEnumDescription(System.Type value, string name) - { - FieldInfo fi= value.GetField(name); - DescriptionAttribute[] attributes = - (DescriptionAttribute[] )fi.GetCustomAttributes( - typeof(DescriptionAttribute), false); + #region Enum TYPE converter + + /// + /// EnumConverter supporting System.ComponentModel.DescriptionAttribute + /// + public class EnumDescConverter : System.ComponentModel.EnumConverter + { + protected System.Type myVal; + + /// + /// Gets Enum Value's Description Attribute + /// This can be called directly from anywhere to return + /// the localized text value of an enumeration. + /// + /// The value you want the description attribute for + /// The description, if any, else it's .ToString() + public static string GetEnumDescription(Enum value) + { + FieldInfo fi = value.GetType().GetField(value.ToString()); + DescriptionAttribute[] attributes = + (DescriptionAttribute[])fi.GetCustomAttributes( + typeof(DescriptionAttribute), false); + + if (!(attributes.Length > 0)) + return value.ToString(); - - if(! (attributes.Length>0)) - return name; - - - if(attributes[0].Description.StartsWith("LT:")) - { + if (attributes[0].Description.StartsWith("LT:")) + { //case 1801 //BusinessPrincipal p = ((BusinessPrincipal)Thread.CurrentPrincipal); - return LocaleText.GetLocalizedText(attributes[0].Description.Replace("LT:","")); + return LocaleText.GetLocalizedText(attributes[0].Description.Replace("LT:", "")); - } - else - return attributes[0].Description; + } + else + return attributes[0].Description; - //return (attributes.Length>0)?attributes[0].Description:name; - } - - /// - /// Gets the value of an Enum, based on it's Description Attribute or named value - /// - /// The Enum type - /// The description or name of the element - /// The value, or the passed in description, if it was not found - public static object GetEnumValue(System.Type value, string description) - { - - + } - FieldInfo [] fis = value.GetFields(); - foreach(FieldInfo fi in fis) - { - DescriptionAttribute[] attributes = - (DescriptionAttribute[] )fi.GetCustomAttributes( - typeof(DescriptionAttribute), false); - if(attributes.Length>0) - { - //Localized? - if(attributes[0].Description.StartsWith("LT:")) - { - //see if decoded string equals passed in string - if(LocaleText.GetLocalizedText(attributes[0].Description.Replace("LT:",""))==description) - { - return fi.GetValue(fi.Name); - } - - } - else - {//Not localized... - if(attributes[0].Description == description) - { - return fi.GetValue(fi.Name); - } - } - } - if(fi.Name == description) - { - return fi.GetValue(fi.Name); - } - } - return description; - } - - //public EnumDescConverter(System.Type type) : base(type.GetType()) - public EnumDescConverter(System.Type type) : base(type) - { - myVal = type; - } - - public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) - { - if(value is Enum && destinationType == typeof(string)) - { - return GetEnumDescription((Enum)value); - } - if(value is string && destinationType == typeof(string)) - { - return GetEnumDescription(myVal, (string)value); - } - return base.ConvertTo (context, culture, value, destinationType); - } - - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) - { - if(value is string) - { - return GetEnumValue(myVal, (string)value); - } - if(value is Enum) - { - return GetEnumDescription((Enum)value); - } - return base.ConvertFrom (context, culture, value); - } + /// + /// Gets the description for certain named value in an Enumeration + /// + /// The type of the Enumeration + /// The name of the Enumeration value + /// The description, if any, else the passed name + public static string GetEnumDescription(System.Type value, string name) + { + FieldInfo fi = value.GetField(name); + DescriptionAttribute[] attributes = + (DescriptionAttribute[])fi.GetCustomAttributes( + typeof(DescriptionAttribute), false); - } - #endregion + + if (!(attributes.Length > 0)) + return name; + + + if (attributes[0].Description.StartsWith("LT:")) + { + //case 1801 + //BusinessPrincipal p = ((BusinessPrincipal)Thread.CurrentPrincipal); + return LocaleText.GetLocalizedText(attributes[0].Description.Replace("LT:", "")); + + } + else + return attributes[0].Description; + + //return (attributes.Length>0)?attributes[0].Description:name; + } + + /// + /// Gets the value of an Enum, based on it's Description Attribute or named value + /// + /// The Enum type + /// The description or name of the element + /// The value, or the passed in description, if it was not found + public static object GetEnumValue(System.Type value, string description) + { + + + + FieldInfo[] fis = value.GetFields(); + foreach (FieldInfo fi in fis) + { + DescriptionAttribute[] attributes = + (DescriptionAttribute[])fi.GetCustomAttributes( + typeof(DescriptionAttribute), false); + if (attributes.Length > 0) + { + //Localized? + if (attributes[0].Description.StartsWith("LT:")) + { + //see if decoded string equals passed in string + if (LocaleText.GetLocalizedText(attributes[0].Description.Replace("LT:", "")) == description) + { + return fi.GetValue(fi.Name); + } + + } + else + {//Not localized... + if (attributes[0].Description == description) + { + return fi.GetValue(fi.Name); + } + } + } + if (fi.Name == description) + { + return fi.GetValue(fi.Name); + } + } + return description; + } + + //public EnumDescConverter(System.Type type) : base(type.GetType()) + public EnumDescConverter(System.Type type) + : base(type) + { + myVal = type; + } + + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + if (value is Enum && destinationType == typeof(string)) + { + return GetEnumDescription((Enum)value); + } + if (value is string && destinationType == typeof(string)) + { + return GetEnumDescription(myVal, (string)value); + } + return base.ConvertTo(context, culture, value, destinationType); + } + + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + if (value is string) + { + return GetEnumValue(myVal, (string)value); + } + if (value is Enum) + { + return GetEnumDescription((Enum)value); + } + return base.ConvertFrom(context, culture, value); + } + + + } + #endregion #region handy helpers from WBI public static string GetNonBizName(string EnumListName, int i) @@ -7775,87 +7777,87 @@ At first I was happy to find your code that solved my problem, but I did not lik } - /// - /// Used for combo box initialization - /// and for label intialization in grid - /// columns that contain a combo but are - /// not in edit mode - /// - /// - /// - /// - /// - static public string GetBizObjectName(string ObjectName, Guid SelectedID) - { - if (SelectedID == Guid.Empty) - return " "; - switch (ObjectName) + /// + /// Used for combo box initialization + /// and for label intialization in grid + /// columns that contain a combo but are + /// not in edit mode + /// + /// + /// + /// + /// + static public string GetBizObjectName(string ObjectName, Guid SelectedID) { - case "UserPickList": - case "User": - { - UserPickList upl = UserPickList.GetListOfOneSpecificUser(SelectedID); - if (upl.Count == 0) - return ""; - return upl[0].Name; - } - case "Part": - { - PartPickList pl = PartPickList.GetOnePart(SelectedID); - if (pl.Count == 0) - return ""; - return pl[0].DisplayName(GlobalSettings.DefaultPartDisplayFormat); - } - case "PartSerial": - { - NameFetcher nf = NameFetcher.GetItem(ObjectName, "SerialNumber", SelectedID); - return nf.RecordName; - } - case "LoanItem": - { - LoanItemPickList pl = LoanItemPickList.GetOneLoanItem(SelectedID); - if (pl.Count == 0) - return ""; - return pl[0].Name + " " + pl[0].Serial; - } - case "Unit": - { - return UnitNameFetcher.GetUnitNameFromUnitID(SelectedID); + if (SelectedID == Guid.Empty) + return " "; + switch (ObjectName) + { + case "UserPickList": + case "User": + { + UserPickList upl = UserPickList.GetListOfOneSpecificUser(SelectedID); + if (upl.Count == 0) + return ""; + return upl[0].Name; + } + case "Part": + { + PartPickList pl = PartPickList.GetOnePart(SelectedID); + if (pl.Count == 0) + return ""; + return pl[0].DisplayName(GlobalSettings.DefaultPartDisplayFormat); + } + case "PartSerial": + { + NameFetcher nf = NameFetcher.GetItem(ObjectName, "SerialNumber", SelectedID); + return nf.RecordName; + } + case "LoanItem": + { + LoanItemPickList pl = LoanItemPickList.GetOneLoanItem(SelectedID); + if (pl.Count == 0) + return ""; + return pl[0].Name + " " + pl[0].Serial; + } + case "Unit": + { + return UnitNameFetcher.GetUnitNameFromUnitID(SelectedID); + + } + case "UnitModel": + { + UnitModelPickList pl = UnitModelPickList.GetListOfOneSpecificUnitModel(SelectedID); + if (pl.Count == 0) + return ""; + return pl[0].Name; + } + case "Template": + { + TemplatePickList pl = TemplatePickList.GetListOfOne(SelectedID); + if (pl.Count == 0) + return ""; + return pl[0].Description; + } + default: + { + NameFetcher nf = NameFetcher.GetItem(ObjectName, "Name", SelectedID); + return nf.RecordName; + } + } - } - case "UnitModel": - { - UnitModelPickList pl = UnitModelPickList.GetListOfOneSpecificUnitModel(SelectedID); - if (pl.Count == 0) - return ""; - return pl[0].Name; - } - case "Template": - { - TemplatePickList pl = TemplatePickList.GetListOfOne(SelectedID); - if (pl.Count == 0) - return ""; - return pl[0].Description; - } - default: - { - NameFetcher nf = NameFetcher.GetItem(ObjectName, "Name", SelectedID); - return nf.RecordName; - } } - } - - /// - /// Convenience overload - /// - /// - /// - /// - static public string GetBizObjectName(string ObjectName, string SelectedID) - { - return GetBizObjectName(ObjectName, new Guid(SelectedID)); - } + /// + /// Convenience overload + /// + /// + /// + /// + static public string GetBizObjectName(string ObjectName, string SelectedID) + { + return GetBizObjectName(ObjectName, new Guid(SelectedID)); + } #endregion @@ -7869,7 +7871,7 @@ At first I was happy to find your code that solved my problem, but I did not lik /// public static HotKeyAction HotKeys(Keys keydata) { - + switch (keydata) { @@ -7879,45 +7881,45 @@ At first I was happy to find your code that solved my problem, but I did not lik //New workorder case (Keys.Alt | Keys.W): - if(AyaBizUtils.Right("Object.WorkorderService")> (int)SecurityLevelTypes.ReadOnly) - return HotKeyAction.NewWorkorder; - break; + if (AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.ReadOnly) + return HotKeyAction.NewWorkorder; + break; //New PM workorder case (Keys.Alt | Keys.M): - if (!AyaBizUtils.Lite && AyaBizUtils.Right("Object.WorkorderPreventiveMaintenance") > (int)SecurityLevelTypes.ReadOnly) - return HotKeyAction.NewPreventiveMaintenance; - break; + if (!AyaBizUtils.Lite && AyaBizUtils.Right("Object.WorkorderPreventiveMaintenance") > (int)SecurityLevelTypes.ReadOnly) + return HotKeyAction.NewPreventiveMaintenance; + break; //New quote case (Keys.Alt | Keys.Q): - if (!AyaBizUtils.Lite && AyaBizUtils.Right("Object.WorkorderQuote") > (int)SecurityLevelTypes.ReadOnly) - return HotKeyAction.NewQuote; - break; + if (!AyaBizUtils.Lite && AyaBizUtils.Right("Object.WorkorderQuote") > (int)SecurityLevelTypes.ReadOnly) + return HotKeyAction.NewQuote; + break; //New client case (Keys.Alt | Keys.C): if (AyaBizUtils.Right("Object.Client") > (int)SecurityLevelTypes.ReadOnly) - return HotKeyAction.NewClient; - break; + return HotKeyAction.NewClient; + break; //New unit case (Keys.Alt | Keys.U): if (!AyaBizUtils.Lite && AyaBizUtils.Right("Object.Unit") > (int)SecurityLevelTypes.ReadOnly) - return HotKeyAction.NewUnit; - break; + return HotKeyAction.NewUnit; + break; //New part case (Keys.Alt | Keys.P): if (AyaBizUtils.Right("Object.Part") > (int)SecurityLevelTypes.ReadOnly) - return HotKeyAction.NewPart; - break; + return HotKeyAction.NewPart; + break; + + //Case 776 grid filter criteria for developers + case (Keys.Control | Keys.Alt | Keys.G): + return HotKeyAction.GridFilterCriteria; + + //case 1701 + case (Keys.Control | Keys.Alt | Keys.E): + return HotKeyAction.EmptyWorkingSet; + - //Case 776 grid filter criteria for developers - case (Keys.Control |Keys.Alt | Keys.G): - return HotKeyAction.GridFilterCriteria; - - //case 1701 - case (Keys.Control|Keys.Alt|Keys.E): - return HotKeyAction.EmptyWorkingSet; - - } return HotKeyAction.NoAction; } @@ -7939,8 +7941,8 @@ At first I was happy to find your code that solved my problem, but I did not lik /// public static void CopyAyaNovaUrl(TypeAndID t) { - - Clipboard.SetText(t.ToAyaURL()); + + Clipboard.SetText(t.ToAyaURL()); } //todo: create desktop shortcut method @@ -8020,10 +8022,10 @@ At first I was happy to find your code that solved my problem, but I did not lik { wf.WindowState = FormWindowState.Minimized; wf.WindowState = FormWindowState.Maximized; - + return wf; } - + } } return new WorkorderForm(); @@ -8062,8 +8064,8 @@ At first I was happy to find your code that solved my problem, but I did not lik } -#endregion - + #endregion + #region Plugins case 941 public static void debugLog(string s) { @@ -8100,32 +8102,32 @@ At first I was happy to find your code that solved my problem, but I did not lik foreach (string PluginFile in PluginFiles) { try - { - a = Assembly.LoadFrom(PluginFile); - + { + a = Assembly.LoadFrom(PluginFile); + foreach (Type t in a.GetTypes()) { - if (!typeof(IAyaNovaPlugin).IsAssignableFrom(t)) + if (!typeof(IAyaNovaPlugin).IsAssignableFrom(t)) continue; - IAyaNovaPlugin p=(IAyaNovaPlugin)Activator.CreateInstance(t); - if (p.PluginID == Guid.Empty) - { - sbErrors.Append("PLUGINS - " + PluginFile + " could not be loaded because it's required PluginID value is empty"); - break; - } + IAyaNovaPlugin p = (IAyaNovaPlugin)Activator.CreateInstance(t); + if (p.PluginID == Guid.Empty) + { + sbErrors.Append("PLUGINS - " + PluginFile + " could not be loaded because it's required PluginID value is empty"); + break; + } + + if (string.IsNullOrEmpty(p.PluginName)) + { + sbErrors.Append("PLUGINS - " + PluginFile + " could not be loaded because it's required PluginName value is empty"); + break; + } + mPlugins.Add(p); + //debugLog("Plugin " + p.PluginName + " sucessfully loaded"); - if (string.IsNullOrEmpty(p.PluginName)) - { - sbErrors.Append("PLUGINS - " + PluginFile + " could not be loaded because it's required PluginName value is empty"); - break; - } - mPlugins.Add(p); - //debugLog("Plugin " + p.PluginName + " sucessfully loaded"); - } - } + } catch (Exception exsingle) { if (exsingle is System.Reflection.ReflectionTypeLoadException) @@ -8151,7 +8153,7 @@ At first I was happy to find your code that solved my problem, but I did not lik catch (Exception ex) { Error("PLUGINS - Error loading plugins", ex.Message); - + } System.Collections.Generic.List failedToInitializeList = new System.Collections.Generic.List(); foreach (IAyaNovaPlugin p in mPlugins) @@ -8159,10 +8161,10 @@ At first I was happy to find your code that solved my problem, but I did not lik try { - if (p.Initialize(Assembly.GetExecutingAssembly().GetName().Version,Util.LocaleText)) + if (p.Initialize(Assembly.GetExecutingAssembly().GetName().Version, Util.LocaleText)) { p.AyaNovaResourceManager = Resource1.ResourceManager; - + } else { @@ -8183,9 +8185,9 @@ At first I was happy to find your code that solved my problem, but I did not lik //consistently in the menu mPlugins.Sort( delegate(IAyaNovaPlugin plugin0, IAyaNovaPlugin plugin1) - { - return plugin0.PluginName.CompareTo(plugin1.PluginName); - } + { + return plugin0.PluginName.CompareTo(plugin1.PluginName); + } ); @@ -8204,26 +8206,27 @@ At first I was happy to find your code that solved my problem, but I did not lik public static void UnloadPluginsEx() { pluginsLoaded = false; - if(mPlugins!=null && mPlugins.Count>0) + if (mPlugins != null && mPlugins.Count > 0) { System.Text.StringBuilder sbErrors = new StringBuilder(); - foreach(IAyaNovaPlugin p in mPlugins) + foreach (IAyaNovaPlugin p in mPlugins) { - try{ - - p.Close(); - debugLog("PLUGINS - Successfully closed: " + p.PluginName); + try + { + + p.Close(); + debugLog("PLUGINS - Successfully closed: " + p.PluginName); } - catch(Exception ex) + catch (Exception ex) { debugLog("PLUGINS - Exception when calling close on: " + p.PluginName); sbErrors.Append("PLUGINS - failed to close: " + p.PluginName + "\r\n" + ex.Message); - + } } - if(sbErrors.Length>0) + if (sbErrors.Length > 0) Error("PLUGINS - Error Unloading plugins", sbErrors.ToString()); - + mPlugins.Clear(); } @@ -8237,9 +8240,9 @@ At first I was happy to find your code that solved my problem, but I did not lik ///
/// /// - public static void PluginInsertMenu( UltraToolbarsManager t, PluginMenuOptionData pmod) + public static void PluginInsertMenu(UltraToolbarsManager t, PluginMenuOptionData pmod) { - if (!pluginsLoaded) return; + if (!pluginsLoaded) return; PluginRemoveMenu(t); PopupMenuTool rootpop = new PopupMenuTool("Pluginsroot"); @@ -8247,20 +8250,20 @@ At first I was happy to find your code that solved my problem, but I did not lik rootpop.SharedProps.AppearancesSmall.Appearance.Image = Resource1.Plugin16; rootpop.SharedProps.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.ImageOnlyOnToolbars; rootpop.SharedProps.Tag = pmod; - - + + foreach (IAyaNovaPlugin cmd in mPlugins) { - bool bShow=false; - - if(pmod.bIsSingleObject && cmd.SingleObjectMenuShow(pmod.oType)) bShow=true; - if(!pmod.bIsSingleObject && cmd.MultipleObjectsMenuShow(pmod.oType)) bShow=true; - if(bShow) + bool bShow = false; + + if (pmod.bIsSingleObject && cmd.SingleObjectMenuShow(pmod.oType)) bShow = true; + if (!pmod.bIsSingleObject && cmd.MultipleObjectsMenuShow(pmod.oType)) bShow = true; + if (bShow) { //New popup here debugLog("PLUGINS - Generating menu for: " + cmd.PluginName); - + ButtonTool b = new ButtonTool("Plugin|" + cmd.PluginID.ToString()); b.SharedProps.Caption = cmd.PluginName; b.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText; @@ -8269,17 +8272,17 @@ At first I was happy to find your code that solved my problem, but I did not lik b.ToolClick += new ToolClickEventHandler(Pluginsroot_ToolClick); t.Tools.Add(b); rootpop.Tools.Add(b); - + } } - if (rootpop.Tools.Count>0) + if (rootpop.Tools.Count > 0) { t.Tools.Add(rootpop); - - if(t.Toolbars.Count>0) + + if (t.Toolbars.Count > 0) t.Toolbars[0].Tools.InsertTool(1, "Pluginsroot"); else { @@ -8293,9 +8296,9 @@ At first I was happy to find your code that solved my problem, but I did not lik break; } } - if (pmt!=null) + if (pmt != null) { - + pmt.Tools.AddTool("Pluginsroot"); } @@ -8318,7 +8321,7 @@ At first I was happy to find your code that solved my problem, but I did not lik } //Popup a context menu here for the plugin in question - Point clickpoint=Cursor.Position; + Point clickpoint = Cursor.Position; //create the context menu PopupMenuTool p = new PopupMenuTool("PluginCommandsPopup"); UltraToolbarsManager m = new UltraToolbarsManager(); @@ -8326,7 +8329,7 @@ At first I was happy to find your code that solved my problem, but I did not lik PluginMenuOptionData pmod = (PluginMenuOptionData)e.Tool.ToolbarsManager.Tools["Pluginsroot"].SharedProps.Tag; p.SharedProps.Tag = pmod;//required so click command can retrieve the info required System.Collections.Generic.List list = new System.Collections.Generic.List(); - + IAyaNovaPlugin PopPlugin = null; Guid PopPluginID = new Guid(e.Tool.Key.Split('|')[1]); foreach (IAyaNovaPlugin cmd in mPlugins) @@ -8344,7 +8347,7 @@ At first I was happy to find your code that solved my problem, but I did not lik if (!pmod.bIsSingleObject) list = PopPlugin.MultipleObjectsMenuOptions(pmod.oType); else - list = PopPlugin.SingleObjectMenuOptions(pmod.oType,pmod.oAyaObject); + list = PopPlugin.SingleObjectMenuOptions(pmod.oType, pmod.oAyaObject); if (list != null && list.Count > 0) { @@ -8358,7 +8361,7 @@ At first I was happy to find your code that solved my problem, but I did not lik Infragistics.Win.UltraWinToolbars.ButtonTool b = new Infragistics.Win.UltraWinToolbars.ButtonTool("PluginMenuItem|" + PopPlugin.ToString() + "|" + i.CommandKey.Replace('|', ' ') + "|" + PopPlugin.PluginID); b.ToolClick += new ToolClickEventHandler(Plugincommand_ToolClick); - b.SharedProps.Caption = i.Display; + b.SharedProps.Caption = i.Display; debugLog("PLUGINS - menuitem added: \"" + i.Display + "\" command:" + b.Key); if (i.MenuItemSmallImage != null) b.SharedProps.AppearancesSmall.Appearance.Image = i.MenuItemSmallImage; @@ -8367,16 +8370,16 @@ At first I was happy to find your code that solved my problem, but I did not lik m.Tools.Add(b); p.Tools.Add(b); } - - m.DockWithinContainer = e.Tool.ToolbarsManager.DockWithinContainer; - - m.ShowPopup("PluginCommandsPopup",clickpoint); - } + + m.DockWithinContainer = e.Tool.ToolbarsManager.DockWithinContainer; + + m.ShowPopup("PluginCommandsPopup", clickpoint); + } } - + /// /// Remove inserted plugin menu /// @@ -8385,8 +8388,8 @@ At first I was happy to find your code that solved my problem, but I did not lik { ArrayList al = new ArrayList(); foreach (ToolBase tb in t.Tools) - { - if (tb.Key.StartsWith("Plugin")) + { + if (tb.Key.StartsWith("Plugin")) al.Add(tb); } @@ -8404,9 +8407,9 @@ At first I was happy to find your code that solved my problem, but I did not lik private static void Plugincommand_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { - if (!e.Tool.Key.StartsWith("PluginMenuItem|")) return; + if (!e.Tool.Key.StartsWith("PluginMenuItem|")) return; PluginMenuOptionData pmod = (PluginMenuOptionData)e.Tool.ToolbarsManager.Tools["PluginCommandsPopup"].SharedProps.Tag; - + string[] s = e.Tool.Key.Split('|'); //should be 3 items Plugin:, then the plugin object name, then the command if (s.GetLength(0) != 4) return; @@ -8421,7 +8424,7 @@ At first I was happy to find your code that solved my problem, but I did not lik AyaBizUtils.AllowAutomaticClosedWorkorderStatus = false; //iterate plugins, find the one that matches then send it the command - foreach (IAyaNovaPlugin cmd in mPlugins) + foreach (IAyaNovaPlugin cmd in mPlugins) if (cmd.ToString().Equals(s[1], StringComparison.InvariantCultureIgnoreCase)) { debugLog("PLUGINS - command: " + e.Tool.Key); @@ -8437,21 +8440,21 @@ At first I was happy to find your code that solved my problem, but I did not lik } else { - ScheduleFormEx sfex=(ScheduleFormEx)pmod.oAyaObject; + ScheduleFormEx sfex = (ScheduleFormEx)pmod.oAyaObject; cmd.CommandSelectedForList(s[2], RootObjectTypes.Schedule, sfex.VisibleUsers, sfex.SelectedAppointments); } } - + } - AyaBizUtils.AllowAutomaticMRUOnUpdate = AutoMRUWas; - AyaBizUtils.AllowAutomaticClosedWorkorderStatus = AutoCloseWOStatusWas; - + AyaBizUtils.AllowAutomaticMRUOnUpdate = AutoMRUWas; + AyaBizUtils.AllowAutomaticClosedWorkorderStatus = AutoCloseWOStatusWas; + } - - + + public struct PluginMenuOptionData { public PluginMenuOptionData(bool SingleObject, RootObjectTypes ObjectType, object AyaObject, System.Collections.Generic.List IDList) @@ -8467,9 +8470,9 @@ At first I was happy to find your code that solved my problem, but I did not lik public object oAyaObject; public System.Collections.Generic.List objectIDList; } - - + + #endregion menu command processing @@ -8494,7 +8497,7 @@ At first I was happy to find your code that solved my problem, but I did not lik try { sName = p.PluginName; - sb.AppendLine(p.About.Replace("\r\n"," ") + " v" + p.PluginVersion); + sb.AppendLine(p.About.Replace("\r\n", " ") + " v" + p.PluginVersion); } catch (Exception ex) { @@ -8531,15 +8534,15 @@ At first I was happy to find your code that solved my problem, but I did not lik //long lnValue = loProcess.WorkingSet; // see what the actual value } #endregion - - #region Help url + + #region Help url //case 1172 public static string BaseHelpUrl { get { - if(AyaBizUtils.Lite) + if (AyaBizUtils.Lite) return @"https://www.ayanova.com/AyaNovaLite7webHelp/"; return @"https://www.ayanova.com/AyaNova7webHelp/"; @@ -8548,7 +8551,7 @@ At first I was happy to find your code that solved my problem, but I did not lik #endregion help url #region Grid delete buttons case 1105 - + static public void GridAddDeleteButton(Infragistics.Win.UltraWinGrid.UltraGrid Grid) { //remove and replace because other columns might have been shown @@ -8590,7 +8593,7 @@ At first I was happy to find your code that solved my problem, but I did not lik rootpop.SharedProps.Tag = theForm; rootpop.SharedProps.Caption = LocaleText.GetLocalizedText("UI.Label.ShowAll"); rootpop.SharedProps.DisplayStyle = ToolDisplayStyle.TextOnlyAlways; - + ShowAllInsertMenuItem(t, rootpop, "WorkorderService.Label.List", sourceTid); if (!AyaBizUtils.Lite && sourceTid.RootObjectType != RootObjectTypes.LoanItem)//case 3158 @@ -8600,18 +8603,18 @@ At first I was happy to find your code that solved my problem, but I did not lik ShowAllInsertMenuItem(t, rootpop, "WorkorderQuote.Label.List", sourceTid); ShowAllInsertMenuItem(t, rootpop, "WorkorderPreventiveMaintenance.Label.List", sourceTid); } - + if (rootpop.Tools.Count > 0) { t.Tools.Add(rootpop); UltraToolbar hostToolbar = t.Toolbars[0]; - hostToolbar.Tools.AddTool("ShowAllRoot"); + hostToolbar.Tools.AddTool("ShowAllRoot"); } } private static void ShowAllInsertMenuItem(UltraToolbarsManager t, PopupMenuTool rootpop, string KeyCaption, TypeAndID tid) { - ButtonTool b = new ButtonTool("ShowAll"+KeyCaption); + ButtonTool b = new ButtonTool("ShowAll" + KeyCaption); b.SharedProps.Caption = LocaleText.GetLocalizedText(KeyCaption); b.SharedProps.DisplayStyle = ToolDisplayStyle.TextOnlyAlways; b.SharedProps.Tag = tid; @@ -8642,18 +8645,24 @@ At first I was happy to find your code that solved my problem, but I did not lik if (tid.ID == Guid.Empty) return; Form theForm = e.Tool.OwningMenu.SharedProps.Tag as Form; string crit = ""; - + //Show list if (e.Tool.Key.Contains("WorkorderService.Label.List"))//show workorders { #region Show service workorders list if (tid.RootObjectType == RootObjectTypes.Client) { + //case 3759 - remove redundant name fetcher call + // crit = " \r\n" + + //" \r\n" + + //" \r\n"; + crit = " \r\n" + - " \r\n" + - " \r\n"; +" \r\n" + +"
\r\n"; + frmMain.ForceNavPaneTreesUpdate(); frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Service"]; gGridLastViews["WorkorderServiceList"].SubstituteCriteria = crit; @@ -8683,12 +8692,22 @@ At first I was happy to find your code that solved my problem, but I did not lik } else { + //it's a unit + + //case 3759 - remove redundant name fetcher + // crit = " \r\n" + + //" \r\n" + + //" "; + + crit = " \r\n" + -" \r\n" + +" \r\n" + " "; + + frmMain.ForceNavPaneTreesUpdate(); gGridLastViews["WorkorderServiceItemList"].SubstituteCriteria = crit; frmMain.ShowForm("LT:UI.Go.Service", "LT:WorkorderItem.Label.List", true); @@ -8703,11 +8722,18 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + #region Show Quote list if (tid.RootObjectType == RootObjectTypes.Client) { + //case 3759 - remove redundant name fetcher call + + // crit = " \r\n" + + //" \r\n" + + //" \r\n"; + crit = " \r\n" + - " \r\n" + - " \r\n"; + " \r\n" + + "
\r\n"; + frmMain.ForceNavPaneTreesUpdate(); frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Quotes"]; gGridLastViews["WorkorderQuoteList"].SubstituteCriteria = crit; @@ -8717,10 +8743,16 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + else { //it's a unit + + //case 3759 - remove redundant name fetcher call + // crit = " \r\n" + + //" \r\n" + + //" "; + crit = " \r\n" + -" \r\n" + +" \r\n" + " "; frmMain.ForceNavPaneTreesUpdate(); @@ -8737,11 +8769,17 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + #region Show PM list if (tid.RootObjectType == RootObjectTypes.Client) { + //case 3759 - remove redundant name fetcher call + // crit = " \r\n" + + //" \r\n" + + //" \r\n"; + crit = " \r\n" + - " \r\n" + + " \r\n" + " \r\n"; + frmMain.ForceNavPaneTreesUpdate(); frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.PreventiveMaintenance"]; gGridLastViews["WorkorderPMList"].SubstituteCriteria = crit; @@ -8751,10 +8789,16 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + else { //it's a unit + + //case 3759 - remove redundant name fetcher call + // crit = " \r\n" + + //" \r\n" + + //" "; + crit = " \r\n" + -" \r\n" + +" \r\n" + " "; frmMain.ForceNavPaneTreesUpdate(); @@ -8771,18 +8815,25 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + #region Show Unit list if (tid.RootObjectType == RootObjectTypes.Client) { + //case 3759 - remove redundant name fetcher call + + // crit = " \r\n" + + //" \r\n" + + //" \r\n"; + crit = " \r\n" + - " \r\n" + - " \r\n"; + " \r\n" + + "
\r\n"; + frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:Unit.Label.List"]; frmMain.UltraExplorerBar1.EventManager.SetEnabled(Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarEventIds.ItemCheckStateChanged, false); frmMain.UltraExplorerBar1.SelectedGroup.Items["LT:Unit.Label.List"].Checked = true; frmMain.UltraExplorerBar1.EventManager.SetEnabled(Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarEventIds.ItemCheckStateChanged, true); gGridLastViews["UnitList"].SubstituteCriteria = crit; frmMain.ShowForm("LT:Unit.Label.List", "LT:Unit.Label.List", true); - + } #endregion show units list @@ -8794,9 +8845,9 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + else theForm.WindowState = FormWindowState.Minimized; } - #endregion Show all menu options - - #region Localization helper + #endregion Show all menu options + + #region Localization helper #region Locale keyXform cache private static System.Collections.Generic.Dictionary> localizeHelperFormKeyCache = null; @@ -8804,7 +8855,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + { get { - if(localizeHelperFormKeyCache==null) + if (localizeHelperFormKeyCache == null) localizeHelperFormKeyCache = new System.Collections.Generic.Dictionary>(); return localizeHelperFormKeyCache; @@ -8825,7 +8876,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + //check if current user is admin or this is ayanova lite LocalizeHelperUserCanLocalize = User.IsAdmin || AyaBizUtils.Lite; - + if (!LocalizeHelperUserCanLocalize) return; //Iterate through the form fields and gather a list of the keys being used on the form @@ -8839,9 +8890,9 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + b.SharedProps.DisplayStyle = ToolDisplayStyle.TextOnlyAlways; b.SharedProps.Tag = theForm.Name; b.ToolClick += new ToolClickEventHandler(LocalizeHelper_ToolClick); - t.Tools.Add(b); + t.Tools.Add(b); UltraToolbar hostToolbar = t.Toolbars[0]; - hostToolbar.Tools.AddTool("LocalizeHelper"); + hostToolbar.Tools.AddTool("LocalizeHelper"); } @@ -8865,16 +8916,16 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + { //if chosen then call localizehelper LocalizeHelper(e.Tool.SharedProps.Tag.ToString()); - + } private static void LocalizeHelper(string formName) { - + LocalizeHelperForm f = new LocalizeHelperForm(LocalizeHelperFormKeyCache[formName]); f.ShowDialog(); f.Dispose(); - // MessageBox.Show("STUB: LocalizeHelper for form: " + formName + " (" + LocalizeHelperFormKeyCache[formName].Count.ToString() + " keys auto gathered)"); + // MessageBox.Show("STUB: LocalizeHelper for form: " + formName + " (" + LocalizeHelperFormKeyCache[formName].Count.ToString() + " keys auto gathered)"); } @@ -8902,11 +8953,11 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + if (c is Infragistics.Win.UltraWinEditors.UltraOptionSet) { - Infragistics.Win.UltraWinEditors.UltraOptionSet uos = (Infragistics.Win.UltraWinEditors.UltraOptionSet)c; - foreach (Infragistics.Win.ValueListItem vi in uos.Items) + Infragistics.Win.UltraWinEditors.UltraOptionSet uos = (Infragistics.Win.UltraWinEditors.UltraOptionSet)c; + foreach (Infragistics.Win.ValueListItem vi in uos.Items) if (vi.DisplayText.StartsWith("LT:")) LocalizeHelperInsertKeyInCache(formNameKey, vi.DisplayText); - + //An ultraoptionset doesn't contain any child controls so bump up a level now return; } @@ -8933,12 +8984,12 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + } if (c is Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea) - LocalizeHelperSuckOutKeys(formNameKey, ((Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)c).ToolbarsManager); + LocalizeHelperSuckOutKeys(formNameKey, ((Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)c).ToolbarsManager); if (c is Infragistics.Win.UltraWinGrid.UltraGrid) - LocalizeHelperSuckOutKeys(formNameKey, (Infragistics.Win.UltraWinGrid.UltraGrid)c); + LocalizeHelperSuckOutKeys(formNameKey, (Infragistics.Win.UltraWinGrid.UltraGrid)c); - if (c is Infragistics.Win.UltraWinTabControl.UltraTabControl) + if (c is Infragistics.Win.UltraWinTabControl.UltraTabControl) foreach (Infragistics.Win.UltraWinTabControl.UltraTab ut in ((Infragistics.Win.UltraWinTabControl.UltraTabControl)c).Tabs) { if (ut.Text.StartsWith("LT:")) @@ -8946,7 +8997,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + LocalizeHelperSuckOutKeys(formNameKey, ut); } - + if (c is ToolStrip) { foreach (ToolStripItem i in ((ToolStrip)c).Items) @@ -8961,34 +9012,34 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + { if (di.Text != null && di.Text.StartsWith("LT:")) LocalizeHelperInsertKeyInCache(formNameKey, di.Text); - + } } } } - + //=================================== foreach (Control c2 in c.Controls) - LocalizeHelperSuckOutKeys(formNameKey, c2); + LocalizeHelperSuckOutKeys(formNameKey, c2); } #endregion control generic #region UltraExplorerBar static public void LocalizeHelperSuckOutKeys(string formNameKey, Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Bar) - { + { foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup BarGroup in Bar.Groups) { if (BarGroup.Key.StartsWith("LT:")) LocalizeHelperInsertKeyInCache(formNameKey, BarGroup.Key); - if (BarGroup.Settings.Style == Infragistics.Win.UltraWinExplorerBar.GroupStyle.ControlContainer) + if (BarGroup.Settings.Style == Infragistics.Win.UltraWinExplorerBar.GroupStyle.ControlContainer) foreach (Control cc in BarGroup.Container.Controls) - LocalizeHelperSuckOutKeys(formNameKey, cc); - else - foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem BarItem in BarGroup.Items) + LocalizeHelperSuckOutKeys(formNameKey, cc); + else + foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem BarItem in BarGroup.Items) if (BarItem.Key.StartsWith("LT:")) - LocalizeHelperInsertKeyInCache(formNameKey, BarItem.Key); + LocalizeHelperInsertKeyInCache(formNameKey, BarItem.Key); } } #endregion @@ -9014,20 +9065,20 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + if (!LocalizeHelperUserCanLocalize) return; //Loop through the columns in the grid's bands - foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in Grid.DisplayLayout.Bands) - foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn cm in band.Columns) + foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in Grid.DisplayLayout.Bands) + foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn cm in band.Columns) if (cm.Header.Caption.StartsWith("LT_")) - LocalizeHelperInsertKeyInCache(formNameKey, cm.Header.Caption.Replace("LT_", "").Replace("_", ".")); + LocalizeHelperInsertKeyInCache(formNameKey, cm.Header.Caption.Replace("LT_", "").Replace("_", ".")); } - + #endregion #region UltraTab static public void LocalizeHelperSuckOutKeys(string formNameKey, Infragistics.Win.UltraWinTabControl.UltraTab t) { foreach (Control c2 in t.TabPage.Controls) - LocalizeHelperSuckOutKeys(formNameKey, c2); + LocalizeHelperSuckOutKeys(formNameKey, c2); } #endregion @@ -9069,7 +9120,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + #region UltraDockManager static public void LocalizeHelperSuckOutKeys(string formNameKey, Infragistics.Win.UltraWinDock.UltraDockManager udm) { - foreach (Infragistics.Win.UltraWinDock.DockAreaPane dap in udm.DockAreas) + foreach (Infragistics.Win.UltraWinDock.DockAreaPane dap in udm.DockAreas) foreach (Infragistics.Win.UltraWinDock.DockablePaneBase dpb in dap.Panes) { if (dpb.TextTab.StartsWith("LT:")) @@ -9079,7 +9130,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + LocalizeHelperSuckOutKeys(formNameKey, ((Infragistics.Win.UltraWinDock.DockableControlPane)dpb).Control); } - + } #endregion @@ -9087,10 +9138,10 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + #endregion localization helper - + #region Password redactor //case 3589 - + ///////////////////////////////////////////// ////clean out password from connection string ////for log purposes @@ -9099,7 +9150,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + return System.Text.RegularExpressions.Regex.Replace(cs, "Password\\s*=.*?;", "Password=[REDACTED]", System.Text.RegularExpressions.RegexOptions.IgnoreCase); } - + #endregion //------------------------------------------ @@ -9126,7 +9177,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + /// /// Set of words you want to add. /// - string[] _words={ + string[] _words ={ "lorem","ipsum","dolor","sit","amet","consectetur","adipiscing", "elit","ut","facilisis","metus","quis","massa","malesuada","vitae", "fringilla","elit","imperdiet","sed","rutrum","felis","a","odio", @@ -9204,7 +9255,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + public RandomText() { _builder = new StringBuilder(); - + } /// @@ -9222,11 +9273,11 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + for (int i = 0; i < numberParagraphs; i++) { AddParagraph(_random.Next(minSentences, maxSentences + 1), minWords, maxWords); - if(i>1 && i< numberParagraphs-1) - _builder.Append("\n\n"); + if (i > 1 && i < numberParagraphs - 1) + _builder.Append("\n\n"); } return _builder.ToString(); - + } public string GetRandomSentence(int nWords) @@ -9277,7 +9328,7 @@ UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) + } } -#endregion randomtextgenerator + #endregion randomtextgenerator #region Form font fixer