9436 lines
380 KiB
C#
9436 lines
380 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using GZTW.AyaNova.BLL;
|
|
using CSLA.Security;
|
|
using System.Threading;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using Infragistics.Win.UltraWinGrid;
|
|
using Infragistics.Win;
|
|
using Infragistics.Win.UltraWinEditors;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using System.Reflection;
|
|
using System.Drawing;
|
|
using Infragistics.Win.UltraWinToolbars;
|
|
using System.ComponentModel;
|
|
using System.Drawing.Design;
|
|
using System.Windows.Forms.Design;
|
|
using System.Runtime.InteropServices;
|
|
using Microsoft.Win32;
|
|
using log4net;
|
|
using System.Configuration;
|
|
using DevExpress.XtraReports;
|
|
using DevExpress.XtraReports.UI;
|
|
using System.Drawing.Imaging;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using AyaNova.PlugIn;
|
|
//using FirebirdSql.Data.Firebird;
|
|
|
|
namespace AyaNova
|
|
{
|
|
|
|
//Namespace-Wide enums
|
|
|
|
/// <summary>
|
|
/// Used within sub forms to indicate what to do
|
|
/// with the current record
|
|
/// </summary>
|
|
public enum RecordActionType : int
|
|
{
|
|
SaveOnly = 1,
|
|
SaveAndExit = 2,
|
|
SaveAndNew = 3,
|
|
PromptToSave = 4,
|
|
DeleteAndExit = 5
|
|
|
|
}
|
|
|
|
//Case 37
|
|
public enum HotKeyAction
|
|
{
|
|
NoAction,
|
|
CloseForm,
|
|
NewWorkorder,
|
|
NewPreventiveMaintenance,
|
|
NewQuote,
|
|
NewClient,
|
|
NewUnit,
|
|
NewPart,
|
|
Help,
|
|
GridFilterCriteria,//case 776,
|
|
EmptyWorkingSet//case 1701
|
|
}
|
|
|
|
/// <summary>
|
|
/// Summary description for Util.
|
|
/// </summary>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// Current thread security businessprinciple object
|
|
/// </summary>
|
|
//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;
|
|
|
|
|
|
|
|
//case 939
|
|
public static bool CurrentUserIsAdminType = false;
|
|
//private static string DiagnosticConnectionInfo=null;
|
|
|
|
internal static LocalizedTextTable LocaleText=null;
|
|
//set by config file value <add key="GenerateFromThisConnection" value="true"/>
|
|
//used to run generator from client winform background process
|
|
//internal static bool IAmAGenerator=false;
|
|
|
|
//internal static bool UsingDataPortal=false;
|
|
//Case 534
|
|
//Case 697 now also uses this
|
|
internal static Form1 frmMain = null;
|
|
|
|
//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?
|
|
//
|
|
|
|
}
|
|
|
|
public static void InitUtil(Form1 form1)
|
|
{
|
|
//case 3112
|
|
fixFonts = true;
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
foreach (string sarg in args)
|
|
{
|
|
if (sarg.ToLowerInvariant() == "use_os_fonts")
|
|
{
|
|
fixFonts = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
//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
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="FormName"></param>
|
|
/// <returns></returns>
|
|
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
|
|
|
|
/// <summary>
|
|
/// Load the form and toolbar customization as per the users last view
|
|
/// </summary>
|
|
/// <param name="FormName">UIUserFormSettings key</param>
|
|
/// <param name="TheForm"></param>
|
|
/// <param name="TheToolBarManager"></param>
|
|
static public void LoadFormCustomization(string FormName, System.Windows.Forms.Form TheForm, UltraToolbarsManager TheToolBarManager, bool ToolBarOnly)
|
|
{
|
|
int x = 0;
|
|
int y = 0;
|
|
LoadFormCustomization(FormName, TheForm, TheToolBarManager, ToolBarOnly, ref x, ref y);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
static public void LoadFormCustomization(string FormName, System.Windows.Forms.Form TheForm,
|
|
UltraToolbarsManager TheToolBarManager, bool ToolBarOnly, ref int Split1, ref int Split2)
|
|
{
|
|
DataSet ds = GetFormSettings(FormName).LayoutDS;
|
|
if (ds.Tables.Count == 0)
|
|
{
|
|
//first time opening this form so trigger the forms
|
|
//onsize changed code to clean up the layout
|
|
TheForm.Width = TheForm.Width - 1;
|
|
TheForm.Width = TheForm.Width + 1;
|
|
EnsureFormVisible(TheForm);
|
|
return;
|
|
}
|
|
|
|
|
|
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 nHeight = int.Parse(dr["FormHeight"].ToString());
|
|
if (nWidth == 0 || nHeight == 0)
|
|
TheForm.WindowState = FormWindowState.Maximized;
|
|
else
|
|
{
|
|
TheForm.Width = nWidth;
|
|
TheForm.Height = nHeight;
|
|
TheForm.Left = int.Parse(dr["LocationX"].ToString());
|
|
TheForm.Top = int.Parse(dr["LocationY"].ToString());
|
|
}
|
|
Split1 = int.Parse(dr["SplitPosition1"].ToString());
|
|
Split2 = int.Parse(dr["SplitPosition2"].ToString());
|
|
|
|
}
|
|
else
|
|
{
|
|
//No form settings but this was called with the intention of setting the form settings, so
|
|
//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)
|
|
{
|
|
foreach (DataRow dr in ds.Tables["TOOLBAR"].Rows)
|
|
{
|
|
if (TheToolBarManager.Toolbars.Exists(dr["Key"].ToString()))
|
|
{
|
|
TheToolBarManager.UseLargeImagesOnToolbar = bool.Parse(dr["UseLargeImagesOnToolbar"].ToString());
|
|
UltraToolbar tb = TheToolBarManager.Toolbars[dr["Key"].ToString()];
|
|
tb.DockedColumn = int.Parse(dr["DockedColumn"].ToString());
|
|
tb.DockedRow = int.Parse(dr["DockedRow"].ToString());
|
|
|
|
switch (dr["DockedColumn"].ToString())
|
|
{
|
|
case "Top":
|
|
tb.DockedPosition = DockedPosition.Top;
|
|
break;
|
|
case "Right":
|
|
tb.DockedPosition = DockedPosition.Right;
|
|
break;
|
|
case "Bottom":
|
|
tb.DockedPosition = DockedPosition.Bottom;
|
|
break;
|
|
case "Left":
|
|
tb.DockedPosition = DockedPosition.Left;
|
|
break;
|
|
case "Floating":
|
|
tb.DockedPosition = DockedPosition.Floating;
|
|
break;
|
|
default:
|
|
tb.DockedPosition = DockedPosition.Top;
|
|
break;
|
|
|
|
}
|
|
}
|
|
//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 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
|
|
//string s = GetControls(e.CustomizerForm);
|
|
|
|
//case 1681
|
|
HideToolBarCustomizeUnusedControls(e.CustomizerForm);
|
|
|
|
|
|
}
|
|
|
|
|
|
private static string GetControls(Control c)
|
|
{
|
|
System.Text.StringBuilder sb=new StringBuilder();
|
|
sb.Append("* " + c.Name + " - " + c.GetType().ToString() + "\r\n");
|
|
foreach (Control cc in c.Controls)
|
|
{
|
|
sb.Append(GetControls(cc));
|
|
}
|
|
|
|
//if (c is Infragistics.Win.UltraWinTabControl.UltraTabSharedControlsPage)
|
|
// c.Visible = false;
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
private static void HideToolBarCustomizeUnusedControls(Control ParentControl)
|
|
{
|
|
|
|
Control c = FindControl(ParentControl, "cmdKeyboard");
|
|
if (c != null)
|
|
c.Visible = false;
|
|
|
|
c = FindControl(ParentControl, "cmdResetToolbar");
|
|
if (c != null)
|
|
c.Visible = false;
|
|
|
|
//c = FindControl(ParentControl, "spToolbars");
|
|
//if (c != null)
|
|
// c.Visible = false;
|
|
|
|
//c = FindControl(ParentControl, "pnlToolbars");
|
|
//if (c != null)
|
|
// c.Visible = false;
|
|
}
|
|
|
|
private static Control FindControl(Control ParentControl, string Name)
|
|
{
|
|
if (ParentControl.Name == Name) return ParentControl;
|
|
foreach (Control c in ParentControl.Controls)
|
|
{
|
|
if (c.Name == Name) return c;
|
|
if (c.Controls.Count > 0)
|
|
{
|
|
Control cTemp = FindControl(c, Name);
|
|
if (cTemp != null) return cTemp;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
//http://www.codeproject.com/KB/cs/restoreformstate.aspx?msg=1381198#xx1381198xx
|
|
/*
|
|
* One thing that most people forget when saving Window Positions is that some people use multiple screens. If this isn't taken into consideration when saving/retrieving window coordinates, windows can be 'lost' if the positioning of a secondary monitor is changed in between uses of an application, causing a user great frustration. Microsoft Photo Editor (included with Office 2000) had this problem, and I had to go into the registry to fix the screen position if I changed my screen configurations between uses.
|
|
|
|
Window positions are saved with respect to the primary monitor's top left corner (this being x,y coordinate 0,0). This means that if a secondary monitor (Set up in Windows Display Properties) was positioned to the left and above the primary monitor, then it would have negative form.Top and form.Left properties. Now all this is fine, until the configuration of the monitors change. Consider the following two scenarios:
|
|
|
|
A - Laptop User> I use a laptop, and when it's docked, I use a dual monitor configuration. If I exit an application which saves a form's position, where that form is on the non-primary monitor, then undock my laptop (leaving only a primary monitor - the laptop monitor), then when I re-run the application, if it doesn't do a check to see whether the form is able to be displayed, then the form is lost.
|
|
|
|
B - Repositioning of 2nd Form> I have two monitors, and the second is positioned to the left of the primary monitor. I exit an application that saves form position, leaving the form on the secondary monitor. Once the application is closed, I reposition the secondary monitor to be to the right of the first. When re-starting the application, the window will be lost unless a check is performed to determine whether the form is visible.
|
|
|
|
The following code, which I have used in a static class, performs a check on a form to ensure it is visible, and if not, partially repositions the form to ensure the user can adjust it * */
|
|
|
|
/*
|
|
* There is hardly a thing that cannot be improved...
|
|
At first I was happy to find your code that solved my problem, but I did not like two things: First, whenever the window was just a little bit off the lower border of the screen, it snapped back to the top. So I changed the code to check the two cases separately. Second thing is the Task bar. The window can be hidden beneath the task bar and docked tool bars, especially when they are is at the top of the screen. Here is the code that I ended up with:
|
|
* */
|
|
|
|
public static void EnsureFormVisible(Form form)
|
|
{
|
|
Rectangle bounds = bounds = Screen.GetWorkingArea(form);
|
|
|
|
// Ensure top visible
|
|
if (form.Top < bounds.Top)
|
|
{
|
|
form.Top = bounds.Top;
|
|
}
|
|
|
|
// Move the form up if it is too low
|
|
if (form.Top + 40 > bounds.Bottom)
|
|
{
|
|
form.Top = bounds.Bottom - 40;
|
|
}
|
|
|
|
// MOve form inside screen horizontally
|
|
if (form.Right - 80 < bounds.Left)
|
|
{
|
|
form.Left = bounds.Left - form.Width + 80;
|
|
}
|
|
if (form.Left + 60 > bounds.Right)
|
|
{
|
|
form.Left = bounds.Right - 60;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Save the form and toolbar customization as per the users last view
|
|
/// </summary>
|
|
/// <param name="FormName">UIUserFormSettings key</param>
|
|
/// <param name="TheForm"></param>
|
|
/// <param name="TheToolBarManager"></param>
|
|
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);
|
|
}
|
|
|
|
static public void SaveFormCustomization(string FormName, System.Windows.Forms.Form TheForm,
|
|
UltraToolbarsManager TheToolBarManager, bool ToolBarOnly, int Split1, int Split2)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
System.IO.StringWriter sr = new System.IO.StringWriter(sb);
|
|
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(sr);
|
|
w.Formatting = System.Xml.Formatting.Indented;
|
|
w.WriteStartDocument(true);
|
|
|
|
//Containing element
|
|
w.WriteStartElement("LAYOUT");
|
|
|
|
if (!ToolBarOnly)
|
|
{
|
|
//Save the form settings
|
|
|
|
//Don't save a minimized form as minimized
|
|
if (TheForm.WindowState == FormWindowState.Minimized)
|
|
TheForm.WindowState=FormWindowState.Maximized;
|
|
|
|
w.WriteStartElement("FORM");
|
|
if (TheForm.WindowState == FormWindowState.Maximized)//case 1594
|
|
{
|
|
w.WriteAttributeString("FormWidth","0"); //zero means maximized
|
|
w.WriteAttributeString("FormHeight", "0");
|
|
}
|
|
else
|
|
{
|
|
w.WriteAttributeString("FormWidth", TheForm.Width.ToString());
|
|
w.WriteAttributeString("FormHeight", TheForm.Height.ToString());
|
|
}
|
|
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.WriteEndElement();//Form section
|
|
}
|
|
|
|
//toolbar
|
|
//w.WriteStartElement("TOOLBARS");
|
|
if (TheToolBarManager != null)
|
|
{
|
|
foreach (UltraToolbar tb in TheToolBarManager.Toolbars)
|
|
{
|
|
w.WriteStartElement("TOOLBAR");
|
|
//right now there is only one setting for large images but
|
|
//in future it might be customizable for each toolbar and it makes more
|
|
//overall sense to put it here anyway
|
|
w.WriteAttributeString("UseLargeImagesOnToolbar", TheToolBarManager.UseLargeImagesOnToolbar.ToString());
|
|
w.WriteAttributeString("Key", tb.Key);
|
|
w.WriteAttributeString("DockedColumn", tb.DockedColumn.ToString());
|
|
w.WriteAttributeString("DockedRow", tb.DockedRow.ToString());
|
|
w.WriteAttributeString("DockedPosition", tb.DockedPosition.ToString());
|
|
w.WriteEndElement();
|
|
}
|
|
}
|
|
// w.WriteEndElement();//Toolbar section
|
|
|
|
w.WriteEndElement();//Layout
|
|
w.WriteEndDocument();
|
|
sr.Close();
|
|
GetFormSettings(FormName).Layout = sr.ToString();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Localize
|
|
|
|
#region Grid
|
|
/// <summary>
|
|
/// Modify ui elements to display localized values
|
|
/// specific to a grid control because it's quirky when
|
|
/// on a tab control (invisible)
|
|
///
|
|
/// </summary>
|
|
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)
|
|
|
|
//case 2108
|
|
// 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("_","."));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="ObjectName">Name of business object band represents</param>
|
|
/// <param name="Band"> band to be pre-localized</param>
|
|
|
|
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
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="tbm"></param>
|
|
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 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 UltraDockManager
|
|
static public void Localize(Infragistics.Win.UltraWinDock.UltraDockManager udm)
|
|
{
|
|
foreach (Infragistics.Win.UltraWinDock.DockAreaPane dap in udm.DockAreas)
|
|
{
|
|
foreach (Infragistics.Win.UltraWinDock.DockablePaneBase dpb in dap.Panes)
|
|
{
|
|
if (dpb.TextTab.StartsWith("LT:"))
|
|
dpb.TextTab = LocaleText.GetLocalizedText(dpb.TextTab.Replace("LT:", ""));
|
|
|
|
if (dpb is Infragistics.Win.UltraWinDock.DockableControlPane)
|
|
Localize(((Infragistics.Win.UltraWinDock.DockableControlPane)dpb).Control);
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region UltraExplorerBar
|
|
static public void Localize(Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Bar)
|
|
{
|
|
Bar.ViewStyle= defaultExplorerBarViewStyle;
|
|
Bar.UseOsThemes=defaultUseOsThemes;
|
|
foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup BarGroup in Bar.Groups)
|
|
{
|
|
if (BarGroup.Key.StartsWith("LT:"))
|
|
BarGroup.Text = LocaleText.GetLocalizedText(BarGroup.Key.Replace("LT:", ""));
|
|
if (BarGroup.Settings.Style == Infragistics.Win.UltraWinExplorerBar.GroupStyle.ControlContainer)
|
|
{
|
|
foreach (Control cc in BarGroup.Container.Controls)
|
|
Localize(cc);
|
|
|
|
}
|
|
else
|
|
{
|
|
foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem BarItem in BarGroup.Items)
|
|
{
|
|
if (BarItem.Key.StartsWith("LT:"))
|
|
BarItem.Text = LocaleText.GetLocalizedText(BarItem.Key.Replace("LT:", ""));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#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
|
|
|
|
#region Form or any control that can host controls
|
|
|
|
|
|
#region STYLING OVERRIDES
|
|
//case 2108 testing - this is how it has been styled forever up to case 2108 before any changes:
|
|
//static Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarViewStyle defaultExplorerBarViewStyle = Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarViewStyle.XP;
|
|
//static UIElementButtonStyle defaultButtonStyle = UIElementButtonStyle.WindowsXPCommandButton;
|
|
//static DefaultableBoolean defaultUseOsThemes = DefaultableBoolean.False;
|
|
//static EmbeddableElementDisplayStyle defaultEmbeddableElementDisplayStyle = EmbeddableElementDisplayStyle.OfficeXP;
|
|
//static Infragistics.Win.UltraWinToolbars.ToolbarStyle defaultToolBarStyle = ToolbarStyle.OfficeXP;
|
|
|
|
|
|
//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 UIElementButtonStyle defaultButtonStyle = UIElementButtonStyle.Default;
|
|
|
|
static DefaultableBoolean defaultUseOsThemes = DefaultableBoolean.True;
|
|
static EmbeddableElementDisplayStyle defaultEmbeddableElementDisplayStyle = EmbeddableElementDisplayStyle.Default;
|
|
static Infragistics.Win.UltraWinToolbars.ToolbarStyle defaultToolBarStyle = ToolbarStyle.Default;
|
|
|
|
//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
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Modify ui elements to display localized values
|
|
/// Style them as well
|
|
/// </summary>
|
|
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
|
|
if (c is GZTW.WinForm.Controls.GZUltraComboEditor)
|
|
{
|
|
((GZTW.WinForm.Controls.GZUltraComboEditor)c).ButtonStyle = defaultButtonStyle;
|
|
((GZTW.WinForm.Controls.GZUltraComboEditor)c).UseOsThemes = defaultUseOsThemes;
|
|
}
|
|
|
|
if (c is GZTW.WinForm.Controls.GZDateTimePicker)
|
|
{
|
|
((GZTW.WinForm.Controls.GZDateTimePicker)c).DisplayStyle = defaultEmbeddableElementDisplayStyle;
|
|
((GZTW.WinForm.Controls.GZDateTimePicker)c).ButtonStyle = defaultButtonStyle;
|
|
((GZTW.WinForm.Controls.GZDateTimePicker)c).UseOsThemes = defaultUseOsThemes;
|
|
}
|
|
|
|
if (c is Infragistics.Win.Misc.UltraButton)
|
|
{
|
|
((Infragistics.Win.Misc.UltraButton)c).ButtonStyle = defaultButtonStyle;
|
|
((Infragistics.Win.Misc.UltraButton)c).UseOsThemes = defaultUseOsThemes;
|
|
}
|
|
|
|
if (c is Infragistics.Win.UltraWinEditors.UltraCheckEditor)
|
|
{
|
|
//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;
|
|
}
|
|
|
|
if (c is Infragistics.Win.Misc.UltraDropDownButton)
|
|
{
|
|
((Infragistics.Win.Misc.UltraDropDownButton)c).ButtonStyle = defaultButtonStyle;
|
|
((Infragistics.Win.Misc.UltraDropDownButton)c).UseOsThemes = defaultUseOsThemes;
|
|
}
|
|
|
|
|
|
|
|
//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;
|
|
|
|
//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;
|
|
|
|
}
|
|
|
|
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)
|
|
{
|
|
Localize(((Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)c).ToolbarsManager);
|
|
}
|
|
|
|
if (c is Infragistics.Win.UltraWinGrid.UltraGrid)
|
|
{
|
|
LocalizeGrid((Infragistics.Win.UltraWinGrid.UltraGrid)c);
|
|
}
|
|
|
|
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:"))
|
|
ut.Text = LocaleText.GetLocalizedText(ut.Text.Replace("LT:", ""));
|
|
Localize(ut);
|
|
|
|
}
|
|
|
|
}
|
|
if (c is ToolStrip)
|
|
{
|
|
foreach(ToolStripItem i in ((ToolStrip)c).Items)
|
|
{
|
|
if (i.Text!=null && i.Text.StartsWith("LT:"))
|
|
i.Text = LocaleText.GetLocalizedText(i.Text.Replace("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 (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)
|
|
{
|
|
Localize(c2);
|
|
#region old crap
|
|
//if( c2.Text.StartsWith("LT:"))
|
|
// c2.Text=LocaleText.GetLocalizedText(c2.Text.Replace("LT:",""));
|
|
//else if(c2 is Panel)
|
|
// Localize(c2);
|
|
//else if(c2 is Infragistics.Win.UltraWinGrid.UltraGrid)
|
|
//{
|
|
// LocalizeGrid((Infragistics.Win.UltraWinGrid.UltraGrid)c2);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else if(c2 is Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar)
|
|
//{
|
|
// #region UltraExplorerBar
|
|
// //with special code for Infragistics UltraExplorerBar which doesn't
|
|
// //technically host the bars as controls so they must be done "manually"
|
|
// Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar Bar=(Infragistics.Win.UltraWinExplorerBar.UltraExplorerBar)c2;
|
|
// Localize(Bar);
|
|
// #endregion
|
|
//}
|
|
//else if(c2 is Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)
|
|
//{
|
|
// #region Toolbars
|
|
// Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbm=((Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)c2).ToolbarsManager;
|
|
// tbm.Style = ToolbarStyle.Office2007;
|
|
// //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
|
|
|
|
//}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 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)
|
|
/// </summary>
|
|
/// <param name="BizObject"></param>
|
|
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();
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Localize Infragistics message strings
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
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"));
|
|
|
|
//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
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Localized DateTime mask for input
|
|
/// <summary>
|
|
/// Returns input mask to use in date and time editor for this locale
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
static public string LocaleDateTimeMask()
|
|
{
|
|
|
|
CultureInfo ciCurrent = System.Globalization.CultureInfo.CurrentCulture;
|
|
|
|
//Use date and time editor to calculate input mask
|
|
DateTimeEditor editor = new DateTimeEditor();
|
|
|
|
string dateMask = editor.CalcDefaultDateMask(ciCurrent );
|
|
string timeMask = editor.CalcDefaultTimeMask(ciCurrent);
|
|
|
|
//Case 137
|
|
//.net doesn't set the short time format in the current culture object based on the
|
|
//regional settings, but instead sets the long time pattern instead since the regional
|
|
//settings only has one box to set a custom format in. Infragistics uses the incorrect
|
|
//pattern (short) so it doesn't pick up the customized setting in calcdefaulttimemask
|
|
//reported to infragistics and if they fix it I can revert this code back, but it probably internally
|
|
//just does the same thing anyway.
|
|
|
|
if (ciCurrent.DateTimeFormat.ShortTimePattern != ciCurrent.DateTimeFormat.LongTimePattern)
|
|
{
|
|
//timeMask = ciCurrent.DateTimeFormat.LongTimePattern;
|
|
timeMask = "{longtime}";
|
|
}
|
|
|
|
|
|
//case 1039 //if(log.IsDebugEnabled)
|
|
//case 1039 //log.Debug("Detected LocaleDateTimeMask is: ["+dateMask + " " + timeMask+"]");
|
|
|
|
return dateMask + " " + timeMask;
|
|
|
|
//-------------------------------------------
|
|
}
|
|
#endregion
|
|
|
|
#region Load / save grid layout
|
|
/// <summary>
|
|
/// Save layout of grid
|
|
/// </summary>
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Fetch and set the grid layout
|
|
/// </summary>
|
|
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 + ")");
|
|
|
|
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);
|
|
}
|
|
c.Hidden = false;
|
|
//Set sort indicator for first visible column only
|
|
if (nPosition == 0)
|
|
{
|
|
if (GridKey != "WorkorderItemTasks")//Case 46 - added
|
|
{
|
|
if (TabRow["SORT"].ToString() == "DESC")
|
|
c.SortIndicator = SortIndicator.Descending;
|
|
else
|
|
c.SortIndicator = SortIndicator.Ascending;
|
|
}
|
|
|
|
}
|
|
|
|
c.Header.VisiblePosition = nPosition++;
|
|
c.Width = System.Convert.ToInt32(TabRow["WIDTH"]);
|
|
c.Header.Fixed = (TabRow["PIN"].ToString() == "1") ? true : false;
|
|
|
|
}
|
|
|
|
//Turn back on the events for the grid
|
|
//Grid.EventManager.SetEnabled(Infragistics.Win.UltraWinGrid.EventGroups.AllEvents, true);
|
|
#endregion new method
|
|
}
|
|
else
|
|
{
|
|
#region Use old method to load saved grid layout
|
|
//which will later be saved as new method when they close the form that loaded it
|
|
try
|
|
{
|
|
|
|
Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange, false);
|
|
|
|
|
|
/*
|
|
*
|
|
* NOTE: the tag copying thing below should be redundant, no grid should be localized before it loads
|
|
* it's saved state and it should use the key for localizing in any case, not the caption or tag right?
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
//Changed: 15-March-2005
|
|
//Will now use users setting if found, if none, will try to use manager's setting
|
|
//if none then will do as normal
|
|
UIGridLayout ugl = UIGridLayout.GetItem(GridKey, GridSubKey, User.CurrentThreadUserID);
|
|
//check to see if it exists yet...
|
|
if (ugl.GridKey == "")
|
|
{
|
|
|
|
if (User.IsAdmin)
|
|
return;
|
|
|
|
//case 1039 //log.Debug("No previously saved grid layout for this grid and user, trying manager account's setting...");
|
|
|
|
|
|
|
|
ugl = UIGridLayout.GetItem(GridKey, GridSubKey, User.AdministratorID);
|
|
//check to see if it exists yet...
|
|
if (ugl.GridKey == "")
|
|
{
|
|
//case 1039 //log.Debug("No previously saved grid layout for manager either no default will be used.");
|
|
return;
|
|
}
|
|
}
|
|
//case 1039 //log.Debug("Grid layout exists, loading from previously saved layout...");
|
|
//Copy all the grid column headings to thier tag property so we have them for localizing
|
|
//this is because the load layout is going to fetch the headings as they
|
|
//were last displayed (localized) in addition to the other settings and
|
|
//we don't want that to happen.
|
|
foreach (UltraGridBand b in Grid.DisplayLayout.Bands)
|
|
{
|
|
////case 1039 //log.Debug("Copying to tags band " + b.Index.ToString() + " columns: " + b.Columns.Count.ToString());
|
|
foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn c in b.Columns)
|
|
{
|
|
//case 1039 //log.Debug("Processing Column: " + c.Key);
|
|
c.Header.Tag = c.Header.Caption;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
System.IO.MemoryStream ms = new System.IO.MemoryStream(ugl.GetLayoutContent());
|
|
|
|
////case 1039 //log.Debug("Layout content size: " + ugl.LayoutSize.ToString());
|
|
Grid.DisplayLayout.Load(ms, PropertyCategories.Bands | PropertyCategories.SortedColumns | PropertyCategories.ColumnFilters);
|
|
|
|
|
|
// //Copy them back again
|
|
foreach (UltraGridBand b in Grid.DisplayLayout.Bands)
|
|
{
|
|
////case 1039 //log.Debug("Copying from tags band " + b.Index.ToString() + " columns: " + b.Columns.Count.ToString());
|
|
foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn c in b.Columns)
|
|
{
|
|
|
|
//in the case of unbound columns that were present
|
|
//when the grid was saved they will not really be there
|
|
// so this will avoid an error
|
|
if (c.Header.Tag != null)
|
|
{
|
|
////case 1039 //log.Debug("Processing Column: " + c.Key);
|
|
c.Header.Caption = c.Header.Tag.ToString();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
////case 1039 //log.Debug("Done processing load layout");
|
|
Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange, true);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("FetchGridLayout", ex);
|
|
MessageBox.Show("FetchGridLayout Error: \r\n" + ex.Message);
|
|
|
|
}
|
|
#endregion old method
|
|
}
|
|
|
|
//Case 240
|
|
//catches most of the editable grids inside edit forms
|
|
GridStyler(Grid);
|
|
}
|
|
|
|
|
|
#region Band 1
|
|
|
|
//Added: 02-August-2006 new methods to save and load layout for band 1
|
|
//i.e. contact phones
|
|
/// <summary>
|
|
/// Save layout of grid
|
|
/// </summary>
|
|
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 + ")");
|
|
|
|
bool bFiltered = false;
|
|
Util.gGridLastViews[GridKey].ViewXML = Util.GetGridSortAndFilterXML(Grid.DisplayLayout.Bands[1], false, ref bFiltered);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Fetch and set the grid layout
|
|
/// </summary>
|
|
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 + ")");
|
|
|
|
if (gGridLastViews.Contains(GridKey))
|
|
{
|
|
#region Use new UI agnostic method to load settings
|
|
int nPosition = 0;
|
|
Infragistics.Win.UltraWinGrid.UltraGridBand band = Grid.DisplayLayout.Bands[1];
|
|
|
|
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);
|
|
}
|
|
c.Hidden = false;
|
|
//Set sort indicator for first visible column only
|
|
if (nPosition == 0)
|
|
{
|
|
|
|
if (TabRow["SORT"].ToString() == "DESC")
|
|
c.SortIndicator = SortIndicator.Descending;
|
|
else
|
|
c.SortIndicator = SortIndicator.Ascending;
|
|
|
|
|
|
}
|
|
|
|
c.Header.VisiblePosition = nPosition++;
|
|
c.Width = System.Convert.ToInt32(TabRow["WIDTH"]);
|
|
// c.Header.Fixed = (TabRow["PIN"].ToString() == "1") ? true : false;
|
|
|
|
}
|
|
|
|
|
|
#endregion new method
|
|
}
|
|
|
|
|
|
|
|
}
|
|
#endregion band1
|
|
#endregion
|
|
|
|
#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;
|
|
}
|
|
|
|
//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<GridBand.Columns.Count;x++)
|
|
{
|
|
foreach(Infragistics.Win.UltraWinGrid.UltraGridColumn c in GridBand.Columns)
|
|
{
|
|
if(c.Header.VisiblePosition==x )
|
|
{
|
|
//it's visible and it's the one we want
|
|
if(c.Hidden==false)
|
|
{
|
|
return c;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Goofy workaround for case 1040
|
|
/// all this does is flip the sort order for the first visible column
|
|
/// then reflip it back triggering a redraw that I can't seem to find any other way to accomplish
|
|
/// Should test this with future releases of infragistics grid because it seems possible it's a bug
|
|
/// in the grid itself causing case 1040
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
public static void FlipFlopSort(Infragistics.Win.UltraWinGrid.UltraGrid grid)
|
|
{
|
|
|
|
UltraGridColumn c = GetLeftMostColumnInBand(grid.DisplayLayout.Bands[0]);
|
|
if (c != null)
|
|
{
|
|
SortIndicator si = c.SortIndicator;
|
|
c.SortIndicator = SortIndicator.None;
|
|
c.SortIndicator = si;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
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;
|
|
|
|
Grid.EventManager.SetEnabled(GridEventIds.BeforeSortChange,true);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Get grid sort and filter xml
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="ObjType"></param>
|
|
/// <returns></returns>
|
|
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)
|
|
return "grid";
|
|
}
|
|
|
|
if (c.PropertyDescriptor == null) return "";
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// checks for the SqlColumnNameAttribute and returns
|
|
/// the *value* column name if present
|
|
/// else retuns empty string
|
|
///
|
|
/// A value of "grid" indicates not sql sortable / filterable
|
|
/// and grid should handle it
|
|
/// </summary>
|
|
/// <param name="ObjType"></param>
|
|
/// <returns></returns>
|
|
public static string GetSqlValueColumnNameAttribute(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)
|
|
return "grid";
|
|
}
|
|
|
|
|
|
if (c.PropertyDescriptor == null) return "";
|
|
|
|
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.SqlValueColumnName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Takes a grid band, returns a fragment of XML containing the column order
|
|
/// And filter conditions for that band
|
|
///
|
|
/// </summary>
|
|
/// <param name="GridBand"></param>
|
|
/// <returns></returns>
|
|
public static string GetGridSortAndFilterXML(Infragistics.Win.UltraWinGrid.UltraGridBand GridBand, bool bReverseSort, ref bool bFiltered)
|
|
{
|
|
try
|
|
{
|
|
//case 1039 //log.Debug("GetGridSortAndFilterXML");
|
|
|
|
//Stuff required for creating xml fragment on the fly in memory (string)
|
|
StringBuilder sb = new StringBuilder();
|
|
System.IO.StringWriter sr = new System.IO.StringWriter(sb);
|
|
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(sr);
|
|
|
|
w.Formatting = System.Xml.Formatting.Indented;
|
|
w.WriteStartDocument(true);
|
|
|
|
//Containing element
|
|
w.WriteStartElement("GRIDCRITERIA");
|
|
|
|
#region Sorting
|
|
//used to determine if first visible column
|
|
//has been processed or not in order to write sort order out
|
|
//for first item only
|
|
bool bFirstVisibleColumnProcessed = false;
|
|
//iterate through visible columns in grid create an xml fragment
|
|
//that contains the column order for order by clause
|
|
|
|
|
|
for (int x = 0; x < GridBand.Columns.Count; x++)
|
|
{
|
|
|
|
foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn c in GridBand.Columns)
|
|
{
|
|
|
|
if (c.Header.VisiblePosition == x)
|
|
{
|
|
//it's visible and it's the one we want
|
|
if (c.Hidden == false && !PrivateColumns.Contains(c.Header.Caption))
|
|
{
|
|
string sFieldName = c.Key.ToString().Replace("LT_", "").Replace("_Label_", ".");
|
|
|
|
//does this column contain a sql field attribute?
|
|
string sDerivedFieldName = GetSqlColumnNameAttribute(c);
|
|
if (sDerivedFieldName != "")
|
|
{
|
|
sFieldName = sDerivedFieldName;
|
|
|
|
}
|
|
else
|
|
{
|
|
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 the column and table name don't already start with a lowercase a
|
|
//then add it
|
|
|
|
if (!sFieldName.StartsWith("a"))
|
|
sFieldName = "a" + sFieldName;
|
|
|
|
int nPeriod = sFieldName.IndexOf(".");
|
|
if (nPeriod != -1)
|
|
{
|
|
if (sFieldName[nPeriod + 1] != 'a')
|
|
{
|
|
sFieldName = sFieldName.Replace(".", ".a");
|
|
}
|
|
}
|
|
}
|
|
|
|
w.WriteStartElement("COLUMNITEM");
|
|
//write out the field name
|
|
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
|
|
w.WriteAttributeString("UI", c.Key);
|
|
w.WriteAttributeString("PIN", c.Header.Fixed ? "1" : "0");
|
|
w.WriteAttributeString("WIDTH", c.Width.ToString());
|
|
|
|
if (bFirstVisibleColumnProcessed == false)
|
|
{
|
|
bFirstVisibleColumnProcessed = true;
|
|
//Write sort order attribute
|
|
if (bReverseSort)
|
|
{
|
|
if (c.Header.Column.SortIndicator == SortIndicator.Descending)
|
|
w.WriteAttributeString("SORT", "ASC");//A-Z
|
|
else
|
|
w.WriteAttributeString("SORT", "DESC"); //Z-A
|
|
}
|
|
else
|
|
{
|
|
if (c.Header.Column.SortIndicator == SortIndicator.Descending)
|
|
w.WriteAttributeString("SORT", "DESC");//Z-A
|
|
else
|
|
w.WriteAttributeString("SORT", "ASC"); //A-Z
|
|
|
|
}
|
|
}
|
|
w.WriteEndElement();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
#endregion sorting
|
|
|
|
#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());
|
|
//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;
|
|
}
|
|
|
|
//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 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;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
//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
|
|
//the matching guid contained in that cell item
|
|
|
|
//Finally, if it's alphanumeric then it should filter by the display name
|
|
//text value alphanumerically
|
|
|
|
|
|
if (f.CompareValue == null || f.CompareValue == System.DBNull.Value)
|
|
{
|
|
#region Filter by null Guid
|
|
|
|
string sFieldName=GetSqlColumnNameAttribute(cf.Column);
|
|
//if there is a sql column name then change to
|
|
//filter by an empty string
|
|
if (sFieldName != "")
|
|
{
|
|
w.WriteAttributeString("CM", sFieldName);
|
|
w.WriteAttributeString("UICOMPAREVALUE", "");
|
|
|
|
//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;
|
|
}
|
|
|
|
w.WriteAttributeString("COMPAREVALUE", "");
|
|
|
|
}
|
|
else
|
|
{
|
|
//otherwise proceed as normal
|
|
|
|
//It's a guid value comparison for the database,
|
|
//but it's a string comparison for the user interface when
|
|
//loading a grid from the saved filter, so the UI string
|
|
//value (in this case and empty string) must be saved here so that the grid can be loaded and
|
|
//filters set properly
|
|
w.WriteAttributeString("CM", GetSqlValueColumnNameAttribute(cf.Column));
|
|
w.WriteAttributeString("UICOMPAREVALUE", "");
|
|
w.WriteAttributeString("TYPE", "System.Guid");
|
|
w.WriteAttributeString("COMPAREVALUE", "");
|
|
}
|
|
|
|
#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" &&
|
|
(f.ComparisionOperator == FilterComparisionOperator.Match ||
|
|
f.ComparisionOperator == FilterComparisionOperator.Equals ||
|
|
f.ComparisionOperator == FilterComparisionOperator.NotEquals)
|
|
)
|
|
{
|
|
#region Filter by specific Guid
|
|
|
|
//It's a filter on the underlying GUID value
|
|
GridNameValueCellItem g=(GridNameValueCellItem)f.CompareValue;
|
|
|
|
//get field name
|
|
string sFieldName = GetSqlValueColumnNameAttribute(cf.Column);
|
|
|
|
//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;
|
|
|
|
int nPeriod = sFieldName.IndexOf(".");
|
|
if (nPeriod != -1)
|
|
{
|
|
if (sFieldName[nPeriod + 1] != 'a')
|
|
{
|
|
sFieldName = sFieldName.Replace(".", ".a");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
w.WriteAttributeString("CM", sFieldName);
|
|
|
|
//It's a guid value comparison for the database,
|
|
//but it's a string comparison for the user interface when
|
|
//loading a grid from the saved filter, so the UI string
|
|
//value must be saved here so that the grid can be loaded and
|
|
//filters set properly
|
|
|
|
//This is the first of only two places where an actual value other than an empty string
|
|
//needs to be written to the UICOMPAREVALUE TAG
|
|
w.WriteAttributeString("UICOMPAREVALUE", System.Convert.ToString(f.CompareValue));
|
|
|
|
//it's a Guid value comparison, let's see if it's empty
|
|
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;
|
|
case "aPurchaseOrder.aPONumber":
|
|
w.WriteAttributeString("TYPE", typeof(int).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());
|
|
}
|
|
|
|
#endregion filter by name
|
|
}
|
|
#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);
|
|
|
|
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;
|
|
}
|
|
|
|
//--------------------
|
|
|
|
|
|
//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;
|
|
|
|
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);//);
|
|
//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", f.Column.Key);
|
|
|
|
if (f.Column.DataType.BaseType == typeof(Enum))
|
|
w.WriteAttributeString("TYPE", "System.Int32");
|
|
else
|
|
w.WriteAttributeString("TYPE", f.Column.DataType.ToString());
|
|
|
|
//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
|
|
{
|
|
|
|
//AyaNova Enumerated list?
|
|
if (f.Column.DataType.BaseType == typeof(Enum))
|
|
{
|
|
//Changed:03-08-2006
|
|
//used to assume the comparevalue was always the string of
|
|
//the enum type not a numeric value,
|
|
//however sometimes it's a numeric value...why? No idea
|
|
//Fucking grid filter I hate it more than ever.
|
|
|
|
//Changed: 10-Nov-2006
|
|
//this code is flawed, it will return the first key that matches which might
|
|
//not be the enum key at all.
|
|
//the grid code is too fragile to change at this point to save the actual enum
|
|
//type and value from the grid, so instead going to modify the GetLocalizedTextKey
|
|
//method to pass it also a "hint" which is the datatype name from the column
|
|
//which should always be in the key name as well so it will double check it first
|
|
//See LocalizedTextTable.cs for mods
|
|
//changed following line to pass the datatype name as well.
|
|
|
|
string sKey = LocaleText.GetLocalizedTextKey(f.Column.DataType.Name, f.CompareValue.ToString());
|
|
if (sKey != "")
|
|
w.WriteAttributeString("COMPAREVALUE", AyaEnumConverter.Convert(sKey).ToString());
|
|
else
|
|
w.WriteAttributeString("COMPAREVALUE", f.CompareValue.ToString());
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//case 1951 xml text writer is escaping ampersands in the following line and god knows what else.
|
|
//for now we'll just worry about ampersands
|
|
//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
|
|
}
|
|
|
|
w.WriteEndElement();
|
|
|
|
}//End filter conditions loop
|
|
#endregion filter conditions loop
|
|
|
|
w.WriteEndElement();
|
|
}//End column filter loop
|
|
#endregion filtering
|
|
|
|
|
|
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
|
|
/// <summary>
|
|
/// Added in response to Case 240
|
|
/// though highly overdue
|
|
///
|
|
/// One centralized location to style all grids in the application
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
public static void GridStyler(Infragistics.Win.UltraWinGrid.UltraGrid Grid)
|
|
{
|
|
//case 2108 - now going through and making sure this is called for *EVERY* grid as before it was just a few
|
|
|
|
|
|
//Case 240
|
|
|
|
//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;
|
|
|
|
//set the font to the left and bold and control dark
|
|
Grid.DisplayLayout.CaptionAppearance.TextHAlign = HAlign.Left;
|
|
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;
|
|
|
|
//and borders
|
|
Grid.DisplayLayout.CaptionAppearance.BorderAlpha = Alpha.Opaque;
|
|
Grid.DisplayLayout.CaptionAppearance.BorderColor = Color.Black;
|
|
|
|
//case 2108 column headers
|
|
Grid.DisplayLayout.Override.HeaderAppearance.ThemedElementAlpha = Alpha.Transparent;
|
|
Grid.DisplayLayout.Override.HeaderAppearance.BorderAlpha = Alpha.Opaque;
|
|
Grid.DisplayLayout.Override.HeaderAppearance.BorderColor = Color.Black;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GridPreparation
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
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<e.ValueList.ValueListItems.Count;x++)
|
|
// {
|
|
// if(e.ValueList.ValueListItems[x].DisplayText=="(Custom)")
|
|
// e.ValueList.ValueListItems.RemoveAt(x);
|
|
// }
|
|
|
|
|
|
e.ValueList.SortStyle=ValueListSortStyle.Ascending;
|
|
|
|
|
|
//Custom string filters
|
|
if(e.Column.DataType==typeof(string) || e.Column.DataType.ToString()=="GZTW.AyaNova.BLL.GridNameValueCellItem" )
|
|
{
|
|
ColumnFilter filterMulti;
|
|
|
|
////Add a special blanks option just for gridnamevaluecellitems
|
|
//if (e.Column.DataType != typeof(string))
|
|
//{
|
|
|
|
// filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
// filterMulti.FilterConditions.Add(FilterComparisionOperator.Equals, new GridNameValueCellItem(Guid.Empty,"---",RootObjectTypes.Nothing));
|
|
// e.ValueList.ValueListItems.Insert(0, filterMulti, "[---]");
|
|
//}
|
|
|
|
if (e.Column.SortComparer is Util.AYStringToIntComparer)
|
|
{
|
|
//It's a string representation of an Int32 visible ID number column on a grid name value cell item so we need
|
|
//to present filters that make sense for an underlying Int value which is very few
|
|
;
|
|
}
|
|
else
|
|
{
|
|
|
|
//Changes: 20-July-2006 Noticed not filtering exclusive on <= ranges
|
|
//After messing around with both FireBird and Sql server realized it's because
|
|
//for example A-H with anything less than or equal to H is only going to match H
|
|
//Hx would not match because it's greater than H same applies to all less than or equal
|
|
//bits below for text so changed them all to work properly.
|
|
|
|
//A-H
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
//changed: 20-July2006 changed from H to Hz as was missing H's
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.LessThanOrEqualTo, "Hz");
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[A - H]");
|
|
|
|
//I-P
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThanOrEqualTo, "I");
|
|
//changed: 20-July-2006 from "P" to "Pz"
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.LessThanOrEqualTo, "Pz");
|
|
e.ValueList.ValueListItems.Insert(1, filterMulti, "[I - P]");
|
|
|
|
//Q-Z
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThanOrEqualTo, "Q");
|
|
e.ValueList.ValueListItems.Insert(2, filterMulti, "[Q - Z]");
|
|
|
|
//0-3
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
//changed: 20-July-2006 from "3" to "3z"
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.LessThanOrEqualTo, "3z");
|
|
e.ValueList.ValueListItems.Insert(3, filterMulti, "[0 - 3]");
|
|
|
|
//4-6
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThanOrEqualTo, "4");
|
|
//changed: 20-July-2006 from "6" to "6z"
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.LessThanOrEqualTo, "6z");
|
|
e.ValueList.ValueListItems.Insert(4, filterMulti, "[4 - 6]");
|
|
|
|
//7-9
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThanOrEqualTo, "7");
|
|
//changed: 20-July-2006 from "9" to "9z"
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.LessThanOrEqualTo, "9z");
|
|
e.ValueList.ValueListItems.Insert(5, filterMulti, "[7 - 9]");
|
|
}
|
|
|
|
}
|
|
else if((e.Column.DataType==typeof(System.DateTime)) || (e.Column.DataType==typeof(System.Object)) )
|
|
{
|
|
ColumnFilter filterMulti;
|
|
|
|
// Add a custom FilterCondition to the grid column
|
|
// ColumnFilter colFilter = band.ColumnFilters["String 1"];
|
|
// UltraGridColumn column = band.Columns["String 1"];
|
|
// colFilter.FilterConditions.Add(new FirstLetterFilterCondition(column, FilterComparisionOperator.Custom, filterChar));
|
|
|
|
//can't let a "grid" marked field use these custom filters
|
|
//as they are done by sql only
|
|
if(GetSqlColumnNameAttribute(e.Column)=="grid") return;
|
|
|
|
|
|
|
|
//YESTERDAY - Case 402
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[YESTERDAY]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.Yesterday") + "]");
|
|
|
|
|
|
//
|
|
//TODAY
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[TODAY]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.Today")+"]");
|
|
|
|
|
|
//TOMORROW
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[TOMORROW]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.Tomorrow")+"]");
|
|
|
|
//LAST WEEK - Case 402
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[LAST WEEK]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.LastWeek") + "]");
|
|
|
|
|
|
//THIS WEEK
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[THIS WEEK]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.ThisWeek")+"]");
|
|
|
|
//NEXT WEEK
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[NEXT WEEK]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.NextWeek")+"]");
|
|
|
|
|
|
//LAST MONTH
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[LAST MONTH]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.LastMonth")+"]");
|
|
|
|
//THIS MONTH
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[THIS MONTH]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.ThisMonth")+"]");
|
|
|
|
//NEXT MONTH
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[NEXT MONTH]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.NextMonth")+"]");
|
|
|
|
//14DAYWINDOW
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column,FilterComparisionOperator.Custom,"[14DAYWINDOW]"));
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"["+LocaleText.GetLocalizedText("UI.Label.DateRange.14DayWindow")+"]");
|
|
|
|
//case 2067 NEW RANGES
|
|
|
|
//PAST
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[PAST]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.Past") + "]");
|
|
|
|
//FUTURE
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[FUTURE]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.Future") + "]");
|
|
|
|
//LASTYEAR
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[LASTYEAR]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.LastYear") + "]");
|
|
|
|
//THISYEAR
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[THISYEAR]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.ThisYear") + "]");
|
|
|
|
//INTHELAST3MONTHS
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[INTHELAST3MONTHS]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.InTheLastThreeMonths") + "]");
|
|
|
|
//INTHELAST6MONTHS
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[INTHELAST6MONTHS]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.InTheLastSixMonths") + "]");
|
|
|
|
//INTHELASTYEAR
|
|
filterMulti = new ColumnFilter(e.Column, FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(new LetSQLDoItFilterCondition(e.Column, FilterComparisionOperator.Custom, "[INTHELASTYEAR]"));
|
|
e.ValueList.ValueListItems.Insert(0, filterMulti, "[" + LocaleText.GetLocalizedText("UI.Label.DateRange.InTheLastYear") + "]");
|
|
|
|
|
|
}
|
|
else if ((e.Column.DataType == typeof(System.Decimal)) || (e.Column.DataType == typeof(System.Int32)) || (e.Column.DataType == typeof(System.Int64)) )//case 808
|
|
{
|
|
ColumnFilter filterMulti;
|
|
//<0
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.LessThan,0);
|
|
e.ValueList.ValueListItems.Insert(0,filterMulti,"[<0]");
|
|
|
|
//=0
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.Equals,0);
|
|
e.ValueList.ValueListItems.Insert(1,filterMulti,"[=0]");
|
|
|
|
//>0
|
|
filterMulti=new ColumnFilter(e.Column,FilterLogicalOperator.And);
|
|
filterMulti.FilterConditions.Add(FilterComparisionOperator.GreaterThan,0);
|
|
e.ValueList.ValueListItems.Insert(2,filterMulti,"[>0]");
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Business object data binding and broken rule feedback
|
|
/// <summary>
|
|
/// Take care of binding form controls to business object properties
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
/// <param name="propertyName"></param>
|
|
/// <param name="dataSource"></param>
|
|
/// <param name="dataMember"></param>
|
|
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;
|
|
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Display errorProvider icons beside any fields that have broken rules
|
|
/// on the form
|
|
/// </summary>
|
|
/// <param name="F">Form containing business object</param>
|
|
/// <param name="Obj">Business object instance variable</param>
|
|
/// <param name="EP">instance variable of ErrorProvider object on form</param>
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Takes a broken rule text and xforms it into the localized version
|
|
/// applying all formatting as required
|
|
/// </summary>
|
|
/// <param name="BrokenRuleString"></param>
|
|
/// <returns></returns>
|
|
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<sarray.GetLength(0);x++)
|
|
{
|
|
sitems[x-1]=LocaleText.GetLocalizedText(sarray[x]);
|
|
}
|
|
|
|
return string.Format(LocaleText.GetLocalizedText(sarray[0]),sitems);
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 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 |
|
|
/// </summary>
|
|
/// <param name="BrokenRuleCollection"></param>
|
|
/// <returns></returns>
|
|
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
|
|
|
|
/// <summary>
|
|
/// 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.)
|
|
///
|
|
/// </summary>
|
|
/// <param name="Grid"></param>
|
|
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
|
|
|
|
/// <summary>
|
|
/// Find which band user right clicked on in grid
|
|
/// </summary>
|
|
/// <param name="Grid">Grid in question</param>
|
|
/// <param name="e">MouseEvent argument from click event</param>
|
|
/// <returns>Band that was right clicked on</returns>
|
|
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()+ ")");
|
|
|
|
//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 = 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).Band;
|
|
|
|
|
|
|
|
// }
|
|
// else
|
|
// return null;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Check if user left clicked on a column header and return column key if so
|
|
/// </summary>
|
|
/// <param name="Grid">Grid in question</param>
|
|
/// <param name="e">MouseEvent argument from click event</param>
|
|
/// <returns>Key of column header if clicked else null</returns>
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Check if user right clicked on a nameValuebutton
|
|
/// and return if so
|
|
/// </summary>
|
|
/// <param name="Grid">Grid in question</param>
|
|
/// <param name="e">MouseEvent argument from click event</param>
|
|
/// <returns>GridNameValueCellItem if that's what was clicked</returns>
|
|
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);
|
|
|
|
oUIElement = Grid.DisplayLayout.UIElement.ElementFromPoint(point);
|
|
if ( oUIElement == null ) { return null; }
|
|
|
|
oUIElement=oUIElement.GetAncestor(typeof(CellButtonUIElement));
|
|
if(null == oUIElement)
|
|
return null;
|
|
|
|
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;
|
|
|
|
return (GridNameValueCellItem)((UltraGridCell)oUIElement.SelectableItem).Value;
|
|
|
|
|
|
|
|
}
|
|
else
|
|
return null;
|
|
|
|
}
|
|
#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()
|
|
{
|
|
DialogResult dr = MessageBox.Show(LocaleText.GetLocalizedText("UI.Label.DeleteWorkorderPrompt"), "", MessageBoxButtons.YesNoCancel,
|
|
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3);
|
|
//if (log.IsDebugEnabled) //case 1039 //log.Debug("PromptForDeleteWORKORDER (user selected " + dr.ToString() + ")");
|
|
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 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;
|
|
}
|
|
|
|
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 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)
|
|
{
|
|
if (AyaBizUtils.Lite) return;
|
|
|
|
if (UserID == Guid.Empty) return;
|
|
if (ClientID == Guid.Empty) return;
|
|
if(!AyaBizUtils.InClientRegion(ClientID,UserID))
|
|
{
|
|
PromptWithIconOKOnlyFromLocaleKey("WorkorderItemScheduledUser.Label.Warn.OutOfRegion", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ComboBox helpers
|
|
|
|
#region combo performance enhancement when loading
|
|
//These methods added 19-July-2006 and changed
|
|
//combos on forms to call these before and after update
|
|
//the alphasort was causing terrible performance when loading large
|
|
//sets of data into combo
|
|
|
|
//Customized version...
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
static public void ComboEndUpdate(GZTW.WinForm.Controls.GZUltraComboEditor cb)
|
|
{
|
|
//Added: 19-July-2006 see above
|
|
cb.SortStyle = ValueListSortStyle.Ascending;
|
|
cb.EndUpdate();
|
|
}
|
|
|
|
|
|
//Stock versions...
|
|
|
|
static public void ComboBeginUpdate(UltraComboEditor cb)
|
|
{
|
|
//Added: 19-July-2006 Huge performance increase with large lists
|
|
cb.BeginUpdate();
|
|
cb.SortStyle = ValueListSortStyle.None;
|
|
}
|
|
|
|
static public void ComboEndUpdate(UltraComboEditor cb)
|
|
{
|
|
//Added: 19-July-2006 see above
|
|
cb.SortStyle = ValueListSortStyle.Ascending;
|
|
cb.EndUpdate();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Select the value list item in the combo that
|
|
/// matches the ID passed in with it
|
|
///
|
|
///
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <param name="SelectRecord"></param>
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if guid present in combo
|
|
///
|
|
///
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <param name="SelectRecord"></param>
|
|
static public bool ComboContainsGuid(UltraComboEditor cb, Guid SelectRecord)
|
|
{
|
|
//case 1168
|
|
foreach (ValueListItem vi in cb.Items)
|
|
{
|
|
if ((Guid)vi.DataValue == SelectRecord)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove from the value list the item in the combo that
|
|
/// matches the ID passed in with it
|
|
///
|
|
///
|
|
/// </summary>
|
|
/// <param name="cb"></param>
|
|
/// <param name="SelectRecord"></param>
|
|
static public void ComboRemoveFromListGuid(UltraComboEditor cb, Guid SelectRecord)
|
|
{
|
|
////case 1039 //log.Debug("ComboRemoveFromListGuid");
|
|
ValueListItem viRemove=null;
|
|
foreach (ValueListItem vi in cb.Items)
|
|
{
|
|
if ((Guid)vi.DataValue == SelectRecord)
|
|
{
|
|
viRemove = vi;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(viRemove!=null)
|
|
cb.Items.Remove(viRemove);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="cb"></param>
|
|
/// <param name="SelectMode"></param>
|
|
/// <param name="SelectRecord"></param>
|
|
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();
|
|
|
|
|
|
//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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//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;
|
|
|
|
|
|
}
|
|
|
|
|
|
cb.EndUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Custom Fields
|
|
/// <summary>
|
|
/// case 1317 check if custom fields are available to be shown
|
|
/// </summary>
|
|
/// <param name="sObject"></param>
|
|
/// <returns></returns>
|
|
static public bool ShowCustomFields(string sObject)
|
|
{
|
|
ObjectCustomFields ocf = ObjectCustomFields.GetItems(sObject);
|
|
if (ocf.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
foreach (ObjectCustomField f in ocf)
|
|
{
|
|
if (f.Visible)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 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
|
|
///
|
|
/// </summary>
|
|
/// <param name="sObject">AyaNova business object name (i.e. "Client")</param>
|
|
/// <param name="Grid">Grid to customize</param>
|
|
/// <returns>true if there are custom fields to show, false if not</returns>
|
|
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;
|
|
Grid.DisplayLayout.CaptionAppearance.ForeColor = System.Drawing.SystemColors.ControlText;
|
|
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;
|
|
}
|
|
|
|
}
|
|
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...
|
|
|
|
//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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="BizObject"></param>
|
|
/// <param name="Grid"></param>
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
catch(NullReferenceException e)
|
|
{
|
|
log.Error("GridToCustomFields",e);
|
|
MessageBox.Show("GridToCustomFields:" + e.Message);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set grid from Custom field values
|
|
/// </summary>
|
|
/// <param name="BizObject"></param>
|
|
/// <param name="Grid"></param>
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
catch(NullReferenceException e)
|
|
{
|
|
log.Error("GridFromCustomFields",e);
|
|
MessageBox.Show("GridFromCustomFields:"+ e.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Business object editing handler
|
|
|
|
/// <summary>
|
|
/// Stub method to avoid having to re-edit all the existing code for EditRecord callers
|
|
/// because of new optional id parameter required for single grid list object editing (maingrid)
|
|
/// Open object for editing
|
|
/// If ID is Guid.empty then creates that object before editing
|
|
/// </summary>
|
|
/// <param name="ObjectType">AyaNova RootObjectType</param>
|
|
/// <param name="ID">ID of existing object or Guid.empty to create a new one</param>
|
|
/// <returns></returns>
|
|
static public bool EditRecord(RootObjectTypes ObjectType, Guid ID)
|
|
{
|
|
//call version with optional id as optional id empty
|
|
return EditRecord(ObjectType, ID, null);
|
|
}
|
|
|
|
//case 227
|
|
/// <summary>
|
|
/// Overload for grid buttons
|
|
/// </summary>
|
|
/// <param name="nvi"></param>
|
|
/// <returns></returns>
|
|
static public bool EditRecord(GridNameValueCellItem nvi)
|
|
{
|
|
if (nvi.Value == Guid.Empty) return false;
|
|
if (nvi.RootObjectType == RootObjectTypes.Nothing) return false;
|
|
return EditRecord(nvi.RootObjectType, nvi.Value, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Overload for MRU
|
|
/// </summary>
|
|
/// <param name="TID"></param>
|
|
/// <returns></returns>
|
|
static public bool EditRecord(TypeAndID TID)
|
|
{
|
|
return EditRecord(TID.RootObjectType, TID.ID, null);
|
|
}
|
|
/// <summary>
|
|
/// Same as edit record but with optional id parameter
|
|
/// to be used when creating a work order or other object that requires the optional id value
|
|
/// </summary>
|
|
/// <param name="ObjectType"></param>
|
|
/// <param name="ID"></param>
|
|
/// <param name="subTypeIdToOpen"></param>
|
|
/// <returns></returns>
|
|
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
|
|
//before editing. Used mainly by the main grid
|
|
//UI form when a user clicks on the new tool
|
|
//Most of the biz object recognize this ID
|
|
//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;
|
|
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();
|
|
|
|
|
|
//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
|
|
{
|
|
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.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
|
|
{
|
|
//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.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);
|
|
if (AyaBizUtils.Lite)//case 1172
|
|
{
|
|
WorkorderFormLite wfl = new WorkorderFormLite();
|
|
wfl.WorkorderToEdit = o;
|
|
wfl.GoTo = RootObjectTypes.WorkorderItemPart;
|
|
wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemPart, 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.WorkorderItemPart;
|
|
w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemPart, ID);
|
|
w.Visible = false;
|
|
}
|
|
w.Show();
|
|
}
|
|
//bObjectEdited = w.ChangesMade;
|
|
//w.Dispose();
|
|
|
|
}
|
|
break;
|
|
|
|
case RootObjectTypes.WorkorderItemLoan:
|
|
{
|
|
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();
|
|
|
|
}
|
|
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)
|
|
{
|
|
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:
|
|
{
|
|
PurchaseOrderReceiptInfoForm porForm = new PurchaseOrderReceiptInfoForm(true);
|
|
porForm.PurchaseOrderReceiptToEdit = PurchaseOrderReceipt.GetItem(ID);
|
|
porForm.ShowDialog();
|
|
//receipts are never editable after creation
|
|
bObjectEdited = false;
|
|
porForm.Dispose();
|
|
|
|
}
|
|
break;
|
|
|
|
//Added:4-Sept-2006
|
|
case RootObjectTypes.ServiceBank:
|
|
{
|
|
ServiceBank s = ServiceBank.GetItem(ID);
|
|
ServiceBankForm sbf = new ServiceBankForm();
|
|
sbf.ObjectType = s.AppliesToRootObjectType;
|
|
sbf.ObjectID = s.AppliesToRootObjectID;
|
|
sbf.ShowDialog();
|
|
//receipts are never editable after creation
|
|
bObjectEdited = false;
|
|
sbf.Dispose();
|
|
|
|
}
|
|
break;
|
|
|
|
//Added:4-Sept-2006
|
|
case RootObjectTypes.ScheduleMarker:
|
|
{
|
|
ScheduleMarker s = ScheduleMarker.GetItem(ID);
|
|
ScheduleMarkerForm f = new ScheduleMarkerForm();
|
|
f.ScheduleMarkerToEdit = s;
|
|
//f.AppointmentToEdit=mActiveCalendarAppointment;
|
|
// f.Info = ultraCalendarInfo1;
|
|
f.ShowDialog();
|
|
bObjectEdited = f.ChangesMade;
|
|
f.Dispose();
|
|
|
|
}
|
|
break;
|
|
|
|
|
|
//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;
|
|
f.Dispose();
|
|
}
|
|
break;
|
|
|
|
//Added: 2-Oct-2006
|
|
case RootObjectTypes.Task:
|
|
{
|
|
GenericListForm f = new GenericListForm();
|
|
Tasks o = Tasks.GetItems();
|
|
f.SelectedRecordID = ID;
|
|
f.GridDataSource = o;
|
|
f.Visible = false;
|
|
f.ShowDialog();
|
|
bObjectEdited = f.ChangesMade;
|
|
f.Dispose();
|
|
}
|
|
break;
|
|
|
|
//Added: 2-Oct-2006
|
|
case RootObjectTypes.WorkorderItemMiscExpense:
|
|
{
|
|
Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItemMiscExpense, ID);
|
|
if (AyaBizUtils.Lite)//case 1172
|
|
{
|
|
WorkorderFormLite wfl = new WorkorderFormLite();
|
|
wfl.WorkorderToEdit = o;
|
|
wfl.GoTo = RootObjectTypes.WorkorderItemMiscExpense;
|
|
wfl.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemMiscExpense, 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.WorkorderItemMiscExpense;
|
|
w.GoToWorkorderItemID = o.GetWorkorderItemIDFromDescendant(RootObjectTypes.WorkorderItemMiscExpense, ID);
|
|
w.GoToWorkorderItemSubItemID = ID;
|
|
w.Visible = false;
|
|
}
|
|
w.Show();
|
|
//bObjectEdited = w.ChangesMade;
|
|
//w.Dispose();
|
|
}
|
|
|
|
}
|
|
break;
|
|
|
|
//Added: 2-Oct-2006
|
|
case RootObjectTypes.UnitServiceType:
|
|
{
|
|
GenericListForm f = new GenericListForm();
|
|
UnitServiceTypes o = UnitServiceTypes.GetItems();
|
|
f.SelectedRecordID = ID;
|
|
f.GridDataSource = o;
|
|
f.Visible = false;
|
|
f.ShowDialog();
|
|
bObjectEdited = f.ChangesMade;
|
|
f.Dispose();
|
|
}
|
|
break;
|
|
|
|
|
|
//Added:2-Oct-2006
|
|
case RootObjectTypes.ScheduleableUserGroup:
|
|
{
|
|
ScheduleableUserGroup s = ScheduleableUserGroup.GetItem(ID);
|
|
ScheduleableUserGroupsForm f = new ScheduleableUserGroupsForm();
|
|
f.ScheduleableUserGroupToEdit = s;
|
|
f.ShowDialog();
|
|
bObjectEdited = f.ChangesMade;
|
|
f.Dispose();
|
|
|
|
}
|
|
break;
|
|
|
|
//Added:3-Oct-2006
|
|
case RootObjectTypes.TaskGroup:
|
|
{
|
|
TaskGroup s = TaskGroup.GetItem(ID);
|
|
TaskGroupsForm f = new TaskGroupsForm();
|
|
f.TaskGroupToEdit = s;
|
|
f.ShowDialog();
|
|
bObjectEdited = f.ChangesMade;
|
|
f.Dispose();
|
|
|
|
}
|
|
break;
|
|
|
|
//Added:11-Nov-2006
|
|
case RootObjectTypes.ClientServiceRequest:
|
|
{
|
|
ClientServiceRequestInfoForm f = new ClientServiceRequestInfoForm();
|
|
ClientServiceRequest o = ClientServiceRequest.GetItem(ID);
|
|
f.ClientServiceRequestToEdit = o;
|
|
f.Visible = false;
|
|
f.ShowDialog();
|
|
bObjectEdited = f.ChangesMade;
|
|
f.Dispose();
|
|
}
|
|
break;
|
|
|
|
//case 750
|
|
case RootObjectTypes.WorkorderServiceTemplate:
|
|
{
|
|
Workorder o = Workorder.GetItem(ID);
|
|
//Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderService, ID);
|
|
//Case 677
|
|
WorkorderForm w = GetWorkorderForm(o.ID);
|
|
if (w.WorkorderToEdit == null)
|
|
{
|
|
w.WorkorderToEdit = o;
|
|
w.Visible = false;
|
|
}
|
|
w.Show();
|
|
}
|
|
break;
|
|
|
|
//case 750
|
|
case RootObjectTypes.WorkorderQuoteTemplate:
|
|
{
|
|
// Workorder o = Workorder.GetItem(ID);
|
|
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();
|
|
}
|
|
break;
|
|
|
|
//case 750
|
|
case RootObjectTypes.WorkorderPreventiveMaintenanceTemplate:
|
|
{
|
|
// Workorder o = Workorder.GetItem(ID);
|
|
Workorder o = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderPreventiveMaintenance, ID);
|
|
//Case 677
|
|
WorkorderForm w = GetWorkorderForm(o.ID);
|
|
if (w.WorkorderToEdit == null)
|
|
{
|
|
w.WorkorderToEdit = o;
|
|
w.Visible = false;
|
|
}
|
|
w.Show();
|
|
}
|
|
break;
|
|
//case 73
|
|
case RootObjectTypes.AyaFile:
|
|
{
|
|
AyaFileList l=AyaFileList.GetListOfOne(ID);
|
|
if(l.Count==0) return false;
|
|
|
|
AyaFileList.AyaFileListInfo i = l[0];
|
|
WikiFileOpenSave d = new WikiFileOpenSave(i);
|
|
DialogResult rslt = d.ShowDialog();
|
|
if (rslt == DialogResult.Cancel) return false;
|
|
if (rslt == DialogResult.OK)
|
|
{
|
|
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
|
//save the file to location of users choosing
|
|
saveFileDialog1.FileName = i.LT_O_AyaFile.Display;
|
|
|
|
if (saveFileDialog1.ShowDialog() == DialogResult.Cancel) return false;
|
|
if (!string.IsNullOrEmpty(saveFileDialog1.FileName))
|
|
{
|
|
AyaFile.GetAndWriteFileToDisk(i.LT_O_AyaFile.Value, System.IO.Path.GetDirectoryName(saveFileDialog1.FileName), System.IO.Path.GetFileName(saveFileDialog1.FileName));
|
|
}
|
|
return false;
|
|
|
|
}
|
|
|
|
//Open the file so save to temp folder then open
|
|
if (rslt == DialogResult.Yes)
|
|
{
|
|
OpenAyaFileAndUpdateWhenClosed(i.LT_O_AyaFile.Value);
|
|
|
|
//Util.OpenDocumentURL(AyaFile.GetAndWriteFileToDisk(i.LT_O_AyaFile.Value, TempFolder, i.LT_O_AyaFile.Display));
|
|
}
|
|
}
|
|
break;
|
|
//case 73
|
|
case RootObjectTypes.WikiPage:
|
|
{
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
WikiPage wp = WikiPage.GetItem(ID);
|
|
WikiInfoForm wi = new WikiInfoForm(false);
|
|
wi.WikiPageToEdit = wp;
|
|
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
|
|
else if (ex is System.Security.SecurityException)
|
|
{
|
|
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
log.Warn("Edit record security exception " + ObjectType.ToString() + ", " + ID.ToString(), ex);
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Grid broken rules display
|
|
|
|
/// <summary>
|
|
/// If the current row's underlying list object
|
|
/// has broken rules, then show a broken rule error icon in the row selector
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show tool tip containing all broken rules if mouse over a
|
|
/// broken rule icon in the row selector
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
/// <param name="tipError"></param>
|
|
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
|
|
/// <summary>
|
|
/// sets icon to use for assigned docs
|
|
/// to an incomplete image or a filled one
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <param name="HasDocs"></param>
|
|
public static void AssignedDocsSetImage(UltraToolbarsManager t, bool HasDocs)
|
|
{//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);
|
|
t.Tools["LT:AssignedDoc.Label.List"].SharedProps.AppearancesSmall.Appearance.Image = Util.ImageIncomplete(Resource1.Documents16);
|
|
|
|
}
|
|
else
|
|
{
|
|
t.Tools["LT:AssignedDoc.Label.List"].SharedProps.AppearancesLarge.Appearance.Image = Resource1.Documents32;
|
|
t.Tools["LT:AssignedDoc.Label.List"].SharedProps.AppearancesSmall.Appearance.Image = Resource1.Documents16;
|
|
|
|
}
|
|
t.EndUpdate();
|
|
}
|
|
#endregion
|
|
|
|
#region Icons and Priority flags
|
|
/// <summary>
|
|
/// Give an ARGB value, returns a flag bitmpa in that color
|
|
/// </summary>
|
|
/// <param name="ARGB"></param>
|
|
/// <returns></returns>
|
|
static public Bitmap Flag(int ARGB)
|
|
{
|
|
|
|
//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;
|
|
|
|
int width = flag.Width;
|
|
int height = flag.Height;
|
|
|
|
int i, j;
|
|
for (i = 0; i< width; i++)
|
|
{
|
|
for (j=0; j<height; j++)
|
|
{
|
|
Color pixelColor = flag.GetPixel(i, j);
|
|
|
|
//Replace each all black pixel with the chosen color
|
|
if(pixelColor.R==0 && pixelColor.G==0 && pixelColor.B==0 && pixelColor.A!=0)
|
|
{
|
|
flag.SetPixel(i, j, NewColor);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return flag;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// /// <summary>
|
|
// /// Gets icon image from assembly
|
|
// /// </summary>
|
|
// /// <param name="ImageName"></param>
|
|
// /// <returns></returns>
|
|
// 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));
|
|
// }
|
|
|
|
// /// <summary>
|
|
// ///DEPRECATED. REMOVE ONCE CASE 918 has been completed
|
|
// /// </summary>
|
|
// /// <param name="ImageName"></param>
|
|
// /// <returns></returns>
|
|
// 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;
|
|
// }
|
|
|
|
/// <summary>
|
|
/// Returns bitmap with line drawn through it to indicate incompleteness
|
|
/// </summary>
|
|
/// <param name="i"></param>
|
|
/// <returns></returns>
|
|
static public Bitmap ImageIncomplete(Image i)
|
|
{
|
|
//case
|
|
//Bitmap b = new Bitmap(i);
|
|
Bitmap b = MakeGrayscale3(new Bitmap(i));
|
|
Graphics g = Graphics.FromImage(b);
|
|
//Pen p = new Pen(Color.FromArgb(128, 255, 255, 255), 5);
|
|
Pen p = new Pen(Color.FromArgb(128, 0, 0, 0), 5);
|
|
g.DrawLine(p, 0, 0, b.Width, b.Height);
|
|
return b;
|
|
}
|
|
|
|
public static Bitmap MakeGrayscale3(Bitmap original)
|
|
{
|
|
//create a blank bitmap the same size as original
|
|
Bitmap newBitmap = new Bitmap(original.Width, original.Height);
|
|
|
|
//get a graphics object from the new image
|
|
Graphics g = Graphics.FromImage(newBitmap);
|
|
|
|
//create the grayscale ColorMatrix
|
|
ColorMatrix colorMatrix = new ColorMatrix(
|
|
new float[][]
|
|
{
|
|
new float[] {.3f, .3f, .3f, 0, 0},
|
|
new float[] {.59f, .59f, .59f, 0, 0},
|
|
new float[] {.11f, .11f, .11f, 0, 0},
|
|
new float[] {0, 0, 0, 1, 0},
|
|
new float[] {0, 0, 0, 0, 1}
|
|
});
|
|
|
|
//create some image attributes
|
|
ImageAttributes attributes = new ImageAttributes();
|
|
|
|
//set the color matrix attribute
|
|
attributes.SetColorMatrix(colorMatrix);
|
|
|
|
//draw the original image on the new image
|
|
//using the grayscale color matrix
|
|
g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
|
|
0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);
|
|
|
|
//dispose the Graphics object
|
|
g.Dispose();
|
|
return newBitmap;
|
|
}
|
|
#endregion
|
|
|
|
#region Form access restrictions helpers
|
|
|
|
/// <summary>
|
|
/// Set all form controls to read only or read/write
|
|
///
|
|
/// </summary>
|
|
/// <param name="ReadOnly"></param>
|
|
/// <param name="c">Parent control</param>
|
|
/// <param name="bNoDelete">Don't allow delete on grids</param>
|
|
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.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.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(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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
///// case 1562 redux
|
|
///// </summary>
|
|
///// <param name="IsEditable"></param>
|
|
///// <param name="roType"></param>
|
|
///// <param name="c"></param>
|
|
//static public void SetAccessOnGrid(bool IsEditable, Control c)
|
|
//{
|
|
// if (!IsEditable)
|
|
// {
|
|
// SetAccessOnGrid(true, c, true);
|
|
// }
|
|
// else
|
|
// {
|
|
// int nRight = AyaBizUtils.Right(roType);
|
|
// SetAccessOnGrid(nRight < (int)SecurityLevelTypes.ReadWrite, c, nRight < (int)SecurityLevelTypes.ReadWriteDelete);
|
|
// }
|
|
//}
|
|
|
|
/// <summary>
|
|
/// for case 1562, identical to setaccess above but only for grid
|
|
/// </summary>
|
|
/// <param name="ReadOnly"></param>
|
|
/// <param name="c"></param>
|
|
/// <param name="bNoDelete"></param>
|
|
static public void SetAccessOnGrid(bool ReadOnly, Control c, bool bNoDelete)
|
|
{
|
|
Infragistics.Win.UltraWinGrid.UltraGrid Grid = (Infragistics.Win.UltraWinGrid.UltraGrid)c;
|
|
|
|
if (ReadOnly)
|
|
{
|
|
Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.No;
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
|
|
Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False;
|
|
GridRemoveDeleteButton(Grid);
|
|
}
|
|
else
|
|
{
|
|
if (Grid.Name != "gridCustom")
|
|
{
|
|
Grid.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom;
|
|
|
|
if (!bNoDelete)
|
|
{
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.True;
|
|
GridAddDeleteButton(Grid);
|
|
}
|
|
else
|
|
{
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
|
|
GridRemoveDeleteButton(Grid);
|
|
}
|
|
}
|
|
Grid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#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+")");
|
|
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);
|
|
|
|
|
|
|
|
switch(ObjectType)
|
|
{
|
|
|
|
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);
|
|
|
|
//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
|
|
|
|
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");
|
|
|
|
//Case 284
|
|
pop.Tools.AddTool("NEW_NOTE");
|
|
|
|
//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));
|
|
}
|
|
}
|
|
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)
|
|
{
|
|
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);
|
|
|
|
//Case 534
|
|
pop.Tools.AddTool("VIEW_WOLIST");
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
default:
|
|
return false;
|
|
|
|
}
|
|
|
|
//case 73 wikilink
|
|
if (!AyaBizUtils.Lite)
|
|
{
|
|
ButtonTool bWiki = new ButtonTool("WIKILINK");
|
|
//bWiki.SharedProps.Caption = LocaleText.GetLocalizedText("WikiPage.Label.WikiLink");//maybe an icon only anyway
|
|
bWiki.SharedProps.AppearancesLarge.Appearance.Image = Resource1.AyaNovaLink32;
|
|
bWiki.SharedProps.Tag = new TypeAndID(ObjectType, ID);
|
|
tbManager.Tools.Add(bWiki);
|
|
pop.Tools.AddTool("WIKILINK");
|
|
}
|
|
|
|
|
|
tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(ObjectContextMenu_ToolClick);
|
|
tbManager.ShowPopup("POPKEY",InsideForm);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Handle popup menu clicks
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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)
|
|
{
|
|
ClientNotesForm CN = new ClientNotesForm();
|
|
CN.ClientID = ((TypeAndID)e.Tool.SharedProps.Tag).ID;
|
|
CN.ShowDialog();
|
|
}
|
|
break;
|
|
|
|
//Case 534
|
|
case "VIEW_WOLIST":
|
|
if (e.Tool.SharedProps.Tag != null)
|
|
{
|
|
TypeAndID t=(TypeAndID)e.Tool.SharedProps.Tag;
|
|
switch (t.RootObjectType)
|
|
{
|
|
case RootObjectTypes.Client:
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("<WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_O_Client\">");
|
|
sb.Append("\r\n");
|
|
sb.Append("\t<WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aClient.aID\" UICOMPAREVALUE=\"");
|
|
sb.Append(NameFetcher.GetItem("aClient", "aName", t.ID).RecordName.Replace("&","&"));//case 784
|
|
sb.Append("\" TYPE=\"System.Guid\" COMPAREVALUE=\"{");
|
|
sb.Append(t.ID.ToString().ToUpper());
|
|
sb.Append("}\" />\r\n");
|
|
sb.Append("</WHEREITEMGROUP>");
|
|
gGridLastViews["WorkorderServiceList"].SubstituteCriteria = sb.ToString();
|
|
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("<WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Unit_Label_Serial\">");
|
|
sb.Append("\r\n");
|
|
sb.Append("\t<WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItem.aUnitID\" UICOMPAREVALUE=\"");
|
|
sb.Append(UnitNameFetcher.GetUnitNameFromUnitID(t.ID));
|
|
sb.Append("\" TYPE=\"System.Guid\" COMPAREVALUE=\"{");
|
|
sb.Append(t.ID.ToString().ToUpper());
|
|
sb.Append("}\" />\r\n");
|
|
sb.Append("</WHEREITEMGROUP>");
|
|
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;
|
|
}
|
|
break;
|
|
|
|
//case 3158
|
|
case RootObjectTypes.LoanItem:
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("<WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemLoan_Label_LoanItem\">");
|
|
sb.Append("\r\n");
|
|
sb.Append("\t<WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItemLoan.aLoanItemID\" UICOMPAREVALUE=\"");
|
|
//It shouldn't matter what name is in uicomparevalue
|
|
//but it sure crashes if it retrieves a 58" tool because of the quote so just
|
|
//put static text there instead
|
|
sb.Append("LOANITEM");
|
|
sb.Append("\" TYPE=\"System.Guid\" COMPAREVALUE=\"{");
|
|
sb.Append(t.ID.ToString().ToUpper());
|
|
sb.Append("}\" />\r\n");
|
|
sb.Append("</WHEREITEMGROUP>");
|
|
gGridLastViews["WorkorderServiceLoanList"].SubstituteCriteria = sb.ToString();
|
|
frmMain.ShowForm("LT:UI.Go.Service", "LT:WorkorderItem.Label.Loans", true);
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Service"];
|
|
frmMain.MainServiceTree.Nodes["LT:WorkorderService.Label.List"].Nodes["LT:WorkorderItem.Label.List"].Nodes["LT:WorkorderItem.Label.Loans"].Selected = true;
|
|
|
|
}
|
|
break;
|
|
}
|
|
|
|
}
|
|
break;
|
|
case "WIKILINK":
|
|
{
|
|
CopyAyaNovaUrl((TypeAndID)e.Tool.SharedProps.Tag);
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Create and open for editing a new workorder based off the indicated
|
|
/// object passed in.
|
|
/// </summary>
|
|
/// <param name="From">TypeAndID object to create workorder from</param>
|
|
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;
|
|
|
|
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
|
|
{
|
|
WorkorderForm wf = new WorkorderForm();
|
|
wf.WorkorderToEdit = w;
|
|
wf.GoTo = RootObjectTypes.WorkorderItemLabor;
|
|
//Case 677
|
|
wf.Show();
|
|
}
|
|
|
|
}
|
|
break;
|
|
|
|
case RootObjectTypes.Unit:
|
|
{
|
|
Unit u = Unit.GetItemMRU(From.ID, false);
|
|
|
|
Workorder w = null;
|
|
try
|
|
{
|
|
ClientSelector c = new ClientSelector(WorkorderTypes.TemplateService);
|
|
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.Service);
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Create and open for editing a new quote based off the indicated
|
|
/// object passed in.
|
|
/// </summary>
|
|
/// <param name="From">TypeAndID object to create quote from</param>
|
|
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;
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Create and open for editing a new PM based off the indicated
|
|
/// object passed in.
|
|
/// </summary>
|
|
/// <param name="From">TypeAndID object to create PM from</param>
|
|
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;
|
|
|
|
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;
|
|
}
|
|
w.ClientID=From.ID;
|
|
WorkorderForm wf= new WorkorderForm();
|
|
wf.WorkorderToEdit=w;
|
|
wf.GoTo=RootObjectTypes.WorkorderItemLabor;
|
|
//Case 677
|
|
wf.Show();
|
|
|
|
}
|
|
break;
|
|
|
|
case RootObjectTypes.Unit:
|
|
{
|
|
|
|
Unit u=Unit.GetItemMRU(From.ID,false);
|
|
Workorder w=null;
|
|
try
|
|
{
|
|
|
|
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
|
|
|
|
#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();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// translates obscure sql errors into human readable form,
|
|
/// logs and reports them to user
|
|
/// </summary>
|
|
/// <param name="ex"></param>
|
|
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)
|
|
{
|
|
if (err.Number == 335544466)
|
|
{
|
|
if (log.IsDebugEnabled) log.Debug("FbException", fex);
|
|
sErrorMessage = LocaleText.GetLocalizedText("Error.DB.ForeignKeyViolation") + "\r\n\r\n----------------------------------------\r\n" + fex.Message;
|
|
bHandled = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//not the typical foreign key violation we expect
|
|
//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:
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
#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
|
|
|
|
}
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Save the file to a temp location, start a process to edit it
|
|
/// Throw up a dialog and when it closes update if they chose to
|
|
/// </summary>
|
|
/// <param name="f"></param>
|
|
static public void OpenAyaFileAndUpdateWhenClosed(Guid AyaFileID)
|
|
{
|
|
AyaFile f = AyaFile.GetItem(AyaFileID);
|
|
string sFullPath=TempFolder + Path.DirectorySeparatorChar + f.Name;
|
|
//1st Write the file to disk
|
|
f.WriteToDisk(TempFolder, f.Name);
|
|
|
|
//Open it
|
|
Process.Start(sFullPath);
|
|
|
|
//If they have read only rights to files then at this point we are done
|
|
if (!AyaFile.CanWrite) return;
|
|
|
|
//Wait for user
|
|
WikiFileUpdatePrompt p = new WikiFileUpdatePrompt(f.Name);
|
|
DialogResult d = p.ShowDialog();
|
|
if (d == DialogResult.OK)
|
|
{
|
|
//Update the file
|
|
if (File.Exists(sFullPath))
|
|
{
|
|
f.SetContent(File.ReadAllBytes(sFullPath));
|
|
f.Save();
|
|
}
|
|
}
|
|
|
|
//attempt to delete the temp file
|
|
try
|
|
{
|
|
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
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#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="";
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Fill an infragistics list tool
|
|
/// with all reports for given key
|
|
/// </summary>
|
|
/// <param name="ReportKey"></param>
|
|
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;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
//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;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
/// <param name="lTool"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Handle report and take optional email address to set
|
|
/// for report so it can be prefilled when export to email selected
|
|
/// </summary>
|
|
/// <param name="lTool"></param>
|
|
/// <param name="ReportKey"></param>
|
|
/// <param name="DataSource"></param>
|
|
/// <param name="email"></param>
|
|
/// <returns></returns>
|
|
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)
|
|
|
|
// source.WriteXml("c:\\temp\\" + ReportKey + ".xsd", XmlWriteMode.WriteSchema);
|
|
//#endif
|
|
|
|
|
|
//Add localized text and display name to reportdataset
|
|
source.LocaleTextTable=LocaleText;
|
|
source.DisplayName=ReportKey;
|
|
|
|
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());
|
|
|
|
//case 1039 //log.Debug("ReportHandleToolClick: Calling LoadLayout on report content from db");
|
|
|
|
//Case 232
|
|
x.LoadLayout(r.GetReportContent());
|
|
//XtraReport x = XtraReport.FromStream(r.GetReportContent(),true);
|
|
//case 1039 //log.Debug("ReportHandleToolClick: LoadLayout completed");
|
|
|
|
LocalizeReport(x);
|
|
|
|
|
|
//Case 232 change block:
|
|
//x.DataSource=source;
|
|
if (source.Tables.Count == 1)
|
|
{
|
|
//It's a summary report so just bind to the report as normal
|
|
x.DataSource = source;
|
|
}
|
|
else
|
|
{
|
|
//It's a detailed report made of subreports so remove the datasource
|
|
//from the main report and set it on the detailereport band
|
|
x.DataSource = null;
|
|
DetailReportBand detailReport = x.Bands[BandKind.DetailReport] as DetailReportBand;
|
|
if (detailReport != null)
|
|
{
|
|
detailReport.DataSource = source;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//case 3646 removed
|
|
//if(AyaBizUtils.Trial)
|
|
//{
|
|
// WatermarkReport(x,true);
|
|
// x.PrintingSystem.SetCommandVisibility(DevExpress.XtraPrinting.PrintingSystemCommand.Watermark,DevExpress.XtraPrinting.CommandVisibility.None);
|
|
//}
|
|
|
|
//case 1039 //log.Debug("ReportHandleToolClick: Initialization complete, displaying report");
|
|
|
|
|
|
//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);
|
|
ReportEditor2 re = new ReportEditor2(r, source);
|
|
|
|
re.ShowDialog();
|
|
return re.ChangesMade;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
#region Report localization
|
|
static public void LocalizeReport(XtraReport r)
|
|
{
|
|
foreach(Band b in r.Bands)
|
|
{
|
|
LocalizeReportControl(b);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Localize the text on the report if it starts with LT
|
|
/// </summary>
|
|
/// <param name="c"></param>
|
|
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
|
|
|
|
|
|
#endregion
|
|
|
|
#region PropertyBag
|
|
// /// <summary>
|
|
// /// Represents a single property in a PropertySpec.
|
|
// /// </summary>
|
|
// 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;
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
// public PropertySpec(string key, string name, string type) : this(key, name, type, null, null, null) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">A Type that represents the type of the property.</param>
|
|
// public PropertySpec(string key, string name, Type type) :
|
|
// this(key, name, type.AssemblyQualifiedName, null, null, null) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
// /// <param name="category">The category under which the property is displayed in the
|
|
// /// property grid.</param>
|
|
// public PropertySpec(string key,string name, string type, string category) : this(key, name, type, category, null, null) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">A Type that represents the type of the property.</param>
|
|
// /// <param name="category"></param>
|
|
// public PropertySpec(string key,string name, Type type, string category) :
|
|
// this(key, name, type.AssemblyQualifiedName, category, null, null) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
// /// <param name="category">The category under which the property is displayed in the
|
|
// /// property grid.</param>
|
|
// /// <param name="description">A string that is displayed in the help area of the
|
|
// /// property grid.</param>
|
|
// public PropertySpec(string key,string name, string type, string category, string description) :
|
|
// this(key, name, type, category, description, null) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">A Type that represents the type of the property.</param>
|
|
// /// <param name="category">The category under which the property is displayed in the
|
|
// /// property grid.</param>
|
|
// /// <param name="description">A string that is displayed in the help area of the
|
|
// /// property grid.</param>
|
|
// public PropertySpec(string name, Type type, string category, string description) :
|
|
// this(name, type.AssemblyQualifiedName, category, description, null) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
// /// <param name="category">The category under which the property is displayed in the
|
|
// /// property grid.</param>
|
|
// /// <param name="description">A string that is displayed in the help area of the
|
|
// /// property grid.</param>
|
|
// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
// /// no default value.</param>
|
|
// 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;
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">A Type that represents the type of the property.</param>
|
|
// /// <param name="category">The category under which the property is displayed in the
|
|
// /// property grid.</param>
|
|
// /// <param name="description">A string that is displayed in the help area of the
|
|
// /// property grid.</param>
|
|
// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
// /// no default value.</param>
|
|
// public PropertySpec(string key,string name, Type type, string category, string description, object defaultValue) :
|
|
// this(key, name, type.AssemblyQualifiedName, category, description, defaultValue) { }
|
|
//
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The fully qualified name of the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The fully qualified name of the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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;
|
|
//// }
|
|
////
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">A Type that represents the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The fully qualified name of the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The fully qualified name of the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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) { }
|
|
//
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The Type that represents the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The fully qualified name of the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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) { }
|
|
//
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">A Type that represents the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The Type that represents the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The fully qualified name of the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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) { }
|
|
//
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The fully qualified name of the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The Type that represents the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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) { }
|
|
////
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">A Type that represents the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The fully qualified name of the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The Type that represents the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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) { }
|
|
//
|
|
//// /// <summary>
|
|
//// /// Initializes a new instance of the PropertySpec class.
|
|
//// /// </summary>
|
|
//// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
//// /// <param name="type">The fully qualified name of the type of the property.</param>
|
|
//// /// <param name="category">The category under which the property is displayed in the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="description">A string that is displayed in the help area of the
|
|
//// /// property grid.</param>
|
|
//// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
//// /// no default value.</param>
|
|
//// /// <param name="editor">The Type that represents the type of the editor for this
|
|
//// /// property. This type must derive from UITypeEditor.</param>
|
|
//// /// <param name="typeConverter">The Type that represents the type of the type
|
|
//// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
//// 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) { }
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpec class.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the property displayed in the property grid.</param>
|
|
// /// <param name="type">A Type that represents the type of the property.</param>
|
|
// /// <param name="category">The category under which the property is displayed in the
|
|
// /// property grid.</param>
|
|
// /// <param name="description">A string that is displayed in the help area of the
|
|
// /// property grid.</param>
|
|
// /// <param name="defaultValue">The default value of the property, or null if there is
|
|
// /// no default value.</param>
|
|
// /// <param name="editor">The Type that represents the type of the editor for this
|
|
// /// property. This type must derive from UITypeEditor.</param>
|
|
// /// <param name="typeConverter">The Type that represents the type of the type
|
|
// /// converter for this property. This type must derive from TypeConverter.</param>
|
|
// 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;
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
//
|
|
// /// <summary>
|
|
// /// 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.
|
|
// /// </summary>
|
|
// public Attribute[] Attributes
|
|
// {
|
|
// get { return attributes; }
|
|
// set { attributes = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the key of this property.
|
|
// /// </summary>
|
|
// public string Key
|
|
// {
|
|
// get { return key; }
|
|
// set { key = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the category name of this property.
|
|
// /// </summary>
|
|
// public string Category
|
|
// {
|
|
// get { return category; }
|
|
// set { category = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the fully qualified name of the type converter
|
|
// /// type for this property.
|
|
// /// </summary>
|
|
// public string ConverterTypeName
|
|
// {
|
|
// get { return typeConverter; }
|
|
// set { typeConverter = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the default value of this property.
|
|
// /// </summary>
|
|
// public object DefaultValue
|
|
// {
|
|
// get { return defaultValue; }
|
|
// set { defaultValue = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the help text description of this property.
|
|
// /// </summary>
|
|
// public string Description
|
|
// {
|
|
// get { return description; }
|
|
// set { description = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the fully qualified name of the editor type for
|
|
// /// this property.
|
|
// /// </summary>
|
|
// public string EditorTypeName
|
|
// {
|
|
// get { return editor; }
|
|
// set { editor = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the name of this property.
|
|
// /// </summary>
|
|
// public string Name
|
|
// {
|
|
// get { return name; }
|
|
// set { name = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the fully qualfied name of the type of this
|
|
// /// property.
|
|
// /// </summary>
|
|
// public string TypeName
|
|
// {
|
|
// get { return type; }
|
|
// set { type = value; }
|
|
// }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Provides data for the GetValue and SetValue events of the PropertyBag class.
|
|
// /// </summary>
|
|
// public class PropertySpecEventArgs : EventArgs
|
|
// {
|
|
// private PropertySpec property;
|
|
// private object val;
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpecEventArgs class.
|
|
// /// </summary>
|
|
// /// <param name="property">The PropertySpec that represents the property whose
|
|
// /// value is being requested or set.</param>
|
|
// /// <param name="val">The current value of the property.</param>
|
|
// public PropertySpecEventArgs(PropertySpec property, object val)
|
|
// {
|
|
// this.property = property;
|
|
// this.val = val;
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets the PropertySpec that represents the property whose value is being
|
|
// /// requested or set.
|
|
// /// </summary>
|
|
// public PropertySpec Property
|
|
// {
|
|
// get { return property; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the current value of the property.
|
|
// /// </summary>
|
|
// public object Value
|
|
// {
|
|
// get { return val; }
|
|
// set { val = value; }
|
|
// }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Represents the method that will handle the GetValue and SetValue events of the
|
|
// /// PropertyBag class.
|
|
// /// </summary>
|
|
// public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e);
|
|
//
|
|
// /// <summary>
|
|
// /// 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.
|
|
// /// </summary>
|
|
// public class PropertyBag : ICustomTypeDescriptor
|
|
// {
|
|
// #region PropertySpecCollection class definition
|
|
// /// <summary>
|
|
// /// Encapsulates a collection of PropertySpec objects.
|
|
// /// </summary>
|
|
// [Serializable]
|
|
// public class PropertySpecCollection : IList
|
|
// {
|
|
// private ArrayList innerArray;
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertySpecCollection class.
|
|
// /// </summary>
|
|
// public PropertySpecCollection()
|
|
// {
|
|
// innerArray = new ArrayList();
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets the number of elements in the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <value>
|
|
// /// The number of elements contained in the PropertySpecCollection.
|
|
// /// </value>
|
|
// public int Count
|
|
// {
|
|
// get { return innerArray.Count; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets a value indicating whether the PropertySpecCollection has a fixed size.
|
|
// /// </summary>
|
|
// /// <value>
|
|
// /// true if the PropertySpecCollection has a fixed size; otherwise, false.
|
|
// /// </value>
|
|
// public bool IsFixedSize
|
|
// {
|
|
// get { return false; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets a value indicating whether the PropertySpecCollection is read-only.
|
|
// /// </summary>
|
|
// public bool IsReadOnly
|
|
// {
|
|
// get { return false; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
|
|
// /// </summary>
|
|
// /// <value>
|
|
// /// true if access to the PropertySpecCollection is synchronized (thread-safe); otherwise, false.
|
|
// /// </value>
|
|
// public bool IsSynchronized
|
|
// {
|
|
// get { return false; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets an object that can be used to synchronize access to the collection.
|
|
// /// </summary>
|
|
// /// <value>
|
|
// /// An object that can be used to synchronize access to the collection.
|
|
// /// </value>
|
|
// object ICollection.SyncRoot
|
|
// {
|
|
// get { return null; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the element at the specified index.
|
|
// /// In C#, this property is the indexer for the PropertySpecCollection class.
|
|
// /// </summary>
|
|
// /// <param name="index">The zero-based index of the element to get or set.</param>
|
|
// /// <value>
|
|
// /// The element at the specified index.
|
|
// /// </value>
|
|
// public PropertySpec this[int index]
|
|
// {
|
|
// get { return (PropertySpec)innerArray[index]; }
|
|
// set { innerArray[index] = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Adds a PropertySpec to the end of the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="value">The PropertySpec to be added to the end of the PropertySpecCollection.</param>
|
|
// /// <returns>The PropertySpecCollection index at which the value has been added.</returns>
|
|
// public int Add(PropertySpec value)
|
|
// {
|
|
// int index = innerArray.Add(value);
|
|
//
|
|
// return index;
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Adds the elements of an array of PropertySpec objects to the end of the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="array">The PropertySpec array whose elements should be added to the end of the
|
|
// /// PropertySpecCollection.</param>
|
|
// public void AddRange(PropertySpec[] array)
|
|
// {
|
|
// innerArray.AddRange(array);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Removes all elements from the PropertySpecCollection.
|
|
// /// </summary>
|
|
// public void Clear()
|
|
// {
|
|
// innerArray.Clear();
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Determines whether a PropertySpec is in the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="item">The PropertySpec to locate in the PropertySpecCollection. The element to locate
|
|
// /// can be a null reference (Nothing in Visual Basic).</param>
|
|
// /// <returns>true if item is found in the PropertySpecCollection; otherwise, false.</returns>
|
|
// public bool Contains(PropertySpec item)
|
|
// {
|
|
// return innerArray.Contains(item);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Determines whether a PropertySpec with the specified name is in the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the PropertySpec to locate in the PropertySpecCollection.</param>
|
|
// /// <returns>true if item is found in the PropertySpecCollection; otherwise, false.</returns>
|
|
// public bool Contains(string name)
|
|
// {
|
|
// foreach(PropertySpec spec in innerArray)
|
|
// if(spec.Name == name)
|
|
// return true;
|
|
//
|
|
// return false;
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Copies the entire PropertySpecCollection to a compatible one-dimensional Array, starting at the
|
|
// /// beginning of the target array.
|
|
// /// </summary>
|
|
// /// <param name="array">The one-dimensional Array that is the destination of the elements copied
|
|
// /// from PropertySpecCollection. The Array must have zero-based indexing.</param>
|
|
// public void CopyTo(PropertySpec[] array)
|
|
// {
|
|
// innerArray.CopyTo(array);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Copies the PropertySpecCollection or a portion of it to a one-dimensional array.
|
|
// /// </summary>
|
|
// /// <param name="array">The one-dimensional Array that is the destination of the elements copied
|
|
// /// from the collection.</param>
|
|
// /// <param name="index">The zero-based index in array at which copying begins.</param>
|
|
// public void CopyTo(PropertySpec[] array, int index)
|
|
// {
|
|
// innerArray.CopyTo(array, index);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Returns an enumerator that can iterate through the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <returns>An IEnumerator for the entire PropertySpecCollection.</returns>
|
|
// public IEnumerator GetEnumerator()
|
|
// {
|
|
// return innerArray.GetEnumerator();
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Searches for the specified PropertySpec and returns the zero-based index of the first
|
|
// /// occurrence within the entire PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="value">The PropertySpec to locate in the PropertySpecCollection.</param>
|
|
// /// <returns>The zero-based index of the first occurrence of value within the entire PropertySpecCollection,
|
|
// /// if found; otherwise, -1.</returns>
|
|
// public int IndexOf(PropertySpec value)
|
|
// {
|
|
// return innerArray.IndexOf(value);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Searches for the PropertySpec with the specified name and returns the zero-based index of
|
|
// /// the first occurrence within the entire PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the PropertySpec to locate in the PropertySpecCollection.</param>
|
|
// /// <returns>The zero-based index of the first occurrence of value within the entire PropertySpecCollection,
|
|
// /// if found; otherwise, -1.</returns>
|
|
// public int IndexOf(string name)
|
|
// {
|
|
// int i = 0;
|
|
//
|
|
// foreach(PropertySpec spec in innerArray)
|
|
// {
|
|
// if(spec.Name == name)
|
|
// return i;
|
|
//
|
|
// i++;
|
|
// }
|
|
//
|
|
// return -1;
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Inserts a PropertySpec object into the PropertySpecCollection at the specified index.
|
|
// /// </summary>
|
|
// /// <param name="index">The zero-based index at which value should be inserted.</param>
|
|
// /// <param name="value">The PropertySpec to insert.</param>
|
|
// public void Insert(int index, PropertySpec value)
|
|
// {
|
|
// innerArray.Insert(index, value);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Removes the first occurrence of a specific object from the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="obj">The PropertySpec to remove from the PropertySpecCollection.</param>
|
|
// public void Remove(PropertySpec obj)
|
|
// {
|
|
// innerArray.Remove(obj);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Removes the property with the specified name from the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="name">The name of the PropertySpec to remove from the PropertySpecCollection.</param>
|
|
// public void Remove(string name)
|
|
// {
|
|
// int index = IndexOf(name);
|
|
// RemoveAt(index);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Removes the object at the specified index of the PropertySpecCollection.
|
|
// /// </summary>
|
|
// /// <param name="index">The zero-based index of the element to remove.</param>
|
|
// public void RemoveAt(int index)
|
|
// {
|
|
// innerArray.RemoveAt(index);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Copies the elements of the PropertySpecCollection to a new PropertySpec array.
|
|
// /// </summary>
|
|
// /// <returns>A PropertySpec array containing copies of the elements of the PropertySpecCollection.</returns>
|
|
// public PropertySpec[] ToArray()
|
|
// {
|
|
// return (PropertySpec[])innerArray.ToArray(typeof(PropertySpec));
|
|
// }
|
|
//
|
|
// #region Explicit interface implementations for ICollection and IList
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// void ICollection.CopyTo(Array array, int index)
|
|
// {
|
|
// CopyTo((PropertySpec[])array, index);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// int IList.Add(object value)
|
|
// {
|
|
// return Add((PropertySpec)value);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// bool IList.Contains(object obj)
|
|
// {
|
|
// return Contains((PropertySpec)obj);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// object IList.this[int index]
|
|
// {
|
|
// get
|
|
// {
|
|
// return ((PropertySpecCollection)this)[index];
|
|
// }
|
|
// set
|
|
// {
|
|
// ((PropertySpecCollection)this)[index] = (PropertySpec)value;
|
|
// }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// int IList.IndexOf(object obj)
|
|
// {
|
|
// return IndexOf((PropertySpec)obj);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// void IList.Insert(int index, object value)
|
|
// {
|
|
// Insert(index, (PropertySpec)value);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
|
// /// </summary>
|
|
// 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;
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertyBag class.
|
|
// /// </summary>
|
|
// public PropertyBag()
|
|
// {
|
|
// defaultProperty = null;
|
|
// properties = new PropertySpecCollection();
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the name of the default property in the collection.
|
|
// /// </summary>
|
|
// public string DefaultProperty
|
|
// {
|
|
// get { return defaultProperty; }
|
|
// set { defaultProperty = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets the collection of properties contained within this PropertyBag.
|
|
// /// </summary>
|
|
// public PropertySpecCollection Properties
|
|
// {
|
|
// get { return properties; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Occurs when a PropertyGrid requests the value of a property.
|
|
// /// </summary>
|
|
// public event PropertySpecEventHandler GetValue;
|
|
//
|
|
// /// <summary>
|
|
// /// Occurs when the user changes the value of a property in a PropertyGrid.
|
|
// /// </summary>
|
|
// public event PropertySpecEventHandler SetValue;
|
|
//
|
|
// /// <summary>
|
|
// /// Raises the GetValue event.
|
|
// /// </summary>
|
|
// /// <param name="e">A PropertySpecEventArgs that contains the event data.</param>
|
|
// protected virtual void OnGetValue(PropertySpecEventArgs e)
|
|
// {
|
|
// if(GetValue != null)
|
|
// GetValue(this, e);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Raises the SetValue event.
|
|
// /// </summary>
|
|
// /// <param name="e">A PropertySpecEventArgs that contains the event data.</param>
|
|
// 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
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// An extension of PropertyBag that manages a table of property values, in
|
|
// /// addition to firing events when property values are requested or set.
|
|
// /// </summary>
|
|
// public class PropertyTable : PropertyBag
|
|
// {
|
|
// private Hashtable propValues;
|
|
//
|
|
// /// <summary>
|
|
// /// Initializes a new instance of the PropertyTable class.
|
|
// /// </summary>
|
|
// public PropertyTable()
|
|
// {
|
|
// propValues = new Hashtable();
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// Gets or sets the value of the property with the specified name.
|
|
// /// <p>In C#, this property is the indexer of the PropertyTable class.</p>
|
|
// /// </summary>
|
|
// public object this[string key]
|
|
// {
|
|
// get { return propValues[key]; }
|
|
// set { propValues[key] = value; }
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member overrides PropertyBag.OnGetValue.
|
|
// /// </summary>
|
|
// protected override void OnGetValue(PropertySpecEventArgs e)
|
|
// {
|
|
// e.Value = propValues[e.Property.Name];
|
|
// base.OnGetValue(e);
|
|
// }
|
|
//
|
|
// /// <summary>
|
|
// /// This member overrides PropertyBag.OnSetValue.
|
|
// /// </summary>
|
|
// 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
|
|
|
|
|
|
/// <summary>
|
|
/// Handle a drop by putting the object dropped into the file
|
|
/// collection of the object and return an internal hyperlink
|
|
/// to insert in it's place in the document if applicable
|
|
///
|
|
/// </summary>
|
|
public static string WikiDragDrop(System.Windows.Forms.DragEventArgs e, Guid RootObjectID)
|
|
{
|
|
//case 1039 //log.Debug("WikiDragDrop");
|
|
|
|
//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)
|
|
{
|
|
//if (log.IsDebugEnabled)
|
|
//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;
|
|
|
|
}
|
|
|
|
}
|
|
return "";//no link, it's a file that will sit in the files grid below the rtf control
|
|
}
|
|
//Handle URLS being dropped
|
|
else if (e.Data.GetDataPresent("UniformResourceLocator"))
|
|
{
|
|
string sUrl=e.Data.GetData(DataFormats.Text).ToString();
|
|
//if (log.IsDebugEnabled)
|
|
//case 1039 //log.Debug("WikiDragDrop: dropping URL [" + sUrl + "] to WikiPage ID=" + RootObjectID.ToString());
|
|
|
|
//AssignedDoc doc = docs.Add(RootObjectType, RootObjectID);
|
|
//doc.Description = "URL";
|
|
//doc.URL = e.Data.GetData(DataFormats.Text).ToString();
|
|
|
|
//It's a URL so return it as is for insertion into the document text itself
|
|
//nothing to store in the db
|
|
return sUrl;
|
|
}
|
|
|
|
|
|
|
|
////ok, it's something else, let's figure it out
|
|
string[] s = e.Data.GetFormats(false);
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("Unknown data format:\r\n");
|
|
foreach (string s1 in s)
|
|
sb.Append(s1 + "\r\n");
|
|
MessageBox.Show(sb.ToString());
|
|
|
|
|
|
return "other";
|
|
}
|
|
|
|
|
|
//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("UniformResourceLocator")
|
|
)
|
|
{
|
|
e.Effect = DragDropEffects.Copy;
|
|
}
|
|
else
|
|
{
|
|
e.Effect = DragDropEffects.None;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion wikiform
|
|
|
|
#region Documents form
|
|
//provide visual feedback if object being dragged is allowed
|
|
public static void DragEnter(System.Windows.Forms.DragEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("DragEnter");
|
|
//Files are ok
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
{
|
|
e.Effect = DragDropEffects.Link;
|
|
}//So are URL's
|
|
else if (e.Data.GetDataPresent("UniformResourceLocator"))
|
|
{
|
|
e.Effect = DragDropEffects.Link;
|
|
|
|
}//anything else is bogus
|
|
else
|
|
{
|
|
e.Effect = DragDropEffects.None;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Handle a drop by putting the object dropped into the docs
|
|
/// collection of the object
|
|
/// </summary>
|
|
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);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
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
|
|
|
|
#endregion
|
|
|
|
#region Icons from association
|
|
public enum IconSize : uint
|
|
{
|
|
Small = 0x0, //16x16
|
|
Large = 0x1 //32x32
|
|
}
|
|
|
|
//the function that will extract the icons from a file
|
|
public class IconHandler
|
|
{
|
|
[DllImport("Shell32", CharSet = CharSet.Auto)]
|
|
internal extern static int ExtractIconEx(
|
|
[MarshalAs(UnmanagedType.LPTStr)]
|
|
string lpszFile, //size of the icon
|
|
int nIconIndex, //index of the icon (in case we have more then 1 icon in the file
|
|
IntPtr[] phIconLarge, //32x32 icon
|
|
IntPtr[] phIconSmall, //16x16 icon
|
|
int nIcons); //how many to get
|
|
|
|
//will return an array of icons
|
|
public static Icon[] IconsFromFile(string Filename, IconSize Size)
|
|
{
|
|
int IconCount = ExtractIconEx(Filename, -1, null, null, 0); //checks how many icons.
|
|
IntPtr[] IconPtr = new IntPtr[IconCount];
|
|
|
|
//extracts the icons by the size that was selected.
|
|
if (Size == IconSize.Small)
|
|
ExtractIconEx(Filename, 0, null, IconPtr, IconCount);
|
|
else
|
|
ExtractIconEx(Filename, 0, IconPtr, null, IconCount);
|
|
|
|
Icon[] IconList = new Icon[IconCount];
|
|
|
|
//gets the icons in a list.
|
|
for (int i = 0; i < IconCount; i++)
|
|
IconList[i] = Icon.FromHandle(IconPtr[i]);
|
|
|
|
return IconList;
|
|
}
|
|
|
|
//extract one selected by index icon from a file.
|
|
public static Icon IconFromFile(string Filename, IconSize Size, int Index)
|
|
{
|
|
|
|
//case 3751
|
|
if (!File.Exists(Filename)) return null;
|
|
|
|
int IconCount = ExtractIconEx(Filename, -1, null, null, 0); //checks how many icons.
|
|
if (IconCount < Index) return null; // no icons was found.
|
|
|
|
IntPtr[] IconPtr = new IntPtr[1];
|
|
|
|
//extracts the icon that we want in the selected size.
|
|
if (Size == IconSize.Small)
|
|
ExtractIconEx(Filename, Index, null, IconPtr, 1);
|
|
else
|
|
ExtractIconEx(Filename, Index, IconPtr, null, 1);
|
|
|
|
return Icon.FromHandle(IconPtr[0]);
|
|
}
|
|
|
|
//this will look throw the registry to find if the Extension have an icon.
|
|
public static Icon IconFromExtension(string Extension, IconSize Size)
|
|
{
|
|
try
|
|
{
|
|
//add '.' if nessesry
|
|
if (Extension[0] != '.') Extension = '.' + Extension;
|
|
|
|
//opens the registry for the wanted key.
|
|
RegistryKey Root = Registry.ClassesRoot;
|
|
RegistryKey ExtensionKey = Root.OpenSubKey(Extension);
|
|
ExtensionKey.GetValueNames();
|
|
RegistryKey ApplicationKey = Root.OpenSubKey(ExtensionKey.GetValue("").ToString());
|
|
if (ApplicationKey != null)
|
|
{
|
|
//gets the name of the file that have the icon.
|
|
RegistryKey DefaultIconKey = ApplicationKey.OpenSubKey("DefaultIcon");
|
|
if (DefaultIconKey != null)
|
|
{
|
|
object o = DefaultIconKey.GetValue("");
|
|
if (o != null)
|
|
{
|
|
string IconLocation = o.ToString();
|
|
string[] IconPath = IconLocation.Split(',');
|
|
|
|
if (IconPath[1] == null) IconPath[1] = "0";
|
|
IntPtr[] Large = new IntPtr[1], Small = new IntPtr[1];
|
|
|
|
//extracts the icon from the file.
|
|
ExtractIconEx(IconPath[0], Convert.ToInt16(IconPath[1]), Large, Small, 1);
|
|
return Size == IconSize.Large ? Icon.FromHandle(Large[0]) : Icon.FromHandle(Small[0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("error while trying to get icon for " + Extension + " :" + e.Message);
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Custom Grid SortComparers
|
|
/// <summary>
|
|
/// Compare two dates that are strings
|
|
/// </summary>
|
|
public class AYStringToDateComparer : IComparer
|
|
{
|
|
public int Compare(object x, object y)
|
|
{
|
|
//Cast objects passed in to ultragrid cells...
|
|
UltraGridCell xCell = (UltraGridCell)x;
|
|
UltraGridCell yCell = (UltraGridCell)y;
|
|
|
|
try
|
|
{
|
|
//If this fails then they are likey unparseable strings
|
|
//so compare as strings in the catch block
|
|
DateTime dx = DateTime.Parse(xCell.Value.ToString());
|
|
DateTime dy = DateTime.Parse(yCell.Value.ToString());
|
|
return DateTime.Compare(dx, dy);
|
|
}
|
|
catch
|
|
{
|
|
return String.Compare(xCell.Value.ToString(), yCell.Value.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Compare two whole numbers that are strings
|
|
/// (Used for visible id numbers such as workorder number etc)
|
|
/// </summary>
|
|
public class AYStringToIntComparer : IComparer
|
|
{
|
|
public int Compare(object x, object y)
|
|
{
|
|
//Cast objects passed in to ultragrid cells...
|
|
UltraGridCell xCell = (UltraGridCell)x;
|
|
UltraGridCell yCell = (UltraGridCell)y;
|
|
|
|
try
|
|
{
|
|
//If this fails then they are likey unparseable strings
|
|
//so compare as strings in the catch block
|
|
int dx = int.Parse(xCell.Value.ToString());
|
|
int dy = int.Parse(yCell.Value.ToString());
|
|
|
|
//compare
|
|
if (dx < dy) return -1;
|
|
if (dx > dy) return 1;
|
|
|
|
//must be equal
|
|
return 0;
|
|
|
|
|
|
}
|
|
catch
|
|
{
|
|
return String.Compare(xCell.Value.ToString(), yCell.Value.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LetSQLDoItFilterCondition class
|
|
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
[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
|
|
|
|
#region Support info
|
|
static public string FullSupportInfo()
|
|
{
|
|
log.Debug("FullSupportInfo");
|
|
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 user name: " + System.Environment.UserName + "\r\n" +
|
|
"\tNetworked: " + SystemInformation.Network.ToString() + "\r\n" +
|
|
"\tOS user domain name: " + System.Environment.UserDomainName + "\r\n" +
|
|
//"\tOS version: " + System.Environment.OSVersion.ToString() + "\r\n" +
|
|
OSVersionInfo.FullOperatingSystemInformationForDisplay + "\r\n" +
|
|
"\tSystem folder: " + System.Environment.SystemDirectory + "\r\n" +
|
|
|
|
"\tCLR version: " + System.Environment.Version.ToString() + "\r\n" +
|
|
|
|
"\tCurrent directory: " + System.Environment.CurrentDirectory + "\r\n" +
|
|
"\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();
|
|
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("\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");
|
|
}
|
|
|
|
if (AyaBizUtils.AyaNovaConnectionSetting.UsingDataPortal && 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();
|
|
}
|
|
|
|
|
|
//case 3663
|
|
static public void LogFullSupportInfoToFile()
|
|
{
|
|
log.Info("##############################");
|
|
log.Info("Support info requested, logging extra:\r\n");
|
|
log.Info(FullSupportInfo());
|
|
log.Info("##############################");
|
|
|
|
}
|
|
|
|
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" );
|
|
|
|
|
|
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("\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();
|
|
}
|
|
|
|
#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("\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("\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
|
|
|
|
/// <summary>
|
|
/// EnumConverter supporting System.ComponentModel.DescriptionAttribute
|
|
/// </summary>
|
|
public class EnumDescConverter : System.ComponentModel.EnumConverter
|
|
{
|
|
protected System.Type myVal;
|
|
|
|
/// <summary>
|
|
/// Gets Enum Value's Description Attribute
|
|
/// This can be called directly from anywhere to return
|
|
/// the localized text value of an enumeration.
|
|
/// </summary>
|
|
/// <param name="value">The value you want the description attribute for</param>
|
|
/// <returns>The description, if any, else it's .ToString()</returns>
|
|
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;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the description for certain named value in an Enumeration
|
|
/// </summary>
|
|
/// <param name="value">The type of the Enumeration</param>
|
|
/// <param name="name">The name of the Enumeration value</param>
|
|
/// <returns>The description, if any, else the passed name</returns>
|
|
public static string GetEnumDescription(System.Type value, string name)
|
|
{
|
|
FieldInfo fi= value.GetField(name);
|
|
DescriptionAttribute[] attributes =
|
|
(DescriptionAttribute[] )fi.GetCustomAttributes(
|
|
typeof(DescriptionAttribute), false);
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the value of an Enum, based on it's Description Attribute or named value
|
|
/// </summary>
|
|
/// <param name="value">The Enum type</param>
|
|
/// <param name="description">The description or name of the element</param>
|
|
/// <returns>The value, or the passed in description, if it was not found</returns>
|
|
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)
|
|
{
|
|
DataTable dt = GetDataNonBiz(EnumListName);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
if (int.Parse(dr["Value"].ToString()) == i)
|
|
return dr["Display"].ToString();
|
|
}
|
|
return " ";
|
|
}
|
|
public static DataTable GetDataNonBiz(string EnumListName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("Display");
|
|
dt.Columns.Add("Value");
|
|
|
|
|
|
switch (EnumListName)
|
|
{
|
|
case "QuoteStatus":
|
|
{
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.Awarded, LocaleText.GetLocalizedText("WorkorderQuoteStatusTypes.Label.Awarded"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.InProgress, LocaleText.GetLocalizedText("WorkorderQuoteStatusTypes.Label.InProgress"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.NotAwarded, LocaleText.GetLocalizedText("WorkorderQuoteStatusTypes.Label.NotAwarded"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.Submitted, LocaleText.GetLocalizedText("WorkorderQuoteStatusTypes.Label.Submitted"));
|
|
|
|
//case 1556
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.New, LocaleText.GetLocalizedText("WorkorderQuoteStatusTypes.Label.New"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.NotAwarded2, LocaleText.GetLocalizedText("WorkorderQuoteStatusTypes.Label.NotAwarded2"));
|
|
|
|
}
|
|
break;
|
|
case "ClientServiceRequestStatus":
|
|
{
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Accepted, LocaleText.GetLocalizedText("ClientServiceRequestStatus.Accepted"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Declined, LocaleText.GetLocalizedText("ClientServiceRequestStatus.Declined"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Open, LocaleText.GetLocalizedText("ClientServiceRequestStatus.Open"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Closed, LocaleText.GetLocalizedText("ClientServiceRequestStatus.Closed"));
|
|
|
|
}
|
|
break;
|
|
case "ClientServiceRequestPriority":
|
|
{
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.NotUrgent, LocaleText.GetLocalizedText("ClientServiceRequestPriority.NotUrgent"));
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.ASAP, LocaleText.GetLocalizedText("ClientServiceRequestPriority.ASAP"));
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.Emergency, LocaleText.GetLocalizedText("ClientServiceRequestPriority.Emergency"));
|
|
|
|
}
|
|
break;
|
|
case "UnitsOfTime":
|
|
{
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Minutes, LocaleText.GetLocalizedText("UI.Label.TimeSpan.Minutes"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Hours, LocaleText.GetLocalizedText("UI.Label.TimeSpan.Hours"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Days, LocaleText.GetLocalizedText("UI.Label.TimeSpan.Days"));
|
|
//Weeks are not supported because the concept of Week is very "weak" globally :)
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Months, LocaleText.GetLocalizedText("UI.Label.TimeSpan.Months"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Years, LocaleText.GetLocalizedText("UI.Label.TimeSpan.Years"));
|
|
|
|
}
|
|
break;
|
|
case "DaysOfWeek":
|
|
{
|
|
AddNVRow(dt, (int)AyaDayOfWeek.AnyDayOfWeek, LocaleText.GetLocalizedText("UI.Label.Day.Any"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Monday, LocaleText.GetLocalizedText("UI.Label.Day.Monday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Tuesday, LocaleText.GetLocalizedText("UI.Label.Day.Tuesday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Wednesday, LocaleText.GetLocalizedText("UI.Label.Day.Wednesday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Thursday, LocaleText.GetLocalizedText("UI.Label.Day.Thursday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Friday, LocaleText.GetLocalizedText("UI.Label.Day.Friday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Saturday, LocaleText.GetLocalizedText("UI.Label.Day.Saturday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Sunday, LocaleText.GetLocalizedText("UI.Label.Day.Sunday"));
|
|
|
|
}
|
|
break;
|
|
case "VendorTypes":
|
|
{
|
|
AddNVRow(dt, -1, NoSelectionString);//Case 318
|
|
AddNVRow(dt, (int)VendorTypes.Manufacturer, LocaleText.GetLocalizedText("Vendor.Label.VendorType.Manufacturer"));
|
|
AddNVRow(dt, (int)VendorTypes.Shipper, LocaleText.GetLocalizedText("Vendor.Label.VendorType.Shipper"));
|
|
AddNVRow(dt, (int)VendorTypes.SubContractor, LocaleText.GetLocalizedText("Vendor.Label.VendorType.SubContractor"));
|
|
AddNVRow(dt, (int)VendorTypes.ThirdPartyRepair, LocaleText.GetLocalizedText("Vendor.Label.VendorType.ThirdPartyRepair"));
|
|
AddNVRow(dt, (int)VendorTypes.Wholesaler, LocaleText.GetLocalizedText("Vendor.Label.VendorType.Wholesaler"));
|
|
|
|
}
|
|
break;
|
|
case "PurchaseOrderStatus":
|
|
{
|
|
AddNVRow(dt, -1, NoSelectionString);//Case 318
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedFullReceived, LocaleText.GetLocalizedText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedFullReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedNoneReceived, LocaleText.GetLocalizedText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedNoneReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedPartialReceived, LocaleText.GetLocalizedText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedPartialReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenNotYetOrdered, LocaleText.GetLocalizedText("PurchaseOrder.Label.PurchaseOrderStatus.OpenNotYetOrdered"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenOrdered, LocaleText.GetLocalizedText("PurchaseOrder.Label.PurchaseOrderStatus.OpenOrdered"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenPartialReceived, LocaleText.GetLocalizedText("PurchaseOrder.Label.PurchaseOrderStatus.OpenPartialReceived"));
|
|
|
|
|
|
}
|
|
break;
|
|
case "WorkorderItemTaskCompletionType":
|
|
{
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.Complete, LocaleText.GetLocalizedText("WorkorderItemTask.Label.CompletionType.Complete"));
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.Incomplete, LocaleText.GetLocalizedText("WorkorderItemTask.Label.CompletionType.Incomplete"));
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.NotApplicable, LocaleText.GetLocalizedText("WorkorderItemTask.Label.CompletionType.NotApplicable"));
|
|
|
|
}
|
|
break;
|
|
|
|
case "ContactPhoneTypes":
|
|
{
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Unset, NoSelectionString);//Case 318
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Business, LocaleText.GetLocalizedText("ContactPhone.Label.ContactPhoneType.Business"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Mobile, LocaleText.GetLocalizedText("ContactPhone.Label.ContactPhoneType.Mobile"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Fax, LocaleText.GetLocalizedText("ContactPhone.Label.ContactPhoneType.Fax"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Pager, LocaleText.GetLocalizedText("ContactPhone.Label.ContactPhoneType.Pager"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Home, LocaleText.GetLocalizedText("ContactPhone.Label.ContactPhoneType.Home"));
|
|
}
|
|
break;
|
|
|
|
case "UserTypes":
|
|
{
|
|
AddNVRow(dt, (int)UserTypes.Administrator, LocaleText.GetLocalizedText("UserTypes.Label.Administrator"));
|
|
AddNVRow(dt, (int)UserTypes.Schedulable, LocaleText.GetLocalizedText("UserTypes.Label.Schedulable"));
|
|
AddNVRow(dt, (int)UserTypes.NonSchedulable, LocaleText.GetLocalizedText("UserTypes.Label.NonSchedulable"));
|
|
AddNVRow(dt, (int)UserTypes.Client, LocaleText.GetLocalizedText("UserTypes.Label.Client"));
|
|
AddNVRow(dt, (int)UserTypes.HeadOffice, LocaleText.GetLocalizedText("UserTypes.Label.HeadOffice"));
|
|
AddNVRow(dt, (int)UserTypes.Utility, LocaleText.GetLocalizedText("UserTypes.Label.UTILITY"));
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
static private void AddNVRow(DataTable dt, object value, object display)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = display.ToString();
|
|
dr["Value"] = value;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Used for combo box initialization
|
|
/// and for label intialization in grid
|
|
/// columns that contain a combo but are
|
|
/// not in edit mode
|
|
///
|
|
/// </summary>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <returns></returns>
|
|
static public string GetBizObjectName(string ObjectName, Guid 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;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Convenience overload
|
|
/// </summary>
|
|
/// <param name="ObjectName"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <returns></returns>
|
|
static public string GetBizObjectName(string ObjectName, string SelectedID)
|
|
{
|
|
return GetBizObjectName(ObjectName, new Guid(SelectedID));
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region HotKeys
|
|
/// <summary>
|
|
/// Case 37 - Accelerator key processing
|
|
/// centralized here so we can define the hotkeys in one location
|
|
/// </summary>
|
|
/// <param name="keydata"></param>
|
|
/// <returns></returns>
|
|
public static HotKeyAction HotKeys(Keys keydata)
|
|
{
|
|
|
|
|
|
switch (keydata)
|
|
{
|
|
//Close form
|
|
case (Keys.Alt | Keys.X):
|
|
return HotKeyAction.CloseForm;
|
|
|
|
//New workorder
|
|
case (Keys.Alt | Keys.W):
|
|
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;
|
|
//New quote
|
|
case (Keys.Alt | Keys.Q):
|
|
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;
|
|
//New unit
|
|
case (Keys.Alt | Keys.U):
|
|
if (!AyaBizUtils.Lite && AyaBizUtils.Right("Object.Unit") > (int)SecurityLevelTypes.ReadOnly)
|
|
return HotKeyAction.NewUnit;
|
|
break;
|
|
//New part
|
|
case (Keys.Alt | Keys.P):
|
|
if (AyaBizUtils.Right("Object.Part") > (int)SecurityLevelTypes.ReadOnly)
|
|
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;
|
|
|
|
|
|
}
|
|
return HotKeyAction.NoAction;
|
|
}
|
|
#endregion
|
|
|
|
#region AyaNovaUrl
|
|
/// <summary>
|
|
/// Copy AyaNovaUrl to clipboard
|
|
/// </summary>
|
|
/// <param name="RootObjectID"></param>
|
|
/// <param name="ObjectType"></param>
|
|
public static void CopyAyaNovaUrl(Guid RootObjectID, RootObjectTypes ObjectType)
|
|
{
|
|
CopyAyaNovaUrl(new TypeAndID(ObjectType, RootObjectID));
|
|
}
|
|
/// <summary>
|
|
/// Copy AyaNovaUrl to clipboard
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
public static void CopyAyaNovaUrl(TypeAndID t)
|
|
{
|
|
|
|
Clipboard.SetText(t.ToAyaURL());
|
|
}
|
|
|
|
//todo: create desktop shortcut method
|
|
//SEE: http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp
|
|
#endregion
|
|
|
|
#region Exception cracker
|
|
public static Exception CrackException(Exception ex)
|
|
{
|
|
while (ex.InnerException != null)
|
|
ex = ex.InnerException;
|
|
return ex;
|
|
}
|
|
#endregion
|
|
|
|
#region WikiPage opener helper
|
|
/// <summary>
|
|
/// Opens a wiki page for given object type and ID
|
|
/// if the page doesn't exist then it creates a new one
|
|
/// </summary>
|
|
/// <param name="oType"></param>
|
|
/// <param name="oID"></param>
|
|
public static void OpenWikiPage(RootObjectTypes oType, Guid oID, bool bEditMode)
|
|
{
|
|
try
|
|
{
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
WikiPage wp = WikiPage.GetItem(new TypeAndID(oType, oID));
|
|
WikiInfoForm wi = new WikiInfoForm(bEditMode);
|
|
wi.WikiPageToEdit = wp;
|
|
wi.Show();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//There might not be an existing wiki page and the user might not have the rights to create one
|
|
//In the object it should check and not show if the user has no rights to a wikipage with some biz object voodoo
|
|
ex = CrackException(ex);
|
|
if (ex is System.Security.SecurityException)
|
|
MessageBox.Show(ex.Message);
|
|
else
|
|
throw (ex);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//Case 318
|
|
/// <summary>
|
|
/// replacement for the current space character used to indicate no selection
|
|
/// has been made in grids
|
|
/// </summary>
|
|
public static string NoSelectionString
|
|
{
|
|
get
|
|
{
|
|
return "-";
|
|
}
|
|
}
|
|
|
|
#region Case 677 - multiple open work orders
|
|
/// <summary>
|
|
/// Iterates all open forms and if the workorder is already open it
|
|
/// returns the existing open form or a new one if it isn't
|
|
/// </summary>
|
|
/// <param name="workorderID"></param>
|
|
/// <returns></returns>
|
|
public static WorkorderForm GetWorkorderForm(Guid workorderID)
|
|
{
|
|
FormCollection fc = Application.OpenForms;
|
|
foreach (Form f in fc)
|
|
{
|
|
if (f is WorkorderForm)
|
|
{
|
|
WorkorderForm wf = (WorkorderForm)f;
|
|
|
|
if (wf.WorkorderToEdit != null && wf.WorkorderToEdit.ID == workorderID)
|
|
{
|
|
wf.WindowState = FormWindowState.Minimized;
|
|
wf.WindowState = FormWindowState.Maximized;
|
|
|
|
return wf;
|
|
}
|
|
|
|
}
|
|
}
|
|
return new WorkorderForm();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Check for any unsaved work orders that may be open
|
|
/// This will prevent user from closing AyaNova without saving their work
|
|
/// because normally a close form on the main form will close all the child work order forms
|
|
/// without any prompt
|
|
/// </summary>
|
|
public static WorkorderForm OpenDirtyWorkOrder
|
|
{
|
|
get
|
|
{
|
|
FormCollection fc = Application.OpenForms;
|
|
foreach (Form f in fc)
|
|
{
|
|
if (f is WorkorderForm)
|
|
{
|
|
WorkorderForm wf = (WorkorderForm)f;
|
|
|
|
if (wf.WorkorderToEdit != null && wf.WorkorderToEdit.IsDirty)
|
|
{
|
|
wf.WindowState = FormWindowState.Minimized;
|
|
wf.WindowState = FormWindowState.Maximized;
|
|
return wf;
|
|
}
|
|
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region Plugins case 941
|
|
public static void debugLog(string s)
|
|
{
|
|
if (log.IsDebugEnabled)
|
|
log.Debug(s);
|
|
}
|
|
|
|
#region Load / Unload
|
|
|
|
private static System.Collections.Generic.List<IAyaNovaPlugin> mPlugins = null;
|
|
|
|
public static void LoadPluginsEx()
|
|
{
|
|
if (mPlugins == null) mPlugins = new System.Collections.Generic.List<IAyaNovaPlugin>();
|
|
UnloadPluginsEx();
|
|
try
|
|
{
|
|
string PluginsPath = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "plugins" + Path.DirectorySeparatorChar;
|
|
Assembly a = null;
|
|
string[] PluginFiles = Directory.GetFiles(PluginsPath, "*.dll", SearchOption.AllDirectories);
|
|
System.Text.StringBuilder sbErrors = new StringBuilder();
|
|
if (PluginFiles.Length == 0)
|
|
{
|
|
debugLog("PLUGINS - No .dll files found in plugins folder: " + PluginsPath);
|
|
return;
|
|
}
|
|
|
|
debugLog("PLUGINS - The following .dll files were found in the plugins folder: ");
|
|
foreach (string PluginFile in PluginFiles)
|
|
{
|
|
debugLog(PluginFile);
|
|
|
|
}
|
|
foreach (string PluginFile in PluginFiles)
|
|
{
|
|
try
|
|
{
|
|
a = Assembly.LoadFrom(PluginFile);
|
|
|
|
foreach (Type t in a.GetTypes())
|
|
{
|
|
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;
|
|
}
|
|
|
|
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)
|
|
{
|
|
var typeLoadException = exsingle as ReflectionTypeLoadException;
|
|
var loaderExceptions = typeLoadException.LoaderExceptions;
|
|
sbErrors.AppendLine("PLUGINS - failed to load: " + PluginFile + "\r\n" + exsingle.Message);
|
|
sbErrors.AppendLine("\tLoader exceptions: ");
|
|
for (int x = 0; x < loaderExceptions.Length; x++)
|
|
{
|
|
sbErrors.AppendLine("\tLoad exception: " + PluginFile + "\r\n" + loaderExceptions[x].Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sbErrors.AppendLine("PLUGINS - failed to load: " + PluginFile + "\r\n" + exsingle.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (sbErrors.Length > 0) throw new System.ApplicationException(sbErrors.ToString());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Error("PLUGINS - Error loading plugins", ex.Message);
|
|
|
|
}
|
|
System.Collections.Generic.List<IAyaNovaPlugin> failedToInitializeList = new System.Collections.Generic.List<IAyaNovaPlugin>();
|
|
foreach (IAyaNovaPlugin p in mPlugins)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (p.Initialize(Assembly.GetExecutingAssembly().GetName().Version,Util.LocaleText))
|
|
{
|
|
p.AyaNovaResourceManager = Resource1.ResourceManager;
|
|
|
|
}
|
|
else
|
|
{
|
|
debugLog("PLUGINS - " + p.PluginName + " returned false on call to initialize.");
|
|
failedToInitializeList.Add(p);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
debugLog("PLUGINS - " + p.PluginName + " threw the following exception when it's Initialize method was called: \r\n" + ex.Message);
|
|
}
|
|
}
|
|
|
|
foreach (IAyaNovaPlugin p in failedToInitializeList)
|
|
mPlugins.Remove(p);
|
|
|
|
//Sort the plugins by alphabetical order so they appear
|
|
//consistently in the menu
|
|
mPlugins.Sort(
|
|
delegate(IAyaNovaPlugin plugin0, IAyaNovaPlugin plugin1)
|
|
{
|
|
return plugin0.PluginName.CompareTo(plugin1.PluginName);
|
|
}
|
|
);
|
|
|
|
|
|
if (mPlugins.Count > 0)
|
|
{
|
|
pluginsLoaded = true;
|
|
debugLog("PLUGINS - The following plugins sucessfully loaded:");
|
|
foreach (IAyaNovaPlugin p in mPlugins)
|
|
debugLog(" - " + p.PluginName + " version: " + p.PluginVersion + " ID: " + p.PluginID);
|
|
}
|
|
else
|
|
debugLog("PLUGINS - No plugins were loaded");
|
|
|
|
}
|
|
|
|
public static void UnloadPluginsEx()
|
|
{
|
|
pluginsLoaded = false;
|
|
if(mPlugins!=null && mPlugins.Count>0)
|
|
{
|
|
System.Text.StringBuilder sbErrors = new StringBuilder();
|
|
foreach(IAyaNovaPlugin p in mPlugins)
|
|
{
|
|
try{
|
|
|
|
p.Close();
|
|
debugLog("PLUGINS - Successfully closed: " + p.PluginName);
|
|
}
|
|
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)
|
|
Error("PLUGINS - Error Unloading plugins", sbErrors.ToString());
|
|
|
|
mPlugins.Clear();
|
|
|
|
}
|
|
}
|
|
#endregion load/unload
|
|
|
|
#region Menu option insertion
|
|
|
|
/// <summary>
|
|
/// Create menu options for plugins if appropriate
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <param name="pmod"></param>
|
|
public static void PluginInsertMenu( UltraToolbarsManager t, PluginMenuOptionData pmod)
|
|
{
|
|
if (!pluginsLoaded) return;
|
|
PluginRemoveMenu(t);
|
|
|
|
PopupMenuTool rootpop = new PopupMenuTool("Pluginsroot");
|
|
rootpop.SharedProps.AppearancesLarge.Appearance.Image = Resource1.Plugin32;
|
|
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)
|
|
{
|
|
|
|
//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;
|
|
b.SharedProps.AppearancesSmall.Appearance.Image = cmd.PluginSmallIcon;
|
|
b.SharedProps.AppearancesLarge.Appearance.Image = cmd.PluginLargeIcon;
|
|
b.ToolClick += new ToolClickEventHandler(Pluginsroot_ToolClick);
|
|
t.Tools.Add(b);
|
|
rootpop.Tools.Add(b);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (rootpop.Tools.Count>0)
|
|
{
|
|
t.Tools.Add(rootpop);
|
|
|
|
if(t.Toolbars.Count>0)
|
|
t.Toolbars[0].Tools.InsertTool(1, "Pluginsroot");
|
|
else
|
|
{
|
|
PopupMenuTool pmt = null;
|
|
//right click popup menu from grid?
|
|
foreach (ToolBase tb in t.Tools)
|
|
{
|
|
if (tb.Key == "POPKEY")
|
|
{
|
|
pmt = (PopupMenuTool)tb;
|
|
break;
|
|
}
|
|
}
|
|
if (pmt!=null)
|
|
{
|
|
|
|
pmt.Tools.AddTool("Pluginsroot");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// User clicked on a plugin in the pluginsroot popup menu
|
|
/// generate a new popup with all the options for that plugin
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private static void Pluginsroot_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
if (AyaBizUtils.TrialExpired || AyaBizUtils.LockedOut)
|
|
{
|
|
MessageBox.Show("An unexpired AyaNova license is required to use plugins");
|
|
return;
|
|
}
|
|
|
|
//Popup a context menu here for the plugin in question
|
|
Point clickpoint=Cursor.Position;
|
|
//create the context menu
|
|
PopupMenuTool p = new PopupMenuTool("PluginCommandsPopup");
|
|
UltraToolbarsManager m = new UltraToolbarsManager();
|
|
m.Tools.Add(p);
|
|
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<AyaNova.PlugIn.AyaNovaPluginMenuItem> list = new System.Collections.Generic.List<AyaNovaPluginMenuItem>();
|
|
|
|
IAyaNovaPlugin PopPlugin = null;
|
|
Guid PopPluginID = new Guid(e.Tool.Key.Split('|')[1]);
|
|
foreach (IAyaNovaPlugin cmd in mPlugins)
|
|
{
|
|
if (cmd.PluginID == PopPluginID)
|
|
{
|
|
PopPlugin = cmd;
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (PopPlugin == null) return;
|
|
|
|
list.Clear();
|
|
if (!pmod.bIsSingleObject)
|
|
list = PopPlugin.MultipleObjectsMenuOptions(pmod.oType);
|
|
else
|
|
list = PopPlugin.SingleObjectMenuOptions(pmod.oType,pmod.oAyaObject);
|
|
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
//New popup here
|
|
debugLog("PLUGINS - Generating popup menu for: " + PopPlugin.PluginName);
|
|
|
|
foreach (AyaNovaPluginMenuItem i in list)
|
|
{
|
|
if (string.IsNullOrEmpty(i.CommandKey) || (string.IsNullOrEmpty(i.Display) && i.MenuItemLargeImage == null && i.MenuItemSmallImage == null))
|
|
continue;
|
|
|
|
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;
|
|
debugLog("PLUGINS - menuitem added: \"" + i.Display + "\" command:" + b.Key);
|
|
if (i.MenuItemSmallImage != null)
|
|
b.SharedProps.AppearancesSmall.Appearance.Image = i.MenuItemSmallImage;
|
|
if (i.MenuItemLargeImage != null)
|
|
b.SharedProps.AppearancesLarge.Appearance.Image = i.MenuItemLargeImage;
|
|
m.Tools.Add(b);
|
|
p.Tools.Add(b);
|
|
}
|
|
|
|
|
|
|
|
m.DockWithinContainer = e.Tool.ToolbarsManager.DockWithinContainer;
|
|
|
|
m.ShowPopup("PluginCommandsPopup",clickpoint);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Remove inserted plugin menu
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
public static void PluginRemoveMenu(UltraToolbarsManager t)
|
|
{
|
|
ArrayList al = new ArrayList();
|
|
foreach (ToolBase tb in t.Tools)
|
|
{
|
|
if (tb.Key.StartsWith("Plugin"))
|
|
al.Add(tb);
|
|
}
|
|
|
|
foreach (object o in al)
|
|
{
|
|
t.Tools.Remove((ToolBase)o);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion menu option insertion
|
|
|
|
#region Plugin command processor
|
|
|
|
private static void Plugincommand_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
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;
|
|
|
|
//cache these settings and reset back after
|
|
//call to plugin, this is to prevent users from
|
|
//writing a plugin that fills the MRU list unnecessarily (like an importer)
|
|
bool AutoMRUWas = AyaBizUtils.AllowAutomaticMRUOnUpdate;
|
|
bool AutoCloseWOStatusWas = AyaBizUtils.AllowAutomaticClosedWorkorderStatus;
|
|
|
|
AyaBizUtils.AllowAutomaticMRUOnUpdate = false;
|
|
AyaBizUtils.AllowAutomaticClosedWorkorderStatus = false;
|
|
|
|
//iterate plugins, find the one that matches then send it the command
|
|
foreach (IAyaNovaPlugin cmd in mPlugins)
|
|
if (cmd.ToString().Equals(s[1], StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
debugLog("PLUGINS - command: " + e.Tool.Key);
|
|
if (pmod.bIsSingleObject)
|
|
cmd.CommandSelectedForSingleObject(s[2], pmod.oType, pmod.oAyaObject);
|
|
else
|
|
{
|
|
if (pmod.oAyaObject is MainGrid)
|
|
{
|
|
MainGrid m = (MainGrid)pmod.oAyaObject;
|
|
if (cmd.CommandSelectedForList(s[2], m.BaseObjectType, m.SelectedIDList, m.ListObject))
|
|
m.BindData(true);
|
|
}
|
|
else
|
|
{
|
|
ScheduleFormEx sfex=(ScheduleFormEx)pmod.oAyaObject;
|
|
cmd.CommandSelectedForList(s[2], RootObjectTypes.Schedule, sfex.VisibleUsers, sfex.SelectedAppointments);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
AyaBizUtils.AllowAutomaticMRUOnUpdate = AutoMRUWas;
|
|
AyaBizUtils.AllowAutomaticClosedWorkorderStatus = AutoCloseWOStatusWas;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct PluginMenuOptionData
|
|
{
|
|
public PluginMenuOptionData(bool SingleObject, RootObjectTypes ObjectType, object AyaObject, System.Collections.Generic.List<Guid> IDList)
|
|
{
|
|
bIsSingleObject = SingleObject;
|
|
oType = ObjectType;
|
|
oAyaObject = AyaObject;
|
|
objectIDList = IDList;
|
|
}
|
|
|
|
public bool bIsSingleObject;
|
|
public RootObjectTypes oType;
|
|
public object oAyaObject;
|
|
public System.Collections.Generic.List<Guid> objectIDList;
|
|
}
|
|
|
|
|
|
|
|
#endregion menu command processing
|
|
|
|
|
|
#region Plugin diagnostic info
|
|
/// <summary>
|
|
/// Plugin list for tech support info and diagnostics
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string PluginsList()
|
|
{
|
|
if (mPlugins == null) return string.Empty;
|
|
|
|
if (mPlugins.Count < 1)
|
|
return "\tNO PLUGINS LOADED";
|
|
|
|
System.Text.StringBuilder sb = new StringBuilder();
|
|
sb.AppendLine("\tPlugins loaded:");
|
|
string sName = string.Empty;
|
|
foreach (IAyaNovaPlugin p in mPlugins)
|
|
{
|
|
sb.Append("\t\t");
|
|
try
|
|
{
|
|
sName = p.PluginName;
|
|
sb.AppendLine(p.About.Replace("\r\n"," ") + " v" + p.PluginVersion);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.ToString();
|
|
sb.AppendLine(sName + " - did not report full info");
|
|
}
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
#endregion diag info
|
|
|
|
#endregion plugins
|
|
|
|
#region efficiency :)
|
|
//removed as per case 1572
|
|
|
|
//put back in as per case 1701
|
|
/// <summary>
|
|
/// This exists solely for the purpose of end users who
|
|
/// don't understand how .net memory allocation works, run AyaNova,
|
|
/// go and look in the task manager and throw a hissy fit about how AyaNova is a
|
|
/// memory hog when in fact it's only really needs about 7mb but the .net winform
|
|
/// "gunk" at startup makes it appear to be using 80mb or more.
|
|
/// </summary>
|
|
public static void EmptyWorkingSet()//int lnMaxSize, int lnMinSize
|
|
{
|
|
try
|
|
{
|
|
System.Diagnostics.Process loProcess = System.Diagnostics.Process.GetCurrentProcess();
|
|
loProcess.MaxWorkingSet = loProcess.MaxWorkingSet;//doesn't matter what you set it to, just setting it triggers
|
|
}
|
|
catch { };
|
|
|
|
//long lnValue = loProcess.WorkingSet; // see what the actual value
|
|
}
|
|
#endregion
|
|
|
|
#region Help url
|
|
|
|
//case 1172
|
|
public static string BaseHelpUrl
|
|
{
|
|
get
|
|
{
|
|
if(AyaBizUtils.Lite)
|
|
return @"https://www.ayanova.com/AyaNovaLite7webHelp/";
|
|
|
|
return @"https://www.ayanova.com/AyaNova7webHelp/";
|
|
}
|
|
}
|
|
#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
|
|
//and forced it from the rightmost position e.g. case 1252
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("REMOVE"))
|
|
Grid.DisplayLayout.Bands[0].Columns.Remove("REMOVE");
|
|
Grid.DisplayLayout.Bands[0].Columns.Add("REMOVE", "");
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Hidden = false;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Header.Caption = "";
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].CellButtonAppearance.Image = Resource1.Delete16;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].CellButtonAppearance.ImageHAlign = HAlign.Center;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].CellButtonAppearance.ImageVAlign = VAlign.Middle;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Header.Appearance.Image = Resource1.Delete16;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Header.Appearance.ImageHAlign = HAlign.Center;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].Width = 24;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].MinWidth = 24;
|
|
Grid.DisplayLayout.Bands[0].Columns["REMOVE"].MaxWidth = 24;
|
|
|
|
//case 1430
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.True;
|
|
|
|
}
|
|
|
|
static public void GridRemoveDeleteButton(Infragistics.Win.UltraWinGrid.UltraGrid Grid)
|
|
{
|
|
if (Grid.DisplayLayout.Bands[0].Columns.Exists("REMOVE"))
|
|
Grid.DisplayLayout.Bands[0].Columns.Remove("REMOVE");
|
|
//case 1430
|
|
Grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
|
|
}
|
|
#endregion
|
|
|
|
#region Show All... menu options (case 1122)
|
|
public static void ShowAllInsertMenu(UltraToolbarsManager t, TypeAndID sourceTid, Form theForm)
|
|
{
|
|
ShowAllRemoveMenu(t);
|
|
PopupMenuTool rootpop = new PopupMenuTool("ShowAllroot");
|
|
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
|
|
{
|
|
if (sourceTid.RootObjectType != RootObjectTypes.Unit)//don't show a unit's list for a unit
|
|
ShowAllInsertMenuItem(t, rootpop, "Unit.Label.List", sourceTid);
|
|
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");
|
|
}
|
|
}
|
|
|
|
private static void ShowAllInsertMenuItem(UltraToolbarsManager t, PopupMenuTool rootpop, string KeyCaption, TypeAndID tid)
|
|
{
|
|
ButtonTool b = new ButtonTool("ShowAll"+KeyCaption);
|
|
b.SharedProps.Caption = LocaleText.GetLocalizedText(KeyCaption);
|
|
b.SharedProps.DisplayStyle = ToolDisplayStyle.TextOnlyAlways;
|
|
b.SharedProps.Tag = tid;
|
|
b.ToolClick += new ToolClickEventHandler(ShowAll_ToolClick);
|
|
t.Tools.Add(b);
|
|
rootpop.Tools.Add(b);
|
|
}
|
|
|
|
|
|
public static void ShowAllRemoveMenu(UltraToolbarsManager t)
|
|
{
|
|
ArrayList al = new ArrayList();
|
|
foreach (ToolBase tb in t.Tools)
|
|
{
|
|
if (tb.Key.StartsWith("ShowAll"))
|
|
al.Add(tb);
|
|
}
|
|
|
|
foreach (object o in al)
|
|
{
|
|
t.Tools.Remove((ToolBase)o);
|
|
}
|
|
}
|
|
|
|
private static void ShowAll_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
TypeAndID tid = ((TypeAndID)e.Tool.SharedProps.Tag);
|
|
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)
|
|
{
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_O_Client\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aClient.aID\" UICOMPAREVALUE=\"" +
|
|
NameFetcher.GetItem("aClient", "aName", tid.ID).RecordName.Replace("&", "&") +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> \r\n";
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Service"];
|
|
gGridLastViews["WorkorderServiceList"].SubstituteCriteria = crit;
|
|
frmMain.ShowForm("LT:UI.Go.Service", "LT:WorkorderService.Label.List", true);
|
|
frmMain.MainServiceTree.Nodes["LT:WorkorderService.Label.List"].Selected = true;
|
|
}
|
|
else if (tid.RootObjectType == RootObjectTypes.LoanItem)//case 3158
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("<WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_WorkorderItemLoan_Label_LoanItem\">");
|
|
sb.Append("\r\n");
|
|
sb.Append("\t<WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItemLoan.aLoanItemID\" UICOMPAREVALUE=\"");
|
|
//It shouldn't matter what name is in uicomparevalue
|
|
//but it sure crashes if it retrieves a 58" tool because of the quote so just
|
|
//put static text there instead
|
|
sb.Append("LOANITEM");
|
|
sb.Append("\" TYPE=\"System.Guid\" COMPAREVALUE=\"{");
|
|
sb.Append(tid.ID.ToString().ToUpper());
|
|
sb.Append("}\" />\r\n");
|
|
sb.Append("</WHEREITEMGROUP>");
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
gGridLastViews["WorkorderServiceLoanList"].SubstituteCriteria = sb.ToString();
|
|
frmMain.ShowForm("LT:UI.Go.Service", "LT:WorkorderItem.Label.Loans", true);
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Service"];
|
|
frmMain.MainServiceTree.Nodes["LT:WorkorderService.Label.List"].Nodes["LT:WorkorderItem.Label.List"].Nodes["LT:WorkorderItem.Label.Loans"].Selected = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
//it's a unit
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Unit_Label_Serial\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItem.aUnitID\" UICOMPAREVALUE=\"" +
|
|
UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> ";
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
gGridLastViews["WorkorderServiceItemList"].SubstituteCriteria = crit;
|
|
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;
|
|
|
|
}
|
|
#endregion show service workorders list
|
|
}
|
|
else if (e.Tool.Key.Contains("WorkorderQuote.Label.List"))//show Quotes
|
|
{
|
|
#region Show Quote list
|
|
if (tid.RootObjectType == RootObjectTypes.Client)
|
|
{
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_O_Client\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aClient.aID\" UICOMPAREVALUE=\"" +
|
|
NameFetcher.GetItem("aClient", "aName", tid.ID).RecordName.Replace("&", "&") +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> \r\n";
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Quotes"];
|
|
gGridLastViews["WorkorderQuoteList"].SubstituteCriteria = crit;
|
|
frmMain.ShowForm("LT:UI.Go.Quotes", "LT:WorkorderQuote.Label.List", true);
|
|
frmMain.MainQuoteTree.Nodes["LT:WorkorderQuote.Label.List"].Selected = true;
|
|
}
|
|
else
|
|
{
|
|
//it's a unit
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Unit_Label_Serial\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItem.aUnitID\" UICOMPAREVALUE=\"" +
|
|
UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> ";
|
|
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
gGridLastViews["WorkorderQuoteItemList"].SubstituteCriteria = crit;
|
|
frmMain.ShowForm("LT:UI.Go.Quotes", "LT:WorkorderItem.Label.ListQuote", true);
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.Quotes"];
|
|
frmMain.MainQuoteTree.Nodes["LT:WorkorderQuote.Label.List"].Nodes["LT:WorkorderItem.Label.ListQuote"].Selected = true;
|
|
|
|
}
|
|
#endregion show quote workorders list
|
|
}
|
|
else if (e.Tool.Key.Contains("WorkorderPreventiveMaintenance.Label.List"))//show PM's
|
|
{
|
|
#region Show PM list
|
|
if (tid.RootObjectType == RootObjectTypes.Client)
|
|
{
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_O_Client\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aClient.aID\" UICOMPAREVALUE=\"" +
|
|
NameFetcher.GetItem("aClient", "aName", tid.ID).RecordName.Replace("&", "&") +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> \r\n";
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.PreventiveMaintenance"];
|
|
gGridLastViews["WorkorderPMList"].SubstituteCriteria = crit;
|
|
frmMain.ShowForm("LT:UI.Go.PreventiveMaintenance", "LT:WorkorderPreventiveMaintenance.Label.List", true);
|
|
frmMain.MainPMTree.Nodes["LT:WorkorderPreventiveMaintenance.Label.List"].Selected = true;
|
|
}
|
|
else
|
|
{
|
|
//it's a unit
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Unit_Label_Serial\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItem.aUnitID\" UICOMPAREVALUE=\"" +
|
|
UnitNameFetcher.GetUnitNameFromUnitID(tid.ID) +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> ";
|
|
|
|
frmMain.ForceNavPaneTreesUpdate();
|
|
gGridLastViews["WorkorderPMItemList"].SubstituteCriteria = crit;
|
|
frmMain.ShowForm("LT:UI.Go.PreventiveMaintenance", "LT:WorkorderItem.Label.ListPM", true);
|
|
frmMain.UltraExplorerBar1.SelectedGroup = frmMain.UltraExplorerBar1.Groups["LT:UI.Go.PreventiveMaintenance"];
|
|
frmMain.MainPMTree.Nodes["LT:WorkorderPreventiveMaintenance.Label.List"].Nodes["LT:WorkorderItem.Label.ListPM"].Selected = true;
|
|
|
|
}
|
|
#endregion show pm workorders list
|
|
}
|
|
else if (e.Tool.Key.Contains("Unit.Label.List"))//show Units owned by this client
|
|
{
|
|
#region Show Unit list
|
|
if (tid.RootObjectType == RootObjectTypes.Client)
|
|
{
|
|
crit = " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_O_Client\"> \r\n" +
|
|
" <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aChildUnits.aClientID\" UICOMPAREVALUE=\"" +
|
|
NameFetcher.GetItem("aClient", "aName", tid.ID).RecordName.Replace("&", "&") +
|
|
"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + tid.ID.ToString().ToUpper() + "}\" /> \r\n" +
|
|
" </WHEREITEMGROUP> \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
|
|
}
|
|
|
|
//close the caller so the user can see the list
|
|
if (theForm.Name == "ClientInfoForm" || theForm.Name == "UnitInfoForm" || theForm.Name == "LoanItemInfoForm")
|
|
theForm.Close();
|
|
else
|
|
theForm.WindowState = FormWindowState.Minimized;
|
|
}
|
|
#endregion Show all menu options
|
|
|
|
#region Localization helper
|
|
|
|
#region Locale keyXform cache
|
|
private static System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> localizeHelperFormKeyCache = null;
|
|
private static System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> LocalizeHelperFormKeyCache
|
|
{
|
|
get
|
|
{
|
|
if(localizeHelperFormKeyCache==null)
|
|
localizeHelperFormKeyCache = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>();
|
|
|
|
return localizeHelperFormKeyCache;
|
|
}
|
|
}
|
|
#endregion keycache
|
|
static bool LocalizeHelperUserCanLocalize = false;
|
|
//case 1810
|
|
/// <summary>
|
|
/// This is the first call from the form so gather keys here as well as insert menu
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <param name="theForm"></param>
|
|
public static void LocalizeHelperInsertMenu(UltraToolbarsManager t, Form theForm)
|
|
{
|
|
LocalizeHelperRemoveMenu(t);
|
|
|
|
//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
|
|
//Check to see if form fields have been cached, if not then do so
|
|
if (!LocalizeHelperFormKeyCache.ContainsKey(theForm.Name))
|
|
LocalizeHelperSuckOutKeys(theForm.Name, theForm);
|
|
|
|
//Insert menu option to localize keys
|
|
ButtonTool b = new ButtonTool("LocalizeHelper");
|
|
b.SharedProps.Caption = LocaleText.GetLocalizedText("Locale.Label.CustomizeText");
|
|
b.SharedProps.DisplayStyle = ToolDisplayStyle.TextOnlyAlways;
|
|
b.SharedProps.Tag = theForm.Name;
|
|
b.ToolClick += new ToolClickEventHandler(LocalizeHelper_ToolClick);
|
|
t.Tools.Add(b);
|
|
UltraToolbar hostToolbar = t.Toolbars[0];
|
|
hostToolbar.Tools.AddTool("LocalizeHelper");
|
|
|
|
}
|
|
|
|
public static void LocalizeHelperRemoveMenu(UltraToolbarsManager t)
|
|
{
|
|
ArrayList al = new ArrayList();
|
|
foreach (ToolBase tb in t.Tools)
|
|
{
|
|
if (tb.Key.StartsWith("LocalizeHelper"))
|
|
al.Add(tb);
|
|
}
|
|
|
|
foreach (object o in al)
|
|
{
|
|
t.Tools.Remove((ToolBase)o);
|
|
}
|
|
}
|
|
|
|
|
|
private static void LocalizeHelper_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
|
{
|
|
//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)");
|
|
|
|
}
|
|
|
|
#region Suck out keys from forms and controls
|
|
|
|
private static void LocalizeHelperInsertKeyInCache(string formname, string localekey)
|
|
{
|
|
localekey = localekey.Replace("LT:", "");
|
|
if (!LocalizeHelperFormKeyCache.ContainsKey(formname))
|
|
{
|
|
LocalizeHelperFormKeyCache.Add(formname, new System.Collections.Generic.List<string>());
|
|
}
|
|
if (!LocalizeHelperFormKeyCache[formname].Contains(localekey))
|
|
LocalizeHelperFormKeyCache[formname].Add(localekey);
|
|
}
|
|
|
|
#region Control (generic)
|
|
private static void LocalizeHelperSuckOutKeys(string formNameKey, Control c)
|
|
{
|
|
if (c.Text.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, c.Text);
|
|
|
|
//==================================
|
|
|
|
|
|
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)
|
|
if (vi.DisplayText.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, vi.DisplayText);
|
|
|
|
//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;
|
|
LocalizeHelperSuckOutKeys(formNameKey, 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:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, n.Text);
|
|
LocalizeHelperSuckOutKeys(formNameKey, n);
|
|
}
|
|
return;
|
|
#endregion
|
|
}
|
|
|
|
if (c is Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)
|
|
LocalizeHelperSuckOutKeys(formNameKey, ((Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea)c).ToolbarsManager);
|
|
|
|
if (c is Infragistics.Win.UltraWinGrid.UltraGrid)
|
|
LocalizeHelperSuckOutKeys(formNameKey, (Infragistics.Win.UltraWinGrid.UltraGrid)c);
|
|
|
|
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:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, ut.Text);
|
|
LocalizeHelperSuckOutKeys(formNameKey, ut);
|
|
}
|
|
|
|
|
|
if (c is ToolStrip)
|
|
{
|
|
foreach (ToolStripItem i in ((ToolStrip)c).Items)
|
|
{
|
|
if (i.Text != null && i.Text.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, i.Text);
|
|
|
|
if (i is ToolStripDropDownButton)
|
|
{
|
|
ToolStripDropDownButton b = (ToolStripDropDownButton)i;
|
|
foreach (ToolStripItem di in b.DropDownItems)
|
|
{
|
|
if (di.Text != null && di.Text.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, di.Text);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//===================================
|
|
foreach (Control c2 in c.Controls)
|
|
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)
|
|
foreach (Control cc in BarGroup.Container.Controls)
|
|
LocalizeHelperSuckOutKeys(formNameKey, cc);
|
|
else
|
|
foreach (Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarItem BarItem in BarGroup.Items)
|
|
if (BarItem.Key.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, BarItem.Key);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region TreeNodes (recursive)
|
|
static public void LocalizeHelperSuckOutKeys(string formNameKey, Infragistics.Win.UltraWinTree.UltraTreeNode t)
|
|
{
|
|
foreach (Infragistics.Win.UltraWinTree.UltraTreeNode n in t.Nodes)
|
|
{
|
|
if (n.Text.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, n.Text);
|
|
|
|
LocalizeHelperSuckOutKeys(formNameKey, n);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid
|
|
|
|
static public void LocalizeHelperSuckOutKeys(string formNameKey, Infragistics.Win.UltraWinGrid.UltraGrid Grid)
|
|
{
|
|
//this is here because this may be called directly by a form where the grids are lazy initialized (workorder for example)
|
|
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)
|
|
if (cm.Header.Caption.StartsWith("LT_"))
|
|
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);
|
|
}
|
|
#endregion
|
|
|
|
#region ToolBarManager
|
|
|
|
static public void LocalizeHelperSuckOutKeys(string formNameKey, Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbm)
|
|
{
|
|
foreach (Infragistics.Win.UltraWinToolbars.UltraToolbar tb in tbm.Toolbars)
|
|
if (tb.Key.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, tb.Key);
|
|
|
|
//Localize individual tool items
|
|
foreach (Infragistics.Win.UltraWinToolbars.ToolBase tbase in tbm.Tools)
|
|
{
|
|
if (tbase.Key.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, tbase.Key);
|
|
|
|
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:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, lbt.Key);
|
|
}
|
|
else if (sub is Infragistics.Win.UltraWinToolbars.StateButtonTool)
|
|
{
|
|
Infragistics.Win.UltraWinToolbars.StateButtonTool lbt = (Infragistics.Win.UltraWinToolbars.StateButtonTool)sub;
|
|
if (lbt.Key.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, lbt.Key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#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.DockablePaneBase dpb in dap.Panes)
|
|
{
|
|
if (dpb.TextTab.StartsWith("LT:"))
|
|
LocalizeHelperInsertKeyInCache(formNameKey, dpb.TextTab);
|
|
|
|
if (dpb is Infragistics.Win.UltraWinDock.DockableControlPane)
|
|
LocalizeHelperSuckOutKeys(formNameKey, ((Infragistics.Win.UltraWinDock.DockableControlPane)dpb).Control);
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#endregion suck out keys
|
|
|
|
#endregion localization helper
|
|
|
|
|
|
#region Password redactor
|
|
//case 3589
|
|
|
|
/////////////////////////////////////////////
|
|
////clean out password from connection string
|
|
////for log purposes
|
|
internal static string RedactPasswords(string cs)
|
|
{
|
|
return System.Text.RegularExpressions.Regex.Replace(cs, "Password\\s*=.*?;", "Password=[REDACTED]", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
|
}
|
|
|
|
|
|
#endregion
|
|
//------------------------------------------
|
|
|
|
|
|
}// EOC
|
|
|
|
|
|
#region randomtext generator
|
|
/// <summary>
|
|
/// Generate random text.
|
|
/// </summary>
|
|
public class RandomText
|
|
{
|
|
/// <summary>
|
|
/// Stores random number sequence.
|
|
/// </summary>
|
|
static Random _random = new Random();
|
|
|
|
/// <summary>
|
|
/// Contains buffer.
|
|
/// </summary>
|
|
StringBuilder _builder;
|
|
|
|
/// <summary>
|
|
/// Set of words you want to add.
|
|
/// </summary>
|
|
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",
|
|
"consequat","euismod","suspendisse","sed","nibh","eget","enim",
|
|
"aliquam","varius","id","sit","amet","lectus","aenean","fringilla",
|
|
"diam","at","augue","posuere","eleifend","quisque","a","tortor",
|
|
"leo","mauris","auctor","dapibus","est,","at","rhoncus","odio",
|
|
"cursus","vitae","sed","suscipit","mauris","vitae","justo","blandit",
|
|
"quis","vestibulum","turpis","rutrum","praesent","tincidunt",
|
|
"dui","nec","elit","mollis","fermentum","donec","volutpat",
|
|
"quam","non","massa","congue","tincidunt","vestibulum","eget","sem",
|
|
"nullam","purus","dui,","adipiscing","vitae","consequat","vitae",
|
|
"scelerisque","a","justo","sed","porttitor","metus","sed",
|
|
"est","aliquet","mollis","mauris","arcu","diam,","viverra","vel",
|
|
"semper","at","tempor","sit","amet","tellus","aenean","ac","aliquam",
|
|
"diam","vestibulum","varius","tristique","mauris","porta",
|
|
"gravida","praesent","urna","nibh,","dignissim","accumsan","molestie",
|
|
"et","mattis","eu","libero","suspendisse","fringilla",
|
|
"diam","quis","lectus","feugiat","quis","congue","leo","feugiat",
|
|
"proin","facilisis","enim","elementum","condimentum","vestibulum,",
|
|
"justo","quam","iaculis","nulla","sit","amet","viverra",
|
|
"tortor","lacus","et","magna","cras","fermentum","dictum","egestas",
|
|
"vestibulum","sit","amet","massa","at","lorem","cursus","laoreet",
|
|
"ac","eget","mauris","mauris","porttitor","pretium","metus",
|
|
"non","eleifend","mauris","scelerisque","sed","etiam","nec",
|
|
"vehicula","nisi","morbi","mattis","aliquam","felis","sed","ornare",
|
|
"elit","posuere","nec","suspendisse","et","est","nec","justo",
|
|
"dictum","pharetra","non","hendrerit","nibh","quisque","dictum",
|
|
"mauris","id","felis","porta","iaculis","donec","adipiscing",
|
|
"justo","ut","diam","consectetur","condimentum","ut","a","nibh","vitae",
|
|
"neque","dignissim","pharetra","integer","sed","purus","in",
|
|
"nunc","feugiat","sodales","id","ac","ligula","praesent","sed",
|
|
"tortor","ut","magna","dapibus","porttitor","vel","ac","ligula","in",
|
|
"cursus","ante","nec","nisl","ullamcorper","convallis","nullam",
|
|
"eros","erat,","ullamcorper","vitae","aliquam","vitae,","condimentum",
|
|
"nec","turpis","sed","eu","risus","eros","maecenas","odio",
|
|
"velit","convallis","eu","feugiat","in","auctor","sapien",
|
|
"quisque","elementum","risus","non","sapien","posuere","tempus",
|
|
"mollis","metus","hendrerit","maecenas","euismod","accumsan",
|
|
"justo","viverra","maecenas","consectetur","felis",
|
|
"accumsan","tincidunt","sagittis,","an",
|
|
"gracess","thin","ruirm","faty",
|
|
"fate","truse","condam","ords",
|
|
"auth","poths","beinion","hora",
|
|
"recone","quarms","upon","verones",
|
|
"wour","unds","notle","hortue",
|
|
"preate","hite","garmelf","dispase",
|
|
"unish","unine","anowich","shower",
|
|
"bonder","nath","town","thoure",
|
|
"auther","arothe","agan","shose",
|
|
"ablam","bancle","dounks","knain",
|
|
"sorril","coveraw","'downs","hear",
|
|
"ladnes","madle","hisom","slight",
|
|
"noths","'cape","rided","titled",
|
|
"ambs","befend","unfect","infit",
|
|
"seak","affich","edmunt","sweek",
|
|
"comill","unpospeak","thers","trow",
|
|
"othe","afty","exprow","deade",
|
|
"exeunds","dish","aidst","speats",
|
|
"rate","ever'st","breful","beth",
|
|
"smelembs","tardery","hout","moned",
|
|
"fraved","rides","entend","advant",
|
|
"abunes","knign","whous","plasts",
|
|
"risort-up","engunt","hannacks","foxcon",
|
|
"stor","mign","flaign","dred",
|
|
"ampubtic","ingdom","chee","thady"};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Initialize new random text class.
|
|
/// </summary>
|
|
/// <param name="words">Collection of words you want to choose from.</param>
|
|
public RandomText()
|
|
{
|
|
_builder = new StringBuilder();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add paragraphs of jumbled sentences.
|
|
/// </summary>
|
|
/// <param name="numberParagraphs">The number of paragraphs.</param>
|
|
/// <param name="minSentences">Minimum number of sentences in a paragraph.</param>
|
|
/// <param name="maxSentences">Maximum number of sentences in a paragraph.</param>
|
|
/// <param name="minWords">Minimum number of words in a sentence.</param>
|
|
/// <param name="maxWords">Maximum number of words in a sentence.</param>
|
|
public string GetRandomText(int numberParagraphs, int minSentences,
|
|
int maxSentences, int minWords, int maxWords)
|
|
{
|
|
_builder.Length = 0;
|
|
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");
|
|
}
|
|
return _builder.ToString();
|
|
|
|
}
|
|
|
|
public string GetRandomSentence(int nWords)
|
|
{
|
|
_builder.Length = 0;
|
|
AddSentence(nWords);
|
|
return _builder.ToString();
|
|
}
|
|
/// <summary>
|
|
/// Add single pararaph consisting of several sentences.
|
|
/// </summary>
|
|
void AddParagraph(int numberSentences, int minWords, int maxWords)
|
|
{
|
|
for (int i = 0; i < numberSentences; i++)
|
|
{
|
|
int count = _random.Next(minWords, maxWords + 1);
|
|
AddSentence(count);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add single sentence consisting of several random words.
|
|
/// </summary>
|
|
void AddSentence(int numberWords)
|
|
{
|
|
StringBuilder b = new StringBuilder();
|
|
// Add n words together.
|
|
for (int i = 0; i < numberWords; i++) // Number of words
|
|
{
|
|
b.Append(_words[_random.Next(_words.Length)]).Append(" "); // Random word
|
|
}
|
|
string sentence = b.ToString().Trim() + ". ";
|
|
// Uppercase sentence
|
|
sentence = char.ToUpper(sentence[0]) + sentence.Substring(1);
|
|
// Add this sentence to the class
|
|
_builder.Append(sentence);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Text content of random class.
|
|
/// </summary>
|
|
public string Content
|
|
{
|
|
get
|
|
{
|
|
return _builder.ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion randomtextgenerator
|
|
|
|
|
|
#region Form font fixer
|
|
|
|
//case 2108 - this appears to be obsolete as fonts look better when it's not called
|
|
//so basically just removing calls to it
|
|
public static class FormFontFixer
|
|
{
|
|
//This list contains the fonts we want to replace.
|
|
static readonly System.Collections.Generic.List<string> FontReplaceList
|
|
= new System.Collections.Generic.List<string>(new string[] { "Microsoft Sans Serif", "Tahoma" });
|
|
|
|
|
|
static Font _DefaultFont;
|
|
static bool _CanFixFonts;
|
|
|
|
|
|
static FormFontFixer()
|
|
{
|
|
//case 2108, do nothing
|
|
//return;
|
|
|
|
//Basically the font name we want to use should be easy to choose by using the SystemFonts class. However, this class
|
|
//is hard-coded (!!) and doesn't seem to work right. On XP, it will mostly return "Microsoft Sans Serif" except
|
|
//for the DialogFont property (=Tahoma) but on Vista, this class will return "Tahoma" instead of "SegoiUI" for this property!
|
|
|
|
//Therefore we will do the following: If we are running on a OS below XP, we will exit because the only font available
|
|
//will be MS Sans Serif. On XP, we gonna use "Tahoma", and any other OS we will use the value of the MessageBoxFont
|
|
//property because this seems to be set correctly on Vista an above.
|
|
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
|
|
{
|
|
//95, 98 and other crap
|
|
_CanFixFonts = false;
|
|
return;
|
|
}
|
|
|
|
if (Environment.OSVersion.Version.Major < 5)
|
|
{
|
|
//Windows NT
|
|
_CanFixFonts = false;
|
|
return;
|
|
}
|
|
|
|
if (Environment.OSVersion.Version.Major < 6)
|
|
{
|
|
//Windows 2000 (5.0), Windows XP (5.1), Windows Server 2003 and XP Pro x64 Edtion v2003 (5.2)
|
|
_CanFixFonts = true;
|
|
_DefaultFont = SystemFonts.DialogFont; //Tahoma hopefully
|
|
}
|
|
else
|
|
{
|
|
//Vista and above
|
|
_CanFixFonts = true;
|
|
_DefaultFont = SystemFonts.MessageBoxFont; //should be SegoiUI
|
|
}
|
|
}
|
|
|
|
public static void Fix(Control controlToFix)
|
|
{
|
|
//If we can't fix the font, exit
|
|
if (_CanFixFonts == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
//Now start with the real work...
|
|
foreach (Control c in controlToFix.Controls)
|
|
{
|
|
if (c.Controls.Count > 0) Fix(c);
|
|
//only replace fonts that use one the "system fonts" we have declared
|
|
if (FontReplaceList.IndexOf(c.Font.Name) > -1)
|
|
{
|
|
//Now check the size, when the size is 9 or below it's the default font size and we do not keep the size since
|
|
//SegoiUI has a complete different spacing (and thus size) than MS SansS or Tahoma.
|
|
|
|
//Also check if there are any styles applied on the font (e.g. Italic) which we need to apply to the new
|
|
//font as well.
|
|
|
|
bool bUseDefaultSize = true;
|
|
bool bUseDefaultStyle = true;
|
|
|
|
//is this a special size?
|
|
if ((c.Font.Size <= 8) || (c.Font.Size >= 9))
|
|
{
|
|
bUseDefaultSize = false;
|
|
}
|
|
|
|
//are any special styles (bold, italic etc.) applied to this font?
|
|
if ((c.Font.Italic == true) ||
|
|
(c.Font.Strikeout == true) ||
|
|
(c.Font.Underline == true) ||
|
|
(c.Font.Bold == true))
|
|
{
|
|
bUseDefaultStyle = false;
|
|
}
|
|
|
|
//if everything is set to defaults, we can use our prepared font right away
|
|
if ((bUseDefaultSize == true) && (bUseDefaultStyle == true))
|
|
{
|
|
c.Font = _DefaultFont;
|
|
}
|
|
else
|
|
{
|
|
//There are non default properties set so
|
|
//there is some work we need to do...
|
|
|
|
|
|
//Restrive custom font style
|
|
FontStyle Style = FontStyle.Regular;
|
|
if (bUseDefaultStyle == false)
|
|
{
|
|
if (c.Font.Italic)
|
|
{
|
|
Style = Style | FontStyle.Italic;
|
|
}
|
|
if (c.Font.Strikeout)
|
|
{
|
|
Style = Style | FontStyle.Strikeout;
|
|
}
|
|
if (c.Font.Underline)
|
|
{
|
|
Style = Style | FontStyle.Underline;
|
|
}
|
|
if (c.Font.Bold)
|
|
{
|
|
Style = Style | FontStyle.Bold;
|
|
}
|
|
}
|
|
|
|
//Retrive custom size
|
|
float fFontSize = _DefaultFont.SizeInPoints;
|
|
if (bUseDefaultSize == false)
|
|
{
|
|
fFontSize = c.Font.SizeInPoints;
|
|
|
|
}
|
|
|
|
//Finally apply this font...
|
|
Font font = new Font(_DefaultFont.Name, fFontSize, Style, GraphicsUnit.Point);
|
|
c.Font = font;
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion form font fixer
|
|
|
|
|
|
|
|
}//EONS
|