Example #1
0
        public static void Main(params string[] args)
        {
            bool fRunUI = true;
            MFPortDefinition transport = null;
            MFPortDefinition transportTinyBooter = null;

            if (args.Length > 0)
            {
                try
                {
                    string error;
                    string all_args = NormalizeArgs( args );

                    ArgumentParser parser = new ArgumentParser();
                    // error condition
                    if (!parser.ValidateArgs(all_args, out error))
                    {
                        fRunUI = false;
                        NativeMethods.AllocConsole( );
                        Console.WriteLine(Properties.Resources.ErrorPrefix + error);
                    }
                    else if (parser.Command != (ArgumentParser.Commands)(-1))
                    {   // valid command, no UI
                        fRunUI = false;
                        NativeMethods.AllocConsole( );
                        parser.Execute();
                    }
                    else if (parser.Interface != null && parser.Interface.Transport != (TransportType)(-1))
                    {    // no command, but interface defined, so update UI transport field
                        transport = parser.Interface;
                        transportTinyBooter = parser.TinybtrInterface;
                    }
                }
                catch (Exception e)
                {
                    NativeMethods.AllocConsole( );
                    Console.WriteLine(Properties.Resources.ErrorPrefix + e.Message);
                }
            }

            if (fRunUI)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Form1 form = new Form1();
                form.Transport = transport;
                form.TransportTinyBooter = transportTinyBooter;
                Application.Run(form);
            }
        }
Example #2
0
        public static void Main(params string[] args)
        {
            bool fRunUI = true;
            MFPortDefinition transport = null;
            MFPortDefinition transportTinyBooter = null;

            #if CODE_REMOVED
            if (args.Length > 0)
            {
                try
                {
                    StringBuilder sb = new StringBuilder();
                    string all_args = "";
                    string error;

                    foreach (string arg in args)
                    {
                        // take care of spaces in path names
                        if (arg.ToUpper().StartsWith(ArgumentParser.Commands.Deploy.ToString().ToUpper() + ArgumentParser.ArgSeparator))
                        {
                            string tmp = arg;
                            // place double quoutes around files
                            tmp = tmp.Replace(ArgumentParser.ArgSeparator.ToString(), ArgumentParser.ArgSeparator + "\"");
                            tmp = tmp.Replace(ArgumentParser.FileSeparator.ToString(), "\"" + ArgumentParser.FileSeparator + "\"");
                            sb.AppendFormat("{0}\"", tmp);
                        }
                        else
                        {
                            sb.AppendFormat("{0} ", arg);
                        }
                    }
                    all_args = sb.ToString().Trim();

                    ArgumentParser parser = new ArgumentParser();
                    // error condition
                    if (!parser.ValidateArgs(all_args, out error))
                    {
                        fRunUI = false;
                        Console.WriteLine(Properties.Resources.ErrorPrefix + error);
                    }
                    // valid command, no UI
                    else if (parser.Command != (ArgumentParser.Commands)(-1))
                    {
                        fRunUI = false;
                        parser.Execute();
                    }
                    // no command, but interface defined, so update UI transport field
                    else if (parser.Interface != null && parser.Interface.Transport != (TransportType)(-1))
                    {
                        transport = parser.Interface;
                        transportTinyBooter = parser.TinybtrInterface;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(Properties.Resources.ErrorPrefix + e.Message);
                }
            }
            #endif

            if (fRunUI)
            {
            #if CODE_REMOVED
                NativeMethods.FreeConsole();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
            #endif
                Form1 form = new Form1();
                form.Transport = transport;
                form.TransportTinyBooter = transportTinyBooter;
                Application.Run(form);
            }
        }
Example #3
0
        private MFPortDefinition GetSelectedItem()
        {
            if (comboBoxDevice.SelectedItem == null && comboBoxDevice.Text.Length == 0) return null;

            MFPortDefinition port = comboBoxDevice.SelectedItem as MFPortDefinition;

            if (port == null)
            {
                ArgumentParser parser = new ArgumentParser();
                string err;

                if (parser.ValidateArgs("/I:TcpIp:" + comboBoxDevice.Text, out err))
                {
                    port = parser.Interface;
                }
            }

            if (port == null)
            {
                MessageBox.Show(Properties.Resources.ErrorInvalidDevice, Properties.Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                comboBoxDevice.SelectionStart = 0;
                comboBoxDevice.SelectionLength = comboBoxDevice.Text.Length;
                comboBoxDevice.Focus();
            }
            return port;
        }