示例#1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Parent == null)
            {
                lvApplications.Visible = true;
                TsTask currentTask = (TsTask)e.Node.Tag;
                _supressChecked = true;

                foreach (ListViewItem appItem in lvApplications.Items)
                {
                    TsApplication currentApp = (TsApplication)appItem.Tag;
                    if (currentTask.AssignedApplications.Find(a => a.PID == currentApp.PID) == null)
                    {
                        appItem.Checked = false;
                    }
                    else
                    {
                        appItem.Checked = true;
                    }
                }

                _supressChecked = false;
            }
            else
            {
                lvApplications.Visible = false;
            }
        }
示例#2
0
        void TsWinLoggerStateChanged(object sender, WindowLogger.AppWindowChangedHandlerArgs args)
        {
            var prevApp = _applicationList.Find(app =>
                                                app.Name == args.OldState.ProcesName &&
                                                app.Description == args.OldState.ProcessDesc);
            var newApp = _applicationList.Find(app =>
                                               app.Name == args.NewState.ProcesName &&
                                               app.Description == args.NewState.ProcessDesc);

            if (prevApp != null)
            {
                TsApplication app  = null;
                TsTask        task = _taskList.Find(t => (app = t.AssignedApplications.Find(a => a.PID == prevApp.PID)) != null);
                if (task != null)
                {
                    task.ActualTimeToSpend += DateTime.Now - app.StartTime;
                    _taskDbs.UpdateTask(task);
                }
                //TODO : work with application's windows
                //var wind = new TsWindow(args.OldState.WindowTitle, args.OldState.Ts);
                //if (!actApp.RunningWindows.Contains(wind))
                //    actApp.RunningWindows.Add(wind);
            }
            if (newApp != null)
            {
                newApp.StartTime = DateTime.Now;
            }
        }
示例#3
0
 public void NewTask(TsTask task)
 {
     if (!_taskList.Contains(task))
     {
         _taskDbs.NewTask(task);
         _taskList.Add(task);
     }
 }
示例#4
0
		public void UpdateTask(TsTask task)
		{
			//TODO : very bad code!
			//refactoring is needed
			var q = (from oldTask in _dtTasks.AsEnumerable()
					where (int)oldTask["Id"] == task.Id
					select oldTask).First();
			q.SetField("ActualTimeToSpend", task.ActualTimeToSpend);
		}
示例#5
0
        private void AddTask(TsTask task)
        {
            TreeNode tn = new TreeNode(task.TaskName)
            {
                Name = task.TaskName, Tag = task
            };

            if (!treeView1.Nodes.ContainsKey(task.TaskName))
            {
                treeView1.Nodes.Add(tn);
            }
        }
示例#6
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (textBox1.Text != String.Empty)
                {
                    TsTask _task = new TsTask(textBox1.Text, textBox1.Text, DateTime.Now);
                    InvokeNewTask(new TsTask.NewTaskHandlerArgs(_task));
                    AddTask(_task);
                }

                textBox1.Text = String.Empty;
            }
        }
示例#7
0
 public void AddNewTask(TsTask task)
 {
     TsAppCore.Instance.NewTask(task);
 }
示例#8
0
		public void DelTask(TsTask task)
		{
			_dtTasks.Rows.Remove(_dtTasks.Rows.Find(task.Id));
		}
示例#9
0
		public void NewTask(TsTask task)
		{
			_dtTasks.Rows.Add(task.ToDataRow());
		}