Ejemplo n.º 1
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            gaugeTemp.Value     = 0;
            gaugeRainfall.Value = 0;
            gaugeRainfall.Update();
            gaugeTemp.Update();
            try                                                                       //trying to show data from monitors on the GUI.
            {
                Console.Out.WriteLine(lbMonitors.SelectedItem + " monitor selected"); // Confirming logic to console
                MonitorFactory mf = monCol5m.MonitorArray[lbMonitors.SelectedIndex];  //Assigning the monitor corresponding to the one created and then selected by the user.
                //Updating Outputs
                Console.Out.WriteLine(mf.LocationName + "   -   " + mf.Rain[1] + "mm   -   " + mf.Temp[1] + "°c -  @" + mf.TimeStamp);
                if (!mf.Rain[1].Equals("Server Error"))
                {
                    if (mf.ReadRain == true)
                    {
                        gaugeRainfall.Value = Convert.ToDouble(mf.Rain[1]);
                    }
                    else
                    {
                        gaugeRainfall.Value = 0.0;
                    }
                }
                else
                {
                    gaugeRainfall.Value = Convert.ToDouble("0");
                    MessageBox.Show("Error in retreiving rainfall data", "Melbourne Weather Service", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                if (!mf.Temp[1].Equals("Server Error"))
                {
                    if (mf.ReadTemp == true)
                    {
                        gaugeTemp.Value = Convert.ToDouble(mf.Temp[1]);
                    }
                    else
                    {
                        gaugeTemp.Value = 0.0;
                    }
                }
                else
                {
                    gaugeTemp.Value = 0.0;
                    MessageBox.Show("Error in retreiving temperature data", "Melbourne Weather Service", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                gBoxLocation.Text    = mf.LocationName;
                gBoxLastUpdated.Text = mf.UpdateTimeStamp;
            }
            catch (Exception e3)//Catching any errors along the way
            {
                Console.Out.WriteLine(e3);
            }
        }
        public MonitorTemplate(MonitorFactory input)//Modified Constructor
        {
            InitializeComponent();
            mf = input;
            this.Show();
            // this is temp measuremodel input <<>>
            var mapper = Mappers.Xy <MeasureModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <MeasureModel>(mapper);

            //the ChartValues property will store our values array
            ChartValues            = new ChartValues <MeasureModel>();
            ChartValues2           = new ChartValues <MeasureModel>();
            cartesianChart1.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Title             = "Rain",
                    Values            = ChartValues,
                    PointGeometrySize = 18,
                    StrokeThickness   = 3
                },
                new LineSeries
                {
                    Title             = "Temperature",
                    Values            = ChartValues2,
                    PointGeometrySize = 18,
                    StrokeThickness   = 3
                }
            };


            cartesianChart1.AxisX.Add(new Axis
            {
                DisableAnimations = true,
                LabelFormatter    = value => "",
                Separator         = new Separator
                {
                    Step = TimeSpan.FromSeconds(20).Ticks
                }
            });

            SetAxisLimits(System.DateTime.Now);
        }
Ejemplo n.º 3
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     try                                                                       //trying to show data from monitors on the GUI.
     {
         Console.Out.WriteLine(lbMonitors.SelectedItem + " monitor selected"); // Confirming logic to console
         MonitorFactory mf = monCol.MonitorArray[lbMonitors.SelectedIndex];    //Assigning the monitor corresponding to the one created and then selected by the user.
         //Updating Outputs
         Console.Out.WriteLine(mf.LocationName + "   -   " + mf.Rain[1] + "mm   -   " + mf.Temp[1] + "°c -  @" + mf.TimeStamp);
         lblLocation.Text    = mf.LocationName;
         lblRainfall.Text    = mf.Rain[1] + " mm of rain";
         lblTemperature.Text = mf.Temp[1] + "°C";
         lblLastUpdated.Text = mf.TimeStamp;
     }
     catch (Exception e3)//Catching any errors along the way
     {
         Console.Out.WriteLine(e3);
     }
 }
Ejemplo n.º 4
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     gaugeTemp.Value     = 0;
     gaugeRainfall.Value = 0;
     gaugeRainfall.Update();
     gaugeTemp.Update();
     try                                                             //Trying to add a monitor to the monitor collection
     {
         if (!(cBoxLocation.Text.Equals("Please Make a Selection"))) //If they have selected something
         {
             if (rbx5min.Checked)
             {
                 LocationFactory lf = locCol5m.LocationArray[cBoxLocation.SelectedIndex];                          //assigning a location factory to the one selected by the user from the drop down.
                 monCol5m.addToCollection(new MonitorFactory(lf, cbxRain.Checked, cbxTemp.Checked, 1));            //Creating a new monitor factory element and adding it to the collection.
                 lbMonitors.Items.Add(lf.LocationName + ": Temp-" + cbxTemp.Checked + " Rain-" + cbxRain.Checked); //Adding the monitor to the visual list.
                 lbMonitors.SelectedIndex = lbMonitors.Items.Count - 1;
             }
             else
             {
                 LocationFactory lf = locCol20s.LocationArray[cBoxLocation.SelectedIndex];                    //assigning a location factory to the one selected by the user from the drop down.
                 MonitorFactory  mf = new MonitorFactory(lf, cbxRain.Checked, cbxTemp.Checked, 2);
                 monCol20s.addToCollection(mf);                                                               //Creating a new monitor factory element and adding it to the collection.
                 lb20s.Items.Add(lf.LocationName + ": Temp-" + cbxTemp.Checked + " Rain-" + cbxRain.Checked); //Adding the monitor to the visual list.
                 lb20s.SelectedIndex = lb20s.Items.Count - 1;
             }
         }
         else
         {
             Console.Out.WriteLine("Please select a location!");
             MessageBox.Show("Please select a location from the location drop down menu", "Melbourne Weather Service", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception e2)
     {
         Console.Out.WriteLine(e2);//Output errors
     }
 }