using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using Config.Entities; using TBF.BenchControl; namespace TBF.BenchControl.Configs { public class ConfigCtrlUtils : UserControl { protected PageOrientation GetOrientation(string str) { if (str.Equals(PageOrientation.Landscape.ToString())) return PageOrientation.Landscape; if (str.Equals(PageOrientation.Portrait.ToString())) return PageOrientation.Portrait; return (PageOrientation)(-1); } /// /// Updates destination variable when its value differes from the source value. /// Returns appropriate flags /// /// Reference to destination variable /// Source value /// Flags returned when an update occurs /// Flags or 0 protected CfgUpdateFlags UpdateDifferent(ref int cfgVar, int intVal, CfgUpdateFlags flagsWhenUpdated) { if (cfgVar != intVal) { cfgVar = intVal; return flagsWhenUpdated; } else return 0; } /// /// Updates destination variable when its value differes from the source value. /// Returns appropriate flags /// /// Reference to destination variable /// Source integer value is obtained by parsing this string /// Flags returned when an update occurs /// Flags or 0 protected CfgUpdateFlags UpdateDifferent(ref int cfgVar, string toBeParsedString, CfgUpdateFlags flagsWhenUpdated) { int itmp = int.Parse(toBeParsedString); if (cfgVar != itmp) { cfgVar = itmp; return flagsWhenUpdated; } else return 0; } /// /// Updates destination variable when its value differes from the source value. /// Returns appropriate flags /// /// Reference to destination variable /// Source value /// Flags returned when an update occurs /// Flags or 0 protected CfgUpdateFlags UpdateDifferent(ref bool cfgVar, bool boolVal, CfgUpdateFlags flagsWhenUpdated) { if (cfgVar != boolVal) { cfgVar = boolVal; return flagsWhenUpdated; } else return 0; } /// /// Updates destination variable when its value differes from the source value. /// Returns appropriate flags /// /// Reference to destination variable /// Source value /// Flags returned when an update occurs /// Flags or 0 protected CfgUpdateFlags UpdateDifferent(ref string cfgVar, string stringVal, CfgUpdateFlags flagsWhenUpdated) { if (cfgVar != stringVal) { cfgVar = stringVal; return flagsWhenUpdated; } else return 0; } /// /// Updates destination variable when its value differes from the source value. /// Returns appropriate flags /// /// Reference to destination array /// Source array of strings /// Flags returned when an update occurs /// Flags or 0 protected CfgUpdateFlags UpdateDifferent(ref string[] cfgVar, string[] stringArrVal, CfgUpdateFlags flagsWhenUpdated) { if (cfgVar == null && stringArrVal == null) { return 0; } else if (cfgVar == null || stringArrVal == null || !cfgVar.SequenceEqual(stringArrVal)) { cfgVar = stringArrVal; return flagsWhenUpdated; } else { return 0; } } } }