/// <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; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.Visible = true; try { if (UserProfiles.Instance.Current != null) { try { _tvOperations = new TreeViewOperations((ExpandLevel)UserProfiles.Instance.Current.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(); } } // Toolbar Icons on the basis of UserProfile this.setIconSize(); //Load AllEventSeries this.displayAllEventSeries(); this.enableDisableButtons(TreeViewNodeTypes.Root); this.enableDisableToolbarButtons(_actualLvl); EventSeriess.Instance.Current = null; } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Severe Program Exception (" + ex.Message + "). Program couldn't be started."); this.Close(); } // GPS try { this.StartGPS(); StaticGPS.updatePositionDataHandler = new EventHandler(UpdatePositionData); StaticGPS.updateDeviceDataHandler = new EventHandler(UpdateDeviceData); if (StaticGPS.device == null || StaticGPS.device.DeviceState == GpsServiceState.Off || StaticGPS.position == null) { this.setPictureBoxImage((int)TreeViewIconIndex.GPSGrey, this.pictureBoxGPS); this.setPictureBoxImage((int)TreeViewIconIndex.Location0, this.pictureBoxNewLocalisation); } else { if (StaticGPS.position != null) { if (StaticGPS.position.SatelliteCount <= 2) { this.setPictureBoxImage((int)TreeViewIconIndex.GPSGrey, this.pictureBoxGPS); } else { this.setPictureBoxImage((int)TreeViewIconIndex.GPS, this.pictureBoxGPS); } if (StaticGPS.position.SatelliteCount < 4) this.setPictureBoxImage((int)TreeViewIconIndex.Location0, this.pictureBoxNewLocalisation); else if (StaticGPS.position.SatelliteCount == 4) this.setPictureBoxImage((int)TreeViewIconIndex.Location4, this.pictureBoxNewLocalisation); else if (StaticGPS.position.SatelliteCount == 5) this.setPictureBoxImage((int)TreeViewIconIndex.Location5, this.pictureBoxNewLocalisation); else if (StaticGPS.position.SatelliteCount == 6) this.setPictureBoxImage((int)TreeViewIconIndex.Location6, this.pictureBoxNewLocalisation); else this.setPictureBoxImage((int)TreeViewIconIndex.LocationMore, this.pictureBoxNewLocalisation); } } } catch (Exception ex) { MessageBox.Show("GPS functions aren't available. ("+ex.Message+")", "GPS Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } Cursor.Current = Cursors.Default; }