Exemple #1
0
        private void SetEnvUIForm_Load(object sender, System.EventArgs e)
        {
            setEnvUIParams.configFile = Path.GetFullPath(setEnvUIParams.configFile);
            setEnvUIConfig            = SetEnvUIConfig.LoadFromFile(setEnvUIParams.configFile);
            if (setEnvUIConfig.ConfigItems.Count == 0)
            {
                throw (new ApplicationException("There are no configuration items in SetEnvUIConfig.xml"));
            }

            if (setEnvUIConfig.ConfigItems.Count > 1)
            {
                this.btnFinish.Enabled   = false;
                this.btnPrevious.Enabled = false;
                this.AcceptButton        = this.btnNext;
            }
            else
            {
                this.btnNext.Enabled     = false;
                this.btnPrevious.Enabled = false;
                this.AcceptButton        = this.btnFinish;
            }

            this.Text = setEnvUIConfig.DialogCaption;

            RefreshCurrent();
        }
        /// <summary>
        /// Load a configuration file, and return an instance of this class.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static SetEnvUIConfig LoadFromFile(string filename)
        {
            SetEnvUIConfig config = null;

            XmlSerializer serializer = new XmlSerializer(typeof(SetEnvUIConfig));

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                config = (SetEnvUIConfig)serializer.Deserialize(fs);
            }
            return(config);
        }