public NewSamplesForm(Project currentProject, Station currentStation)
		{
			InitializeComponent();
			_updatedProject=currentProject;
			_updatedStation=currentStation;
			selectPicturesFolderDialog.ShowNewFolderButton = false;
		}
		private SpeciesStats StatsByStation(string species, Station st)
		{
			try {
				int speciesCount=0;
				int speciesPictures=0;
				
				foreach(SpeciesObservation sp in SpeciesObservationsInStation(st))
				{
					if(sp.Value==species)
					{
						speciesCount+=sp.Count;
						speciesPictures++;
					}
				}

				SpeciesStats spst=new SpeciesStats(species,speciesCount,speciesPictures);
				
				return spst;
			} catch (Exception ex) {
				throw ex;
			}

		}
		void BtCreateStationClick(object sender, EventArgs e)
		{
			try {
				if(_pictureSelected== DialogResult.OK)
				{
					GisSharpBlog.NetTopologySuite.IO.WKTReader wkt=new GisSharpBlog.NetTopologySuite.IO.WKTReader();
					IPolygon grd = (IPolygon)wkt.Read(txtWKT.Text);
					
					_newStationCreated=new Station(txtStationID.Text, grd, txtMainPicture.Text);
					_newStationCreated.SamplesList=new System.Collections.Generic.List<Sample>();
					
					_updatedProject.StationsList.Add(_newStationCreated);
					
					this.Close();
				}
				else
				{
					MessageBox.Show("You must select at least one main picture to create a Station");
				}
			} catch (Exception ex) {
				throw ex;
			}
			
		}
		private List<SpeciesObservation> SpeciesObservationsInStation(Station currentStation)
		{
			try {
				List<SpeciesObservation> _allSpeciesObservations=new List<SpeciesObservation>();
				
				foreach(Sample smp in currentStation.SamplesList)
				{
					foreach(SpeciesObservation obs in smp.Species_Observations_list)
					{
						_allSpeciesObservations.Add(obs);
					}
				}
				
				return _allSpeciesObservations;
			} catch (Exception ex) {
				throw ex;
			}
			
			
		}		
		private List<string> SpeciesInStation(Station currentStation)
		{
			try {
				List<string> _allSpeciesList = new List<string>();
				

				foreach(Sample smp in currentStation.SamplesList)
				{
					foreach(Observation obs in smp.Species_Observations_list)
					{
						if(_allSpeciesList.Contains((string)obs.Value)== false)
						{
							_allSpeciesList.Add((string)obs.Value);
						}
					}
				}
				
				return _allSpeciesList;
			} catch (Exception ex) {
				throw ex;
			}

		}
Beispiel #6
0
		private void refreshViewData(Station currentStation)
		{
			try {
				//Refresh the listview
				lstViewData.Items.Clear();
				lstViewData.Columns.Clear();
				
				ColumnHeader columnheader;		// Used for creating column headers.
				ListViewItem listviewitem;		// Used for creating listview items.
				
				// Ensure that the view is set to show details.
				lstViewData.View = View.Details;
				
				listviewitem = new ListViewItem("Station ID");
				listviewitem.SubItems.Add(currentStation.StationID);
				this.lstViewData.Items.Add(listviewitem);
				
				listviewitem = new ListViewItem("Latitude");
				listviewitem.SubItems.Add(currentStation.Lat.ToString());
				this.lstViewData.Items.Add(listviewitem);
				
				listviewitem = new ListViewItem("Longitude");
				listviewitem.SubItems.Add(currentStation.Lon.ToString());
				this.lstViewData.Items.Add(listviewitem);
				
				listviewitem = new ListViewItem("Altitude");
				listviewitem.SubItems.Add(currentStation.Alt.ToString());
				this.lstViewData.Items.Add(listviewitem);
				
				listviewitem = new ListViewItem("Orientation");
				listviewitem.SubItems.Add(currentStation.Compass.ToString());
				this.lstViewData.Items.Add(listviewitem);
				
				listviewitem = new ListViewItem("Main Picture Raw Name");
				listviewitem.SubItems.Add(currentStation.MainPictureFilename);
				this.lstViewData.Items.Add(listviewitem);
				
				
				// Create some column headers for the data.
				columnheader = new ColumnHeader();
				columnheader.Text = "Prop";
				this.lstViewData.Columns.Add(columnheader);
				
				columnheader = new ColumnHeader();
				columnheader.Text = "Value";
				this.lstViewData.Columns.Add(columnheader);
				
				// Loop through and size each column header to fit the column header text.
				foreach (ColumnHeader ch in this.lstViewData.Columns)
				{
					ch.Width = -2;
				}
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Beispiel #7
0
		void TvProjectAfterSelect(object sender, TreeViewEventArgs e)
		{

			try {
				if(tvProject.SelectedNode.Tag.GetType() == typeof(Station))
				{
					_currentStation= (Station)tvProject.SelectedNode.Tag;
					pictureBox1.Image= CameratrapManager_db.ProjectDAO.GetCurrentImage(_currentProject.Name,_currentStation.Guid);
					
					
					refreshViewData(_currentStation);
				}
				
				else if(tvProject.SelectedNode.Tag.GetType() == typeof(Sample))
				{
					_currentSample=(Sample)tvProject.SelectedNode.Tag;
					_currentStation= (Station)tvProject.SelectedNode.Parent.Tag;
					
					pictureBox1.Image= CameratrapManager_db.ProjectDAO.GetCurrentImage(_currentProject.Name,_currentSample.Guid);
					
					refreshViewData(_currentSample);
				}
			} catch (Exception ex) {
				throw ex;
			}
			
			
			
		}
Beispiel #8
0
		void ExitApplication()
		{
			try {
				DialogResult result = MessageBox.Show("Would you like to save your changes?", "Save project?",
				                                      MessageBoxButtons.YesNo,MessageBoxIcon.Question);
				
				if (result == DialogResult.Yes)
				{
					ProjectDAO.UpdateProject(_currentProject.Name,_currentProject);
					ProjectDAO.RemoveOrphanImages(_currentProject);
					
					tvProject.Dispose();
					pictureBox1.Dispose();
					_currentProject=null;
					_currentStation=null;
					_currentSample=null;
					lstViewData.Dispose();
					dgvSelectSpecies.Dispose();
				}
				else if (result == DialogResult.Cancel)
				{
					//				Stop the closing and return to the form
					//				e.Cancel = true;
				}
			} catch (Exception ex) {
				throw ex;
			}

		}
Beispiel #9
0
		void CloseProjectToolStripMenuItemClick(object sender, EventArgs e)
		{
			try {
				DialogResult result = MessageBox.Show("Would you like to save your changes?","Save project?",
				                                      MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);
				
				if (result == DialogResult.Yes)
				{
					ProjectDAO.UpdateProject(_currentProject.Name,_currentProject);
					ProjectDAO.RemoveOrphanImages(_currentProject);
				}
				else if (result == DialogResult.Cancel)
				{
					// Stop the closing and return to the form
					//	            e.Cancel = true;
				}
				else
				{
					tvProject.Nodes.Clear();
					pictureBox1.Image=null;
					_currentProject=null;
					_currentStation=null;
					_currentSample=null;
					lstViewData.Clear();
					dgvSelectSpecies.DataSource=null;
					speciesList.Rows.Clear();
				}
			} catch (Exception ex) {
				throw ex;
			}
			
		}