Beispiel #1
0
        private void Initialize()
        {
            initializing = true;
            this.editHistorySize.Value           = this.Options.HistorySize;
            this.editPollTime.Value              = this.Options.PollTime;
            this.listCounters.DataSource         = this.Options.CounterOptions.Keys.AsEnumerable().ToList();
            this.listShowTitle.DataSource        = Enum.GetValues(typeof(CounterOptions.DisplayType));
            this.listShowCurrentValue.DataSource = Enum.GetValues(typeof(CounterOptions.DisplayType));
            this.listSummaryPosition.DataSource  = Enum.GetValues(typeof(CounterOptions.DisplayPosition));
            this.listTitlePosition.DataSource    = Enum.GetValues(typeof(CounterOptions.DisplayPosition));

            lblVersion.Text = "v" + Version.ToString(3);

            ActiveCounter = this.Options.CounterOptions.First().Value;
            UpdateForm();
            UpdateReplicateSettingsMenu();
            btnColorBar.BackColor                = this.Theme.BarColor;
            btnColorCurrentValue.BackColor       = this.Theme.TextColor;
            btnColorCurrentValueShadow.BackColor = this.Theme.TextShadowColor;
            btnColorTitle.BackColor              = this.Theme.TitleColor;
            btnColorTitleShadow.BackColor        = this.Theme.TitleShadowColor;

            ChosenTitleFont    = new Font(this.Theme.TitleFont, this.Theme.TitleSize, FontStyle.Bold);
            linkTitleFont.Text = ChosenTitleFont.Name + ", " + ChosenTitleFont.Size + "pt";

            ChosenCurrentValueFont    = new Font(this.Theme.CurrentValueFont, this.Theme.CurrentValueSize, FontStyle.Bold);
            linkCurrentValueFont.Text = ChosenCurrentValueFont.Name + ", " + Math.Round(ChosenCurrentValueFont.Size) + "pt";

            btnColor1.BackColor = this.Theme.StackedColors[0];
            btnColor2.BackColor = this.Theme.StackedColors[1];

            UpdatePreview();

            initializing = false;
        }
Beispiel #2
0
 private void ListCounters_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (initializing)
     {
         return;
     }
     ActiveCounter = Options.CounterOptions[listCounters.Text];
     UpdateReplicateSettingsMenu();
     UpdateForm();
     UpdatePreview();
 }
Beispiel #3
0
        private void drawStackedGraph(System.Drawing.Graphics formGraphics, int x, int y, int maxH, bool invertido, List <TaskbarMonitor.Counters.CounterInfo> infos, GraphTheme theme, CounterOptions opt)
        {
            float        absMax    = 0;
            List <float> lastValue = new List <float>();

            // accumulate values for stacked effect
            List <List <float> > values = new List <List <float> >();

            foreach (var info in infos.AsEnumerable().Reverse())
            {
                absMax += info.MaximumValue;
                var value = new List <float>();
                int z     = 0;
                foreach (var item in info.History)
                {
                    value.Add(item + (lastValue.Count > 0 ? lastValue.ElementAt(z) : 0));
                    z++;
                }
                values.Add(value);
                lastValue = value;
            }
            var historySize = values.Count > 0 ? values[0].Count : 0;
            // now we draw it

            var colors = theme.GetColorGradient(theme.StackedColors[0], theme.StackedColors[1], values.Count);
            int w      = 0;

            if (!invertido)
            {
                values.Reverse();
            }
            foreach (var info in values)
            {
                float currentValue = info.Count > 0 ? info.Last() : 0;
                var   pos          = maxH - ((currentValue * maxH) / absMax);
                if (pos > Int32.MaxValue)
                {
                    pos = Int32.MaxValue;
                }
                int posInt = Convert.ToInt32(pos) + y;

                var height = (currentValue * maxH) / absMax;
                if (height > Int32.MaxValue)
                {
                    height = Int32.MaxValue;
                }
                int heightInt = Convert.ToInt32(height);

                SolidBrush BrushBar = new SolidBrush(theme.BarColor);
                formGraphics.FillRectangle(BrushBar, new Rectangle(x + Options.HistorySize, posInt, 4, heightInt));
                BrushBar.Dispose();

                int     i = 0;
                var     initialGraphPosition = x + Options.HistorySize - historySize;
                Point[] points = new Point[historySize + 2];
                foreach (var item in info)
                {
                    var heightItem = (item * maxH) / absMax;
                    if (heightItem > Int32.MaxValue)
                    {
                        heightItem = Int32.MaxValue;
                    }
                    var convertido = Convert.ToInt32(heightItem);

                    points[i] = new Point(initialGraphPosition + i, maxH - convertido + y);
                    i++;
                }
                points[i]     = new Point(initialGraphPosition + i, maxH + y);
                points[i + 1] = new Point(initialGraphPosition, maxH + y);

                Brush brush = new SolidBrush(colors.ElementAt(w));
                w++;
                formGraphics.FillPolygon(brush, points);
                brush.Dispose();
            }
        }
Beispiel #4
0
        private void drawGraph(System.Drawing.Graphics formGraphics, int x, int y, int maxH, bool invertido, TaskbarMonitor.Counters.CounterInfo info, GraphTheme theme, CounterOptions opt)
        {
            var pos = maxH - ((info.CurrentValue * maxH) / info.MaximumValue);

            if (pos > Int32.MaxValue)
            {
                pos = Int32.MaxValue;
            }
            int posInt = Convert.ToInt32(pos) + y;

            var height = (info.CurrentValue * maxH) / info.MaximumValue;

            if (height > Int32.MaxValue)
            {
                height = Int32.MaxValue;
            }
            int heightInt = Convert.ToInt32(height);

            using (SolidBrush BrushBar = new SolidBrush(theme.BarColor))
            {
                if (invertido)
                {
                    formGraphics.FillRectangle(BrushBar, new Rectangle(x + Options.HistorySize, maxH, 4, heightInt));
                }
                else
                {
                    formGraphics.FillRectangle(BrushBar, new Rectangle(x + Options.HistorySize, posInt, 4, heightInt));
                }
            }

            var initialGraphPosition = x + Options.HistorySize - info.History.Count;

            Point[] points   = new Point[info.History.Count + 2];
            int     i        = 0;
            int     inverter = invertido ? -1 : 1;

            foreach (var item in info.History)
            {
                var heightItem = (item * maxH) / info.MaximumValue;
                if (heightItem > Int32.MaxValue)
                {
                    height = Int32.MaxValue;
                }
                var convertido = Convert.ToInt32(heightItem);


                if (invertido)
                {
                    points[i] = new Point(initialGraphPosition + i, 0 + convertido + y);
                }
                else
                {
                    points[i] = new Point(initialGraphPosition + i, maxH - convertido + y);
                }
                i++;
            }
            if (invertido)
            {
                points[i]     = new Point(initialGraphPosition + i, 0 + y);
                points[i + 1] = new Point(initialGraphPosition, 0 + y);
            }
            else
            {
                points[i]     = new Point(initialGraphPosition + i, maxH + y);
                points[i + 1] = new Point(initialGraphPosition, maxH + y);
            }
            using (SolidBrush BrushGraph = new SolidBrush(theme.getNthColor(2, invertido ? 1 : 0)))
            {
                formGraphics.FillPolygon(BrushGraph, points);
            }
        }
Beispiel #5
0
        public OptionForm(Options opt, GraphTheme theme, Version version)
        {
            this.Version         = version;
            this.Theme           = theme;
            this.Options         = new Options();
            this.OriginalOptions = opt;
            opt.CopyTo(this.Options);
            AvailableGraphTypes = new Dictionary <string, IList <Counters.ICounter.CounterType> >
            {
                { "CPU", new List <TaskbarMonitor.Counters.ICounter.CounterType>
                  {
                      TaskbarMonitor.Counters.ICounter.CounterType.SINGLE,
                      TaskbarMonitor.Counters.ICounter.CounterType.STACKED
                  } },
                { "MEM", new List <TaskbarMonitor.Counters.ICounter.CounterType>
                  {
                      TaskbarMonitor.Counters.ICounter.CounterType.SINGLE
                  } },
                { "DISK", new List <TaskbarMonitor.Counters.ICounter.CounterType>
                  {
                      TaskbarMonitor.Counters.ICounter.CounterType.SINGLE,
                      TaskbarMonitor.Counters.ICounter.CounterType.STACKED,
                      TaskbarMonitor.Counters.ICounter.CounterType.MIRRORED
                  } },
                { "NET", new List <TaskbarMonitor.Counters.ICounter.CounterType>
                  {
                      TaskbarMonitor.Counters.ICounter.CounterType.SINGLE,
                      TaskbarMonitor.Counters.ICounter.CounterType.STACKED,
                      TaskbarMonitor.Counters.ICounter.CounterType.MIRRORED
                  } }
            };
            InitializeComponent();

            float dpiX, dpiY;

            using (Graphics graphics = this.CreateGraphics())
            {
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiY;
            }

            if (dpiX >= 96)
            {
                var fontSize = 7.25f;
                this.Font = new Font("Calibri", fontSize, FontStyle.Regular);
            }

            this.editHistorySize.Value           = this.Options.HistorySize;
            this.editPollTime.Value              = this.Options.PollTime;
            this.listCounters.DataSource         = this.Options.CounterOptions.Keys.AsEnumerable().ToList();
            this.listShowTitle.DataSource        = Enum.GetValues(typeof(CounterOptions.DisplayType));
            this.listShowCurrentValue.DataSource = Enum.GetValues(typeof(CounterOptions.DisplayType));
            this.listSummaryPosition.DataSource  = Enum.GetValues(typeof(CounterOptions.DisplayPosition));
            this.listTitlePosition.DataSource    = Enum.GetValues(typeof(CounterOptions.DisplayPosition));

            lblVersion.Text = "v" + version.ToString(3);

            ActiveCounter = this.Options.CounterOptions.First().Value;
            UpdateForm();
            UpdateReplicateSettingsMenu();
            btnColorBar.BackColor                = this.Theme.BarColor;
            btnColorCurrentValue.BackColor       = this.Theme.TextColor;
            btnColorCurrentValueShadow.BackColor = this.Theme.TextShadowColor;
            btnColorTitle.BackColor              = this.Theme.TitleColor;
            btnColorTitleShadow.BackColor        = this.Theme.TitleShadowColor;
            btnColor1.BackColor = this.Theme.StackedColors[0];
            btnColor2.BackColor = this.Theme.StackedColors[1];

            UpdatePreview();

            initializing = false;
        }