Exemple #1
0
 public void Deactivate_CalledTwice_Throws()
 {
     try
     {
         _task.Activate();
         _task.Deactivate();
     }
     finally
     {
         Assert.Throws <InvalidOperationException>(() => _task.Deactivate());
     }
     //    _task = null;
     //            GC.Collect();
     //            GC.WaitForPendingFinalizers();
 }
Exemple #2
0
        void OnTaskToggled(object sender, Gtk.ToggledArgs args)
        {
            Logger.Debug("OnTaskToggled");
            Gtk.TreeIter iter;
            Gtk.TreePath path = new Gtk.TreePath(args.Path);
            if (!Model.GetIter(out iter, path))
            {
                return;                 // Do nothing
            }
            ITask task = Model.GetValue(iter, 0) as ITask;

            if (task == null)
            {
                return;
            }

            // remove any timer set up on this task
            InactivateTimer.CancelTimer(task);

            if (task.State == TaskState.Active)
            {
                bool showCompletedTasks =
                    Application.Preferences.GetBool(
                        Preferences.ShowCompletedTasksKey);

                // When showCompletedTasks is true, complete the tasks right
                // away.  Otherwise, set a timer and show the timer animation
                // before marking the task completed.
                if (showCompletedTasks)
                {
                    task.Complete();
                    ShowCompletedTaskStatus();
                }
                else
                {
                    task.Inactivate();

                    // Read the inactivate timeout from a preference
                    int timeout =
                        Application.Preferences.GetInt(Preferences.InactivateTimeoutKey);
                    Logger.Debug("Read timeout from prefs: {0}", timeout);
                    InactivateTimer timer =
                        new InactivateTimer(this, iter, task, (uint)timeout);
                    timer.StartTimer();
                    toggled = true;
                }
            }
            else
            {
                status = Catalog.GetString("Action Canceled");
                TaskWindow.ShowStatus(status);
                task.Activate();
            }
        }
        /// <summary>
        /// Marks a task active
        /// </summary>
        /// <param name="id">
        /// A <see cref="System.String"/> for the ID of the task
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>, true for success, false
        /// for failure.
        /// </returns>
        public bool MarkTaskAsActiveById(string id)
        {
            ITask task = GetTaskById(id);

            if (task == null)
            {
                return(false);
            }

            task.Activate();
            return(true);
        }
Exemple #4
0
        private void  OnNotebookSwitchPage(object o, SwitchPageArgs args)
        {
            ITask t = (ITask)_tabsToTools[(int)args.PageNum];

            if (_currentTool == t)
            {
                return;            //debounce
            }
            if (_currentTool != null)
            {
                _currentTool.Deactivate();
            }
            if (t != null)
            {
                t.Activate();
            }
            _currentTool = t;
        }
Exemple #5
0
        private void ActivateTask(Control page, ITask task)
        {
            Logger.WriteEvent("Activating " + page.Text);             //enhance: get in English always
            if (ActiveTask == task)
            {
                return;
            }
            try
            {
                task.Activate();
            }
            catch (ConfigurationException e)             //let others go through the normal reporting system
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
                Logger.WriteEvent("Failed Activating");
                return;
            }

            task.Control.Dock = DockStyle.Fill;

            if (task.Control.GetType() == typeof(Chorus.UI.Notes.Browser.NotesBrowserPage))
            {
                page.Controls.Add(task.Control);
            }
            else             //I (JH) don't know what problem this code was intended to solve, but it prevents the notes browser from docking properly
            {
                // Prevent partial scrollbars and the like from displaying before the page's Control actually lays itself out below.
                // Suspending layout of the topmost Control works fine on Windows, but not for Linux/Mono.  But suspending/resuming
                // all the way down should be okay on Windows even if it's overkill.
                PreventLayout(task.Control);
                page.Controls.Add(task.Control);
                AllowLayout(task.Control);
            }
            task.Control.SelectNextControl(task.Control, true, true, true, true);

            // The .FocusDesiredControl() gives the task specific control over which child field gets focus when the task is activated.  If every task implemented this method, then the above task.Control.SelectNextControl would be unnecessary
            task.FocusDesiredControl();
            task.Control.PerformLayout();
            task.Control.Invalidate(true);

            page.Cursor = Cursors.Default;
            _activeTask = task;
            Logger.WriteEvent("Done Activating");
        }
        /// <summary>
        ///   Activation. This method is called when the task was chosen to be executed. It's called right before the first update of the task. The task can setup its specific task data in here and do initial actions.
        /// </summary>
        /// <param name="agentData"> Agent data. </param>
        /// <param name="decisionData"> Decision data to use in activate method. </param>
        /// <returns> Execution status after activation. </returns>
        public override ExecutionStatus Activate(IAgentData agentData, IDecisionData decisionData)
        {
            ITask task = this.GetTask(agentData);

            return(task == null ? ExecutionStatus.Failed : task.Activate(agentData, decisionData));
        }
Exemple #7
0
		private void ActivateTask(Control page, ITask task)
		{
			Logger.WriteEvent("Activating " + page.Text); //enhance: get in English always
			if (ActiveTask == task)
			{
				return;
			}
			try
			{
				task.Activate();
			}
			catch (ConfigurationException e) //let others go through the normal bug reporting system
			{
				ErrorReport.ReportNonFatalMessage(e.Message);
				Logger.WriteEvent("Failed Activating");
				return;
			}

			// RunCommand(new ActivateTaskCommand(page, task));
			task.Control.Dock = DockStyle.Fill;
			page.Controls.Add(task.Control);
			task.Control.SelectNextControl(task.Control, true, true, true, true);
			task.Control.PerformLayout();
			task.Control.Invalidate(true);
			page.Cursor = Cursors.Default;
			_activeTask = task;
			Logger.WriteEvent("Done Activating");
		}