Inheritance: System.Windows.Forms.Form
Exemplo n.º 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);
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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();
		}
Exemplo n.º 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();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
		}
Exemplo n.º 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;
		}