Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 3
0
        void TsWinLoggerAppChanged(object sender, WindowTracker.ActApplicationChangedHandlerArgs args)
        {
            var currApp = _applicationList.Find(a =>
                                                a.Name == args.NewPname && a.Description == args.NewPdesc);

            if (currApp != null)
            {
                if (currApp.PID != args.NewPID)
                {
                    currApp.StartTime = DateTime.Now;
                    currApp.PID       = args.NewPID;
                }
            }
            else
            {
                var app = new TsApplication(args.NewPname, args.NewPdesc, args.NewPID)
                {
                    StartTime = DateTime.Now
                };
                app.SmallIcon = IconHelper.GetApplicationIcon(app.Name, app.Description, false).ToBitmap();
                app.LargeIcon = IconHelper.GetApplicationIcon(app.Name, app.Description, true).ToBitmap();
                _taskDbs.NewApplication(app);
                _applicationList.Add(app);
                InvokeNewApplication(new TsApplication.NewApplicationHandlerArgs(app));
            }
        }
Ejemplo n.º 4
0
 public void AddNewApplication(TsApplication app)
 {
     if (lvApplications.InvokeRequired)
     {
         lvApplications.Invoke(new AddAppDelegate(AddApp), app);
     }
     else
     {
         AddApp(app);
     }
 }
Ejemplo n.º 5
0
 private void AddApp(TsApplication app)
 {
     if (lvApplications.Items.Find(app.Id.ToString(), false).Length > 0)
     {
         return;
     }
     ilAppLarge.Images.Add(app.LargeIcon ?? Properties.Resources.defAppL);
     ilAppSmall.Images.Add(app.SmallIcon ?? Properties.Resources.defAppS);
     lvApplications.Items.Add(new ListViewItem(app.Description, ilAppSmall.Images.Count - 1)
     {
         Name = app.Id.ToString(), Tag = app
     });
 }
Ejemplo n.º 6
0
		public void NewApplication(TsApplication app)
		{
			_dtApplication.Rows.Add(app.ToDataRow());
		}