Inheritance: System.Windows.Forms.Form
Example #1
0
        public bool LoadConfiguration()
        {
            if (!File.Exists(filename))
            {
                return(false);
            }

            try
            {
                StreamReader  tr = new StreamReader(filename);
                XmlTextReader xr = new XmlTextReader(tr);
                XmlSerializer xs = new XmlSerializer(typeof(Settings));
                object        c;
                if (xs.CanDeserialize(xr))
                {
                    c = xs.Deserialize(xr); // Don´t know why this didn´t work directly
                    Settings.Global = (Settings)c;
                }
                xr.Close();
                tr.Close();
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog();
                return(false);
            }

            return(true);
        }
Example #2
0
 public static void MoveConfigFile(string FileToMove, string NewFilePath)
 {
     if (File.Exists(NewFilePath))
     {
         try
         {
             File.Delete(NewFilePath);
         }
         catch (Exception)
         {
             Exception ex = new Exception("MoveConfigFile() could not delete the pre-existing " + NewFilePath);
             ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
             tmp.ShowDialog();
         }
     }
     try
     {
         File.Move(FileToMove, NewFilePath);
     }
     catch (Exception)
     {
         Exception ex = new Exception("MoveConfigFile() could not move " + FileToMove + " to " + NewFilePath);
         ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
         tmp.ShowDialog();
     }
 }
Example #3
0
 public static void MoveConfigFile(string FileToMove, string NewFilePath)
 {
     if (File.Exists(NewFilePath))
     {
         try
         {
             File.Delete(NewFilePath);
         }
         catch (Exception)
         {
             Exception ex = new Exception("MoveConfigFile() could not delete the pre-existing " + NewFilePath);
             ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
             tmp.ShowDialog();
         }
     }
     try
     {
         File.Move(FileToMove, NewFilePath);
     }
     catch (Exception)
     {
         Exception ex = new Exception("MoveConfigFile() could not move " + FileToMove + " to " + NewFilePath);
         ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
         tmp.ShowDialog();
     }
 }
Example #4
0
        private void BTN_ECompileSave_Click(object sender, EventArgs e)
        {
            if (ECompileCFG == null)
            {
                try
                {
                    ECompileCFG = new EConfig();
                    ECompileCFG.LoadConfig(Settings.Global.Properties["ECompileCfgPath"]);
                }
                catch (Exception ex)
                {
                    ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                    tmp.ShowDialog(this);
                }
            }
            foreach (CheckBox ThisBox in PNL_ECompileFlags.Controls)
            {
                ECompileCFG.Option(ThisBox.Name.Substring(15), ThisBox.Checked);
            }

            foreach (TextBox ThisBox in PNL_ECompilePaths.Controls)
            {
                ECompileCFG.Option(ThisBox.Name.Substring(11), ThisBox.Text);
            }

            ECompileCFG.SaveConfig();
        }
Example #5
0
        private void BTN_EcompileLoad_Click(object sender, EventArgs e)
        {
            try
            {
                ECompileCFG = new EConfig();
                ECompileCFG.LoadConfig(Settings.Global.Properties["ECompileCfgPath"]);

                foreach (CheckBox ThisBox in PNL_ECompileFlags.Controls)
                {
                    ThisBox.Checked = Settings.Global.ToBoolean(ECompileCFG.Option(ThisBox.Name.Substring(15)));
                    Settings.Global.Ecompile[ThisBox.Name.Substring(15)] = ECompileCFG.Option(ThisBox.Name.Substring(15));
                }
                foreach (TextBox ThisBox in PNL_ECompilePaths.Controls)
                {
                    ThisBox.Text = ECompileCFG.Option(ThisBox.Name.Substring(11));
                    Settings.Global.Ecompile[ThisBox.Name.Substring(11)] = ECompileCFG.Option(ThisBox.Name.Substring(11));
                }
                foreach (TextBox ThisBox in PNL_ECompilePathsEditTBS.Controls)
                {
                    ThisBox.Text = ECompileCFG.Option(ThisBox.Name.Substring(20));
                    Settings.Global.Ecompile[ThisBox.Name.Substring(20)] = ECompileCFG.Option(ThisBox.Name.Substring(20));
                }
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog(this);
            }
        }
Example #6
0
 private void BTN_StopPOL_Click(object sender, EventArgs e)
 {
     if (this.POLConsole != null)
     {
         try
         {
             POLConsole.Write(Settings.Global.Properties["POLTabShutdown"]);
         }
         catch (Exception ex)
         {
             ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
             tmp.ShowDialog(this);
         }
         return;
     }
 }
Example #7
0
        public bool SaveConfiguration()
        {
            try
            {
                TextWriter    tw = new StreamWriter(filename);
                XmlSerializer xs = new XmlSerializer(this.GetType());
                xs.Serialize(tw, Settings.Global);
                tw.Close();
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog();
                return(false);
            }

            return(true);
        }
Example #8
0
        /// <summary>
        /// Find all files in a directory, and all files within every nested
        /// directory.
        /// </summary>
        /// <param name="baseDir">The starting directory you want to use.</param>
        /// <returns>A string array containing all the file names.</returns>
        static public string[] GetAllFileNames(string baseDir, string filter)
        {
            // Store results in the file results list.
            List <string> fileResults = new List <string>();

            // Store a stack of our directories.
            Stack <string> directoryStack = new Stack <string>();

            directoryStack.Push(baseDir);

            // While there are directories to process and we don't have too many results
            while (directoryStack.Count > 0 && fileResults.Count < 1000)
            {
                string currentDir = directoryStack.Pop();

                // Add all files at this directory.
                try
                {
                    foreach (string fileName in Directory.GetFiles(currentDir, filter))
                    {
                        fileResults.Add(fileName);
                    }

                    // Add all directories at this directory.
                    foreach (string directoryName in Directory.GetDirectories(currentDir))
                    {
                        directoryStack.Push(directoryName);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                    tmp.ShowDialog();
                }
            }
            return(fileResults.ToArray());
        }
Example #9
0
		/// <summary>
		/// Find all files in a directory, and all files within every nested
		/// directory.
		/// </summary>
		/// <param name="baseDir">The starting directory you want to use.</param>
		/// <returns>A string array containing all the file names.</returns>
		static public string[] GetAllFileNames(string baseDir, string filter)
		{
			// Store results in the file results list.
			List<string> fileResults = new List<string>();

			// Store a stack of our directories.
			Stack<string> directoryStack = new Stack<string>();
			directoryStack.Push(baseDir);

			// While there are directories to process and we don't have too many results
			while (directoryStack.Count > 0 && fileResults.Count < 1000)
			{
				string currentDir = directoryStack.Pop();

				// Add all files at this directory.
                try
                {
                    foreach (string fileName in Directory.GetFiles(currentDir, filter))
                    {
                        fileResults.Add(fileName);
                    }

                    // Add all directories at this directory.
                    foreach (string directoryName in Directory.GetDirectories(currentDir))
                    {
                        directoryStack.Push(directoryName);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                    tmp.ShowDialog();
                }
			}
			return fileResults.ToArray();
		}
Example #10
0
        private void BTN_ECompileSave_Click(object sender, EventArgs e)
        {
            if (ECompileCFG == null)
            {
                try
                {
                    ECompileCFG = new EConfig();
                    ECompileCFG.LoadConfig(Settings.Global.Properties["ECompileCfgPath"]);
                }
                catch (Exception ex)
                {
                    ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                    tmp.ShowDialog(this);
                }
            }
            foreach (CheckBox ThisBox in PNL_ECompileFlags.Controls)
            {
                ECompileCFG.Option(ThisBox.Name.Substring(15), ThisBox.Checked);
            }

            foreach (TextBox ThisBox in PNL_ECompilePaths.Controls)
            {
                ECompileCFG.Option(ThisBox.Name.Substring(11), ThisBox.Text);
            }

            ECompileCFG.SaveConfig();
        }
Example #11
0
        private void BTN_EcompileLoad_Click(object sender, EventArgs e)
        {
            try
            {
                ECompileCFG = new EConfig();
                ECompileCFG.LoadConfig(Settings.Global.Properties["ECompileCfgPath"]);

                foreach (CheckBox ThisBox in PNL_ECompileFlags.Controls)
                {
                    ThisBox.Checked = Settings.Global.ToBoolean(ECompileCFG.Option(ThisBox.Name.Substring(15)));
                    Settings.Global.Ecompile[ThisBox.Name.Substring(15)] = ECompileCFG.Option(ThisBox.Name.Substring(15));
                }
                foreach (TextBox ThisBox in PNL_ECompilePaths.Controls)
                {
                    ThisBox.Text = ECompileCFG.Option(ThisBox.Name.Substring(11));
                    Settings.Global.Ecompile[ThisBox.Name.Substring(11)] = ECompileCFG.Option(ThisBox.Name.Substring(11));
                }
                foreach (TextBox ThisBox in PNL_ECompilePathsEditTBS.Controls)
                {
                    ThisBox.Text = ECompileCFG.Option(ThisBox.Name.Substring(20));
                    Settings.Global.Ecompile[ThisBox.Name.Substring(20)] = ECompileCFG.Option(ThisBox.Name.Substring(20));
                }
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog(this);
            }
        }
Example #12
0
 private void BTN_StopPOL_Click(object sender, EventArgs e)
 {
     if (this.POLConsole != null)
     {
         try
         {
             POLConsole.Write(Settings.Global.Properties["POLTabShutdown"]);
         }
         catch (Exception ex)
         {
             ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
             tmp.ShowDialog(this);
         }
         return;
     }
 }
Example #13
0
		public bool LoadConfiguration()
		{
			if (!File.Exists(filename))
				return false;

           try
            {
                StreamReader tr = new StreamReader(filename);
                XmlTextReader xr = new XmlTextReader(tr);
                XmlSerializer xs = new XmlSerializer(typeof(Settings));
                object c;
                if (xs.CanDeserialize(xr))
                {
                    c = xs.Deserialize(xr); // Don´t know why this didn´t work directly
                    Settings.Global = (Settings)c;
                }
                xr.Close();
                tr.Close();
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog();
                return false;
            }

			return true;
		}
Example #14
0
		public bool SaveConfiguration()
		{
            try
            {
                TextWriter tw = new StreamWriter(filename);
                XmlSerializer xs = new XmlSerializer(this.GetType());
                xs.Serialize(tw, Settings.Global);
                tw.Close();
            }
            catch (Exception ex)
            {
                ExceptionBox.ExceptionForm tmp = new ExceptionBox.ExceptionForm(ref ex);
                tmp.ShowDialog();
                return false;
            }

			return true;
		}