Пример #1
0
        private void UpdateDisplayLayout()
        {
            MainPanel.Background = new SolidColorBrush(Setting.param.BackColor);
            timer_count_max      = Setting.param.GetMeterUpdatePerInfo();

            for (int i = 0; i < MAX_METER_NUM; i++)
            {
                MeasureObj obj;
                InfoTypeId id = Setting.param.GetInfoTypeAt(i);
                switch (id)
                {
                case InfoTypeId.INFO_CPU_TOTAL:
                    obj = new MeasureCpuTotal(false);
                    break;

                case InfoTypeId.INFO_CPU_REMAIN:
                    obj = new MeasureCpuTotal(true);
                    break;

                case InfoTypeId.INFO_MEM_TOTAL:
                    obj = new MeasureMemory();
                    break;

                default:
                    if (id >= InfoTypeId.INFO_CPUEACH_START)
                    {
                        obj = new MeasureCpuEach((int)id - (int)InfoTypeId.INFO_CPUEACH_START);
                        break;
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }

                meter_controls[i] = new MeterControl()
                {
                    Meter        = meters[i],
                    MeasureObj   = obj,
                    MaxTimeIndex = timer_count_max
                };
            }

            if (timer != null)
            {
                timer.Interval = TimeSpan.FromMilliseconds(Setting.param.GetUpdateInterval());
            }
            SetNumRows(Setting.param.NumberOfRows);

            for (int i = 0; i < Setting.param.NumberOfRows; i++)
            {
                labels[i].Content = GetTitleText(Setting.param.GetInfoTypeAt(2 * i), Setting.param.GetInfoTypeAt(2 * i + 1));
            }
        }
Пример #2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            timer.Stop();
            MeasureCpuTotal.Dispose();

            timer          = null;
            meter_controls = null;

            // Save settings
            Setting.param.WindowWidth  = Width;
            Setting.param.WindowHeight = Height;
            Setting.Save();
        }
Пример #3
0
        void timer_Tick(object sender, EventArgs e)
        {
            if (meter_controls == null)
            {
                return;
            }

            if (Setting.param.IsSmooth)
            {
                if (timer_count == 0)
                {
                    MeasureCpuTotal.Update();
                    MeasureCpuEach.Update();
                    MeasureMemory.Update();
                    foreach (var x in meter_controls)
                    {
                        x.UpdateData();
                    }
                }
                foreach (var x in meter_controls)
                {
                    x.UpdateSmooth(timer_count);
                }
                timer_count++;
                if (timer_count == timer_count_max)
                {
                    timer_count = 0;
                }
            }
            else
            {
                MeasureCpuTotal.Update();
                MeasureCpuEach.Update();
                MeasureMemory.Update();
                foreach (var x in meter_controls)
                {
                    x.UpdateData();
                    x.UpdateDirect();
                }
            }
        }