Esempio n. 1
0
        public void ApplyOptions(Options Options)
        {
            this.Options = Options;
            Counters     = new List <Counters.ICounter>();
            if (Options.CounterOptions.ContainsKey("CPU"))
            {
                var ct = new Counters.CounterCPU(Options);
                ct.Initialize();
                Counters.Add(ct);
            }
            if (Options.CounterOptions.ContainsKey("MEM"))
            {
                var ct = new Counters.CounterMemory(Options);
                ct.Initialize();
                Counters.Add(ct);
            }
            if (Options.CounterOptions.ContainsKey("DISK"))
            {
                var ct = new Counters.CounterDisk(Options);
                ct.Initialize();
                Counters.Add(ct);
            }
            if (Options.CounterOptions.ContainsKey("NET"))
            {
                var ct = new Counters.CounterNetwork(Options);
                ct.Initialize();
                Counters.Add(ct);
            }

            AdjustControlSize();
            UpdateGraphs();
            this.Invalidate();
        }
        private void Initialize(Options opt, GraphTheme theme)
        {
            Counters = new List <Counters.ICounter>();
            if (opt.CounterOptions.ContainsKey("CPU"))
            {
                var ct = new Counters.CounterCPU(opt);
                ct.Initialize();
                Counters.Add(ct);
            }
            if (opt.CounterOptions.ContainsKey("MEM"))
            {
                var ct = new Counters.CounterMemory(opt);
                ct.Initialize();
                Counters.Add(ct);
            }
            if (opt.CounterOptions.ContainsKey("DISK"))
            {
                var ct = new Counters.CounterDisk(opt);
                ct.Initialize();
                Counters.Add(ct);
            }
            if (opt.CounterOptions.ContainsKey("NET"))
            {
                var ct = new Counters.CounterNetwork(opt);
                ct.Initialize();
                Counters.Add(ct);
            }

            ApplyOptions(opt, theme);
            //Initialize();
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.UserPaint, true);

            InitializeComponent();
            AdjustControlSize();

            pollingTimer          = new System.Timers.Timer(opt.PollTime * 1000);
            pollingTimer.Enabled  = true;
            pollingTimer.Elapsed += PollingTimer_Elapsed;
            pollingTimer.Start();
        }