This commit is contained in:
789
source/WinFormApp/LocaleInfoForm.cs
Normal file
789
source/WinFormApp/LocaleInfoForm.cs
Normal file
@@ -0,0 +1,789 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using Infragistics.Win;
|
||||
using Infragistics.Win.UltraWinGrid;
|
||||
using Infragistics.Win.UltraWinToolbars;
|
||||
using log4net;
|
||||
using System.Globalization;
|
||||
|
||||
|
||||
namespace AyaNova
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for LocaleInfoForm.
|
||||
/// </summary>
|
||||
public class LocaleInfoForm : System.Windows.Forms.Form
|
||||
{
|
||||
// Create a logger for use in this class
|
||||
//case 1039 private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private System.Windows.Forms.CheckBox ckIsDirty;
|
||||
private System.Windows.Forms.ErrorProvider ErrorProvider;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsManager tbManager;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _LocaleInfoForm_Toolbars_Dock_Area_Left;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _LocaleInfoForm_Toolbars_Dock_Area_Right;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _LocaleInfoForm_Toolbars_Dock_Area_Top;
|
||||
private Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea _LocaleInfoForm_Toolbars_Dock_Area_Bottom;
|
||||
private Infragistics.Win.UltraWinGrid.UltraGrid grid;
|
||||
private System.Windows.Forms.SaveFileDialog dlgSave;
|
||||
private System.Windows.Forms.HelpProvider helpProvider1;
|
||||
private System.ComponentModel.IContainer components;
|
||||
|
||||
|
||||
public LocaleInfoForm()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
Infragistics.Win.UltraWinToolbars.UltraToolbar ultraToolbar1 = new Infragistics.Win.UltraWinToolbars.UltraToolbar("LocaleEntryMenuBar");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Label.FindAndReplace");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Locale.Label.Export");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool3 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveClose");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool4 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool5 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Delete");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool6 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Close");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool7 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.SaveClose");
|
||||
Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
|
||||
Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool8 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Save");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool9 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Close");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool10 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Label.FindAndReplace");
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool11 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:UI.Command.Delete");
|
||||
Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
|
||||
Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
|
||||
Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool12 = new Infragistics.Win.UltraWinToolbars.ButtonTool("LT:Locale.Label.Export");
|
||||
this.ckIsDirty = new System.Windows.Forms.CheckBox();
|
||||
this.tbManager = new Infragistics.Win.UltraWinToolbars.UltraToolbarsManager(this.components);
|
||||
this.ErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom = new Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea();
|
||||
this.grid = new Infragistics.Win.UltraWinGrid.UltraGrid();
|
||||
this.dlgSave = new System.Windows.Forms.SaveFileDialog();
|
||||
this.helpProvider1 = new System.Windows.Forms.HelpProvider();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbManager)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ckIsDirty
|
||||
//
|
||||
this.ckIsDirty.Location = new System.Drawing.Point(-336, 28);
|
||||
this.ckIsDirty.Name = "ckIsDirty";
|
||||
this.ckIsDirty.Size = new System.Drawing.Size(199, 27);
|
||||
this.ckIsDirty.TabIndex = 5;
|
||||
//
|
||||
// tbManager
|
||||
//
|
||||
this.tbManager.DesignerFlags = 1;
|
||||
this.tbManager.DockWithinContainer = this;
|
||||
this.tbManager.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form);
|
||||
this.tbManager.ShowFullMenusDelay = 500;
|
||||
ultraToolbar1.DockedColumn = 0;
|
||||
ultraToolbar1.DockedRow = 0;
|
||||
ultraToolbar1.NonInheritedTools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
||||
buttonTool1,
|
||||
buttonTool2,
|
||||
buttonTool3,
|
||||
buttonTool4,
|
||||
buttonTool5,
|
||||
buttonTool6});
|
||||
ultraToolbar1.Text = "LocaleEntryMenuBar";
|
||||
this.tbManager.Toolbars.AddRange(new Infragistics.Win.UltraWinToolbars.UltraToolbar[] {
|
||||
ultraToolbar1});
|
||||
this.tbManager.ToolbarSettings.AllowCustomize = Infragistics.Win.DefaultableBoolean.False;
|
||||
this.tbManager.ToolbarSettings.AllowFloating = Infragistics.Win.DefaultableBoolean.False;
|
||||
this.tbManager.ToolbarSettings.AllowHiding = Infragistics.Win.DefaultableBoolean.False;
|
||||
buttonTool7.SharedPropsInternal.AccessibleDescription = "recorddd";
|
||||
appearance1.Image = global::AyaNova.Resource1.SaveExit32;
|
||||
buttonTool7.SharedPropsInternal.AppearancesLarge.Appearance = appearance1;
|
||||
appearance2.Image = global::AyaNova.Resource1.SaveExit16;
|
||||
buttonTool7.SharedPropsInternal.AppearancesSmall.Appearance = appearance2;
|
||||
buttonTool7.SharedPropsInternal.Caption = "LT:UI.Command.SaveClose";
|
||||
buttonTool8.SharedPropsInternal.Caption = "LT:UI.Command.Save";
|
||||
buttonTool8.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
||||
buttonTool9.SharedPropsInternal.Caption = "LT:UI.Command.Close";
|
||||
buttonTool9.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
||||
buttonTool10.SharedPropsInternal.Caption = "LT:UI.Label.FindAndReplace";
|
||||
buttonTool10.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
||||
appearance3.Image = global::AyaNova.Resource1.Delete32;
|
||||
buttonTool11.SharedPropsInternal.AppearancesLarge.Appearance = appearance3;
|
||||
appearance4.Image = global::AyaNova.Resource1.Delete16;
|
||||
buttonTool11.SharedPropsInternal.AppearancesSmall.Appearance = appearance4;
|
||||
buttonTool11.SharedPropsInternal.Caption = "LT:UI.Command.Delete";
|
||||
buttonTool12.SharedPropsInternal.Caption = "LT:Locale.Label.Export";
|
||||
buttonTool12.SharedPropsInternal.DisplayStyle = Infragistics.Win.UltraWinToolbars.ToolDisplayStyle.TextOnlyAlways;
|
||||
this.tbManager.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {
|
||||
buttonTool7,
|
||||
buttonTool8,
|
||||
buttonTool9,
|
||||
buttonTool10,
|
||||
buttonTool11,
|
||||
buttonTool12});
|
||||
this.tbManager.UseLargeImagesOnToolbar = true;
|
||||
this.tbManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.tbManager_ToolClick);
|
||||
//
|
||||
// ErrorProvider
|
||||
//
|
||||
this.ErrorProvider.ContainerControl = this;
|
||||
//
|
||||
// _LocaleInfoForm_Toolbars_Dock_Area_Left
|
||||
//
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Left;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 43);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.Name = "_LocaleInfoForm_Toolbars_Dock_Area_Left";
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 258);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Left.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// _LocaleInfoForm_Toolbars_Dock_Area_Right
|
||||
//
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Right;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(632, 43);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.Name = "_LocaleInfoForm_Toolbars_Dock_Area_Right";
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 258);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Right.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// _LocaleInfoForm_Toolbars_Dock_Area_Top
|
||||
//
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Top;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.Name = "_LocaleInfoForm_Toolbars_Dock_Area_Top";
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(632, 43);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Top.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// _LocaleInfoForm_Toolbars_Dock_Area_Bottom
|
||||
//
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.DockedPosition = Infragistics.Win.UltraWinToolbars.DockedPosition.Bottom;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 301);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.Name = "_LocaleInfoForm_Toolbars_Dock_Area_Bottom";
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(632, 0);
|
||||
this._LocaleInfoForm_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.tbManager;
|
||||
//
|
||||
// grid
|
||||
//
|
||||
this.grid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grid.Location = new System.Drawing.Point(0, 43);
|
||||
this.grid.Name = "grid";
|
||||
this.grid.Size = new System.Drawing.Size(632, 258);
|
||||
this.grid.TabIndex = 101;
|
||||
this.grid.Tag = "";
|
||||
this.grid.Text = "LT:O.Locale";
|
||||
//
|
||||
// LocaleInfoForm
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 301);
|
||||
this.Controls.Add(this.grid);
|
||||
this.Controls.Add(this.ckIsDirty);
|
||||
this.Controls.Add(this._LocaleInfoForm_Toolbars_Dock_Area_Left);
|
||||
this.Controls.Add(this._LocaleInfoForm_Toolbars_Dock_Area_Right);
|
||||
this.Controls.Add(this._LocaleInfoForm_Toolbars_Dock_Area_Bottom);
|
||||
this.Controls.Add(this._LocaleInfoForm_Toolbars_Dock_Area_Top);
|
||||
this.helpProvider1.SetHelpKeyword(this, "");
|
||||
this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
|
||||
this.Name = "LocaleInfoForm";
|
||||
this.helpProvider1.SetShowHelp(this, true);
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
|
||||
this.Closing += new System.ComponentModel.CancelEventHandler(this.LocaleInfoForm_Closing);
|
||||
this.Load += new System.EventHandler(this.LocaleInfoForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbManager)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ErrorProvider)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
||||
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
||||
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
||||
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
||||
//
|
||||
|
||||
#region Form Load / Close
|
||||
//variable to hold user form settings
|
||||
//UIUserFormSetting mFormSetting;
|
||||
|
||||
string sCurrentLocale="";
|
||||
/// <summary>
|
||||
/// Prepare the form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LocaleInfoForm_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
//case 1039 //log.Debug("LocaleInfoForm_Load");
|
||||
//
|
||||
// helpProvider1
|
||||
//
|
||||
this.helpProvider1.HelpNamespace = Util.BaseHelpUrl + "localized_text_designer.htm";
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
this.Visible=false;
|
||||
this.Icon = Resource1.Localization16icon;
|
||||
|
||||
//See if user has any rights to be here...
|
||||
//(this is done here to ensure that no matter what happens if a user has no rights they can't get here
|
||||
//useful in case we miss a way of getting to a Locale edit screen from elsewhere in the program)
|
||||
if(AyaBizUtils.Right("Object.LocalizedText")< (int)SecurityLevelTypes.ReadOnly)//Less than read only instead of NoAccess to catch records where it's zero instead of 1
|
||||
{
|
||||
//Inform them of their wicked ways and boot them out of here...
|
||||
|
||||
MessageBox.Show(string.Format(
|
||||
Util.LocaleText.GetLocalizedText("Error.Security.NotAuthorizedToRetrieve"),
|
||||
Util.LocaleText.GetLocalizedText("O.LocalizedText")));
|
||||
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
grid.DataSource=mLocale;
|
||||
InitializeGrid();
|
||||
|
||||
sCurrentLocale=grid.Rows[0].Cells["Locale"].Value.ToString();
|
||||
//Set the cell
|
||||
this.Text=Util.LocaleText.GetLocalizedText("O.Locale")+": " +sCurrentLocale;
|
||||
grid.Text=this.Text;
|
||||
|
||||
//size and move form per last setting
|
||||
Util.LoadFormCustomization("LocaleInfo", this, tbManager, false);
|
||||
|
||||
Util.PluginInsertMenu(tbManager, new Util.PluginMenuOptionData(true, RootObjectTypes.Locale, mLocale, null));//case 941
|
||||
|
||||
//restrict UI based on security settings
|
||||
RestrictUI();
|
||||
Util.LocalizeHelperInsertMenu(tbManager, this); //case 1810
|
||||
Util.Localize(this);
|
||||
//Util.Localize(tbManager);
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
Application.Idle+= new EventHandler(Application_Idle);
|
||||
|
||||
this.Visible=true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to track whether the close was done by the program
|
||||
/// or done by the user clicking on the upper left corner X control
|
||||
/// </summary>
|
||||
bool bClosingHandled=false;
|
||||
/// <summary>
|
||||
/// Save form layout and grid layout for next time
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LocaleInfoForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//case 1039 //log.Debug("LocaleInfoForm_Closing");
|
||||
|
||||
|
||||
if(!bClosingHandled)
|
||||
{
|
||||
//Save record if necessary
|
||||
//User may opt to not cancel exit
|
||||
if(!RecordUpdate(RecordActionType.PromptToSave) )
|
||||
{
|
||||
e.Cancel=true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Application.Idle-= new EventHandler(Application_Idle);
|
||||
|
||||
Util.SaveGridLayout("Locale","","",grid);
|
||||
|
||||
Util.SaveFormCustomization("LocaleInfo", this, tbManager, false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Toolbar menu items
|
||||
|
||||
/// <summary>
|
||||
/// Respond to a click on a toolbar menu item
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void tbManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
|
||||
{
|
||||
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("ToolClick: "+e.Tool.Key);
|
||||
|
||||
switch (e.Tool.Key)
|
||||
{
|
||||
case "LT:UI.Command.SaveClose": // ButtonTool
|
||||
RecordUpdate(RecordActionType.SaveAndExit);
|
||||
break;
|
||||
case "LT:UI.Command.Save": // ButtonTool
|
||||
RecordUpdate(RecordActionType.SaveOnly);
|
||||
break;
|
||||
case "LT:UI.Label.FindAndReplace": // ButtonTool
|
||||
LocaleInfoFormSearchAndReplace d = new LocaleInfoFormSearchAndReplace();
|
||||
|
||||
if(d.ShowDialog()!=DialogResult.OK) return;
|
||||
if(d.ReplaceText==true)
|
||||
DoReplace(d.FindValue,d.ReplaceValue);
|
||||
else
|
||||
DoFind(d.FindValue);
|
||||
|
||||
break;
|
||||
case "LT:UI.Command.Delete": // ButtonTool
|
||||
RecordUpdate(RecordActionType.DeleteAndExit);
|
||||
break;
|
||||
|
||||
// case "AYL": // ButtonTool
|
||||
//
|
||||
// //Prompt to save if required
|
||||
// if(!RecordUpdate(RecordActionType.PromptToSave)) return;
|
||||
// dlgSave.FileName=sCurrentLocale;
|
||||
//
|
||||
// dlgSave.Filter=
|
||||
// Util.LocaleText.GetLocalizedText("Locale.Label.LocaleFile")+"|*.ayl";
|
||||
//
|
||||
// dlgSave.RestoreDirectory=true;
|
||||
// dlgSave.FilterIndex=1;
|
||||
// if(dlgSave.ShowDialog()==DialogResult.OK)
|
||||
// {
|
||||
// Cursor.Current=Cursors.WaitCursor;
|
||||
// LocalizedTexts.Export(sCurrentLocale,dlgSave.FileName);
|
||||
// }
|
||||
// break;
|
||||
case "LT:Locale.Label.Export": // ButtonTool
|
||||
|
||||
//Prompt to save if required
|
||||
if(!RecordUpdate(RecordActionType.PromptToSave)) return;
|
||||
dlgSave.FileName=sCurrentLocale;
|
||||
|
||||
dlgSave.Filter=
|
||||
Util.LocaleText.GetLocalizedText("Locale.Label.LocaleFile")+"|*.xml";
|
||||
|
||||
dlgSave.RestoreDirectory=true;
|
||||
dlgSave.FilterIndex=1;
|
||||
if(dlgSave.ShowDialog()==DialogResult.OK)
|
||||
{
|
||||
Cursor.Current=Cursors.WaitCursor;
|
||||
LocalizedTexts.ExportXML(sCurrentLocale,dlgSave.FileName);
|
||||
}
|
||||
break;
|
||||
case "LT:UI.Command.Close": // ButtonTool
|
||||
this.Close();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Toolbar menu items
|
||||
|
||||
#region Find and replace
|
||||
|
||||
private void DoFind(string FindTerm)
|
||||
{
|
||||
CompareInfo myComp = CultureInfo.CurrentCulture.CompareInfo;
|
||||
|
||||
bool bNoMatch=false;
|
||||
UltraGridCell c=null;
|
||||
foreach(UltraGridRow r in grid.Rows)
|
||||
{
|
||||
c=r.Cells["DisplayText"];
|
||||
|
||||
bNoMatch=myComp.LastIndexOf(c.Value.ToString(),FindTerm)==-1;
|
||||
//c.Appearance.FontData.Bold=bNoMatch ? DefaultableBoolean.False:DefaultableBoolean.True;
|
||||
c.Appearance.BackColor=bNoMatch ? System.Drawing.SystemColors.Window:System.Drawing.SystemColors.Highlight;
|
||||
c.Appearance.ForeColor=bNoMatch ? System.Drawing.SystemColors.WindowText:System.Drawing.SystemColors.HighlightText;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void DoReplace(string FindTerm, string ReplaceTerm)
|
||||
{
|
||||
CompareInfo myComp = CultureInfo.CurrentCulture.CompareInfo;
|
||||
|
||||
bool bNoMatch=false;
|
||||
UltraGridCell c=null;
|
||||
foreach(UltraGridRow r in grid.Rows)
|
||||
{
|
||||
c=r.Cells["DisplayText"];
|
||||
|
||||
bNoMatch=myComp.LastIndexOf(c.Value.ToString(),FindTerm)==-1;
|
||||
//c.Appearance.FontData.Bold=bNoMatch ? DefaultableBoolean.False:DefaultableBoolean.True;
|
||||
c.Appearance.BackColor=bNoMatch ? System.Drawing.SystemColors.Window:System.Drawing.SystemColors.Highlight;
|
||||
c.Appearance.ForeColor=bNoMatch ? System.Drawing.SystemColors.WindowText:System.Drawing.SystemColors.HighlightText;
|
||||
|
||||
if(!bNoMatch)
|
||||
c.Value=c.Value.ToString().Replace(FindTerm,ReplaceTerm);
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Restrictions and Form UI / Business object synchronization
|
||||
/// <summary>
|
||||
/// Synchronize the state of the UI to the BO's
|
||||
/// </summary>
|
||||
private void SyncUI()
|
||||
{
|
||||
|
||||
|
||||
// //display group name in title bar
|
||||
// this.Text=mLocale.Name;
|
||||
//
|
||||
// //If user is in default security group
|
||||
// //then ensure the UI can't be used to edit it
|
||||
// if(mLocale.IsAyaNovaAdministrator)
|
||||
// {
|
||||
// //make grid read only at this point and make the edit name box read only as well
|
||||
// grid.DisplayLayout.Override.AllowUpdate=DefaultableBoolean.False;
|
||||
// edName.ReadOnly=true;
|
||||
// tbManager.Tools["LT:UserRight.Label.SecurityLevel"].SharedProps.Enabled=false;
|
||||
// tbManager.Tools["LT:UI.Toolbar.LocaleForm.SetAll"].SharedProps.Enabled=false;
|
||||
// tbManager.Tools["LT:UI.Command.Delete"].SharedProps.Enabled=false;
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// When the application enters an idle state
|
||||
/// update the UI to reflect changs in BO status
|
||||
/// (required because grids don't tell the UI to update when they are
|
||||
/// bound to a business object and are edited)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Application_Idle(object sender, EventArgs e)
|
||||
{
|
||||
SyncUI();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adapt UI to accomodate users security access level
|
||||
/// by default form is set with full rights in mind
|
||||
/// so this code just needs to restrict them as required
|
||||
/// </summary>
|
||||
private void RestrictUI()
|
||||
{
|
||||
tbManager.Tools["LT:UI.Command.Delete"].SharedProps.Visible=sCurrentLocale!="English" && AyaBizUtils.Right("Object.LocalizedText")== (int)SecurityLevelTypes.ReadWriteDelete ;
|
||||
bool bReadOnly=AyaBizUtils.Right("Object.LocalizedText")< (int)SecurityLevelTypes.ReadWrite || sCurrentLocale=="English";
|
||||
|
||||
|
||||
tbManager.Tools["LT:UI.Command.SaveClose"].SharedProps.Visible=!bReadOnly;
|
||||
tbManager.Tools["LT:UI.Label.FindAndReplace"].SharedProps.Visible=!bReadOnly;
|
||||
tbManager.Tools["LT:UI.Command.Save"].SharedProps.Visible=!bReadOnly;
|
||||
|
||||
//Case 181
|
||||
tbManager.Tools["LT:UI.Command.Close"].SharedProps.Visible=false;
|
||||
|
||||
//case 668
|
||||
tbManager.Tools["LT:Locale.Label.Export"].SharedProps.Visible = !bReadOnly;
|
||||
|
||||
grid.DisplayLayout.Override.AllowUpdate=bReadOnly?DefaultableBoolean.False:DefaultableBoolean.True;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Business object editing / adding / deletion related code
|
||||
|
||||
|
||||
private LocalizedTexts mLocale;
|
||||
/// <summary>
|
||||
/// Locale record to display
|
||||
/// set by caller
|
||||
/// </summary>
|
||||
public LocalizedTexts LocaleToEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return mLocale;
|
||||
}
|
||||
set
|
||||
{
|
||||
mLocale=value;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Used to signal to main form that there are changes
|
||||
//which could affect it if true
|
||||
private bool mbChangesMade=false;
|
||||
public bool ChangesMade
|
||||
{
|
||||
get
|
||||
{
|
||||
return mbChangesMade;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update record and quit if requested
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>True if handled, false if not handled</returns>
|
||||
private bool RecordUpdate(RecordActionType SaveType)
|
||||
{
|
||||
//case 1039 //if(log.IsDebugEnabled) //case 1039 //log.Debug("SaveHandler(Action="+SaveType.ToString()+")");
|
||||
|
||||
|
||||
grid.UpdateData();
|
||||
switch(SaveType)
|
||||
{
|
||||
case RecordActionType.DeleteAndExit:
|
||||
if(Util.PromptForDelete()==DialogResult.Yes)
|
||||
{
|
||||
//Delete, then exit
|
||||
|
||||
LocalizedTexts.DeleteLocale(this.sCurrentLocale);
|
||||
|
||||
bClosingHandled=true;
|
||||
this.Close();
|
||||
mbChangesMade=true;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
||||
case RecordActionType.SaveAndExit:
|
||||
//Save if necessary and exit
|
||||
if(mLocale.IsSavable)
|
||||
{
|
||||
mLocale.ApplyEdit();
|
||||
mLocale.Save();
|
||||
bClosingHandled=true;
|
||||
mbChangesMade=true;
|
||||
this.Close();
|
||||
return true;
|
||||
}
|
||||
if(mLocale.IsDirty)//dirty and unsaveable due to broken rules
|
||||
{
|
||||
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
||||
{
|
||||
bClosingHandled=true;
|
||||
this.Close();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//not dirty so just exit
|
||||
bClosingHandled=true;
|
||||
this.Close();
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
case RecordActionType.SaveOnly:
|
||||
if(mLocale.IsSavable)
|
||||
{
|
||||
mLocale.ApplyEdit();
|
||||
mLocale=(LocalizedTexts)mLocale.Save();
|
||||
grid.DataSource=mLocale;
|
||||
mbChangesMade=true;
|
||||
return true;
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
case RecordActionType.PromptToSave:
|
||||
//Prompt to save and save if
|
||||
//required
|
||||
if(mLocale.IsDirty)
|
||||
{
|
||||
DialogResult dr=Util.PromptForSave();
|
||||
if(dr==DialogResult.Cancel)
|
||||
{
|
||||
//Cancel
|
||||
return false;
|
||||
}
|
||||
if(dr==DialogResult.Yes)
|
||||
{
|
||||
//Save before exit
|
||||
|
||||
if(mLocale.IsSavable)
|
||||
{
|
||||
mLocale.ApplyEdit();
|
||||
mLocale.Save();
|
||||
mbChangesMade=true;
|
||||
return true;
|
||||
}
|
||||
if(mLocale.IsDirty)//dirty and unsaveable due to broken rules
|
||||
{
|
||||
if(Util.PromptForBrokenRulesCancelSave()==DialogResult.Yes)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize grid
|
||||
|
||||
/// <summary>
|
||||
/// Get grid ready
|
||||
/// </summary>
|
||||
private void InitializeGrid()
|
||||
{
|
||||
//case 1039 //log.Debug("InitializeGrid");
|
||||
|
||||
|
||||
|
||||
//
|
||||
Util.FetchGridLayout("Locale","",grid);
|
||||
Util.GridHideEditableBizObjectInternalFields(grid);
|
||||
grid.DisplayLayout.Bands[0].Columns["Locale"].Hidden=true;
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayTextCustom"].Hidden=true;
|
||||
|
||||
//
|
||||
grid.DisplayLayout.Override.HeaderClickAction=HeaderClickAction.SortSingle;
|
||||
grid.DisplayLayout.Override.AllowAddNew=AllowAddNew.No;
|
||||
//
|
||||
grid.DisplayLayout.Bands[0].Override.RowSelectors=DefaultableBoolean.False;
|
||||
//
|
||||
// //Set the caption to be on the left side of the grid
|
||||
grid.DisplayLayout.CaptionAppearance.TextHAlign=HAlign.Left;
|
||||
|
||||
|
||||
grid.DisplayLayout.Bands[0].Columns["Key"].CellActivation=Activation.ActivateOnly;
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].CellActivation=Activation.AllowEdit;
|
||||
|
||||
grid.DisplayLayout.Bands[0].ScrollTipField="Key";
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].CellMultiLine=DefaultableBoolean.True;
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].AutoSizeEdit=DefaultableBoolean.True;
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].VertScrollBar=true;
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].Nullable=Infragistics.Win.UltraWinGrid.Nullable.Disallow;
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].MaxLength=255;
|
||||
|
||||
|
||||
|
||||
grid.DisplayLayout.Bands[0].Columns["Key"].Header.Caption=Util.LocaleText.GetLocalizedText("LocalizedText.Label.Key");
|
||||
grid.DisplayLayout.Bands[0].Columns["DisplayText"].Header.Caption=Util.LocaleText.GetLocalizedText("LocalizedText.Label.DisplayText");
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endregion initialize grid
|
||||
|
||||
|
||||
#region Accelerator keys
|
||||
/// <summary>
|
||||
/// Case 37
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="keyData"></param>
|
||||
/// <returns></returns>
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
//Short circuit:
|
||||
//Only process modified keystrokes (i.e. when a modifier like ctrl-alt-or shift is also
|
||||
//being held down
|
||||
if (ModifierKeys == Keys.None) return base.ProcessCmdKey(ref msg, keyData);
|
||||
|
||||
switch (Util.HotKeys(keyData))
|
||||
{
|
||||
//Close form
|
||||
case HotKeyAction.CloseForm:
|
||||
this.Close();
|
||||
return true;
|
||||
}
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user