public void LoadConfig() { TIniFile IniFile = new TIniFile(DataModul.GetInstance().IniFileName); Debug = IniFile.ReadBool("General", "Debug", false); LineNumbers = IniFile.ReadInteger("General", "LineNumbers", 0); BlackWhite = IniFile.ReadBool("General", "BlackWhite", true); ReloadFiles = IniFile.ReadBool("General", "ReloadFiles", true); FileName1 = IniFile.ReadString("General", "FileName1", ""); FileName2 = IniFile.ReadString("General", "FileName2", ""); }
public bool Save() { TIniFile IniFile = new TIniFile(IniFileName); IniFile.WriteString("General", "FileName", FileName); IniFile.WriteBool("General", "Glow", Glow); IniFile.UpdateFile(); return(true); }
public void SaveConfig() { TIniFile IniFile = new TIniFile(DataModul.GetInstance().IniFileName); IniFile.WriteBool("General", "Debug", Debug); IniFile.WriteInteger("General", "LineNumbers", LineNumbers); IniFile.WriteBool("General", "BlackWhite", BlackWhite); IniFile.WriteBool("General", "ReloadFiles", ReloadFiles); IniFile.WriteString("General", "FileName1", FileName1); IniFile.WriteString("General", "FileName2", FileName2); IniFile.UpdateFile(); }
private static void LoadConfigurations() { var Ini_DBConfigurator = new TIniFile(string.Format(@"{0}\odbc.dsn", Directory.GetCurrentDirectory())); DATA = new Database ( Ini_DBConfigurator.Read("ODBC", "SERVER"), Ini_DBConfigurator.Read("ODBC", "DATABASE"), Ini_DBConfigurator.Read("ODBC", "UID"), Ini_DBConfigurator.Read("ODBC", "PWD") ); DataSet Query = new DataSet(); }
public static void func_ReadEQPConfig_By_iniFile() { string strFile = "Config\\EQPConfig.ini"; string strTemp; string[] strTemp2; if (File.Exists(strFile)) { TIniFile iniFile = new TIniFile(strFile); //g_TotalAlarmQTY Common.g_TotalAlarmQTY = 261; strTemp = ""; strTemp = iniFile.ReadString("TotalGEMDataSetting", "TotalAlarmQTY", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_TotalAlarmQTY = int.Parse(strTemp); } else { Common.g_TotalAlarmQTY = 261; } //g_MinAlarmID Common.g_MinAlarmID = 100; strTemp = ""; strTemp = iniFile.ReadString("TotalGEMDataSetting", "MinAlarmID", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_MinAlarmID = int.Parse(strTemp); } else { Common.g_MinAlarmID = 100; } //g_MaxAlarmID Common.g_MaxAlarmID = 120; strTemp = ""; strTemp = iniFile.ReadString("TotalGEMDataSetting", "MaxAlarmID", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_MaxAlarmID = int.Parse(strTemp); } else { Common.g_MaxAlarmID = 120; } //g_SlotSpaceInCassette Common.g_SlotSpaceInCassette = 25; strTemp = ""; strTemp = iniFile.ReadString("CassetteDataSetting", "SlotSpaceInCassette", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_SlotSpaceInCassette = int.Parse(strTemp); } else { Common.g_SlotSpaceInCassette = 25; } //g_RemoteRCMD Common.g_RemoteRCMD = "REMOTE"; strTemp = ""; strTemp = iniFile.ReadString("RCMDSetting", "RemoteRCMD", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_RemoteRCMD = strTemp; } else { Common.g_RemoteRCMD = "REMOTE"; } //g_LocalRCMD Common.g_LocalRCMD = "LOCAL"; strTemp = ""; strTemp = iniFile.ReadString("RCMDSetting", "LocalRCMD", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_LocalRCMD = strTemp; } else { Common.g_LocalRCMD = "Y"; } //g_BarcodeTestMode // 0: normal mode, 1:Test Mode (no barcode reader) Common.g_BarcodeTestMode = 1; strTemp = ""; strTemp = iniFile.ReadString("RFIDSetting", "BARCODE_TestMode", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_BarcodeTestMode = int.Parse(strTemp); } else { Common.g_BarcodeTestMode = 1; } //g_PJ_Space Common.g_PJ_Space = 25; strTemp = ""; strTemp = iniFile.ReadString("E40_Setting", "PJ_Space", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_PJ_Space = int.Parse(strTemp); } else { Common.g_PJ_Space = 25; } //g_PTN_Space Common.g_PTN_Space = 1; strTemp = ""; strTemp = iniFile.ReadString("E87_Setting", "PTN_Space", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_PTN_Space = int.Parse(strTemp); } else { Common.g_PTN_Space = 1; } //g_Carrier_Space Common.g_Carrier_Space = 8; strTemp = ""; strTemp = iniFile.ReadString("E87_Setting", "Carrier_Space", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_Carrier_Space = int.Parse(strTemp); } else { Common.g_Carrier_Space = 8; } //g_ST_Location_Space Common.g_ST_Location_Space = 1; strTemp = ""; strTemp = iniFile.ReadString("E90_Setting", "ST_Location_Space", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_ST_Location_Space = int.Parse(strTemp); } else { Common.g_ST_Location_Space = 1; } //g_ST_Step_Space Common.g_ST_Step_Space = 1; strTemp = ""; strTemp = iniFile.ReadString("E90_Setting", "ST_Step_Space", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_ST_Step_Space = int.Parse(strTemp); } else { Common.g_ST_Step_Space = 1; } //g_CJ_Space Common.g_CJ_Space = Common.g_PTN_Space; strTemp = ""; strTemp = iniFile.ReadString("E94_Setting", "CJ_Space", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_CJ_Space = int.Parse(strTemp); } else { Common.g_CJ_Space = Common.g_PTN_Space; } //g_LPTSM_PortID_x Common.g_LPTSM_PortID_1 = 1; Common.g_LPTSM_PortID_2 = 2; Common.g_LPTSM_PortID_3 = 3; Common.g_LPTSM_PortID_4 = 4; Common.g_LPTSM_PortID_5 = 5; Common.g_LPTSM_PortID_6 = 6; Common.g_LPTSM_PortID_7 = 7; Common.g_LPTSM_PortID_8 = 8; strTemp = ""; strTemp = iniFile.ReadString("E87_Setting", "LPTSM_PortID_1", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_LPTSM_PortID_1 = int.Parse(strTemp); } else { Common.g_LPTSM_PortID_1 = 1; } Common.g_LPTSM_PortID_2 = 2; Common.g_LPTSM_PortID_3 = 3; Common.g_LPTSM_PortID_4 = 4; Common.g_LPTSM_PortID_5 = 5; Common.g_LPTSM_PortID_6 = 6; Common.g_LPTSM_PortID_7 = 7; Common.g_LPTSM_PortID_8 = 8; //**Allow NULL Sutstrate ID setting //g_Allow_NULL_SubstID,預設為Allow NULL Sutstrate ID Common.g_Allow_NULL_SubstID = "Y"; strTemp = ""; strTemp = iniFile.ReadString("E87_Setting", "Allow_NULL_SubstID", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_Allow_NULL_SubstID = strTemp; } else { Common.g_Allow_NULL_SubstID = "Y"; } //**Allow NULL Sutstrate ID setting //g_EqpInitTimer Common.g_EqpInitTimer = 5; strTemp = ""; strTemp = iniFile.ReadString("CommonSetting", "EqpInitTimer", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_EqpInitTimer = int.Parse(strTemp); } else { Common.g_EqpInitTimer = 5; } //g_InitShowForm Common.g_InitShowForm = 0; strTemp = ""; strTemp = iniFile.ReadString("CommonSetting", "InitShowForm", ""); strTemp = strTemp.Trim(); if (strTemp != "") { Common.g_InitShowForm = int.Parse(strTemp); } else { Common.g_InitShowForm = 0; } //g_LocationID Common.g_LocationID = new string[Common.g_ST_Location_Space + 1]; strTemp = ""; strTemp = iniFile.ReadString("E90_Setting", "LocationIDs", ""); strTemp = strTemp.Trim(); if (strTemp != "") { strTemp2 = strTemp.Split(new Char[] { ',', '\t' }); for (int i = strTemp2.GetLowerBound(0); i <= strTemp2.GetUpperBound(0); i++) { Common.g_LocationID[i + 1] = strTemp2[i].Trim(); } } iniFile.Close(); iniFile.Dispose(); } }
private void TipOfTheDayForm_Load(object sender, System.EventArgs e) { string fileName = Path.Combine(Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location), csFileName); if (!File.Exists(fileName)) { Lextm.Windows.Forms.MessageBoxFactory.Warn(Text, "File missing", "No tip file exists: " + fileName); this.Close(); return; } ini = new TIniFile(fileName); tips = new TStringList(); ini.ReadSectionValues(csTipItem, tips); curIndex = (new Random()).Next(tips.Count); ShowTip(); }
public static void WriteFormPos(Window window, bool FromBorder) { if (IniFileName != "") { try { if (FromBorder) { bool AlignLeft = true; bool AlignTop = true; double MarginX = 0; double MarginY = 0; if ((window.Left + (window.Width / 2)) > System.Windows.SystemParameters.PrimaryScreenWidth / 2) { // right border AlignLeft = false; MarginX = System.Windows.SystemParameters.PrimaryScreenWidth - window.Left - window.Width; } else { MarginX = window.Left; }; if ((window.Top + (window.Height / 2)) > System.Windows.SystemParameters.PrimaryScreenHeight / 2) { // bottom border AlignTop = false; MarginY = System.Windows.SystemParameters.PrimaryScreenHeight - window.Top - window.Height; } else { MarginY = window.Top; }; TIniFile IniFile = new TIniFile(IniFileName); try { IniFile.WriteBool(window.Name, "AlignLeft", AlignLeft); IniFile.WriteBool(window.Name, "AlignTop", AlignTop); IniFile.WriteInteger(window.Name, "MarginX", (int)MarginX); IniFile.WriteInteger(window.Name, "MarginY", (int)MarginY); IniFile.UpdateFile(); } catch { //on E: Exception do //{ // MessageDlg('Erreur fatale (WriteFormPos): ' + #13 + #10 // + E.Message, mtError, [mbOk], 0); // Application.Terminate; //}; }; } else { { TIniFile IniFile = new TIniFile(IniFileName); try { IniFile.WriteInteger(window.Name, "WindowState", (int)(window.WindowState)); IniFile.WriteInteger(window.Name, "Left", (int)window.Left); IniFile.WriteInteger(window.Name, "Top", (int)window.Top); IniFile.WriteInteger(window.Name, "Width", (int)window.Width); IniFile.WriteInteger(window.Name, "Height", (int)window.Height); IniFile.UpdateFile(); } catch { //on E: Exception do //{ // MessageDlg('Erreur fatale (WriteFormPos): ' + #13 + #10 // + E.Message, mtError, [mbOk], 0); // Application.Terminate; //}; }; }; }; } catch { }; } ; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public static void ReadFormPos(Window window, bool PosOnly, bool FromBorder) { TIniFile IniFile = new TIniFile(IniFileName); TStrings Strings = new TStrings(); if (FromBorder) { bool AlignLeft = IniFile.ReadBool(window.Name, "AlignLeft", false); bool AlignTop = IniFile.ReadBool(window.Name, "AlignTop", false); int MarginX = IniFile.ReadInteger(window.Name, "MarginX", 15); int MarginY = IniFile.ReadInteger(window.Name, "MarginY", 15); if (MarginX < 0) { MarginX = 0; } if (MarginY < 0) { MarginY = 0; } if (AlignLeft) { window.Left = MarginX; } else { window.Left = System.Windows.SystemParameters.PrimaryScreenWidth - window.Width - MarginX; }; if (AlignTop) { window.Top = MarginY; } else { window.Top = System.Windows.SystemParameters.PrimaryScreenHeight - window.Height - MarginY; }; return; } ; window.Left = IniFile.ReadInteger(window.Name, "Left", (int)window.Left); window.Top = IniFile.ReadInteger(window.Name, "Top", (int)window.Top); if (!PosOnly) { window.Width = IniFile.ReadInteger(window.Name, "Width", (int)window.Width); window.Height = IniFile.ReadInteger(window.Name, "Height", (int)window.Height); } ; //if (window.Left < 0) if (window.Left < System.Windows.SystemParameters.VirtualScreenLeft) { window.Left = 0; } ; //if (window.Top < 0) if (window.Top < System.Windows.SystemParameters.VirtualScreenTop) { window.Top = 0; } ; if (!PosOnly) { if (window.Left > System.Windows.SystemParameters.WorkArea.Width) { window.Left = System.Windows.SystemParameters.WorkArea.Width - window.Width; } ; if (window.Top > System.Windows.SystemParameters.WorkArea.Height) { window.Top = System.Windows.SystemParameters.WorkArea.Height - window.Height; } ; if (window.Width > System.Windows.SystemParameters.WorkArea.Width) { window.Width = System.Windows.SystemParameters.WorkArea.Width; } ; if (window.Height > System.Windows.SystemParameters.WorkArea.Height) { window.Height = System.Windows.SystemParameters.WorkArea.Height; } ; } ; int windowState = IniFile.ReadInteger(window.Name, "WindowState", (int)(WindowState.Normal)); if (windowState == (int)(WindowState.Maximized)) { window.WindowState = WindowState.Maximized; } }
public bool Load() { { TIniFile IniFile = new TIniFile(IniFileName); FileName = IniFile.ReadString("General", "FileName", FileName); Glow = IniFile.ReadBool("General", "Glow", Glow); }; // - - - - - - using (Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(TemplatesFileName)) using (StreamReader reader = new StreamReader(stream)) { TStrings text = new TStrings(); text.Text = reader.ReadToEnd(); text.SaveToFile("Templates.ini"); TIniFile IniFile = new TIniFile("Templates.ini"); #if PCL await IniFile.LoadValues(); #else IniFile.LoadValues(); #endif TStrings Sections = IniFile.ReadSections(); Icons.Clear(); for (int s = 0; s < Sections.Count; s++) { if (Sections[s].StartsWith("#")) { TStrings l = IniFile.ReadSectionValues(Sections[s]); for (int i = 0; i < l.Count; i++) { var o = new Icon(); o.Section = Sections[s].Substring(1); o.Name = l.Names(i); string st = l.ValueFromIndex(i); o.Width = int.Parse(st.Split(new char[] { 'x', 'X' })[0]); o.Height = int.Parse(st.Split(new char[] { 'x', 'X', ',' })[1]); if (st.Split(new char[] { 'x', 'X', ',' }).Length > 2) { o.Scale = int.Parse(st.Split(new char[] { 'x', 'X', ',' })[2]); } ; Application.Current.Dispatcher.Invoke(new Action(() => { Icons.Add(o); })); } ; } ; } ; OnPropertyChanged("Icons"); }; return(true); }