Beispiel #1
0
        /// <summary>
        /// Registers a named option.
        /// </summary>
        /// <param name="name">The option name.</param>
        /// <param name="parameterCount">The number of additional parameters for this option.</param>
        /// <returns>The option instance.</returns>
        public CommandLineOption RegisterOption(string name, int parameterCount)
        {
            CommandLineOption option = new CommandLineOption(name, parameterCount);

            options.Add(option);
            return(option);
        }
 /// <summary>
 /// Registers a named option.
 /// </summary>
 /// <param name="name">The option name.</param>
 /// <param name="parameterCount">The number of additional parameters for this option.</param>
 /// <returns>The option instance.</returns>
 public CommandLineOption RegisterOption(string name, int parameterCount)
 {
     CommandLineOption option = new CommandLineOption(name, parameterCount);
     options.Add(option);
     return option;
 }
 /// <summary>
 /// Initialises a new instance of the <see cref="CommandLineArgument"/> class.
 /// </summary>
 /// <param name="option">The <see cref="Option"/> that is set in this argument; or null.</param>
 /// <param name="values">The additional parameter values for the option; or the argument value.</param>
 internal CommandLineArgument(CommandLineOption option, string[] values)
 {
     this.Option = option;
     this.Values = values;
 }
Beispiel #4
0
 /// <summary>
 /// Initialises a new instance of the <see cref="CommandLineArgument"/> class.
 /// </summary>
 /// <param name="option">The <see cref="Option"/> that is set in this argument; or null.</param>
 /// <param name="values">The additional parameter values for the option; or the argument value.</param>
 internal CommandLineArgument(CommandLineOption option, string[] values)
 {
     this.Option = option;
     this.Values = values;
 }
Beispiel #5
0
        public MainForm()
        {
            Instance = this;

            InitializeComponent();

            // Set the XML file's build action to "Embedded Resource" and "Never copy" for this to work.
            Tx.LoadFromEmbeddedResource("Unclassified.LogSubmit.LogSubmit.txd");
            TxDictionaryBinding.AddTextBindings(this);

            // Initialise views
            logSelectionView = new LogSelectionView();

            // Read configuration file
            string configFile = Path.Combine(
                Path.GetDirectoryName(Application.ExecutablePath),
                "submit.config");
            try
            {
                ConfigReader config = new ConfigReader(configFile);
                config.Read();
            }
            catch (Exception ex)
            {
                logSelectionView.SetConfigError(ex);
            }

            // Initialise more views
            timeSelectionView = new TimeSelectionView();
            notesView = new NotesView();
            compressView = new CompressView();
            transportView = new TransportView();
            transportProgressView = new TransportProgressView();

            views.Add(logSelectionView);
            views.Add(timeSelectionView);
            views.Add(notesView);
            views.Add(compressView);
            views.Add(transportView);
            views.Add(transportProgressView);

            // Other initialisation
            Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            UIPreferences.UpdateFormFont(this, Font, SystemFonts.MessageBoxFont);
            USizeGrip.AddToForm(this);

            systemMenu = new SystemMenu(this);
            systemMenu.AddCommand(Tx.T("menu.about"), OnSysMenuAbout, true);

            progressPanel = new Panel();
            progressPanel.Left = 0;
            progressPanel.Top = 0;
            progressPanel.Width = 0;
            progressPanel.Height = 2;
            //progressPanel.BackColor = SystemColors.Highlight;
            progressPanel.BackColor = Color.Gray;
            Controls.Add(progressPanel);
            progressPanel.BringToFront();

            // Parse command line arguments
            CommandLineReader cmdLine = new CommandLineReader();
            fromErrorDlgOption = cmdLine.RegisterOption("errordlg");
            fromShortcutOption = cmdLine.RegisterOption("shortcut");
            logPathOption = cmdLine.RegisterOption("logpath", 1);
            endTimeOption = cmdLine.RegisterOption("endtime", 1);

            try
            {
                cmdLine.Parse();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    Tx.T("msg.command line error", "msg", ex.Message),
                    Tx.T("msg.title.error"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }

            SharedData.Instance.FromErrorDialog = fromErrorDlgOption.IsSet;
            SharedData.Instance.FromShortcut = fromShortcutOption.IsSet;

            if (logPathOption.IsSet)
            {
                try
                {
                    logSelectionView.SetLogBasePath(logPathOption.Value);
                }
                catch
                {
                    MessageBox.Show(
                        Tx.T("msg.logpath parameter invalid", "value", logPathOption.Value),
                        Tx.T("msg.title.error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    logSelectionView.ResetLogBasePath();
                    logSelectionView.FindLogBasePath();
                }
            }
            else
            {
                logSelectionView.FindLogBasePath();
            }

            if (endTimeOption.IsSet)
            {
                try
                {
                    appStartTime = DateTime.Parse(endTimeOption.Value);
                    SharedData.Instance.LastLogUpdateTime = appStartTime;
                }
                catch
                {
                    MessageBox.Show(
                        Tx.T("msg.endtime parameter invalid", "value", endTimeOption.Value),
                        Tx.T("msg.title.error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            // Set start view
            SetView(logSelectionView, true);
        }