private void SaveToIniFile(string iniFilePath)
        {
            IniFile iniFile = new IniFile(iniFilePath);

            for (int i = 0; i < alarmList.Count; i++)
            {
                iniFile.WriteValue(alarmList[i].AlarmCode, "Level", alarmList[i].Level);
                iniFile.WriteValue(alarmList[i].AlarmCode, "Type", alarmList[i].Type);
                iniFile.WriteValue(alarmList[i].AlarmCode, "Reset", alarmList[i].Reset == true ? 1 : 0);
                iniFile.WriteValue(alarmList[i].AlarmCode, "Retry", alarmList[i].Retry == true ? 1 : 0);
                iniFile.WriteValue(alarmList[i].AlarmCode, "Skip", alarmList[i].Skip == true ? 1 : 0);
                iniFile.WriteValue(alarmList[i].AlarmCode, "Continue", alarmList[i].Continue == true ? 1 : 0);

                string strReplaceMessage = alarmList[i].Message.Replace("\r\n", "**********");
                iniFile.WriteValue(alarmList[i].AlarmCode, "Message", strReplaceMessage);

                string strReplaceTroubleShooting = alarmList[i].TroubleShooting.Replace("\r\n", "**********");
                iniFile.WriteValue(alarmList[i].AlarmCode, "Troubleshooting", strReplaceTroubleShooting);
            }
        }
Exemple #2
0
        private void SaveIniFile()
        {
            IniFile iniFile = new IniFile(strINIPath);

            iniFile.WriteValue("PARAMETER", "Cycle Run", D0200.Text);
            iniFile.WriteValue("PARAMETER", "MFC Flow Set", D0201.Text);
            iniFile.WriteValue("PARAMETER", "MFC Flow Time Set", D0202.Text);
            iniFile.WriteValue("PARAMETER", "Lock in Pressure", D0203.Text);
            iniFile.WriteValue("PARAMETER", "Lock in Pressure Alarm", D0204.Text);
            iniFile.WriteValue("PARAMETER", "Watt value Set", D0205.Text);
            iniFile.WriteValue("PARAMETER", "Watt value Alarm", D0206.Text);
            iniFile.WriteValue("PARAMETER", "Current value Set", D0207.Text);
            iniFile.WriteValue("PARAMETER", "Current value Alarm", D0208.Text);
            iniFile.WriteValue("PARAMETER", "LVG", D0209.Text);
            iniFile.WriteValue("PARAMETER", "HVG", D0210.Text);
        }
Exemple #3
0
        /// <summary>
        /// Disposes of the form after saving the changes made
        /// </summary>
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (optionsResolutionAdd.Text == "Save")
            {
                // Show the dialog
                DialogResult result = MessageBox.Show("You did not save the radius you were editing. Are you sure you want to continue?",
                    "Radius not saved", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == System.Windows.Forms.DialogResult.No)
                {
                    // Quit the save process
                    return;
                }
            }

            #region Save Settings

            using (IniFile iniFile = new IniFile())
            {
                // Switch: Default profile
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                #region General

                #region Run the LODRE when FSX starts

                if (optionsGeneral0.Checked)
                {
                    // Write the setting value
                    iniFile.WriteValue("OPTIONS.GENERAL", "runfsx", "1");

                    ///<switch>locations.ini</switch>
                    iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                    using (ExeXml exeXml = new ExeXml(iniFile.ReadValue("LOCATIONS", "cfg") + @"\exe.xml"))
                    {
                        ///<switch>current profile</switch>
                        iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                        iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                        // Check the existence of the document
                        exeXml.CheckExistence("Level of Detail Radius Editor", false, Application.ExecutablePath);
                    }
                }
                else
                {
                    // Write the setting value
                    iniFile.WriteValue("OPTIONS.GENERAL", "runfsx", "0");

                    ///<switch>locations.ini</switch>
                    iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                    using (ExeXml exeXml = new ExeXml(iniFile.ReadValue("LOCATIONS", "cfg") + @"\exe.xml"))
                    {
                        ///<switch>current profile</switch>
                        iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                        iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                        // Check the existence of the document
                        exeXml.CheckExistence("Level of Detail Radius Editor", true, Application.ExecutablePath);
                    }
                }

                #endregion

                #region Run the LODRE when you log onto this user account

                // The full path to the application shortcut
                string shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\Level of Detail Radius Editor.lnk";

                if (optionsGeneral1.Checked)
                {
                    iniFile.WriteValue("OPTIONS.GENERAL", "runwin", "1");

                    if (!System.IO.File.Exists(shortcutPath))
                    {
                        // Create a new shortcut
                        WshShellClass wshShell = new WshShellClass();
                        IWshRuntimeLibrary.IWshShortcut appShortcut;
                        appShortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(shortcutPath);
                        appShortcut.TargetPath = Application.ExecutablePath;
                        appShortcut.Description = "Level of Detail Radius Editor";
                        appShortcut.Save();
                    }
                }
                else
                {
                    iniFile.WriteValue("OPTIONS.GENERAL", "runwin", "0");

                    if (System.IO.File.Exists(shortcutPath))
                    {
                        // Delete the shortcut
                        System.IO.File.Delete(shortcutPath);
                    }
                }

                // Null the path string
                shortcutPath = null;

                #endregion

                #region Start this application minimized:

                if (optionsGeneral2.Checked)
                    iniFile.WriteValue("OPTIONS.GENERAL", "minimize", "1");
                else
                    iniFile.WriteValue("OPTIONS.GENERAL", "minimize", "0");

                #endregion

                #region When started with FSX || Always

                if (optionsGeneral30.Checked)
                    iniFile.WriteValue("OPTIONS.GENERAL", "sub", "0");
                else
                    iniFile.WriteValue("OPTIONS.GENERAL", "sub", "1");

                #endregion

                #endregion

                #region Auto Change

                #region Auto Change enabled

                if (optionsAuto0.Checked)
                {
                    iniFile.WriteValue("OPTIONS.AUTO", "auto", "1");
                }
                else
                {
                    iniFile.WriteValue("OPTIONS.AUTO", "auto", "0");
                }

                #endregion

                #region Auto change radius

                try
                {
                    string[] selectedAutoRes = optionsAuto1.SelectedItem.ToString().Split(' ');
                    iniFile.WriteValue("OPTIONS.AUTO", "radius", selectedAutoRes[0]);
                }
                catch
                {
                    MessageBox.Show("Unable to set the Auto Change radius selected. An item was either not selected or in the wrong format.",
                        "Unable To Save Auto Change Settings", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }

                #endregion

                #region Application to run after change

                iniFile.WriteValue("OPTIONS.AUTO", "application", optionsAuto2.Text.ToString());

                #endregion

                #region Exit after radius change

                if (optionsAuto3.Checked)
                {
                    iniFile.WriteValue("OPTIONS.AUTO", "close", "1");
                }
                else
                {
                    iniFile.WriteValue("OPTIONS.AUTO", "close", "0");
                }

                #endregion

                #endregion

                #region Resolutions

                string trimmedItem;
                int counter = 0;

                while (iniFile.ReadValue("RADII", counter.ToString()) != "")
                {
                    iniFile.WriteValue("RADII", counter.ToString(), "");
                    counter++;
                }

                counter = 0;

                foreach (string item in optionsRadiusR.Items)
                {
                    trimmedItem = item;
                    trimmedItem = trimmedItem.Replace(" (", ",");
                    trimmedItem = trimmedItem.TrimEnd(')');

                    iniFile.WriteValue("RADII", counter.ToString(), trimmedItem);

                    counter++;
                }

                #endregion
            }

            #endregion

            // Dispose of the form
            this.Dispose();
        }