Ejemplo n.º 1
0
        private void SelectedIndexChangedEvent(ComboBox combo,
                                               SettingsList <StaticMod> listSettingsMods, IList <ExplicitMod> listExplicitMods,
                                               IList <ComboBox> listCombo, IList <int> listSelectedIndex, int indexAA,
                                               bool selectEither)
        {
            int selectedIndexLast = listSelectedIndex[indexAA];

            if (AddItemSelected(combo))
            {
                StaticMod itemNew = listSettingsMods.NewItem(this, null, null);
                if (!Equals(itemNew, null))
                {
                    listSettingsMods.Add(itemNew);
                    string itemAdd = (string)combo.SelectedItem;
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, itemNew.GetKey(),
                              selectEither);
                    // If the selection was not successfully set to the new modification,
                    // return to the previous selection.
                    if (Equals(combo.SelectedItem, itemAdd))
                    {
                        combo.SelectedIndex = selectedIndexLast;
                    }
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            else if (EditListSelected(combo))
            {
                IEnumerable <StaticMod> listNew = listSettingsMods.EditList(this, null);
                if (listNew != null)
                {
                    listSettingsMods.Clear();
                    listSettingsMods.AddRange(listNew);

                    string selectedItemLast = null;
                    if (selectedIndexLast != -1)
                    {
                        selectedItemLast = combo.Items[selectedIndexLast].ToString();
                    }
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, selectedItemLast,
                              selectEither);
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            listSelectedIndex[indexAA] = combo.SelectedIndex;
        }
Ejemplo n.º 2
0
        public bool LoadSettings()
        {
            SettingsList.Clear();

            // Loads in the config in XML format
            try
            {
                _configFile = XElement.Load(Settings.Default.ChromaConfigPath);

                if (_configFile == null)
                {
                    SettingsLoaded = false;
                    return(SettingsLoaded);
                }
            }
            catch (Exception ex)
            {
                LastError = ex.ToString();
                Hs.Instance._log.LogException("Error Loading Chroma Config", ex);
                SettingsLoaded = false;
                return(SettingsLoaded);
            }

            // Parses out the XML doc into settings
            try
            {
                foreach (var setting in _configFile.Descendants("setting"))
                {
                    if (setting.Attribute("name") == null)
                    {
                        continue;
                    }

                    var name = setting.Attribute("name")?.Value;
                    var val  = setting.Value;

                    SettingsList.Add(new ChromaSetting()
                    {
                        SettingName = name, SettingValue = val
                    });
                }

                SettingsLoaded = true;
            }
            catch (Exception ex)
            {
                LastError = ex.ToString();
                Hs.Instance._log.LogException("Error Parsing Chroma Config", ex);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public void GetConfigFiles()
        {
            Directory.CreateDirectory(ConfigFileDirectory);
            var files = Directory.GetFiles(ConfigFileDirectory, "*.config.csx");

            SettingsList.Clear();

            var items = new[] { AutoGenerateTemplateName }
            .Concat(files.Select(x => Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(x))));

            foreach (var item in items)
            {
                SettingsList.Add(item);
            }
        }
Ejemplo n.º 4
0
        private void SelectedIndexChangedEvent(ComboBox combo,
            SettingsList<StaticMod> listSettingsMods, IList<ExplicitMod> listExplicitMods,
            IList<ComboBox> listCombo, IList<int> listSelectedIndex, int indexAA,
            bool selectEither)
        {
            int selectedIndexLast = listSelectedIndex[indexAA];
            if (AddItemSelected(combo))
            {
                StaticMod itemNew = listSettingsMods.NewItem(this, null, null);
                if (!Equals(itemNew, null))
                {
                    listSettingsMods.Add(itemNew);
                    string itemAdd = (string) combo.SelectedItem;
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, itemNew.GetKey(),
                        selectEither);
                    // If the selection was not successfully set to the new modification,
                    // return to the previous selection.
                    if (Equals(combo.SelectedItem, itemAdd))
                        combo.SelectedIndex = selectedIndexLast;
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            else if (EditListSelected(combo))
            {
                IEnumerable<StaticMod> listNew = listSettingsMods.EditList(this, null);
                if (listNew != null)
                {
                    listSettingsMods.Clear();
                    listSettingsMods.AddRange(listNew);

                    string selectedItemLast = null;
                    if (selectedIndexLast != -1)
                        selectedItemLast = combo.Items[selectedIndexLast].ToString();
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, selectedItemLast,
                        selectEither);
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            listSelectedIndex[indexAA] = combo.SelectedIndex;
        }
Ejemplo n.º 5
0
        private void SelectedIndexChangedEvent(ComboBox combo,
                                               SettingsList <StaticMod> listSettingsMods, IList <ExplicitMod> listExplicitMods,
                                               IList <ComboBox> listCombo, IList <int> listSelectedIndex, int indexAA,
                                               bool selectEither)
        {
            int selectedIndexLast = listSelectedIndex[indexAA];

            if (AddItemSelected(combo))
            {
                StaticMod itemNew = listSettingsMods.NewItem(this, null, null);
                if (!Equals(itemNew, null))
                {
                    listSettingsMods.Add(itemNew);
                    string itemAdd = (string)combo.SelectedItem;
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, itemNew.GetKey(),
                              selectEither);
                    // If the selection was not successfully set to the new modification,
                    // return to the previous selection.
                    if (Equals(combo.SelectedItem, itemAdd))
                    {
                        combo.SelectedIndex = selectedIndexLast;
                    }
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            else if (EditCurrentSelected(combo))
            {
                StaticMod itemEdit;
                if (listSettingsMods.TryGetValue((string)combo.Items[selectedIndexLast], out itemEdit))
                {
                    StaticMod itemNew = listSettingsMods.EditItem(this, itemEdit, listSettingsMods, null);
                    if (!Equals(itemNew, null))
                    {
                        int i = listSettingsMods.IndexOf(itemEdit);
                        listSettingsMods[i] = itemNew;
                        LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, itemNew.GetKey(),
                                  selectEither);
                    }
                }
                combo.SelectedIndex = selectedIndexLast;
            }
            else if (EditListSelected(combo))
            {
                IEnumerable <StaticMod> listNew = listSettingsMods.EditList(this, null);
                if (listNew != null)
                {
                    listSettingsMods.Clear();
                    listSettingsMods.AddRange(listNew);

                    string selectedItemLast = null;
                    if (selectedIndexLast != -1)
                    {
                        selectedItemLast = combo.Items[selectedIndexLast].ToString();
                    }
                    LoadLists(listSettingsMods, listExplicitMods, listCombo, indexAA, selectedItemLast,
                              selectEither);
                }
                else
                {
                    // Reset the selected index before edit was chosen.
                    combo.SelectedIndex = selectedIndexLast;
                }
            }
            else
            {
                string    modName = (string)combo.SelectedItem;
                StaticMod staticMod;
                if (!string.IsNullOrEmpty(modName) && listSettingsMods.TryGetValue(modName, out staticMod))
                {
                    if (!EnsureLinkedPeptide(staticMod, indexAA))
                    {
                        combo.SelectedIndex = selectedIndexLast;
                    }
                }
            }
            listSelectedIndex[indexAA] = combo.SelectedIndex;
        }