예제 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            // StopWatch Label
            this.stopWatchLabel.Text  = string.Format("{0:hh\\:mm\\:ss}", stopWatch.Elapsed);
            this.stopWatchLabel2.Text = string.Format("{0:fff}", stopWatch.Elapsed);



            // Money Label
            double money;

            this.wageInfoLabel.Text = string.Format("{0} {1} per ", Settings1.Default.wage, Settings1.Default.currency); // Wage information Label
            switch (Settings1.Default.per)
            {
            case 0:
                money = double.Parse(stopWatch.Elapsed.TotalHours.ToString()) * Settings1.Default.wage;
                this.moneyLabel.Text     = string.Format("{0:f2} {1}", money, Settings1.Default.currency);
                this.wageInfoLabel.Text += "hour";
                break;

            case 1:
                money = double.Parse(stopWatch.Elapsed.TotalMinutes.ToString()) * Settings1.Default.wage;
                this.moneyLabel.Text     = string.Format("{0:f2} {1}", money, Settings1.Default.currency);
                this.wageInfoLabel.Text += "minute";
                break;

            case 2:
                money = double.Parse(stopWatch.Elapsed.TotalSeconds.ToString()) * Settings1.Default.wage;
                this.moneyLabel.Text     = string.Format("{0:f2} {1}", money, Settings1.Default.currency);
                this.wageInfoLabel.Text += "second";
                break;
            }


            // Main mechanic
            if ((choosedProcessesName.Count > 0) && releaseStopwatch)
            {
                if (choosedProcessesName.Contains(GetActiveProcess().ProcessName) &&
                    !stopWatch.IsRunning)
                {
                    stopWatch.Start();
                }
                else
                {
                    if (!choosedProcessesName.Contains(GetActiveProcess().ProcessName) &&
                        stopWatch.IsRunning)
                    {
                        stopWatch.Stop();
                    }
                }
            }
        }
예제 #2
0
        private async void RefreshGrid()
        {
            while (true)
            {
                await Task.Run(() =>
                {
                    Thread.Sleep(5000);
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        try
                        {
                            lock (ProcessesList)
                            {
                                List <ProcessListItem> itemsToRemove = ProcessesList.Where(proc => !ProcessesManager.Processes.ContainsKey(proc.ProcessID)).ToList();
                                foreach (ProcessListItem p in itemsToRemove)
                                {
                                    ProcessesList.Remove(p);
                                }

                                List <ProcessListItem> itemsToAdd = ProcessesManager.Processes.Values.Where(proc => !ProcessesList.Contains(proc)).ToList();
                                foreach (ProcessListItem p in itemsToAdd)
                                {
                                    ProcessesList.Add(p);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                    });
                });
            }
        }