public TreeViewNodeData(int IdentificationUnitID, int CollectionSpecimenID, DateTime date) { this.NodeType = TreeViewNodeTypes.GeographyNode; this.IdentificationUnitID = IdentificationUnitID; this.CollectionSpecimenID = CollectionSpecimenID; this.AnalysisDate = date; }
/// <summary> /// Initializes a new instance of the <see cref="TreeViewNodeData"/> class. /// </summary> /// <param name="IdentificationUnitID">The identification unit ID.</param> /// <param name="CollectionSpecimenID">The collection specimen ID.</param> /// <param name="AnalysisID">The analysis ID.</param> /// <param name="AnalysisNumber">The analysis number.</param> public TreeViewNodeData(int IdentificationUnitID, int CollectionSpecimenID, int AnalysisID, string AnalysisNumber) { this.NodeType = TreeViewNodeTypes.AnalysisNode; this.IdentificationUnitID = IdentificationUnitID; this.CollectionSpecimenID = CollectionSpecimenID; this.AnalysisID = AnalysisID; this.AnalysisNumber = AnalysisNumber; }
/// <summary> /// Initializes a new instance of the <see cref="TreeViewNodeData"/> class. /// </summary> /// <param name="ID">The ID.</param> /// <param name="NodeType">Type of the node.</param> public TreeViewNodeData(int? ID, TreeViewNodeTypes NodeType) { this.ID = ID; if (NodeType == null) this.NodeType = TreeViewNodeTypes.Unknown; else this.NodeType = NodeType; }
/// <summary> /// Initializes a new instance of the <see cref="TreeViewNodeData"/> class. /// </summary> /// <param name="ID">The ID.</param> /// <param name="NodeType">Type of the node.</param> public TreeViewNodeData(int?ID, TreeViewNodeTypes NodeType) { this.ID = ID; if (NodeType == null) { this.NodeType = TreeViewNodeTypes.Unknown; } else { this.NodeType = NodeType; } }
// Auslagern der After Select Funktionalität, um direkten Zugriff zu gewährleisten private void afterSelect(TreeNode node) { Cursor.Current = Cursors.WaitCursor; if (node != null) { TreeViewNodeData data = node.Tag as TreeViewNodeData; if (data == null) { Cursor.Current = Cursors.Default; MessageBox.Show("While selecting a node a Display Error occured!", "Display Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } TreeNode represent; try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: CollectionEventSeries es = null; if (data.ID != null) { if (EventSeriess.Instance.Find((int)data.ID)) { es = EventSeriess.Instance.Current; this._events = EventSeriess.Instance.CollectionEvents; } else throw new ArgumentOutOfRangeException("EventSeries not found"); } else { EventSeriess.Instance.Current = null; this._events = new CollectionEvents(null); } this.labelPosition.Text = EventSeriess.Instance.Position; this._actualLvl = TreeViewNodeTypes.EventSeriesNode; represent = this._tvOperations.findRepresentantOfType(node); if (represent.Text.Equals("-1")) { displayEventSeries(es); } else if (represent != this._tvOperations.findRepresentantOfType(this._lastSelection)) { try { displayEventSeries(es); } catch (Exception e) { Cursor.Current = Cursors.Default; MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } } this._lastSelection = this.treeViewFieldData.SelectedNode; break; case TreeViewNodeTypes.EventNode: CollectionEvent ce = DataFunctions.Instance.RetrieveCollectionEvent((int)data.ID); if (ce != null) { int? serID = ce.SeriesID; this._events = new CollectionEvents(serID); this._events.Find(ce.CollectionEventID); ce = this._events.Current; } else { Cursor.Current = Cursors.Default; MessageBox.Show("DisplayError", "DisplayError", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } //Absichern, dass das Event über "+" gefunden wurde. //Absichern, dass das event nicht gefunden wird //Absichern, dass die EventSeries korrekt ist //Absichern, dass specimen belegt ist this._specimen = this._events.Specimen; this.labelPosition.Text = this._events.Position; this._actualLvl = TreeViewNodeTypes.EventNode; represent = this._tvOperations.findRepresentantOfType(node); if (represent.Text.Equals("-1")) { displayEvent(ce); } else if (represent != this._tvOperations.findRepresentantOfType(this._lastSelection)) { try { displayEvent(ce); } catch (Exception e) { Cursor.Current = Cursors.Default; MessageBox.Show(e.Message, "DisplayError", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } } this._lastSelection = this.treeViewFieldData.SelectedNode; break; case TreeViewNodeTypes.SpecimenNode: CollectionSpecimen spec = DataFunctions.Instance.RetrieveCollectionSpecimen((int)data.ID);//Wárum DataFunctions? //Absichern, dass das Event über "+" gefunden wurde. //Absichern, dass das event nicht gefunden wird //Absichern, dass die EventSeries korrekt ist //Absichern, dass specimen belegt ist if (spec != null) { int? serID = spec.CollectionEvent.SeriesID; CollectionEvent ev = spec.CollectionEvent; this._events = new CollectionEvents(serID); this._events.Find(ev.CollectionEventID); try { this._specimen = this._events.Specimen; } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } if (!this._specimen.Find(spec.CollectionSpecimenID)) { Cursor.Current = Cursors.Default; MessageBox.Show("Data of selected Specimen couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } this._iu = this._specimen.IdentificationUnits; spec = this._specimen.Current;//Durch Find erledigt, oder this.labelPosition.Text = this._specimen.Position; this._actualLvl = TreeViewNodeTypes.SpecimenNode; represent = this._tvOperations.findRepresentantOfType(node); if (represent.Text.Equals("-1")) { displaySpecimen(spec); } else if (represent != this._tvOperations.findRepresentantOfType(this._lastSelection)) { try { displaySpecimen(spec); } catch (Exception e) { Cursor.Current = Cursors.Default; MessageBox.Show(e.Message, "DisplayError", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } } } else { Cursor.Current = Cursors.Default; MessageBox.Show("DisplayError", "DisplayError", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } this._lastSelection = this.treeViewFieldData.SelectedNode; break; case TreeViewNodeTypes.IdentificationUnitNode: IdentificationUnit iu = DataFunctions.Instance.RetrieveIdentificationUnit((int)data.ID); //Absichern, dass das Event über "+" gefunden wurde. //Absichern, dass das event nicht gefunden wird //Absichern, dass die EventSeries korrekt ist //Absichern, dass specimen belegt ist if (iu != null) { int? sID = iu.CollectionSpecimen.CollectionEvent.SeriesID; CollectionEvent evIu = iu.CollectionSpecimen.CollectionEvent; this._events = new CollectionEvents(sID); this._events.Find(evIu.CollectionEventID); try { this._specimen = this._events.Specimen; } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } if (!this._specimen.Find(iu.CollectionSpecimenID)) { Cursor.Current = Cursors.Default; MessageBox.Show("Data of selected Specimen couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } this._iu = this._specimen.IdentificationUnits; if (this._iu == null) { Cursor.Current = Cursors.Default; MessageBox.Show("Data of associated Identification Units couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } this._iu.FindTopLevelIU(this.findIUTopLevelID(iu)); this._actualLvl = TreeViewNodeTypes.IdentificationUnitNode; this.labelPosition.Text = this._iu.Position; represent = this._tvOperations.findRepresentantOfType(node); if (represent.Text.Equals("-1")) { displayIdentificationUnit(iu); } else if (represent != this._tvOperations.findRepresentantOfType(this._lastSelection)) { try { displayIdentificationUnit(iu); } catch (Exception e) { Cursor.Current = Cursors.Default; MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } } } else { Cursor.Current = Cursors.Default; MessageBox.Show("DisplayError", "DisplayError", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } this._lastSelection = this.treeViewFieldData.SelectedNode; break; case TreeViewNodeTypes.AnalysisNode: this._actualLvl = TreeViewNodeTypes.AnalysisNode; this.labelPosition.Text = String.Empty; break; case TreeViewNodeTypes.GeographyNode: this._actualLvl = TreeViewNodeTypes.GeographyNode; this.labelPosition.Text = String.Empty; break; case TreeViewNodeTypes.LocalisationNode: this._actualLvl = TreeViewNodeTypes.LocalisationNode; this.labelPosition.Text = String.Empty; break; case TreeViewNodeTypes.AgentNode: this._actualLvl = TreeViewNodeTypes.AgentNode; this.labelPosition.Text = String.Empty; break; case TreeViewNodeTypes.SitePropertyNode: this._actualLvl = TreeViewNodeTypes.SitePropertyNode; this.labelPosition.Text = String.Empty; break; default: this._actualLvl = TreeViewNodeTypes.Unknown; break; } } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } Cursor.Current = Cursors.Default; enableDisableToolbarButtons(_actualLvl); enableDisableButtons(_actualLvl); } }
private void pictureBoxNewLocalisation_Click(object sender, EventArgs e) { if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null || this.treeViewFieldData.SelectedNode.Tag == null) { return; } SelectLocalisationSystemDialog dlg = new SelectLocalisationSystemDialog(); dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() != DialogResult.OK) return; try { TreeNode eventNode = this.treeViewFieldData.SelectedNode; TreeViewNodeData eventData = eventNode.Tag as TreeViewNodeData; if (eventData == null) return; if (eventData.NodeType != TreeViewNodeTypes.EventNode) return; TreeNode seriesNode = eventNode.Parent; TreeViewNodeData seriesData = seriesNode.Tag as TreeViewNodeData; int? seriesID = seriesData.ID; try { if (seriesData.ID != null) { EventSeriess.Instance.Find((int)seriesData.ID); this._events = EventSeriess.Instance.CollectionEvents; } else this._events = new CollectionEvents(null); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this._events.Find((int)eventData.ID); if (dlg.selection.Equals("GPS")) { if (eventData.NodeType == TreeViewNodeTypes.EventNode) { bool updateLocAlt = false; bool updateLocGPS = false; CollectionEventLocalisation locAlt = DataFunctions.Instance.RetrieveCollectionEventLocalisation(4, this._events.Current.CollectionEventID); CollectionEventLocalisation locGPS = DataFunctions.Instance.RetrieveCollectionEventLocalisation(8, this._events.Current.CollectionEventID); //Prüft ob dem Event bereits ein Localisatiobnsystem mit WGS84 Koordinaten und einer Höhe //angelegt sind. Wenn mehrere existieren, wird das erste genommen. if (locAlt != null) { updateLocAlt = true; } else { try { locAlt = DataFunctions.Instance.CreateCollectionEventLocalisation(4, this._events.Current); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message + " (Type: Altitude)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } if (locGPS != null) { updateLocGPS = true; } else { try { locGPS = DataFunctions.Instance.CreateCollectionEventLocalisation(8, this._events.Current); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message + " (Type: GPS)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } NewGPSLocalisationForm gpsForm = null; try { gpsForm = new NewGPSLocalisationForm(locAlt, locGPS); if (gpsForm == null) return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Dialog zentrieren gpsForm.Location = new Point((this.Size.Width) / 2 - (gpsForm.Size.Width) / 2, this.Location.Y); if (gpsForm.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this.treeViewFieldData.BeginUpdate(); // Localisation einbinden try { DataFunctions.Instance.Update(locGPS); DataFunctions.Instance.Update(locAlt); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message + " (Type: GPS / Altitude)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.afterSelect(this.treeViewFieldData.SelectedNode); this.treeViewFieldData.EndUpdate(); return; } if (!updateLocGPS) { TreeNode nodeGPS = new TreeNode(); this._tvOperations.parameterizeCollectionEventLocalisationNode(locGPS, nodeGPS); this.treeViewFieldData.SelectedNode.Nodes.Insert(0, nodeGPS); if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.Expand(); this._expandTrigger = true; } } else { foreach (TreeNode item in this.treeViewFieldData.SelectedNode.Nodes) { if (item != null) { if ((item.Tag as TreeViewNodeData).NodeType == TreeViewNodeTypes.LocalisationNode) { if ((item.Tag as TreeViewNodeData).ID == locGPS.LocalisationSystemID) { this._tvOperations.parameterizeCollectionEventLocalisationNode(locGPS, item); this.treeViewFieldData.Refresh(); } } } } } if (!updateLocAlt) { TreeNode nodeAlt = new TreeNode(); this._tvOperations.parameterizeCollectionEventLocalisationNode(locAlt, nodeAlt); this.treeViewFieldData.SelectedNode.Nodes.Insert(0, nodeAlt); if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.Expand(); this._expandTrigger = true; } } else { foreach (TreeNode item in this.treeViewFieldData.SelectedNode.Nodes) { if (item != null) { if ((item.Tag as TreeViewNodeData).NodeType == TreeViewNodeTypes.LocalisationNode) { if ((item.Tag as TreeViewNodeData).ID == locAlt.LocalisationSystemID) { this._tvOperations.parameterizeCollectionEventLocalisationNode(locAlt, item); this.treeViewFieldData.Refresh(); } } } } } Cursor.Current = Cursors.Default; this.treeViewFieldData.EndUpdate(); } } } if (dlg.selection.Equals("SamplingPlot")) { Cursor.Current = Cursors.WaitCursor; bool update = false; CollectionEventLocalisation ceLoc = DataFunctions.Instance.RetrieveCollectionEventLocalisation(13, this._events.Current.CollectionEventID); if (ceLoc != null) { update = true; } IList<SamplingPlots> plots = DataFunctions.Instance.RetrieveAllSamplingPlots(); List<String> list = new List<string>(); foreach (SamplingPlots plot in plots) { if (plot != null) list.Add(plot.Name); } if (list.Count < 1) { MessageBox.Show("There are no selectable SamplingPlots!"); Cursor.Current = Cursors.Default; return; } SelectDialog sdl = new SelectDialog("Select Sampling Plot", list); Cursor.Current = Cursors.Default; if (sdl.ShowDialog() != DialogResult.OK) return; Cursor.Current = Cursors.WaitCursor; if (update == false) { try { ceLoc = DataFunctions.Instance.CreateCollectionEventLocalisation(13, this._events.Current); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message + " (Type: Sampling Plot)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } if (ceLoc != null) { SamplingPlots selected = DataFunctions.Instance.RetrieveSamplingPlot(sdl.Value); if (selected != null) { ceLoc.Location1 = selected.Name; ceLoc.Location2 = selected.URI; try { DataFunctions.Instance.Update(ceLoc); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message + " (Type: Sampling Plot)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.afterSelect(this.treeViewFieldData.SelectedNode); return; } } this.treeViewFieldData.BeginUpdate(); TreeNode nodePlot = new TreeNode(); this._tvOperations.parameterizeCollectionEventLocalisationNode(ceLoc, nodePlot); TreeViewNodeData plotData = nodePlot.Tag as TreeViewNodeData; if (update == false) this.treeViewFieldData.SelectedNode.Nodes.Insert(0, nodePlot); else { foreach (TreeNode tn in this.treeViewFieldData.SelectedNode.Nodes) { if (tn != null) { TreeViewNodeData childData = tn.Tag as TreeViewNodeData; if (childData.ID == plotData.ID && childData.NodeType == TreeViewNodeTypes.LocalisationNode) { int index = tn.Index; this.treeViewFieldData.SelectedNode.Nodes.Remove(tn); this.treeViewFieldData.SelectedNode.Nodes.Insert(index, nodePlot); break; } } } } if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.Expand(); this._expandTrigger = true; } } } } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } this._actualLvl = TreeViewNodeTypes.LocalisationNode; this.enableDisableToolbarButtons(_actualLvl); this.treeViewFieldData.EndUpdate(); Cursor.Current = Cursors.Default; }
private void pictureBoxNewIUGeoAnalysis_Click(object sender, EventArgs e) { if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null) { return; } TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; try { if (data != null && data.NodeType == TreeViewNodeTypes.IdentificationUnitNode) { // Create IdentificationUnitGeoAnalysis IdentificationUnit iu = DataFunctions.Instance.RetrieveIdentificationUnit((int)data.ID); if (iu == null) { MessageBox.Show("Associated Identification Unit couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (iu.IdentificationUnitGeoAnalysis.First() != null) { MessageBox.Show("There exists already an IdentificationUnitGeoAnalysis for this Unit. You can Edit it with the GPS-Icon.", "Analysis already exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } IdentificationUnitGeoAnalysis iuGeoAnalysis; try { iuGeoAnalysis = DataFunctions.Instance.CreateIdentificationUnitGeoAnalysis(iu, iu.CollectionSpecimen); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (iuGeoAnalysis != null) { if (StaticGPS.isOpened()) { if (StaticGPS.position != null) { try { float latitude = float.Parse(StaticGPS.position.Latitude.ToString()); float longitude = float.Parse(StaticGPS.position.Longitude.ToString()); float altitude = float.Parse(StaticGPS.position.SeaLevelAltitude.ToString()); iuGeoAnalysis.setGeography(latitude,longitude, altitude); } catch (Exception) { Cursor.Current = Cursors.Default; MessageBox.Show("GPS-Data couldn`t be read. Data will be set to default values."); } } } try { DataFunctions.Instance.Update(iuGeoAnalysis); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Geography Data couldn't be automatically created. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } this.treeViewFieldData.BeginUpdate(); TreeNode nodeGeoAnalysis = new TreeNode(); this._tvOperations.parameterizeIUGeoANode(iuGeoAnalysis, nodeGeoAnalysis); this.treeViewFieldData.SelectedNode.Nodes.Insert(0, nodeGeoAnalysis); this.treeViewFieldData.SelectedNode = nodeGeoAnalysis; this.treeViewFieldData.EndUpdate(); } } } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } this._actualLvl = TreeViewNodeTypes.GeographyNode; this.enableDisableButtons(_actualLvl); this.enableDisableToolbarButtons(_actualLvl); }
private void enableDisableButtons(TreeViewNodeTypes type) { if (type != null) { // enable functions in the tree according to the current selection switch (type) { case TreeViewNodeTypes.Root: this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = true; this.pictureBoxHome.Visible = false; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = false; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = false; this.menuItemDisplayPicture.Enabled = false; this.menuItemTakeVideo.Enabled = false; this.menuItemShowVideo.Enabled = false; this.menuItemTakeAudio.Enabled = false; this.menuItemPlayAudio.Enabled = false; break; case TreeViewNodeTypes.EventSeriesNode: this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = true; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = false; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = false; this.menuItemDisplayPicture.Enabled = false; this.menuItemTakeVideo.Enabled = false; this.menuItemShowVideo.Enabled = false; this.menuItemTakeAudio.Enabled = false; this.menuItemPlayAudio.Enabled = false; break; case TreeViewNodeTypes.EventNode: // event node this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = true; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = true; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = true; this.pictureBoxNewIdentificationUnit.Visible = false; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = true; this.menuItemDisplayPicture.Enabled = true; this.menuItemTakeVideo.Enabled = true; this.menuItemShowVideo.Enabled = true; this.menuItemTakeAudio.Enabled = true; this.menuItemPlayAudio.Enabled = true; break; case TreeViewNodeTypes.LocalisationNode: // property, localisation, agent, analysis case TreeViewNodeTypes.SitePropertyNode: case TreeViewNodeTypes.AgentNode: case TreeViewNodeTypes.AnalysisNode: this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = false; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = false; this.menuItemDisplayPicture.Enabled = false; this.menuItemTakeVideo.Enabled = false; this.menuItemShowVideo.Enabled = false; this.menuItemTakeAudio.Enabled = false; this.menuItemPlayAudio.Enabled = false; break; case TreeViewNodeTypes.GeographyNode: this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = false; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = false; this.menuItemDisplayPicture.Enabled = false; this.menuItemTakeVideo.Enabled = false; this.menuItemShowVideo.Enabled = false; this.menuItemTakeAudio.Enabled = false; this.menuItemPlayAudio.Enabled = false; break; case TreeViewNodeTypes.SpecimenNode: // specimen this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = true; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = true; this.menuItemDisplayPicture.Enabled = true; this.menuItemTakeVideo.Enabled = true; this.menuItemShowVideo.Enabled = true; this.menuItemTakeAudio.Enabled = true; this.menuItemPlayAudio.Enabled = true; break; case TreeViewNodeTypes.IdentificationUnitNode: // identification unit this.pictureBoxGPS.Visible = true; this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = true; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = true; this.pictureBoxNewAnalysis.Visible = true; this.menuItemTakePicture.Enabled = true; this.menuItemDisplayPicture.Enabled = true; this.menuItemTakeVideo.Enabled = true; this.menuItemShowVideo.Enabled = true; this.menuItemTakeAudio.Enabled = true; this.menuItemPlayAudio.Enabled = true; break; case TreeViewNodeTypes.Unknown: this.pictureBoxNewEventSeries.Visible = false; this.pictureBoxHome.Visible = true; this.pictureBoxNewEvent.Visible = false; this.pictureBoxNewEventProperty.Visible = false; //this.pictureBoxNewAgent.Visible = false; this.pictureBoxNewLocalisation.Visible = false; this.pictureBoxNewIUGeoAnalysis.Visible = false; this.pictureBoxNewSpecimen.Visible = false; this.pictureBoxNewIdentificationUnit.Visible = false; this.pictureBoxNewAnalysis.Visible = false; this.menuItemTakePicture.Enabled = false; this.menuItemDisplayPicture.Enabled = false; this.menuItemTakeVideo.Enabled = false; this.menuItemShowVideo.Enabled = false; this.menuItemTakeAudio.Enabled = false; this.menuItemPlayAudio.Enabled = false; break; } IList<PictureBox> list = new List<PictureBox>(); list.Add(this.pictureBoxNewAnalysis); list.Add(this.pictureBoxNewIdentificationUnit); list.Add(this.pictureBoxNewSpecimen); list.Add(this.pictureBoxNewLocalisation); list.Add(this.pictureBoxNewIUGeoAnalysis); list.Add(this.pictureBoxNewEventProperty); list.Add(this.pictureBoxNewEvent); list.Add(this.pictureBoxNewEventSeries); //list.Add(this.pictureBoxHome); //list.Add(this.pictureBoxEdit); //list.Add(this.pictureBoxDelete); //list.Add(this.pictureBoxGPS); groupHorizontal(list, locationsPictureBox); } }
//private void pictureBoxNewAgent_Click(object sender, EventArgs e) //{ // if (this.treeViewFieldData.Nodes.Count == 0) // { // return; // } // NewAgentDialog dlg = new NewAgentDialog(); // // Dialog zentrieren // dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); // if (dlg.ShowDialog() == DialogResult.OK) // { // Cursor.Current = Cursors.WaitCursor; // TreeViewNodeData data = this.treeViewFieldData.SelectedNode.Tag as TreeViewNodeData; // // Collection Agent einbinden // int collector = dlg.Collector; // foreach (CollectionAgent item in DataFunctions.Instance.RetrieveAgentForCollectionSpecimen((int)data.ID)) // { // // duplicate entries are not allowed // if (item.CollectorsName.Equals(UserProfiles.Instance.List[collector].CombinedNameCache)) // { // Cursor.Current = Cursors.Default; // MessageBox.Show("Agent is already assigned"); // return; // } // } // CollectionAgent agent = DataFunctions.Instance.CreateCollectionAgent((int)data.ID, collector); // if (!(bool)UserProfiles.Instance.Current.HideAttribute) // { // TreeNode node = new TreeNode(); // this._tvOperations.parameterizeCollectionAgentNode(agent, node); // this.treeViewFieldData.SelectedNode.Nodes.Insert(0, node); // if (!this.treeViewFieldData.SelectedNode.IsExpanded) // { // this._expandTrigger = false; // this.treeViewFieldData.SelectedNode.Expand(); // this._expandTrigger = true; // } // this.treeViewFieldData.SelectedNode = node; // this.afterSelect(node); // } // Cursor.Current = Cursors.Default; // } //} private void pictureBoxNewAnalysis_Click(object sender, EventArgs e) { if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null) { return; } TreeViewNodeData data = this.treeViewFieldData.SelectedNode.Tag as TreeViewNodeData; if (data == null) return; if (data.NodeType != TreeViewNodeTypes.IdentificationUnitNode) return; try { IdentificationUnit iu = DataFunctions.Instance.RetrieveIdentificationUnit((int) data.ID); if (iu == null) { MessageBox.Show("Associated Identification Unit couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Erlaubte Analysen für taxonomoische Gruppe werden geladen IList<Analysis> list = DataFunctions.Instance.RetrievePossibleAnalysis(iu.TaxonomicGroup); if (list.Count < 1) { MessageBox.Show("There is no selectable analysis", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } NewAnalysisDialog nad = null; try { if (UserProfiles.Instance.Current.LastAnalysisID != null) nad = new NewAnalysisDialog((int)UserProfiles.Instance.Current.LastAnalysisID); else nad = new NewAnalysisDialog(true); if (nad == null) return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Dialog zentrieren nad.Location = new Point((this.Size.Width) / 2 - (nad.Size.Width) / 2, this.Location.Y); nad.Analysis = list; Cursor.Current = Cursors.Default; if (nad.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this.treeViewFieldData.BeginUpdate(); String analysisValue = nad.Value; int analysisPerformed = nad.PerformedAnalysis; DateTime analysisDate = nad.AnalysisDate; IdentificationUnitAnalysis iua; try { iua = DataFunctions.Instance.CreateIdentificationUnitAnalysis(iu, analysisPerformed, analysisValue, analysisDate); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } TreeNode node = new TreeNode(); this._tvOperations.parametrizeIUANode(iua, node); this.treeViewFieldData.SelectedNode.Nodes.Insert(0, node); this.treeViewFieldData.SelectedNode = node; // edit last performed analysis in UserProfile if (UserProfiles.Instance.Current != null) { int oldAnalysis = -1; if (UserProfiles.Instance.Current.LastAnalysisID != null) oldAnalysis = (int)UserProfiles.Instance.Current.LastAnalysisID; UserProfiles.Instance.Current.LastAnalysisID = nad.PerformedAnalysis; try { UserProfiles.Instance.Update(UserProfiles.Instance.Current); } catch (UserProfileCorruptedException ex) { Cursor.Current = Cursors.Default; if (oldAnalysis > -1) UserProfiles.Instance.Current.LastAnalysisID = oldAnalysis; else UserProfiles.Instance.Current.LastAnalysisID = null; MessageBox.Show(ex.Message + " Last performed analysis remains: " + oldAnalysis.ToString()); } } this._actualLvl = TreeViewNodeTypes.AnalysisNode; this.enableDisableButtons(_actualLvl); this.enableDisableToolbarButtons(_actualLvl); this.treeViewFieldData.EndUpdate(); Cursor.Current = Cursors.Default; } } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } }
public MainForm() { // initialization related to windows forms Cursor.Current = Cursors.WaitCursor; try { InitializeComponent(); } catch (NotSupportedException) { Cursor.Current = Cursors.Default; MessageBox.Show("Diversity Mobile is not supported by your system!", "Not supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.Close(); } #if DEBUG this.MinimizeBox = false; this.ControlBox = true; #else this.MinimizeBox = true; this.ControlBox = true; #endif this._actualLvl = TreeViewNodeTypes.Root; this._currentToolbarImageList = imageListToolbarButtons; this._currentDiversityImageList = imageListDiversityCollection; }
protected void displayEventSeries(CollectionEventSeries es) { Cursor.Current = Cursors.WaitCursor; this.treeViewFieldData.BeginUpdate(); this.treeViewFieldData.SuspendLayout(); TreeNode node = treeViewFieldData.SelectedNode; try { this.treeViewFieldData.Nodes.Clear(); this.treeViewFieldData.Update(); TreeNode esNode = new TreeNode(); esNode = _tvOperations.displayEventSeries(es); treeViewFieldData.Nodes.Add(esNode); this.treeViewFieldData.SelectedNode = esNode; this._expandTrigger = false; if (this._tvOperations.expandLvl <= ExpandLevel.EventSeries) esNode.ExpandAll(); else esNode.Expand(); this._expandTrigger = true; this._actualLvl = TreeViewNodeTypes.EventSeriesNode; this.enableDisableButtons(TreeViewNodeTypes.EventSeriesNode); } catch (Exception ex) { this.treeViewFieldData.EndUpdate(); this.treeViewFieldData.ResumeLayout(); this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; MessageBox.Show("DisplayError: " + ex.Message); this.pictureBoxHome_Click(null, null); return; } this.treeViewFieldData.ResumeLayout(); this.treeViewFieldData.EndUpdate(); this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; }
private void pictureBoxHome_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { EventSeriess.Instance.Current = null; this._events = null; this._specimen = null; this._iu = null; //this.resetTreeView(); Anzeige wird nicht aktualisert. Warum? this.displayAllEventSeries(); this.labelPosition.Text = String.Empty; this.enableDisableButtons(TreeViewNodeTypes.Root); this._actualLvl = TreeViewNodeTypes.Root; this.enableDisableToolbarButtons(_actualLvl); } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Severe Program Exception (" + ex.Message + "). Program will be closed.", "Severe Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.Close(); } Cursor.Current = Cursors.Default; }
private void pictureBoxDelete_Click(object sender, EventArgs e) { if (this.treeViewFieldData.SelectedNode == null) { return; } TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; if (data == null) return; if ((treeViewFieldData.SelectedNode.Tag as TreeViewNodeData).NodeType == TreeViewNodeTypes.Unknown || (treeViewFieldData.SelectedNode.Tag as TreeViewNodeData).NodeType == TreeViewNodeTypes.Root) { return; } if (data.NodeType == TreeViewNodeTypes.EventSeriesNode) { bool noEventSeries = false; bool emptySeries = false; CollectionEventSeries cs; if (data.ID == null) noEventSeries = true; else { try { cs = EventSeriess.Instance.Current; } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (cs.CollectionEvents.First() == null) emptySeries = true; } if (noEventSeries == true) { MessageBox.Show("There is the NoEventSeries selected. You cannot delete it.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (emptySeries == false) { MessageBox.Show("It's not allowed to delete CollectionEventSeries containing Events. Delete Events first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } if (MessageBox.Show("Do you really want to remove the selected data?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: if (data.ID != EventSeriess.Instance.Current.SeriesID) { Cursor.Current = Cursors.Default; MessageBox.Show("CurrentEventSeries and Selected EventSeries do not match! Abort! GUI inconsistent. Reload"); this.pictureBoxHome_Click(null, null); return; } CollectionEventSeries cs = EventSeriess.Instance.Current; EventSeriess.Instance.Remove(cs); if (EventSeriess.Instance.Count == 0) { this.pictureBoxHome_Click(null, null); Cursor.Current = Cursors.Default; return; } this.displayEventSeries(EventSeriess.Instance.Current);//Abhängig von ExpandLevel machen this.enableDisableButtons(TreeViewNodeTypes.EventSeriesNode); this.treeViewFieldData.Refresh(); this.treeViewFieldData.Focus(); this._actualLvl = TreeViewNodeTypes.EventSeriesNode; Cursor.Current = Cursors.Default; return; case TreeViewNodeTypes.EventNode: // event node // Remove Current Collection Event if (data.ID != this._events.Current.CollectionEventID) { MessageBox.Show("CurrentEvent and Selected Event do not match! Abort! GUI inconsitent. Reload"); this.pictureBoxHome_Click(null, null); Cursor.Current = Cursors.Default; return; } this._events.Remove(); this.enableDisableButtons(TreeViewNodeTypes.EventNode); this._actualLvl = TreeViewNodeTypes.EventNode; if (this._events.Current == null)//Letztes Event wurde gelöscht. { this.displayEventSeries(EventSeriess.Instance.Current);//Abhängig von ExpandLevel machen this.enableDisableButtons(TreeViewNodeTypes.EventSeriesNode); this._actualLvl = TreeViewNodeTypes.EventSeriesNode; this.enableDisableToolbarButtons(_actualLvl); return; } if (this._events.Count == 0) { this.treeViewFieldData.SelectedNode = node.Parent; node.Remove(); this.treeViewFieldData.Refresh(); this.treeViewFieldData.Focus(); this.afterSelect(treeViewFieldData.SelectedNode); Cursor.Current = Cursors.Default; return; } this.displayEvent(this._events.Current);//Durch Remove geupdated this.afterSelect(treeViewFieldData.SelectedNode); this.treeViewFieldData.Refresh(); this.treeViewFieldData.Focus(); Cursor.Current = Cursors.Default; return; case TreeViewNodeTypes.SpecimenNode: // specimen node if (this._specimen != null && this._specimen.Current != null) { if (data.ID != this._specimen.Current.CollectionSpecimenID) { MessageBox.Show("CurrentSpecimen and SelectedSpecimen do not match! Abort!"); Cursor.Current = Cursors.Default; this.pictureBoxHome_Click(null, null); return; } // Remove Collection Specimen this._specimen.Remove(this._specimen.Current); if (this._specimen.Count == 0) { this.treeViewFieldData.SelectedNode = node.Parent; node.Remove(); this.treeViewFieldData.Refresh(); this.treeViewFieldData.Focus(); this.afterSelect(treeViewFieldData.SelectedNode); Cursor.Current = Cursors.Default; return; } this.displaySpecimen(this._specimen.Current);//Abhängig von ExpandLevel machen this.enableDisableButtons(TreeViewNodeTypes.SpecimenNode); this._actualLvl = TreeViewNodeTypes.SpecimenNode; this.enableDisableToolbarButtons(_actualLvl); } Cursor.Current = Cursors.Default; break; case TreeViewNodeTypes.IdentificationUnitNode: // IdentificationUnit node // Remove IdentificationUnit if (this._iu != null && this._iu.Current != null) { IdentificationUnit iu = DataFunctions.Instance.RetrieveIdentificationUnit((int)data.ID); if (this.findIUTopLevelID(iu) != this._iu.Current.IdentificationUnitID) { MessageBox.Show("CurrentIU and SelectedIU do not match! Abort!"); return; } if (iu != null) { IdentificationUnit parent = iu.RelatedUnit; if (parent == null) { this._iu.Remove(iu); if (this._iu.Count == 0) { this.treeViewFieldData.SelectedNode = node.Parent; node.Remove(); this.afterSelect(treeViewFieldData.SelectedNode); this.treeViewFieldData.Refresh(); this.treeViewFieldData.Focus(); Cursor.Current = Cursors.Default; return; } this.displayIdentificationUnit(this._iu.Current);//Abhängig von ExpandLevel machen this.enableDisableButtons(TreeViewNodeTypes.IdentificationUnitNode); this._actualLvl = TreeViewNodeTypes.IdentificationUnitNode; this.enableDisableToolbarButtons(_actualLvl); return; } else { DataFunctions.Instance.Remove(iu);//Läuft weiter bis zum break } } else { MessageBox.Show("IdentificationUnit Not Found. DisplayError"); this.pictureBoxHome_Click(null, null); Cursor.Current = Cursors.Default; return; } } break; case TreeViewNodeTypes.AnalysisNode: // event node //Remove IdentificationUnitAnalysis IdentificationUnitAnalysis iua = DataFunctions.Instance.RetrieveIdentificationUnitAnalysis(data.CollectionSpecimenID, data.IdentificationUnitID, data.AnalysisID, data.AnalysisNumber); DataFunctions.Instance.Remove(iua); break; case TreeViewNodeTypes.LocalisationNode: // localisation node // Remove LocalisationData CollectionEventLocalisation ceLoc = DataFunctions.Instance.RetrieveCollectionEventLocalisation((int)data.ID, this._events.Current.CollectionEventID); DataFunctions.Instance.Remove(ceLoc); break; case TreeViewNodeTypes.GeographyNode: // geography node // Remove LocalisationData IdentificationUnit parentIU = DataFunctions.Instance.RetrieveIdentificationUnit(data.IdentificationUnitID); IdentificationUnitGeoAnalysis iuGeoAnalysis = parentIU.IdentificationUnitGeoAnalysis.First(); DataFunctions.Instance.Remove(iuGeoAnalysis); break; case TreeViewNodeTypes.SitePropertyNode: // site property node // Remove SiteProperty for Event CollectionEventProperty ceProp = DataFunctions.Instance.RetrieveCollectionEventProperty((int)data.ID, this._events.Current.CollectionEventID); DataFunctions.Instance.Remove(ceProp); break; case TreeViewNodeTypes.AgentNode: // site property node // Remove CollectionAgent for Specimen CollectionAgent agent = DataFunctions.Instance.RetrieveCollectionAgent(data.CollectorsName, data.CollectionSpecimenID); DataFunctions.Instance.Remove(agent); break; default: Cursor.Current = Cursors.Default; return; } } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Collection Event Series couldn't be removed. (" + ex.Message + ")", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } node.Remove();//Was geschieht, wenn der node selected ist? if (treeViewFieldData.SelectedNode != null) this.afterSelect(treeViewFieldData.SelectedNode); else { this.pictureBoxHome_Click(null, null); Cursor.Current = Cursors.Default; } Cursor.Current = Cursors.Default; } }
private void enableDisableToolbarButtons(TreeViewNodeTypes type) { if (type != null) { switch (type) { case TreeViewNodeTypes.Root: this.enableDisableToolbarButtons(false); break; case TreeViewNodeTypes.EventSeriesNode: this.pictureBoxDelete.Enabled = true; this.pictureBoxEdit.Enabled = true; if (this._tvOperations.expandLvl >= ExpandLevel.EventSeries) { this.toolBarButtonLevelPicture.ImageIndex = 8; this.toolBarButtonLevelPicture.Enabled = true; this.toolBarButtonMoveFirst.Enabled = true; this.toolBarButtonMoveLast.Enabled = true; this.toolBarButtonNext.Enabled = true; this.toolBarButtonPrevious.Enabled = true; } else { this.toolBarButtonLevelPicture.ImageIndex = 8; this.toolBarButtonLevelPicture.Enabled = false; this.toolBarButtonMoveFirst.Enabled = false; this.toolBarButtonMoveLast.Enabled = false; this.toolBarButtonNext.Enabled = false; this.toolBarButtonPrevious.Enabled = false; } break; case TreeViewNodeTypes.EventNode: this.pictureBoxDelete.Enabled = true; this.pictureBoxEdit.Enabled = true; if (this._tvOperations.expandLvl >= ExpandLevel.Event) { this.toolBarButtonLevelPicture.ImageIndex = 9; this.toolBarButtonLevelPicture.Enabled = true; this.toolBarButtonMoveFirst.Enabled = true; this.toolBarButtonMoveLast.Enabled = true; this.toolBarButtonNext.Enabled = true; this.toolBarButtonPrevious.Enabled = true; } else { this.toolBarButtonLevelPicture.ImageIndex = 9; this.toolBarButtonLevelPicture.Enabled = false; this.toolBarButtonMoveFirst.Enabled = false; this.toolBarButtonMoveLast.Enabled = false; this.toolBarButtonNext.Enabled = false; this.toolBarButtonPrevious.Enabled = false; } break; case TreeViewNodeTypes.SpecimenNode: this.pictureBoxDelete.Enabled = true; this.pictureBoxEdit.Enabled = true; if (this._tvOperations.expandLvl >= ExpandLevel.Specimen) { this.toolBarButtonLevelPicture.ImageIndex = 10; this.toolBarButtonLevelPicture.Enabled = true; this.toolBarButtonMoveFirst.Enabled = true; this.toolBarButtonMoveLast.Enabled = true; this.toolBarButtonNext.Enabled = true; this.toolBarButtonPrevious.Enabled = true; } else { this.toolBarButtonLevelPicture.ImageIndex = 10; this.toolBarButtonLevelPicture.Enabled = false; this.toolBarButtonMoveFirst.Enabled = false; this.toolBarButtonMoveLast.Enabled = false; this.toolBarButtonNext.Enabled = false; this.toolBarButtonPrevious.Enabled = false; } break; case TreeViewNodeTypes.IdentificationUnitNode: this.pictureBoxDelete.Enabled = true; this.pictureBoxEdit.Enabled = true; if (this._tvOperations.expandLvl >= ExpandLevel.IdentificationUnit) { this.toolBarButtonLevelPicture.ImageIndex = 12; this.toolBarButtonLevelPicture.Enabled = true; this.toolBarButtonMoveFirst.Enabled = true; this.toolBarButtonMoveLast.Enabled = true; this.toolBarButtonNext.Enabled = true; this.toolBarButtonPrevious.Enabled = true; } else { this.toolBarButtonLevelPicture.ImageIndex = 12; this.toolBarButtonLevelPicture.Enabled = false; this.toolBarButtonMoveFirst.Enabled = false; this.toolBarButtonMoveLast.Enabled = false; this.toolBarButtonNext.Enabled = false; this.toolBarButtonPrevious.Enabled = false; } break; default: this.pictureBoxDelete.Enabled = true; this.pictureBoxEdit.Enabled = true; this.toolBarButtonMoveFirst.Enabled = false; this.toolBarButtonMoveLast.Enabled = false; this.toolBarButtonNext.Enabled = false; this.toolBarButtonPrevious.Enabled = false; break; } } }
protected void displayAllEventSeries() { Cursor.Current = Cursors.WaitCursor; this.treeViewFieldData.BeginUpdate(); this.treeViewFieldData.SuspendLayout(); this.treeViewFieldData.Nodes.Clear(); try { TreeNode tn = _tvOperations.displayAllEventSeries(null); this.treeViewFieldData.Nodes.Add(tn); IList<CollectionEventSeries> listEs; try { listEs = DataFunctions.Instance.RetrieveEventSeries(); } catch (ConnectionCorruptedException ex) { this.treeViewFieldData.EndUpdate(); Cursor.Current = Cursors.Default; throw ex; } foreach (CollectionEventSeries es in listEs) { if (es != null) { tn = _tvOperations.displayAllEventSeries(es); this.treeViewFieldData.Nodes.Add(tn); } } this.treeViewFieldData.SelectedNode = null; this._actualLvl = TreeViewNodeTypes.Root; } catch (Exception ex) { this.treeViewFieldData.SelectedNode = null; this.treeViewFieldData.ResumeLayout(); this.treeViewFieldData.EndUpdate(); this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; MessageBox.Show("DisplayError: " + ex.Message); return; } this.treeViewFieldData.ResumeLayout(); this.treeViewFieldData.EndUpdate(); this.treeViewFieldData.Refresh(); this.enableDisableButtons(TreeViewNodeTypes.Root); this.enableDisableToolbarButtons(_actualLvl); Cursor.Current = Cursors.Default; }
/// <summary> /// Handles the Click event of the pictureBoxNewSpecimen control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void pictureBoxNewSpecimen_Click(object sender, EventArgs e) { if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null) { return; } Cursor.Current = Cursors.WaitCursor; TreeNode eventNode = this.treeViewFieldData.SelectedNode; TreeViewNodeData eventData = eventNode.Tag as TreeViewNodeData; if (eventData == null) return; if (eventData.NodeType != TreeViewNodeTypes.EventNode) return; TreeNode seriesNode = eventNode.Parent; TreeViewNodeData seriesData = seriesNode.Tag as TreeViewNodeData; int? seriesID = seriesData.ID; try { if (seriesData.ID != null) { EventSeriess.Instance.Find((int)seriesData.ID); this._events = EventSeriess.Instance.CollectionEvents; } else this._events = new CollectionEvents(null); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this._events.Find((int)eventData.ID); this._specimen = this._events.Specimen; if (this._specimen != null) { CollectionSpecimen cs; try { cs = this._specimen.CreateSpecimen(); this._iu = this._specimen.IdentificationUnits; } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Specimen couldn't be created. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.treeViewFieldData.EndUpdate(); return; } this.treeViewFieldData.BeginUpdate(); TreeNode specNode = new TreeNode(); this._tvOperations.parametrizeOnlySpecimenNode(cs, specNode); this.labelPosition.Text = this._specimen.Position; this.treeViewFieldData.SelectedNode.Nodes.Add(specNode); this.treeViewFieldData.SelectedNode = specNode; if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.ExpandAll(); this._expandTrigger = true; } this.enableDisableButtons(TreeViewNodeTypes.SpecimenNode); this._actualLvl = TreeViewNodeTypes.SpecimenNode; this.enableDisableToolbarButtons(_actualLvl); this.treeViewFieldData.EndUpdate(); } Cursor.Current = Cursors.Default; }
private void pictureBoxNewEventProperty_Click(object sender, EventArgs e) { if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null) { return; } TreeNode eventNode = this.treeViewFieldData.SelectedNode; TreeViewNodeData eventData = eventNode.Tag as TreeViewNodeData; if (eventData == null) return; if (eventData.NodeType != TreeViewNodeTypes.EventNode) return; TreeNode seriesNode = eventNode.Parent; TreeViewNodeData seriesData = seriesNode.Tag as TreeViewNodeData; int? seriesID = seriesData.ID; try { if (seriesData.ID != null) { EventSeriess.Instance.Find((int)seriesData.ID); this._events = EventSeriess.Instance.CollectionEvents; } else this._events = new CollectionEvents(null); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this._events.Find((int)eventData.ID); try { NewSitePropertyDialog dlg = new NewSitePropertyDialog(true); // Dialog zentrieren dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); dlg.PropertyList = DataFunctions.Instance.RetrievePossibleProperty((int)this._events.Current.CollectionEventID); if (dlg.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this.treeViewFieldData.BeginUpdate(); // SiteProperty einbinden string propertyText = dlg.DisplayText; int propertyID = dlg.PropertyID; CollectionEventProperty ceProp; try { ceProp = DataFunctions.Instance.CreateCollectionEventProperty(propertyID, propertyText, this._events.Current); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } TreeNode node = new TreeNode(); this._tvOperations.parameterizeCollectionEventPropertyNode(ceProp, node); this.treeViewFieldData.SelectedNode.Nodes.Insert(0, node);//Erst Properties, dann LocalisationSystems this.treeViewFieldData.SelectedNode = node; if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.Expand(); this._expandTrigger = true; } this._actualLvl = TreeViewNodeTypes.SitePropertyNode; this.enableDisableToolbarButtons(_actualLvl); this.enableDisableButtons(_actualLvl); this.treeViewFieldData.EndUpdate(); Cursor.Current = Cursors.Default; } } catch (ConnectionCorruptedException ex) { this.treeViewFieldData.EndUpdate(); Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } catch (ContextCorruptedException ex) { this.treeViewFieldData.EndUpdate(); Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } }
/// <summary> /// Handles the ButtonClick event of the toolBar control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.ToolBarButtonClickEventArgs"/> instance containing the event data.</param> private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e) { try { if (e.Button == this.toolBarButtonMoveFirst && this.treeViewFieldData.SelectedNode != null) { TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: if (this._tvOperations.expandLvl < ExpandLevel.EventSeries) return; EventSeriess.Instance.Current = null; this.displayEventSeries(null); this.labelPosition.Text = EventSeriess.Instance.Position; break; case TreeViewNodeTypes.EventNode: if (this._tvOperations.expandLvl < ExpandLevel.Event) return; if (this._events != null) { this.displayEvent(this._events.First); this.labelPosition.Text = this._events.Position; } break; case TreeViewNodeTypes.SpecimenNode: if (this._tvOperations.expandLvl < ExpandLevel.Specimen) return; if (this._specimen != null) { this.displaySpecimen(this._specimen.First); this.labelPosition.Text = this._specimen.Position; } break; case TreeViewNodeTypes.IdentificationUnitNode: if (this._tvOperations.expandLvl < ExpandLevel.IdentificationUnit) return; if (this._iu != null) { this.displayIdentificationUnit(this._iu.First); this.labelPosition.Text = this._iu.Position; } break; default: return; } } catch (DataFunctionsException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this.afterSelect(treeViewFieldData.SelectedNode); return; } else if (e.Button == this.toolBarButtonMoveLast && this.treeViewFieldData.SelectedNode != null) { TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: if (this._tvOperations.expandLvl < ExpandLevel.EventSeries) return; this.displayEventSeries(EventSeriess.Instance.Last); this.labelPosition.Text = EventSeriess.Instance.Position; break; case TreeViewNodeTypes.EventNode: if (this._tvOperations.expandLvl < ExpandLevel.Event) return; if (this._events != null) { this.displayEvent(this._events.Last); this.labelPosition.Text = this._events.Position; } break; case TreeViewNodeTypes.SpecimenNode: if (this._tvOperations.expandLvl < ExpandLevel.Specimen) return; if (this._specimen != null) { this.displaySpecimen(this._specimen.Last); this.labelPosition.Text = this._specimen.Position; } break; case TreeViewNodeTypes.IdentificationUnitNode: if (this._tvOperations.expandLvl < ExpandLevel.IdentificationUnit) return; if (this._iu != null) { this.displayIdentificationUnit(this._iu.Last); this.labelPosition.Text = this._iu.Position; } break; default: return; } } catch (DataFunctionsException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this.afterSelect(treeViewFieldData.SelectedNode); return; } else if (e.Button == this.toolBarButtonNext && this.treeViewFieldData.SelectedNode != null) { TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: if (this._tvOperations.expandLvl < ExpandLevel.EventSeries) return; if (EventSeriess.Instance.Current == null) { this.displayEventSeries(EventSeriess.Instance.First); this.labelPosition.Text = EventSeriess.Instance.Position; return; } if (EventSeriess.Instance.HasNext) { this.displayEventSeries(EventSeriess.Instance.Next); this.labelPosition.Text = EventSeriess.Instance.Position; } else return; break; case TreeViewNodeTypes.EventNode: if (this._events != null) { if (this._events.HasNext) { if (this._tvOperations.expandLvl < ExpandLevel.Event) return; this.displayEvent(this._events.Next); this.labelPosition.Text = this._events.Position; } else return; } break; case TreeViewNodeTypes.SpecimenNode: if (this._specimen != null) { if (this._specimen.HasNext) { if (this._tvOperations.expandLvl < ExpandLevel.Specimen) return; this.displaySpecimen(this._specimen.Next); this.labelPosition.Text = this._specimen.Position; } else return; } break; case TreeViewNodeTypes.IdentificationUnitNode: if (this._iu != null) { if (this._iu.HasNext) { if (this._tvOperations.expandLvl < ExpandLevel.IdentificationUnit) return; this.displayIdentificationUnit(this._iu.Next); this.labelPosition.Text = this._iu.Position; } else return; } break; default: return; } } catch (DataFunctionsException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this.afterSelect(treeViewFieldData.SelectedNode); return; } else if (e.Button == this.toolBarButtonPrevious && this.treeViewFieldData.SelectedNode != null) { TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: if (EventSeriess.Instance.HasPrevious) { if (this._tvOperations.expandLvl < ExpandLevel.EventSeries) return; this.toolBarButtonLevelPicture.ImageIndex = 8; this.displayEventSeries(EventSeriess.Instance.Previous); this.labelPosition.Text = EventSeriess.Instance.Position; } else { if (this._tvOperations.expandLvl < ExpandLevel.EventSeries || EventSeriess.Instance.Current == null) return; this.toolBarButtonLevelPicture.ImageIndex = 8; this.displayEventSeries(null); this.labelPosition.Text = EventSeriess.Instance.Position; } break; case TreeViewNodeTypes.EventNode: if (this._events != null) { if (this._events.HasPrevious) { if (this._tvOperations.expandLvl < ExpandLevel.Event) return; this.toolBarButtonLevelPicture.ImageIndex = 9; this.displayEvent(this._events.Previous); this.labelPosition.Text = this._events.Position; } else return; } break; case TreeViewNodeTypes.SpecimenNode: if (this._specimen != null) { if (this._specimen.HasPrevious) { if (this._tvOperations.expandLvl < ExpandLevel.Specimen) return; this.toolBarButtonLevelPicture.ImageIndex = 10; this.displaySpecimen(this._specimen.Previous); this.labelPosition.Text = this._specimen.Position; } else return; } break; case TreeViewNodeTypes.IdentificationUnitNode: if (this._iu != null) { if (this._iu.HasPrevious) { if (this._tvOperations.expandLvl < ExpandLevel.IdentificationUnit) return; this.toolBarButtonLevelPicture.ImageIndex = 12; this.displayIdentificationUnit(this._iu.Previous); this.labelPosition.Text = this._iu.Position; } else return; } break; default: return; } } catch (DataFunctionsException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this.afterSelect(treeViewFieldData.SelectedNode); return; } else if (e.Button == this.toolBarButtonSearch) { SearchForm dlg = new SearchForm(); //Suche bis Anpassung deaktiviert if (dlg.ShowDialog() == DialogResult.Yes) { switch (dlg.type) { case "Event": this.displayEvent(SearchResults.Instance.getEvent(dlg.resultID)); break; case "Specimen": this.displayEvent(SearchResults.Instance.getEventForSpecimen(dlg.resultID)); break; case "IU": this.displayEvent(SearchResults.Instance.getEventForIU(dlg.resultID)); break; } } this.afterSelect(treeViewFieldData.SelectedNode); } else if (e.Button == this.toolBarButtonUserProfile) { UserProfileDialog dlg = null; try { dlg = new UserProfileDialog(true); if (dlg == null) return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Dialog zentrieren dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._actualLvl = TreeViewNodeTypes.Unknown; if (treeViewFieldData.SelectedNode == null) { this.pictureBoxHome_Click(null, null); return; } UserProfile up = UserProfiles.Instance.Current; this.setIconSize(); if (up != null) try { this._tvOperations = new TreeViewOperations((ExpandLevel)up.Displaylevel.Index, EventSeriess.Instance.Connector); } catch (TreeViewOperationsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Severe Program Exception (" + ex.Message + "). Program couldn't be started."); this.Close(); } this.afterSelect(treeViewFieldData.SelectedNode); this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; } } else if (e.Button == this.toolBarButtonEditContext)//Das darf doch nicht wahr sein { EditContextForm dlg = new EditContextForm(); // Dialog zentrieren dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() == DialogResult.OK) { } } } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } }
private void pictureBoxNewEventSeries_Click(object sender, EventArgs e) { //Ruft den Dialog auf und wechselt direkt zur neuen Eventseries EventSeriesDialog dlg = null; try { dlg = new EventSeriesDialog(null); if (dlg == null) return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Dialog zentrieren dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; try { EventSeriess.Instance.Find(dlg.EventSeries.SeriesID); this.displayEventSeries(dlg.EventSeries); this.labelPosition.Text = EventSeriess.Instance.Position; this.enableDisableButtons(TreeViewNodeTypes.EventSeriesNode); this._actualLvl = TreeViewNodeTypes.EventSeriesNode; this.enableDisableToolbarButtons(_actualLvl); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } Cursor.Current = Cursors.Default; } else { this.treeViewFieldData.SelectedNode = null; } }
/// <summary> /// Displays a specimen (does not check whether the passed on parameter is valid). /// </summary> /// <param name="specimen">The current specimen.</param> /// <returns></returns> /// private void displaySpecimen(CollectionSpecimen spec) { if (spec != null) { Cursor.Current = Cursors.WaitCursor; this.treeViewFieldData.BeginUpdate(); this.treeViewFieldData.SuspendLayout(); TreeNode parent = treeViewFieldData.SelectedNode.Parent; TreeNode node = treeViewFieldData.SelectedNode; try { treeViewFieldData.SelectedNode = null; TreeNode specNode = new TreeNode(); IList<TreeNode> removeNodes = new List<TreeNode>(); int i = 0; if (this._tvOperations.expandLvl <= ExpandLevel.Event) { removeNodes.Add(node); i = node.Index; } else { foreach (TreeNode tn in parent.Nodes) { TreeViewNodeData td = tn.Tag as TreeViewNodeData; if (td.NodeType == TreeViewNodeTypes.SpecimenNode) removeNodes.Add(tn); else i++; } } specNode = _tvOperations.displaySpecimen(spec); foreach (TreeNode rem in removeNodes) { parent.Nodes.Remove(rem); } parent.Nodes.Insert(i, specNode); this.treeViewFieldData.SelectedNode = specNode; this._expandTrigger = false; if (this._tvOperations.expandLvl <= ExpandLevel.Specimen) specNode.ExpandAll(); else specNode.Expand(); this._expandTrigger = true; this._actualLvl = TreeViewNodeTypes.SpecimenNode; this.enableDisableButtons(TreeViewNodeTypes.SpecimenNode); } catch (Exception ex) { this.treeViewFieldData.SelectedNode = parent; afterSelect(parent); this.treeViewFieldData.EndUpdate(); this.treeViewFieldData.ResumeLayout(); this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; MessageBox.Show("DisplayError: " + ex.Message); return; } this.treeViewFieldData.ResumeLayout(); this.treeViewFieldData.EndUpdate(); this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; } }
public TreeViewNodeData(string collectorsName, int CollectionSpecimenID) { this.CollectorsName = collectorsName; this.CollectionSpecimenID = CollectionSpecimenID; this.NodeType = TreeViewNodeTypes.AgentNode; }
/// <summary> /// Handles the Click event of the pictureBoxNewIdentificationUnit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void pictureBoxNewIdentificationUnit_Click(object sender, EventArgs e) { if (this.treeViewFieldData.Nodes.Count == 0 || this.treeViewFieldData.SelectedNode == null) { return; } Cursor.Current = Cursors.WaitCursor; TreeNode parentNode = this.treeViewFieldData.SelectedNode; NewIdentificationUnitDialog dlg; TreeViewNodeData data = this.treeViewFieldData.SelectedNode.Tag as TreeViewNodeData; if (data == null) return; // if parent Node is also IdentificationUnit then set some default data int? seriesID = null; CollectionEvent ev = null; CollectionSpecimen cs = null; IdentificationUnit parentIU = null; if (data.NodeType == TreeViewNodeTypes.IdentificationUnitNode) { try { parentIU = DataFunctions.Instance.RetrieveIdentificationUnit((int)data.ID); } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Data of parent Identification Unit couldn't be retrieved. ("+ex.Message+")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (parentIU != null) { cs = parentIU.CollectionSpecimen; ev = cs.CollectionEvent; seriesID = ev.SeriesID; try { if (seriesID != null) { EventSeriess.Instance.Find((int)seriesID); this._events = EventSeriess.Instance.CollectionEvents; } else this._events = new CollectionEvents(null); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } this._events.Find((int)ev.CollectionEventID); this._specimen = this._events.Specimen; this._specimen.Find((int)cs.CollectionSpecimenID); this._iu = this._specimen.IdentificationUnits; try { dlg = new NewIdentificationUnitDialog(cs, parentIU, this._iu); } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } else { Cursor.Current = Cursors.Default; MessageBox.Show("Data of parent Identification Unit couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } else if (data.NodeType == TreeViewNodeTypes.SpecimenNode) { try { TreeNode eventNode = parentNode.Parent; TreeViewNodeData eventData = eventNode.Tag as TreeViewNodeData; TreeNode seriesNode = eventNode.Parent; TreeViewNodeData seriesData = seriesNode.Tag as TreeViewNodeData; seriesID = seriesData.ID; if (seriesID != null) { EventSeriess.Instance.Find((int)seriesID); this._events = EventSeriess.Instance.CollectionEvents; } else this._events = new CollectionEvents(null); this._events.Find((int)eventData.ID); ev = this._events.Current; this._specimen = this._events.Specimen; } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (this._specimen.Find((int)data.ID)) { cs = this._specimen.Current; this._iu = this._specimen.IdentificationUnits; try { dlg = new NewIdentificationUnitDialog(cs, this._iu); } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Associated IdentificationUnits with selected Specimen couldn't be retrieved. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Associated IdentificationUnits with selected Specimen couldn't be retrieved. (" + ex.Message + ")", "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } else { Cursor.Current = Cursors.Default; MessageBox.Show("Data of selected Specimen couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } else { Cursor.Current = Cursors.Default; MessageBox.Show("Wrong node selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // center dialog dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); Cursor.Current = Cursors.Default; dlg.ShowDialog(); moveTaxonomicGroupToFront(dlg.TaxonomicGroup); if (dlg.Current != null) { IdentificationUnit iu = dlg.Current; TreeViewNodeData parentData = parentNode.Tag as TreeViewNodeData; this.treeViewFieldData.BeginUpdate(); treeViewFieldData.SuspendLayout(); if (parentData.NodeType == TreeViewNodeTypes.SpecimenNode) { displaySpecimen(cs); } if (parentData.NodeType == TreeViewNodeTypes.IdentificationUnitNode) { displayIdentificationUnit(parentIU); } foreach (TreeNode node in treeViewFieldData.SelectedNode.Nodes) { TreeViewNodeData nodeData = node.Tag as TreeViewNodeData; if (nodeData.NodeType == TreeViewNodeTypes.IdentificationUnitNode && nodeData.ID == iu.IdentificationUnitID) { this.treeViewFieldData.SelectedNode = node; break; } } if (!this.treeViewFieldData.SelectedNode.IsExpanded && this._tvOperations.expandLvl <= ExpandLevel.IdentificationUnit) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.ExpandAll(); this._expandTrigger = true; } this.treeViewFieldData.SelectedNode.EnsureVisible(); this._actualLvl = TreeViewNodeTypes.IdentificationUnitNode; this.enableDisableToolbarButtons(_actualLvl); this.enableDisableButtons(_actualLvl); treeViewFieldData.ResumeLayout(); this.treeViewFieldData.EndUpdate(); } }
private void pictureBoxNewEvent_Click(object sender, EventArgs e) { if (this.treeViewFieldData.SelectedNode == null || this.treeViewFieldData.SelectedNode.Tag == null) { MessageBox.Show("Error, EventSeriesNode has to be selected"); return; } TreeNode seriesNode = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = this.treeViewFieldData.SelectedNode.Tag as TreeViewNodeData; if (data.NodeType != TreeViewNodeTypes.EventSeriesNode) { MessageBox.Show("Error, EventSeriesNode has to be selected!"); return; } int? seriesID = data.ID; try { if (data.ID != null) { EventSeriess.Instance.Find((int) data.ID); this._events = EventSeriess.Instance.CollectionEvents; } else this._events = new CollectionEvents(null); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } NewEventDialog dlg = null; try { dlg = new NewEventDialog(true); if(dlg == null) return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; if (this._events != null) { try { if (StaticGPS.isOpened()) { if (StaticGPS.position != null) { double altitude = StaticGPS.position.SeaLevelAltitude; double latitude = float.Parse(StaticGPS.position.Latitude.ToString()); double longitude = float.Parse(StaticGPS.position.Longitude.ToString()); this._events.CreateNewEvent(seriesID, altitude, longitude, latitude, StaticGPS.position.SatelliteCount, StaticGPS.position.PositionDilutionOfPrecision); } else { this._events.CreateNewEvent(seriesID); } } else { this._events.CreateNewEvent(seriesID); } } catch (ConnectionCorruptedException ex) { MessageBox.Show("New CollectionEvent couldn't be created. ("+ex.Message+")", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } catch (DataFunctionsException ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (dlg.EventNumber != null) this._events.Current.CollectorsEventNumber = dlg.EventNumber; if (dlg.Notes != null) this._events.Current.Notes = dlg.Notes; if (dlg.DateSupplement != null) this._events.Current.CollectionDateSupplement = dlg.DateSupplement; try { DataFunctions.Instance.Update(this._events.Current); } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Collection Event Data (Event Number, Notes, Date Supplement) couldn't be saved. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Collection Event Data (Event Number, Notes, Date Supplement) couldn't be saved. ("+ex.Message+")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } TreeNode evNode = new TreeNode(); this.treeViewFieldData.BeginUpdate(); this._tvOperations.parametrizeEventNode(this._events.Current, evNode); this.treeViewFieldData.SelectedNode.Nodes.Add(evNode); this.treeViewFieldData.SelectedNode = evNode; if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.ExpandAll(); this._expandTrigger = true; } // create automatically CollectionSpecimen CollectionSpecimen spec = null; try { this._specimen = this._events.Specimen; spec = this._specimen.CreateSpecimen(); this._iu = this._specimen.IdentificationUnits; } catch (Exception ex) { String errorMsg = ""; Cursor.Current = Cursors.Default; if (spec != null) { try { DataFunctions.Instance.Remove(spec); } catch (ConnectionCorruptedException except) { errorMsg = "Specimen couldn't be automatically assigned to new Collection Event. (" + except.Message + ")"; } } if (errorMsg.Equals(String.Empty)) { errorMsg = "Specimen couldn't be automatically assigned to new Collection Event. (" + ex.Message + ")"; } MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.treeViewFieldData.EndUpdate(); return; } TreeNode specNode = new TreeNode(); this._tvOperations.parametrizeOnlySpecimenNode(spec, specNode); this.labelPosition.Text = this._specimen.Position; this.treeViewFieldData.SelectedNode.Nodes.Add(specNode); this.treeViewFieldData.SelectedNode = specNode; if (!this.treeViewFieldData.SelectedNode.IsExpanded) { this._expandTrigger = false; this.treeViewFieldData.SelectedNode.ExpandAll(); this._expandTrigger = true; } this.enableDisableButtons(TreeViewNodeTypes.SpecimenNode); this._actualLvl = TreeViewNodeTypes.SpecimenNode; enableDisableToolbarButtons(_actualLvl); this.treeViewFieldData.EndUpdate(); } } Cursor.Current = Cursors.Default; }