コード例 #1
0
 public static StartupAction FindStartupAction(this string[] args, StartupAction defaultValue)
 {
     if (args == null)
     {
         return(defaultValue);
     }
     foreach (var arg in args)
     {
         if (string.IsNullOrEmpty(arg))
         {
             continue;
         }
         if (arg.StartsWith(ActionPrefix, StringComparison.OrdinalIgnoreCase))
         {
             if (Enum.TryParse(arg.Substring(ActionPrefix.Length), out StartupAction action))
             {
                 return(action);
             }
         }
         if (arg.Length == 2 && arg.IndexOfAny(ShortPrefix) == 0)
         {
             var shortAction = char.ToLowerInvariant(arg[1]);
             foreach (StartupAction action in Enum.GetValues(typeof(StartupAction)))
             {
                 var refAction = char.ToLowerInvariant(action.ToString()[0]);
                 if (shortAction == refAction)
                 {
                     return(action);
                 }
             }
         }
     }
     return(defaultValue);
 }
コード例 #2
0
ファイル: Slide.cs プロジェクト: AnomalousMedical/Medical
 public void populateCommand(RunCommandsAction action)
 {
     if (startupAction != null)
     {
         StartupAction.setupAction(this, action);
     }
 }
コード例 #3
0
 public ManagedTask(string name, int delayTimeMs, string filePath, StartupAction action, bool isActivated)
 {
     Name        = name;
     DelayTime   = delayTimeMs;
     TaskPath    = filePath;
     IsActivated = isActivated;
     Action      = action;
 }
コード例 #4
0
 /// <summary>
 /// Treat the current task as done, so we can start another. Typically this is
 /// called when its task() returns, but in one case we want to keep a dialog
 /// launched by the task showing (the Team Collection sync progress dialog)
 /// while other tasks continue. Since idle events happen while running the
 /// dialog, we can go on with the next task as long as we know the one for which
 /// the progress dialog was launched is complete.
 /// </summary>
 public static void ConsiderCurrentTaskDone()
 {
     if (_current == null)
     {
         return;
     }
     _startupActions.Remove(_current);
     _current = null;
 }
コード例 #5
0
        /// <summary>
        /// The specified action should be done when the system is idle and any previous
        /// tasks added have completed (subject to priority)
        /// </summary>
        /// <param name="task">The thing to do</param>
        /// <param name="shouldHideSplashScreen">If true, the splash screen will be hidden
        /// before starting the task, typically because it runs a dialog itself</param>
        /// <param name="lowPriority">Tasks where this is true are postponed until all
        /// tasks where it is false have completed, even if the higher priority tasks
        /// were added later.</param>
        /// <param name="needsToRun"> If not null, the task will run from zero to many times,
        /// until needsToRun returns false, before any subsequent tasks.</param>
        /// <returns></returns>
        public static IStartupAction AddStartupAction(Action task, bool shouldHideSplashScreen = false, bool lowPriority = false, Func <bool> needsToRun = null)
        {
            var startupAction = new StartupAction()
            {
                Priority = lowPriority ? StartupActionPriority.low : StartupActionPriority.high,
                ShouldHideSplashScreen = shouldHideSplashScreen, Task = task, NeedsToRun = needsToRun
            };

            _startupActions.Add(startupAction);
            EnableProcessing();
            return(startupAction);
        }
コード例 #6
0
        //メイン動作
        public void DoAction(ICommandTarget target, StartupAction act)
        {
            switch (act)
            {
            case StartupAction.TelnetSSHDialog:
                _commandManager.Execute(_commandManager.Find("org.poderosa.session.telnetSSH"), target);
                break;

            case StartupAction.OpenCygwin:
                _sessionService.TerminalSessionStartCommand.StartTerminalSession(target,
                                                                                 (ITerminalParameter)_protocolService.CreateDefaultCygwinParameter().GetAdapter(typeof(ITerminalParameter)),
                                                                                 _cygwinService.CreateDefaultCygwinTerminalSettings());
                break;
            }
        }
コード例 #7
0
        public void DoAction(StartupAction action)
        {
            Action = action;

            var window = Owner as SkylineWindow;

            if (window == null)
            {
                MainWindow = new SkylineWindow();
                if (!action(MainWindow))
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }
コード例 #8
0
        private ThreadStart GetThreadAction(
            CancellationToken cancellationToken)
        {
            return(() =>
            {
                try
                {
                    StartupAction?.Invoke(cancellationToken);

                    Loop(cancellationToken);
                }
                catch (OperationCanceledException)
                {
                    // Cancellation was requested
                }
            });
        }
コード例 #9
0
        public GlobalConfigurationForm(StartupAction startupAction, Controller controller)
        {
            InitializeComponent();
            Controller = controller;

            ComPortComboBox.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames());
            ComPortComboBox.SelectedIndex = string.IsNullOrEmpty(controller.ComPort) ? 0 : ComPortComboBox.FindString(controller.ComPort);
            ComPortComboBox.Enabled       = !controller.IsConnected;

            RefreshIntervalNumericUpDown.Value   = controller.RefreshInterval;
            RefreshIntervalNumericUpDown.Enabled = !controller.IsConnected;

            LoadTypeComboBox.Items.AddRange(Enum.GetNames(typeof(LoadType)).Where(item => item != "Unknown").ToArray());
            LoadTypeComboBox.SelectedIndex = LoadTypeComboBox.FindString(controller.GlobalConfiguration.LoadType.ToString());
            LoadTypeComboBox.Enabled       = controller.IsConnected;

            AspirationTypeComboBox.Items.AddRange(Enum.GetNames(typeof(AspirationType)).Where(item => item != "Unknown").ToArray());
            AspirationTypeComboBox.SelectedIndex = AspirationTypeComboBox.FindString(controller.GlobalConfiguration.AspirationType.ToString());
            AspirationTypeComboBox.Enabled       = controller.IsConnected;

            StartupActionComboBox.Items.AddRange(Enum.GetNames(typeof(StartupAction)));
            StartupActionComboBox.SelectedIndex = StartupActionComboBox.FindString(startupAction.ToString());
            StartupActionComboBox.Enabled       = controller.IsConnected;

            EdisTypeComboBox.Items.AddRange(Enum.GetNames(typeof(EdisType)).Where(item => item != "Unknown").ToArray());
            EdisTypeComboBox.SelectedIndex = EdisTypeComboBox.FindString(controller.GlobalConfiguration.EdisType.ToString());
            EdisTypeComboBox.Enabled       = controller.IsConnected;

            PipNoiseFilterNumericUpDown.Value       = controller.GlobalConfiguration.PipNoiseFilter;
            PipNoiseFilterNumericUpDown.Enabled     = controller.IsConnected;
            CrankingAdvanceNumericUpDown.Value      = controller.GlobalConfiguration.CrankingAdvance;
            CrankingAdvanceNumericUpDown.Enabled    = controller.IsConnected;
            TriggerWheelOffsetNumericUpDown.Value   = controller.GlobalConfiguration.TriggerWheelOffset;
            TriggerWheelOffsetNumericUpDown.Enabled = controller.IsConnected;

            if (ComPortComboBox.Enabled)
            {
                ComPortComboBox.Focus();
            }
            else
            {
                LoadTypeComboBox.Focus();
            }
        }
コード例 #10
0
        /// <summary>
        /// Where it all happens. This method, invoked as a handler of Application.Idle,
        /// picks one of _startupActions to run next, if one is not already running.
        /// They are done in the order added, except that high priority ones go first.
        /// If there are none, and the minimum time has expired, it closes the splash screen.
        /// </summary>
        private static void DoStartupAction(object sender, EventArgs e)
        {
            if (_current != null)
            {
                // got Idle event while startup action in progress. Wait till it finishes.
                return;
            }
            _current = _startupActions.FirstOrDefault(a => a.Enabled && a.Priority == StartupActionPriority.high);
            if (_current == null)
            {
                _current = _startupActions.FirstOrDefault(a => a.Enabled);
            }
            if (_current == null)
            {
                if (DateTime.Now > _earliestWeShouldCloseTheSplashScreen)
                {
                    CloseSplashScreen();
                    // We can stop running altogether until some new action gets added or enabled.
                    Application.Idle -= DoStartupAction;
                }
                return;
            }

            if (_current.ShouldHideSplashScreen)
            {
                bool tryAgainLater = false;
                if (_splashForm != null)
                {
                    _splashForm.Hide();
                    _splashForm   = null;                   // it's gone, not needed again
                    tryAgainLater = true;
                }

                if (_doWhenSplashScreenShouldClose != null)
                {
                    _doWhenSplashScreenShouldClose();
                    _doWhenSplashScreenShouldClose = null;
                    tryAgainLater = true;
                }

                // The problem we ran into is that one one machine (but not another) was
                // that the TC progress dialog (which is a ReactDialog) was still showing when the next ReactDialog
                // (Do you want to auto update?) was being shown. This only happened because the TC progress dialog
                // sometimes has to stay open even after it is done, so we let other things continue.
                // In the previous code here, we do try to wait for the TC dialog to close first, but on Hatton's
                // machine somehow that didn't work... it lead to setting the ReactDialog Current when it wasn't null.
                // We considered a more principled approach of having ReactDialogs take a key so that multiple can be
                // open at the same time-- they have to tell us which key to use when they call "close". But the complexity
                // there just felt like it wasn't warranted.
                // So we have a bit of a hack here to work around that; if the topmost screen is not the shell,
                // then either some dialog is open, or Bloom itself is not the active app. The latter case
                // means that we effectively pause if there is a dialog waiting to be shown, which will come up
                // when you activate Bloom. We've decided to try and live with that for what we think is a corner case.
                if (Form.ActiveForm != null && !(Form.ActiveForm is Shell))
                {
                    tryAgainLater = true;
                }

                if (tryAgainLater)
                {
                    // Ok, now we've hidden whatever was in the way...but we might
                    // still be executing from the event loop of a modal dialog
                    // that we're trying to get rid of. Safest to wait until the system
                    // is idle one more time, when we'll find the same event, but
                    // nothing needing to be closed.
                    _current = null;
                    return;
                }
            }

            if (_current.NeedsToRun != null)
            {
                if (_current.NeedsToRun())
                {
                    _current.Task();
                    _current = null;                      // NOT done, but will be found again.
                    return;
                }
                else
                {
                    ConsiderCurrentTaskDone();
                    return;
                }
            }

            _current.Task();
            ConsiderCurrentTaskDone();
        }
コード例 #11
0
ファイル: StartupHandler.cs プロジェクト: Mixi59/Stump
 public static void SendStartupActionFinishedMessage(IPacketReceiver client, StartupAction action)
 {
     //client.Send(new StartupActionFinishedMessage(action.Id));
 }
コード例 #12
0
 //メイン動作
 public void DoAction(ICommandTarget target, StartupAction act) {
     switch (act) {
         case StartupAction.TelnetSSHDialog:
             _commandManager.Execute(_commandManager.Find("org.poderosa.session.telnetSSH"), target);
             break;
         case StartupAction.OpenCygwin:
             _sessionService.TerminalSessionStartCommand.StartTerminalSession(target,
                 (ITerminalParameter)_protocolService.CreateDefaultCygwinParameter().GetAdapter(typeof(ITerminalParameter)),
                 _cygwinService.CreateDefaultCygwinTerminalSettings());
             break;
     }
 }
コード例 #13
0
ファイル: StartPage.cs プロジェクト: lgatto/proteowizard
        public void DoAction(StartupAction action)
        {
            Action = action;

            var window = Owner as SkylineWindow;
            if (window == null)
            {
                MainWindow = new SkylineWindow();
                if (!action(MainWindow))
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }
コード例 #14
0
 public static void SendStartupActionFinishedMessage(IPacketReceiver client, StartupAction action, bool success)
 {
     client.Send(new StartupActionFinishedMessage(success, true, action.Id));
 }