Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            TextWriter outputFile = null;

            try
            {
                GlobalParameters.ParseCommandLineArguments(args);
                if (GlobalParameters.IsGui)
                {
                    HideConsoleWindow();
                    Application application = new Application();
                    application.Run(new Gui());
                }
                else if (GlobalParameters.IsHelp)
                {
                    PrintUsage();
                }
                else
                {
                    outputFile = DoSniff();
                }
            }
            catch (CommandLineArgumentException e)
            {
                Console.WriteLine(e.Message);
                PrintUsage();
            }
            catch (IOException)
            {
                Console.WriteLine("Communication error: check if the port names are correct");
            }

            if (!GlobalParameters.IsGui)
            {
                Console.WriteLine("Press a key to stop sniffing");
                Console.ReadLine();
            }

            if (outputFile != null)
            {
                outputFile.Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event handler called when the start stop button on the GUI is pressed.
        /// </summary>
        /// <param name="sender">The parameter is not used.</param>
        /// <param name="e">The parameter is not used.</param>
        private void StartStop_Click(object sender, RoutedEventArgs e)
        {
            this.StartStop.IsEnabled = false;
            this.startRequest        = true;

            GlobalParameters.VirtualPort          = this.VirtualPort.Text;
            GlobalParameters.RealPort             = this.RealPort.Text;
            GlobalParameters.BytesPerLine         = int.Parse(this.BytesPerLine.Text);
            GlobalParameters.TransmissionBaudRate = int.Parse(this.Baud.Text);
            GlobalParameters.TransmissionStopBits = GlobalParameters.Value2StopBits[this.StopBits.Text];
            GlobalParameters.TransmissionParity   = this.Parity.Text.ToEnum <Parity>();
            GlobalParameters.TransmissionDataBits = int.Parse(this.DataBits.Text);

            GlobalParameters.IsOnlyAscii     = this.OnlyAscii.IsChecked == true;
            GlobalParameters.IsOnlyHex       = this.OnlyHex.IsChecked == true;
            GlobalParameters.IsShowTime      = this.Time.IsChecked == true;
            GlobalParameters.IsShowCollapsed = this.ShowCollapsed.IsChecked == true;

            GlobalParameters.SaveToRegistry();
        }