private void OnTaxaIndexChanged(object sender, EventArgs e) { var o = (ComboBox)sender; if (_dataStatus != fad3DataStatus.statusNew) { _dataStatus = o.Text != _taxaName ? fad3DataStatus.statusEdited : default; } _taxaName = o.Text; _taxa = CatchName.TaxaFromTaxaName(_taxaName); if (_taxa == Taxa.Fish) { var fbData = Names.NameInFishBaseEx(_genus, _species); chkInFishbase.Checked = _inFishBase = fbData.inFishBase; chkInFishbase.Enabled = false; _fishBaseSpeciesNumber = fbData.fishBaseSpeciesNo; } else { _inFishBase = false; _fishBaseSpeciesNumber = null; chkInFishbase.Checked = false; chkInFishbase.Enabled = false; } o = null; }
private void OnForm_Load(object sender, EventArgs e) { global.LoadFormSettings(this, false); dropDownMenu.ItemClicked += OnDropDownMenuItemClicked; Text = "Database of species names of catch in the Philippines"; lvTaxa.View = View.List; foreach (var item in CatchName.RetrieveTaxaDictionary()) { lvTaxa.Items.Add(item.Key.ToString(), item.Value, null); } lvNames.With(o => { o.View = View.Details; o.FullRowSelect = true; o.Columns.Add("Row"); o.Columns.Add("Genus"); o.Columns.Add("Species"); o.Columns.Add("Taxa"); o.Columns.Add("In FishBase"); o.Columns.Add("Records"); o.Columns.Add("Notes"); o.HideSelection = false; }); SizeColumns(lvNames); GetSpeciesNames(); }
public SpeciesNameForm(string genus, string species, string nameGuid, string taxaName, Form Parent) { InitializeComponent(); _genus = genus; _species = species; _nameGuid = nameGuid; _taxaName = taxaName; _dataStatus = fad3DataStatus.statusFromDB; _dialogTitle = $"Data for the species {genus} {species}"; _parentForm = Parent; chkInFishbase.Enabled = taxaName == "Fish"; _taxa = CatchName.TaxaFromTaxaName(taxaName); }
public SpeciesNameForm(string speciesName, Form parent) { InitializeComponent(); var arr = speciesName.Split(' '); for (int n = 0; n < arr.Length; n++) { if (n == 0) { _genus = arr[n]; } else { _species = arr[n] + " "; } } _species = _species.Trim(' '); _taxa = CatchName.TaxaFromCatchName(_genus, _species); _nameGuid = Names.AllSpeciesReverseDictionary[_genus + " " + _species]; _parentForm = parent; }
private void SpeciesNameForm_Load(object sender, EventArgs e) { foreach (var item in CatchName.RetrieveTaxaDictionary()) { cboTaxa.Items.Add(item); } cboTaxa.DisplayMember = "Value"; cboTaxa.ValueMember = "Key"; cboTaxa.DropDownStyle = ComboBoxStyle.DropDownList; cboTaxa.AutoCompleteSource = AutoCompleteSource.ListItems; cboTaxa.AutoCompleteMode = AutoCompleteMode.Append; txtGenus.Text = _genus; txtSpecies.Text = _species; if (_dataStatus != fad3DataStatus.statusNew) { var speciesData = Names.RetrieveSpeciesData(_nameGuid); _taxaName = cboTaxa.Text = CatchName.TaxaNameFromTaxa(speciesData.taxa); _inFishBase = chkInFishbase.Checked = speciesData.inFishbase; _fishBaseSpeciesNumber = speciesData.fishBaseNo; _notes = txtNotes.Text = speciesData.notes; _genusMPH1 = speciesData.genusKey1 ?? default; _genusMPH2 = speciesData.genusKey2 ?? default; _speciesMPH1 = speciesData.speciesKey1 ?? default; _speciesMPH2 = speciesData.speciesKey2 ?? default; _catchCompositionRecordCount = Names.CatchCompositionRecordCount(_nameGuid); labelRecordCount.Text = _catchCompositionRecordCount.ToString(); if (_taxa == Taxa.Cephalopods) { _taxaName = "Cephalopods (squids etc)"; } else { _taxaName = _taxa.ToString(); } cboTaxa.Text = _taxaName; if (_catchCompositionRecordCount == 0) { buttonEdit.Text = "Delete"; } } else { labelRecordCount.Text = "0"; _nameGuid = Guid.NewGuid().ToString(); if (_genus.Length > 0 && _species.Length > 0) { var speciesFishBaseData = Names.NameInFishBaseEx(_genus, _species); _inFishBase = chkInFishbase.Checked = speciesFishBaseData.inFishBase; _fishBaseSpeciesNumber = speciesFishBaseData.fishBaseSpeciesNo; if (chkInFishbase.Checked) { cboTaxa.Text = "Fish"; } var metaPhone = new DoubleMetaphoneShort(); metaPhone.ComputeMetaphoneKeys(_genus, out short k1, out short k2); _genusMPH1 = k1; _genusMPH2 = k2; metaPhone.ComputeMetaphoneKeys(_species, out k1, out k2); _speciesMPH1 = k1; _speciesMPH2 = k2; var SimilarSoundingList = Names.RetrieveSpeciesWithSimilarMetaPhone(_genusMPH1, _genusMPH2, _speciesMPH1, _speciesMPH2); if (SimilarSoundingList.Count > 0) { Width = (int)(Width * 2); ListView lvSimilarNames = new ListView { Name = "lvSimilarNames", Top = txtSpecies.Top, Left = txtGenus.Left + txtGenus.Width + 20, Height = (txtNotes.Top + txtNotes.Height) - txtSpecies.Top, View = View.List, }; lvSimilarNames.Width = Width - (lvSimilarNames.Left + 20); lvSimilarNames.DoubleClick += OnListViewDoubleClick; Label labelSimilar = new Label { Left = lvSimilarNames.Left, Top = labelGenus.Top, Text = "Similar sounding names", AutoSize = false, Width = lvSimilarNames.Width }; Controls.Add(lvSimilarNames); Controls.Add(labelSimilar); foreach (var item in SimilarSoundingList) { var lvi = new ListViewItem(new string[] { item.fullName, item.genus, item.species }); lvSimilarNames.Items.Add(lvi); } } } buttonEdit.Enabled = false; } if (ReadOnly) { buttonCancel.Visible = false; buttonOK.Text = "Close"; } global.LoadFormSettings(this, true); }