Exemple #1
0
        public void SetInitValue()
        {
            MeasureCpuEach mcpue = new MeasureCpuEach(0);

            string[] names = MeasureCpuEach.GetInstanceNames();
            int      n     = (names.Length < MainWindow.MAX_METER_NUM) ? names.Length : MainWindow.MAX_METER_NUM;

            NumberOfRows = (n % 2 == 0) ? n / 2 : (n / 2 + 1);

            for (int i = 0; i < n; i++)
            {
                MeterContentId[i] = i + (int)InfoTypeId.INFO_CPUEACH_START;
            }
            for (int i = n; i < MainWindow.MAX_METER_NUM; i++)
            {
                MeterContentId[i] = 2;
            }

            UpdateInfoInterval = 1000;
            UpdateMoveInterval = 150;
            IsSmooth           = true;
            //BackColor = new Color() { R = 0xCC, G = 0x28, B = 0x28, A = 0xDD };
            BackColor = new Color()
            {
                R = 0xD7, G = 0x0A, B = 0x5A, A = 0xDC
            };
            WindowWidth   = 250;
            WindowHeight  = 520;
            IsAlwaysOnTop = true;
        }
Exemple #2
0
        private string GetCpuDataText(InfoTypeId id)
        {
            if (id == InfoTypeId.INFO_CPU_TOTAL || id == InfoTypeId.INFO_CPU_REMAIN ||
                id >= InfoTypeId.INFO_CPUEACH_START)
            {
                switch (id)
                {
                case InfoTypeId.INFO_CPU_REMAIN:
                    return("Available");

                case InfoTypeId.INFO_CPU_TOTAL:
                    return("Total");

                default:
                    if (id >= InfoTypeId.INFO_CPUEACH_START)
                    {
                        string[] instance_names = MeasureCpuEach.GetInstanceNames();
                        return(instance_names[(int)id - (int)InfoTypeId.INFO_CPUEACH_START]);
                    }
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #3
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));
            }
        }
Exemple #4
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();
                }
            }
        }
Exemple #5
0
        private void CreateTypeComboItems()
        {
            ComboBoxItem[] old_list = Resources["DispInfoTypesItems"] as ComboBoxItem[];
            MeasureCpuEach mcpue    = new MeasureCpuEach(0);

            string[] names = MeasureCpuEach.GetInstanceNames();
            new_list = new ComboBoxItem[names.Length + old_list.Length];
            for (int i = 0; i < old_list.Length; i++)
            {
                new_list[i] = old_list[i];
            }
            for (int i = 0; i < names.Length; i++)
            {
                new_list[old_list.Length + i] = new ComboBoxItem()
                {
                    Content = "CPU " + names[i],
                    Tag     = (i + (int)InfoTypeId.INFO_CPUEACH_START).ToString()
                };
            }
            foreach (var x in combos)
            {
                x.ItemsSource = new_list;
            }
        }