protected ITallyEditPanel GetEditView(TallySetupStratum_Base stratum) { if (stratum == null) { return null; } if (stratum is TallySetupStratum) { if (_standardTallyEditPanel == null) { _standardTallyEditPanel = new TallyEditPanel(); _standardTallyEditPanel.GetHotKeys = this._tallyEditPanel_GetHotKeys; _standardTallyEditPanel.Dock = DockStyle.Fill; } _standardTallyEditPanel.Stratum = (TallySetupStratum)stratum; return _standardTallyEditPanel; } else if (stratum is FixCNTTallySetupStratum) { if (_myfixCNTTallyEditPanel == null) { _myfixCNTTallyEditPanel = new FixCNTTallyEditPanel(); _myfixCNTTallyEditPanel.Dock = DockStyle.Fill; } _myfixCNTTallyEditPanel.Stratum = (FixCNTTallySetupStratum)stratum; return _myfixCNTTallyEditPanel; } else { throw new InvalidOperationException(); } }
/// <summary> /// returns all hot-keys that can be assigned as stratum hot-keys. /// </summary> /// <param name="stratum"></param> /// <returns></returns> public string[] GetAvalibleStratumHotKeys(TallySetupStratum_Base stratum) { IEnumerable<String> avalibleHotKeys = Strings.HOTKEYS; avalibleHotKeys = avalibleHotKeys.Except(from st in this.TallySetupStrata where st != stratum select st.Hotkey); foreach (var straum in TallySetupStrata.OfType<TallySetupStratum>()) { avalibleHotKeys = avalibleHotKeys.Except(straum.ListUsedHotKeys()); } return avalibleHotKeys.ToArray(); }
/// <summary> /// returns all hot-keys that can be assigned as stratum hot-keys. /// </summary> /// <param name="stratum"></param> /// <returns></returns> public string[] GetAvalibleStratumHotKeys(TallySetupStratum_Base stratum) { IEnumerable <String> avalibleHotKeys = Strings.HOTKEYS; avalibleHotKeys = avalibleHotKeys.Except(from st in this.TallySetupStrata where st != stratum select st.Hotkey); foreach (var straum in TallySetupStrata.OfType <TallySetupStratum>()) { avalibleHotKeys = avalibleHotKeys.Except(straum.ListUsedHotKeys()); } return(avalibleHotKeys.ToArray()); }
private void _BS_strata_CurrentChanged(object sender, EventArgs e) { _currentStratumChanging = true; try { _currentStratum = _BS_strata.Current as TallySetupStratum_Base; _stratumHKCB.Enabled = _currentStratum != null; _stratumHKCB.Text = _currentStratum?.Hotkey ?? string.Empty; var tallyEditPanel = GetEditView(_currentStratum); TallyEditPanel = tallyEditPanel; } finally { _currentStratumChanging = false; } }
private bool ValidateHotKeys(TallySetupStratum_Base st, ref StringBuilder errorBuilder) { bool success = true; List<char> usedHotKeys = new List<char>(); //StringBuilder errorBuilder = new StringBuilder(); foreach (TallySetupSampleGroup sgVM in st.SampleGroups) { if ((sgVM.TallyMethod & TallyMode.BySampleGroup) == TallyMode.BySampleGroup) { char hk = HotKeyToChar(sgVM.SgTallie.Hotkey); if (hk == char.MinValue) { errorBuilder.AppendFormat("Missing Hot Key in SG:{0} Stratum:{1}\r\n", sgVM.ToString(), st.Code); } else if (usedHotKeys.IndexOf(hk) >= 0)//see if usedHotKeys already CONTAINS value { //ERROR stratum already has hot-key errorBuilder.AppendFormat("Hot Key '{0}' in SG:{1} Stratum:{2} already in use\r\n", sgVM.SgTallie.Hotkey, sgVM.ToString(), st.Code); success = false; } else { //SUCCESS add hot key to list of in use hot keys usedHotKeys.Add(hk); } } else if ((sgVM.TallyMethod & TallyMode.BySpecies) == TallyMode.BySpecies) { foreach (TallyVM t in sgVM.Tallies.Values) { char hk = HotKeyToChar(t.Hotkey); if (hk == char.MinValue) { errorBuilder.AppendFormat("Missing Hot Key in SG:{0} Stratum:{1}\r\n", sgVM.ToString(), st.Code); } else if (usedHotKeys.IndexOf(hk) >= 0)//see if usedHotKeys already CONTAINS value { //ERROR stratum already has hot-key errorBuilder.AppendFormat("Hot Key '{0}' in SG:{1} Stratum:{2} already in use\r\n", t.Hotkey, sgVM.ToString(), st.Code); success = false; } else { //SUCCESS add hot key to list of in use hot keys usedHotKeys.Add(hk); } } } } return success; }
public string[] GetAvalibleStratumHotKeys(TallySetupStratum_Base stratum) { var usedHotKeys = (from st in this.TallySetupStrata where st != stratum select st.Hotkey); foreach (TallySetupStratum_Base straum in this.TallySetupStrata) { usedHotKeys = usedHotKeys.Union(straum.ListUsedHotKeys()); } return Strings.HOTKEYS.Except(usedHotKeys).ToArray(); //return CSM.Utility.R.Strings.HOTKEYS; }
////called when a samplegroup is selected from the dropdown list in tally setup //public void LoadTallies(SampleGroupViewModel sg) //{ // if (sg.TallyMethod != TallyMode.Unknown) { return; }//assume we have already loaded this samplegroup before, dont reload it // //TODO compare what we see as the tally mode vs. the stored mode on the sample group // sg.TallyMethod = GetSampleGroupTallyMode(sg); // //initialize a tally entity for use with tally by sample group // TallyDO sgTally = Controller.Database.ReadSingleRow<TallyDO>("Tally", // "JOIN CountTree WHERE CountTree.Tally_CN = Tally.Tally_CN AND CountTree.SampleGroup_CN = ? AND ifnull(CountTree.TreeDefaultValue_CN, 0) = 0", // sg.SampleGroup_CN); // if (sgTally == null) // { // sg.SgTallie = new TallyDO(Controller.Database); // sg.SgTallie.Description = sg.Code; // } // else // { // sg.SgTallie = sgTally; // } // //initialize a list of tallys for use with tally by species // sg.Tallies = new Dictionary<TreeDefaultValueDO, TallyDO>(); // sg.TreeDefaultValues.Populate(); // foreach (TreeDefaultValueDO tdv in sg.TreeDefaultValues) // { // TallyDO tally = Controller.Database.Read<TallyDO>("Tally", "JOIN CountTree WHERE CountTree.Tally_CN = Tally.Tally_CN AND CountTree.SampleGroup_CN = ? AND CountTree.TreeDefaultValue_CN = ?", sg.SampleGroup_CN, tdv.TreeDefaultValue_CN).FirstOrDefault(); // if (tally == null) // { // tally = new TallyDO(Controller.Database); // tally.Description = tdv.Species + ((tdv.LiveDead == "D") ? "D" : ""); // } // sg.Tallies.Add(tdv, tally); // } //} public string[] GetAvalibleHotKeysInStratum(TallySetupStratum_Base st) { var useHotKeys = (from stratum in this.TallySetupStrata select stratum.Hotkey).Union(st.ListUsedHotKeys()); var avalibleHotHeys = Strings.HOTKEYS.Except(useHotKeys).ToArray(); return avalibleHotHeys; //return CSM.Utility.R.Strings.HOTKEYS; }