示例#1
0
        private void  ChartGPS_Load(object sender, EventArgs e)
        {
            heightLast = Height;
            widthLast  = Width;

            DeploymentsToPlot.Items.Clear();

            Cruise.Text     = cruiseName;
            Station.Text    = stationName;
            Deployment.Text = deploymentNum;

            cruise  = mainWinConn.SipperCruiseLoad(cruiseName);
            station = mainWinConn.SipperStationLoad(cruiseName, stationName);

            ContextMenuStrip cms = new ContextMenuStrip();

            cms.Items.Add("Copy Chart to clipboard", null, CopyChartToClipboard);
            cms.Items.Add("Save Chart to Disk", null, SaveChartToDisk);
            cms.Items.Add("Copy Data Tab-Delimited to Clipboard", null, SaveTabDelToClipBoard);
            cms.Items.Add("Save Data Tab-Delimited to Disk", null, SaveTabDelToDisk);

            ProfileChart.ContextMenuStrip = cms;

            LoadConfigurationFile();

            PopulatDeploymentsToPlot();

            PlotCruiseField.Checked = plotCruise;

            PlotButton_Click(this, null);
        }
        private void  LoadStations()
        {
            station = null;
            PicesSipperStationList stations = mainWinConn.SipperStationLoad(cruise.CruiseName);

            if (stations == null)
            {
                return;
            }
            StationField.Items.Clear();
            foreach (PicesSipperStation s in  stations)
            {
                StationField.Items.Add(s);
                if (s.StationName.Equals(stationName, StringComparison.InvariantCultureIgnoreCase))
                {
                    station = s;
                }
            }
            if (station == null)
            {
                stationName = "";
            }
            else
            {
                StationField.SelectedItem = station;
            }
        }
示例#3
0
        public TreeNodeStation(PicesDataBase _dbConn,
                               PicesRunLog _runLog,
                               PicesSipperStation _station
                               )
        {
            dbConn  = _dbConn;
            runLog  = _runLog;
            station = _station;
            LoadDeploymentDetails();

            Text = ToString();

            ContextMenuStrip cms = new ContextMenuStrip();

            cms.Items.Add("Edit Station Parameters", null, EditStationParameters);

            if (PicesSipperVariables.AllowUpdates())
            {
                if (Nodes.Count < 1)
                {
                    cms.Items.Add("Delete Station", null, DeleteStation);
                }
                cms.Items.Add("Add a new Deployment", null, AddANewDeployment);
            }
            this.ContextMenuStrip = cms;
        }
示例#4
0
        private void  DeleteStation(Object sender, EventArgs e)
        {
            if (!PicesSipperVariables.AllowUpdates())
            {
                return;
            }

            if (station == null)
            {
                return;
            }
            StationDialog sd = new StationDialog(station, dbConn, runLog, false, true);

            sd.ShowDialog();
            this.Text = this.ToString();
            if (sd.StationDeleted)
            {
                if (this.Parent != null)
                {
                    this.Parent.Nodes.Remove(this);
                    return;
                }

                this.Text             = "Station[" + station.StationName + "]   ***Deleted***";
                this.ContextMenuStrip = null;
                this.station          = null;
            }
        } /* DeleteStation */
        private void StationField_Format(object sender, ListControlConvertEventArgs e)
        {
            if (e.ListItem == null)
            {
                return;
            }
            PicesSipperStation s = (PicesSipperStation)e.ListItem;
            String             m = s.StationName;

            e.Value = m;
        }
 private void  ValidateStation()
 {
     errorProvider1.SetError(StationField, "");
     if (StationField.SelectedItem == null)
     {
         errorProvider1.SetError(StationField, "No Station Selected.");
         validationErrorFound = true;
     }
     else
     {
         station     = (PicesSipperStation)StationField.SelectedItem;
         stationName = station.StationName;
     }
 }
示例#7
0
        } /* LoadDeploymentDetails */

        private void  ValidateStationName()
        {
            errorProvider1.SetError(StationName, null);
            String s = StationName.Text.Trim();

            if (String.IsNullOrEmpty(s))
            {
                errorProvider1.SetError(StationName, "Can not leave  'Station Name'  blank.");
                validationErrorsFound = true;
                return;
            }

            String invalidCharacters = "";

            for (int x = 0; x < s.Length; x++)
            {
                char ch        = char.ToUpper(s[x]);
                bool validChar = ((ch >= '0') && (ch <= '9')) || ((ch >= 'A') && (ch <= 'Z'));
                if (!validChar)
                {
                    if (invalidCharacters.Length > 0)
                    {
                        invalidCharacters += ", ";
                    }
                    invalidCharacters += s[x].ToString();
                }
            }

            if (invalidCharacters.Length > 0)
            {
                errorProvider1.SetError(StationName, "Invalid characters[" + invalidCharacters + "]");
                validationErrorsFound = true;
                return;
            }

            if ((addingNewStation) || (s != station.StationName))
            {
                PicesSipperStation existingStation = DbConn().SipperStationLoad(CruiseName.Text, s);
                if (existingStation != null)
                {
                    errorProvider1.SetError(StationName, "StationName[" + s + "] is already been used for Cruise[" + CruiseName.Text + "].");
                    validationErrorsFound = true;
                    return;
                }
            }

            StationName.Text = s;
        } /* ValidateStationName */
示例#8
0
        } /* DeleteCruise */

        private void  AddANewStation(Object sender, EventArgs e)
        {
            if (!PicesSipperVariables.AllowUpdates())
            {
                return;
            }

            if (cruise == null)
            {
                return;
            }
            PicesSipperStation station = new PicesSipperStation(cruise);
            StationDialog      dd      = new StationDialog(station, dbConn, runLog, true, false);

            dd.ShowDialog();
            LoadStationDetails();
            this.Text = this.ToString();
        }
示例#9
0
        private void AddStationButton_Click(object sender, EventArgs e)
        {
            if (!allowUpdates)
            {
                return;
            }

            if (this.addingNewCruise)
            {
                MessageBox.Show(this, "Can only add stations after you have updated database with new cruise.", "Add a New Station.", MessageBoxButtons.OK);
                return;
            }
            PicesSipperStation station = new PicesSipperStation(cruise);
            StationDialog      sd      = new StationDialog(station, dbConn, runLog, true, false);

            sd.ShowDialog(this);
            LoadCruiseDetails();
        }
示例#10
0
        public StationDialog(PicesSipperStation _station,
                             PicesDataBase _dbConn,
                             PicesRunLog _runLog,
                             bool _addingNewStation,
                             bool _deletingStation
                             )
        {
            station          = _station;
            dbConn           = _dbConn;
            runLog           = _runLog;
            addingNewStation = _addingNewStation;
            deletingStation  = _deletingStation;

            if (runLog == null)
            {
                runLog = new PicesRunLog();
            }

            InitializeComponent();

            allowUpdates = PicesSipperVariables.AllowUpdates();
        }
示例#11
0
        } /* AddStationsToChart */

        private void  UpdateChartAreas()
        {
            goalie.StartBlock();

            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            DateTime minGpsDateTime = DateTime.MaxValue;
            DateTime maxGpsDateTime = DateTime.MinValue;

            timeInterval = (int)TimeInterval.Value;
            //String  plotAction = PlotAction.SelectedText;

            PicesSipperDeploymentList selectedDeployments = CurrentlySelectedDeployments();

            String titleLine = "Station: " + stationName;

            titleLine += "  Time-Interval: " + timeInterval;

            ProfileChart.Titles.Clear();
            ProfileChart.Titles.Add(new Title(titleLine, Docking.Top, titleFont, Color.Black));

            if (series.Count < 1)
            {
                ProfileChart.Series.Clear();
                goalie.EndBlock();
                return;
            }

            ChartArea ca = ProfileChart.ChartAreas[0];

            ca.AxisX.TitleFont = axisTitleFont;
            ca.AxisY.TitleFont = axisTitleFont;

            ProfileChart.Series.Clear();

            // First we will plot cruise level series;  that is series that are not ties to a specific deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.deployment == null)
                {
                    AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);
                }
            }

            PicesSipperStationList stationsToPlot = new PicesSipperStationList();
            Dictionary <String, PicesSipperStation> stationsPlotted = new Dictionary <string, PicesSipperStation> ();

            // Second we plot series that is specific to a deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                PicesSipperDeployment d = dstp.deployment;
                AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);

                if (!stationsPlotted.ContainsKey(d.StationName))
                {
                    PicesSipperStation stationToPlot = mainWinConn.SipperStationLoad(d.CruiseName, d.StationName);
                    stationsPlotted.Add(d.StationName, stationToPlot);
                    stationsToPlot.Add(stationToPlot);
                }
            }

            // Third we add stations that were not in one of the specified deployments but awe in the area of the deployments.
            // Find other stations in plot area.
            // Degrees/Kilo-Meter = 1/111  There are 111 Km/Degree of latitude

            double paddingKms    = (double)PaddingKms.Value;
            double latPadding    = paddingKms * (1.0 / 111.0); // Will add 5km's of padding to latitude.
            double degreesToRads = Math.PI / 180.0;
            double kmsPerDegLong = 111.6 * Math.Cos((minY + maxY) / 2.0 * degreesToRads);
            double longPadding   = paddingKms * (1.0 / (kmsPerDegLong));

            //
            PicesSipperStationList stationsInRange =
                mainWinConn.SipperStationsLoadByGpsRange(minY - latPadding, maxY + latPadding, minX - longPadding, maxX + longPadding);

            if (stationsInRange != null)
            {
                foreach (PicesSipperStation stationToPlot in stationsInRange)
                {
                    if (!stationsPlotted.ContainsKey(stationToPlot.StationName))
                    {
                        stationsPlotted.Add(stationToPlot.StationName, stationToPlot);
                        stationsToPlot.Add(stationToPlot);
                    }
                }
            }

            // Forth We add the stations to the Plot.
            AddStationsToChart(stationsToPlot, ref minX, ref maxX, ref minY, ref maxY);

            double latitudeMid = (maxY + minY) / 2.0;

            float plotAreaHeight = ProfileChart.ChartAreas[0].InnerPlotPosition.Height;
            float plotAreaWidth  = ProfileChart.ChartAreas[0].InnerPlotPosition.Width;

            double yRangeDegs = maxY - minY;
            double xRangeDegs = maxX - minX;

            double yRangeKms = yRangeDegs * 111.0;

            double longKmsPerDeg = 111.6 * Math.Cos(latitudeMid * degToRad);

            double xRangeKms = xRangeDegs * longKmsPerDeg;

            double yDensity = yRangeKms / plotAreaHeight;
            double xDenisty = xRangeKms / plotAreaWidth;

            if (xDenisty > yDensity)
            {
                double newYRangeKms = xDenisty * plotAreaHeight;
                double newYRageDegs = newYRangeKms / 111.0;

                double deltaYRange = newYRageDegs - yRangeDegs;
                minY = minY - deltaYRange / 2.0;
                maxY = maxY + deltaYRange / 2.0;
            }
            else
            {
                double newXRangeKms  = yDensity * plotAreaWidth;
                double newXRangeDegs = newXRangeKms / longKmsPerDeg;

                double deltaXRange = newXRangeDegs - xRangeDegs;
                minX = minX - (deltaXRange / 2.0);
                maxX = maxX + (deltaXRange / 2.0);
            }

            {
                // X Axis Custom Labels
                ca.AxisX.CustomLabels.Clear();
                double delta = (maxX - minX) / 5.0;

                char   d    = (char)176;
                string dStr = d.ToString();

                double fromPos = minX;
                for (int xx = 0; xx < 5; ++xx)
                {
                    double      toPos     = fromPos + delta;
                    double      midPos    = (toPos + fromPos) / 2.0;
                    double      midPosAbs = Math.Abs(midPos);
                    double      degs      = Math.Floor(midPosAbs);
                    double      mins      = (midPosAbs - degs) * 60.0;
                    string      s         = degs.ToString() + dStr + ":" + mins.ToString("00.00") + "'" + ((midPos < 0.0) ? "W" : "E");
                    CustomLabel cl        = new CustomLabel(fromPos, toPos, s, 0, LabelMarkStyle.LineSideMark, GridTickTypes.Gridline);
                    ca.AxisX.CustomLabels.Add(cl);
                    fromPos = toPos;
                }
                ca.AxisX.LabelStyle.Font = axisLabelFont;
            }


            {
                // Y Axis Custom Labels
                ca.AxisY.CustomLabels.Clear();
                double delta = (maxY - minY) / 5.0;

                char   d    = (char)176;
                string dStr = d.ToString();

                double fromPos = minY;
                for (int xx = 0; xx < 5; ++xx)
                {
                    double      toPos     = fromPos + delta;
                    double      midPos    = (toPos + fromPos) / 2.0;
                    double      midPosAbs = Math.Abs(midPos);
                    double      degs      = Math.Floor(midPosAbs);
                    double      mins      = (midPosAbs - degs) * 60.0;
                    string      s         = degs.ToString() + dStr + ":" + mins.ToString("00.00") + "'" + ((midPos < 0.0) ? "S" : "N");
                    CustomLabel cl        = new CustomLabel(fromPos, toPos, s, 0, LabelMarkStyle.LineSideMark, GridTickTypes.Gridline);
                    ca.AxisY.CustomLabels.Add(cl);
                    fromPos = toPos;
                }
                ca.AxisY.LabelStyle.Font = axisLabelFont;
            }


            ca.AxisX.Minimum = minX;
            ca.AxisX.Maximum = maxX;
            ca.AxisY.Minimum = minY;
            ca.AxisY.Maximum = maxY;

            ProfileChart.ChartAreas[0].RecalculateAxesScale();

            goalie.EndBlock();
        } /* UpdateChartAreas */
示例#12
0
        } /* AddStationsToChart */

        private void  UpdateChartAreas()
        {
            goalie.StartBlock();

            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            DateTime minGpsDateTime = DateTime.MaxValue;
            DateTime maxGpsDateTime = DateTime.MinValue;

            timeInterval = (int)TimeInterval.Value;
            //String  plotAction = PlotAction.SelectedText;

            PicesSipperDeploymentList selectedDeployments = CurrentlySelectedDeployments();

            String titleLine = "Cruise: " + cruiseName;

            titleLine += "  Time-Interval: " + timeInterval;

            ProfileChart.Titles.Clear();
            ProfileChart.Titles.Add(titleLine);

            if (series.Count < 1)
            {
                ProfileChart.Series.Clear();
                goalie.EndBlock();
                return;
            }

            ChartArea ca = ProfileChart.ChartAreas[0];
            //ca.AxisY.Title = "Latitude";

            //ca.AxisX.Title = "Longitude";
            Font f = new Font(ca.AxisX.TitleFont.FontFamily, 10);

            ca.AxisX.TitleFont = f;
            f = new Font(ca.AxisY.TitleFont.FontFamily, 10);
            ca.AxisY.TitleFont = f;

            ProfileChart.Series.Clear();

            // First we will plot cruise level series;  that is series that are not ties to a specific deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.deployment == null)
                {
                    AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);
                }
            }

            Dictionary <String, PicesSipperStation> stationsPlotted = new Dictionary <string, PicesSipperStation> ();
            PicesSipperDeploymentList deploymentsPlotted            = new PicesSipperDeploymentList();

            // Second we plot series that is specific to a deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.deployment != null)
                {
                    String stationName = dstp.deployment.StationName;
                    AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);
                    deploymentsPlotted.Add(dstp.deployment);
                }
            }

            String[] stationNamesToPlot           = deploymentsPlotted.ExtractStationNames();
            PicesSipperStationList stationsToPlot = new PicesSipperStationList();

            foreach (String stationName in stationNamesToPlot)
            {
                PicesSipperStation stationToPlot = stations.LookUpByStationName(stationName);
                if (stationToPlot != null)
                {
                    stationsToPlot.Add(stationToPlot);
                    stationsPlotted.Add(stationToPlot.StationName, stationToPlot);
                }
            }

            // Third we add stations that were not in one of the specified deployments but awe in the area of the deployments.
            // Find other stations in plot area.
            // Degrees/Kilo-Meter = 1/111  There are 111 Km/Degree of latitude

            double paddingKms    = (double)PaddingKms.Value;
            double latPadding    = paddingKms * (1.0 / 111.0); // Will add 5km's of padding to latitude.
            double degreesToRads = Math.PI / 180.0;
            double kmsPerDegLong = 111.6 * Math.Cos((minY + maxY) / 2.0 * degreesToRads);
            double longPadding   = paddingKms * (1.0 / (kmsPerDegLong));

            PicesSipperStationList stationsInRange =
                mainWinConn.SipperStationsLoadByGpsRange(minY - latPadding, maxY + latPadding, minX - longPadding, maxX + longPadding);

            if (stationsInRange != null)
            {
                foreach (PicesSipperStation stationToPlot in stationsInRange)
                {
                    if (!stationsPlotted.ContainsKey(stationToPlot.StationName))
                    {
                        stationsPlotted.Add(stationToPlot.StationName, stationToPlot);
                        stationsToPlot.Add(stationToPlot);
                    }
                }
            }

            AddStationsToChart(stationsToPlot, ref minX, ref maxX, ref minY, ref maxY);

            double latitudeMid = (maxY + minY) / 2.0;

            float plotAreaHeight = ProfileChart.Height;
            float plotAreaWidth  = ProfileChart.Width;

            double xRange    = maxX - minX;
            double yRange    = maxY - minY;
            double xRangeAdj = xRange * Math.Cos(latitudeMid * degToRad);

            double yDensity = yRange / plotAreaHeight;
            double xDenisty = xRangeAdj / plotAreaWidth;

            if (xDenisty > yDensity)
            {
                yRange = xDenisty * plotAreaHeight;
                double leftOver = yRange - (maxY - minY);
                minY = minY - leftOver / 2.0;
                maxY = maxY + leftOver / 2.0;
            }
            else
            {
                xRangeAdj = yDensity * plotAreaWidth;
                xRange    = xRangeAdj / Math.Cos(latitudeMid * degToRad);
                double leftOver = xRange - (maxX - minX);
                minX = minX - leftOver / 2.0;
                maxX = maxX + leftOver / 2.0;
            }

            ca.AxisX.Minimum = minX;
            ca.AxisX.Maximum = maxX;
            ca.AxisY.Minimum = minY;
            ca.AxisY.Maximum = maxY;

            ProfileChart.ChartAreas[0].RecalculateAxesScale();

            goalie.EndBlock();
        } /* UpdateChartAreas */