Exemple #1
0
        private void RefreshChart()
        {
            if (_inputData.Count == 0) // no data to draw
            {
                MessageBox.Show("No input data to display", "Error when drawing data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var      selectedDrawers = checkedListBox1.CheckedItems;
            Bitmap   image           = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g = Graphics.FromImage(image);

            g.Clear(Color.White);
            DrawGrid(g, BlackPen, pictureBox1.Width, pictureBox1.Height);
            for (int i = 0; i < selectedDrawers.Count; i++)
            {
                Drawers.IDrawer drawer = (Drawers.IDrawer)selectedDrawers[i];
                progressBar.Value = (int)(i * 100 / selectedDrawers.Count);
                try
                {
                    drawer.DrawChart(ref _inputData,
                                     ref g,
                                     _inputData[0].Timestamp,
                                     _inputData[_inputData.Count - 1].Timestamp,
                                     0,
                                     GetMaxValueBasedOnDrawerType(drawer),
                                     pictureBox1.Width,
                                     pictureBox1.Height);
                }
                catch (Exception exception)
                {
                    Console.WriteLine($"Error:{exception.Message}");
                }
                progressBar.Update();
            }
            progressBar.Value = 100;
            pictureBox1.Image = image;
            pictureBox1.Refresh();
            g.Dispose();
        }
Exemple #2
0
 private int GetMaxValueBasedOnDrawerType(Drawers.IDrawer drawer)
 {
     if (drawer is Drawers.DrawerPM1)
     {
         return(_maxPm1Value);
     }
     else if (drawer is Drawers.DrawerPM10)
     {
         return(_maxPm10Value);
     }
     else if (drawer is Drawers.DrawerPM25)
     {
         return(_maxPm25Value);
     }
     else if (drawer is Drawers.DrawerTemperature)
     {
         return(_maxTemperature);
     }
     else if (drawer is Drawers.DrawerSpeedPercent)
     {
         return(100);
     }
     else if (drawer is Drawers.DrawerMode)
     {
         return(4);
     }
     else if (drawer is Drawers.DrawerAqMode)
     {
         return(6);
     }
     else if (drawer is Drawers.DrawerSpeedRpm)
     {
         return(20000);
     }
     else
     {
         return(0);
     }
 }