Exemple #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     myConsole         = new frmConsole();
     myConsole.Visible = false;
 }
Exemple #2
0
        static void Main(string[] args)
        {
            bool   AllowEdit;
            string Autorun;
            string port;
            bool   ListenMode = false;
            bool   minimised  = false;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Control.CheckForIllegalCrossThreadCalls = false;
            AppSettings     = null;
            AppSettingsFile = Application.UserAppDataPath + "\\AubitSettings.xml";


            // Read the XML file.
            if (System.IO.File.Exists(AppSettingsFile))
            {
                LoadSettings(AppSettingsFile);
            }
            else
            {
                DefaultSettings();
            }

            AllowEdit         = AppSettings.AllowEdit;
            Autorun           = AppSettings.AutoRun;
            port              = AppSettings.Port;
            ListenMode        = AppSettings.ListenMode;
            minimised         = AppSettings.StartMinimized;
            myConsole         = new frmConsole();
            myConsole.Visible = false;

            if (Program.AppSettings.interruptKey == null)
            {
                Program.AppSettings.interruptKey = "Control-C";
            }
            else
            {
                if (Program.AppSettings.interruptKey.Trim().Length == 0)
                {
                    Program.AppSettings.interruptKey = "Control-C";
                }
            }

            for (int a = 0; a < args.Length; a++)
            {
                if (args[a] == "-a")
                {
                    AllowEdit = true;
                }

                if (args[a] == "-L")
                {
                    ListenMode = true;
                }

                if (args[a] == "-l")
                {
                    ListenMode = false;
                }

                if (args[a] == "-S")
                {
                    if (a + 1 < args.Length)
                    {
                        Autorun = args[a + 1];
                        a       = a + 1;
                    }
                }

                if (args[a] == "-p")
                {
                    if (a + 1 < args.Length)
                    {
                        port = args[a + 1];
                        a    = a + 1;
                    }
                }

                if (args[a] == "-M")
                {
                    minimised = true;
                }
            }

            if (Program.AppSettings.defaultEncoding == null)
            {
                Program.AppSettings.defaultEncoding = "ISO8859-1";
                Program.SaveSettings();
            }

            if (Program.AppSettings.defaultEncoding.Trim() == "")
            {
                Program.AppSettings.defaultEncoding = "ISO8859-1";
                Program.SaveSettings();
            }

            if (Program.AppSettings.defaultEncoding != "UTF8")
            {
                try
                {
                    remoteEncoding = System.Text.ASCIIEncoding.GetEncoding(Program.AppSettings.defaultEncoding);
                }
                catch (Exception)
                {
                    remoteEncoding = System.Text.ASCIIEncoding.GetEncoding("UTF-8");
                }
            }

            if (remoteEncoding == null)
            {
                // Dang - still not loaded...
                Program.AppSettings.defaultEncoding = "iso-8859-1";
                Program.SaveSettings();

                System.Text.ASCIIEncoding.GetEncoding(Program.AppSettings.defaultEncoding);
            }


            if (remoteEncoding == null)
            {
                MessageBox.Show("Unable to load encoding : " + Program.AppSettings.defaultEncoding + "\n" + "Program will not function correctly until the encoding has been set correctly");
            }



            frmMain = new mainfrm(AllowEdit, Autorun, port, minimised, ListenMode);
            if (frmMain != null && !frmMain.IsDisposed)
            {
                // try
                //{
                Application.Run(frmMain);
                //}
                //catch (Exception ex)
                // {
                //    Debug.WriteLine("Exception:"+ex.Message);
                // }
            }
        }