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
 public MainForm()
 {
     InitializeComponent();
     AppWindows = IWindowManager.AppWindows;
     IProcessId = Program.IProcessId;
     ApplicationFilter.AddProcessId(IProcessId);
     ApplicationFilter.AddAppPath(@"C:\WINDOWS\");
 }