Exemple #1
0
        /// <summary>
        /// 活动窗口切换时触发, 传入当前活跃窗口进程
        /// </summary>
        /// <param name="processId"></param>
        public void WindowSwitch(Process process)
        {
            OSRunTime = TimeSpan.FromMilliseconds(Environment.TickCount);

            if (ApplicationFilter.isContain(process.Id) || ApplicationFilter.isMatch(process.MainModule.FileName))
            {
                // 更新所有IWindow信息
                IWindowManager.UpdateAll();

                // 更新窗体界面
                UpdateView();
                return;
            }

            // 更新数据:
            // (1) 添加新IWindow
            IWindow window = null;

            if (!IWindowManager.isContain(process))
            {
                window = IWindowManager.Add(process);
                AddViewItem(window);
            }
            // (2) 更新所有IWindow信息
            IWindowManager.UpdateAll();

            // 更新窗体界面
            UpdateView();
            // 保存时间片信息
            if (IWindowManager.CurrentIWindow != null)
            {
                DataPersistence.InsertTimeRange(IWindowManager.CurrentIWindow);
            }
            IWindowManager.SetForeground(process);
        }
Exemple #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IProcessId = Process.GetCurrentProcess().Id;

            DataPersistence.Init();

            mainForm = new MainForm();
            Application.Run(mainForm);
        }
Exemple #3
0
        /// <summary>
        /// 更新历史记录页面
        /// </summary>
        public void UpdateHistory()
        {
            List <Object[]> result = DataPersistence.QueryTimeRange();

            HistoryList.BeginUpdate();
            HistoryList.Items.Clear();
            foreach (Object[] row in result)
            {
                ListViewItem item = new ListViewItem((String)row[3]);
                item.SubItems.Add((((DateTime)row[0]).ToLongTimeString()));
                item.SubItems.Add((((DateTime)row[1]).ToLongTimeString()));
                item.SubItems.Add(((Int64)row[4]).ToString());
                item.SubItems.Add(((String)row[2]));
                HistoryList.Items.Add(item);
            }
            HistoryList.EndUpdate();
        }