Пример #1
0
        private void TestUIModesFileLoadAction(SrmDocument.DOCUMENT_TYPE initialModeUI,
                                               string docName,
                                               SrmDocument.DOCUMENT_TYPE finalModeUI)
        {
            RunUI(() =>
            {
                SkylineWindow.NewDocument();
                SkylineWindow.SetUIMode(initialModeUI);
                Assert.AreEqual(initialModeUI, SkylineWindow.ModeUI);
                VerifyButtonStates();

                SkylineWindow.OpenFile(TestFilesDir.GetTestPath(docName));
                Assert.AreEqual(finalModeUI, SkylineWindow.ModeUI);
                VerifyButtonStates();

                SkylineWindow.NewDocument();
                Assert.AreEqual(finalModeUI, SkylineWindow.ModeUI);
                VerifyButtonStates();
            });

            // Prepare to test per-ui-mode persistence of "peptide" settings tab choice
            var peptideSettingsDlg = ShowDialog <PeptideSettingsUI>(
                () => SkylineWindow.ShowPeptideSettingsUI((PeptideSettingsUI.TABS)finalModeUI));

            OkDialog(peptideSettingsDlg, peptideSettingsDlg.CancelDialog);
        }
Пример #2
0
        private static string ParseColumnCaption(string s, CultureInfo cultureUI, SrmDocument.DOCUMENT_TYPE docType)
        {
            var val = new DataSchemaLocalizer(CultureInfo.CurrentCulture, cultureUI, ColumnCaptions.ResourceManager)
                      .LookupColumnCaption(new ColumnCaption(s));

            return(Helpers.PeptideToMoleculeTextMapper.Translate(val, docType)); // Perform "peptide"->"molecule" translation as needed
        }
Пример #3
0
 protected DiffNode(Property property, PropertyPath propertyPath, SrmDocument.DOCUMENT_TYPE docType, IEnumerable <DiffNode> nodes = null, bool expanded = false)
 {
     Property     = property;
     PropertyPath = propertyPath;
     Nodes        = nodes != null ? new List <DiffNode>(nodes) : new List <DiffNode>();
     Expanded     = expanded;
     DocType      = docType;
 }
Пример #4
0
 public static string Format(string format, SrmDocument.DOCUMENT_TYPE modeUI, params object[] args)
 {
     if (modeUI != SrmDocument.DOCUMENT_TYPE.mixed && modeUI != SrmDocument.DOCUMENT_TYPE.small_molecules)
     {
         return(string.Format(format, args));
     }
     return(SMALL_MOLECULE_MAPPER.FormatTranslateString(format, args));
 }
Пример #5
0
 // Attempt to take a string like "{0} peptides" and return one like "{0} molecules" if doctype is not purely proteomic
 public static string Translate(string text, SrmDocument.DOCUMENT_TYPE modeUI)
 {
     if (modeUI != SrmDocument.DOCUMENT_TYPE.mixed && modeUI != SrmDocument.DOCUMENT_TYPE.small_molecules)
     {
         return(text);
     }
     return(SMALL_MOLECULE_MAPPER.TranslateString(text));
 }
Пример #6
0
        public static string ToString(ObjectPair <object> rootPair, SrmDocument.DOCUMENT_TYPE docType, T obj, ToStringState state)
        {
            var objectInfo = new ObjectInfo <object>().ChangeNewObject(obj)
                             .ChangeRootObjectPair(rootPair ?? ObjectPair <object> .Create(null, null));
            var rootProp = RootProperty.Create(typeof(T));

            var enumerator = EnumerateDiffNodes(objectInfo, rootProp, docType, true);

            return(ToString(objectInfo.ParentObjectPair, docType, DiffTree.FromEnumerator(enumerator, DateTime.UtcNow).Root, state));
        }
Пример #7
0
        public override ToolStripMenuItem CreateMenuItem(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView)
        {
            var menuItem = new ToolStripMenuItem(GetMenuItemText(docType), null, (sender, args) => DeleteNodes(dataGridView));

            if (!GetSelectedNodes(dataGridView).Any())
            {
                menuItem.Enabled = false;
            }

            return(menuItem);
        }
Пример #8
0
        public override ToolStripMenuItem CreateMenuItem(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView)
        {
            var toolStripMenuItem =
                new ToolStripMenuItem(GetMenuItemText(docType), null, (sender, args) => RemovePeaks(docType, dataGridView));

            if (!GetSelectedResults(dataGridView).Any())
            {
                toolStripMenuItem.Enabled = false;
            }
            return(toolStripMenuItem);
        }
Пример #9
0
        public void RemovePeaks(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView)
        {
            var parent        = FormUtil.FindTopLevelOwner(dataGridView);
            var selectedPeaks = GetSelectedPeaks(dataGridView).Distinct().ToArray();

            if (selectedPeaks.Length == 0)
            {
                MessageDlg.Show(parent, Resources.RemovePeaksAction_RemovePeaks_No_peaks_are_selected);
                return;
            }

            var    lookup  = selectedPeaks.ToLookup(tuple => tuple.Item1, tuple => tuple.Item2).ToArray();
            string message = GetConfirmRemoveMessage(docType, selectedPeaks.Length, lookup.Length);

            if (MultiButtonMsgDlg.Show(parent, message, MultiButtonMsgDlg.BUTTON_OK) != DialogResult.OK)
            {
                return;
            }

            var skylineWindow = GetSkylineWindow(dataGridView);

            lock (skylineWindow.GetDocumentChangeLock())
            {
                skylineWindow.ModifyDocument(Resources.RemovePeaksAction_RemovePeaks_Remove_peaks,
                                             doc =>
                {
                    var longOperationRunner = new LongOperationRunner
                    {
                        ParentControl = parent,
                        JobTitle      = Resources.RemovePeaksAction_RemovePeaks_Removing_Peaks
                    };
                    SrmDocument resultDocument = doc;
                    doc = doc.BeginDeferSettingsChanges();
                    longOperationRunner.Run(broker =>
                    {
                        for (int iGroup = 0; iGroup < lookup.Length; iGroup++)
                        {
                            broker.ProgressValue = iGroup * 100 / lookup.Length;
                            if (broker.IsCanceled)
                            {
                                return;
                            }
                            doc = RemovePeaks(doc, lookup[iGroup]);
                        }

                        resultDocument = doc.EndDeferSettingsChanges(resultDocument, null);
                    });
                    return(resultDocument);
                },
                                             docPair => AuditLogEntry.CreateSingleMessageEntry(
                                                 new MessageInfo(MessageType.removed_peaks, docPair.NewDocumentType, selectedPeaks.Length, lookup.Length)));
            }
        }
Пример #10
0
            protected override string GetConfirmRemoveMessage(SrmDocument.DOCUMENT_TYPE docType, int peakCount, int nodeCount)
            {
                if (peakCount == 1)
                {
                    return(Resources.RemoveTransitions_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_this_transition_peak_);
                }

                if (nodeCount == 1)
                {
                    return(string.Format(Resources.RemoveTransitions_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_these__0__peaks_from_one_transition_, peakCount));
                }
                return(string.Format(Resources.RemoveTransitions_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_these__0__peaks_from__1__transitions_, peakCount, nodeCount));
            }
 public BuildPeptideSearchLibrarySettings(double cutoffScore, IList <string> searchFileNames, IrtStandard standard, bool includeAmbiguousMatches, bool filterForDocumentPeptides, ImportPeptideSearchDlg.Workflow workFlow,
                                          SrmDocument.DOCUMENT_TYPE docType)
 {
     CutoffScore     = cutoffScore;
     SearchFileNames = searchFileNames == null
         ? new List <AuditLogPath>()
         : searchFileNames.Select(AuditLogPath.Create).ToList();
     Standard = standard;
     IncludeAmbiguousMatches   = includeAmbiguousMatches;
     FilterForDocumentPeptides = filterForDocumentPeptides;
     WorkFlow = workFlow;
     _docType = docType;
 }
Пример #12
0
            public string Parse(string s, LogLevel logLevel, CultureInfo cultureUI, SrmDocument.DOCUMENT_TYPE docType)
            {
                if (ParseIndex >= 0 && ParseIndex < PARSE_FUNCTIONS.Length)
                {
                    var parsed = PARSE_FUNCTIONS[ParseIndex](ParseInput, logLevel, cultureUI, docType);
                    if (parsed != null)
                    {
                        return(parsed);
                    }
                }

                return(s.Substring(StartIndex, Length));
            }
Пример #13
0
        public static string FromDocumentType(SrmDocument.DOCUMENT_TYPE documentType)
        {
            switch (documentType)
            {
            case SrmDocument.DOCUMENT_TYPE.proteomic:
                return(PROTEOMIC);

            case SrmDocument.DOCUMENT_TYPE.small_molecules:
                return(SMALL_MOLECULES);

            default:
                return(MIXED);
            }
        }
Пример #14
0
        public static IEnumerable <IUiModeInfo> AvailableModes(SrmDocument.DOCUMENT_TYPE documentType)
        {
            if (documentType == SrmDocument.DOCUMENT_TYPE.proteomic)
            {
                return(AllModes.Where(mode => mode.Name != SMALL_MOLECULES));
            }

            if (documentType == SrmDocument.DOCUMENT_TYPE.small_molecules)
            {
                return(AllModes.Where(mode => mode.Name != PROTEOMIC));
            }

            return(AllModes);
        }
Пример #15
0
 public ImportPeptideSearchSettings(
     ImportResultsSettings importResultsSettings,
     MatchModificationsControl.MatchModificationsSettings modificationsSettings,
     TransitionSettingsControl.TransitionFilterAndLibrariesSettings filterAndLibSettings,
     TransitionFullScan fullScanSettings, ImportFastaControl.ImportFastaSettings importFastaSettings,
     SrmDocument.DOCUMENT_TYPE docType)
 {
     ImportResultsSettings      = importResultsSettings;
     ModificationsSettings      = modificationsSettings;
     FilterAndLibrariesSettings = filterAndLibSettings;
     FullScanSettings           = fullScanSettings;
     ImportFastaSettings        = importFastaSettings;
     _docType = docType;
 }
Пример #16
0
            // For all items in a menu, attempt to take a string like "{0} peptides" and return one like "{0} molecules" if menu item is not purely proteomic
            // Update keyboard accelerators as needed
            public static void TranslateMenuItems(ToolStripItemCollection items, SrmDocument.DOCUMENT_TYPE modeUI, ModeUIExtender extender)
            {
                var mapper = new PeptideToMoleculeTextMapper(modeUI, extender);

                if (items != null)
                {
                    mapper.FindInUseKeyboardAccelerators(items);
                    var activeItems = new List <ToolStripItem>();
                    for (int i = 0; i < items.Count; i++)
                    {
                        var item = items[i];
                        ModeUIExtender.MODE_UI_HANDLING_TYPE handlingType;
                        if (!mapper.HandledComponents.TryGetValue(item, out handlingType))
                        {
                            handlingType = ModeUIExtender.MODE_UI_HANDLING_TYPE.auto;
                        }

                        bool isActive;
                        switch (modeUI)
                        {
                        case SrmDocument.DOCUMENT_TYPE.proteomic:
                            isActive = handlingType != ModeUIExtender.MODE_UI_HANDLING_TYPE.small_mol &&
                                       handlingType != ModeUIExtender.MODE_UI_HANDLING_TYPE.small_mol_only &&
                                       handlingType != ModeUIExtender.MODE_UI_HANDLING_TYPE.mixed_only;
                            break;

                        case SrmDocument.DOCUMENT_TYPE.small_molecules:
                            isActive = handlingType != ModeUIExtender.MODE_UI_HANDLING_TYPE.proteomic &&
                                       handlingType != ModeUIExtender.MODE_UI_HANDLING_TYPE.mixed_only;
                            break;

                        case SrmDocument.DOCUMENT_TYPE.mixed:
                            isActive = handlingType != ModeUIExtender.MODE_UI_HANDLING_TYPE.small_mol_only;
                            break;

                        default:
                            isActive = false;
                            Assume.Fail(@"unknown UI mode");
                            break;
                        }

                        if (isActive)
                        {
                            activeItems.Add(item);
                        }
                        item.Visible = isActive;
                    }
                    mapper.Translate(activeItems); // Update the menu items that aren't inherently wrong for current UI mode
                }
            }
Пример #17
0
        /// <summary>
        /// Handler for the toolbar button dropdown that allow user to switch between proteomic, small mol, or mixed UI display.
        /// </summary>
        public override void SetUIMode(SrmDocument.DOCUMENT_TYPE mode)
        {
            base.SetUIMode(mode);

            PopulateWizardPanel();          // Update wizards for new UI mode
            PopulateTutorialPanel();        // Update tutorial order for new UI mode

            GetModeUIHelper().OnLoad(this); // Reprocess any needed translations

            // Update the menu structure for this mode
            if (Program.MainWindow != null)
            {
                Program.MainWindow.SetUIMode(ModeUI);
            }
        }
Пример #18
0
 private SrmDocument.DOCUMENT_TYPE GetNewDocType(SrmDocument.DOCUMENT_TYPE expected, SrmDocument.DOCUMENT_TYPE actual)
 {
     SrmDocument.DOCUMENT_TYPE setTo;
     if (expected == SrmDocument.DOCUMENT_TYPE.none &&
         actual == SrmDocument.DOCUMENT_TYPE.proteomic)
     {
         setTo = SrmDocument.DOCUMENT_TYPE.none;
     }
     else if (expected == SrmDocument.DOCUMENT_TYPE.proteomic &&
              actual == SrmDocument.DOCUMENT_TYPE.none)
     {
         setTo = SrmDocument.DOCUMENT_TYPE.proteomic;
     }
     else
     {
         return(actual);
     }
     return(setTo);
 }
Пример #19
0
            // For all controls in a form, attempt to take a string like "{0} peptides" and return one like "{0} molecules" if doctype is not purely proteomic
            public static void TranslateForm(Form form, SrmDocument.DOCUMENT_TYPE modeUI, ModeUIExtender extender = null)
            {
                if (form != null)
                {
                    var mapper = new PeptideToMoleculeTextMapper(modeUI, extender);
                    form.Text = mapper.TranslateString(form.Text); // Update the title

                    // Find tooltip components in the form, if any
                    mapper.ToolTips = (from field in form.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                       where typeof(Component).IsAssignableFrom(field.FieldType)
                                       let component = (Component)field.GetValue(form)
                                                       where component is ToolTip
                                                       select component as ToolTip).ToList();

                    mapper.FindInUseKeyboardAccelerators(form.Controls);

                    mapper.Translate(form.Controls); // Update the controls
                }
            }
Пример #20
0
        // bools, ints and doubles are localized
        private static string ParsePrimitive(string s, CultureInfo cultureUI, SrmDocument.DOCUMENT_TYPE docType)
        {
            var result = s;

            if (bool.TryParse(s, out bool b))
            {
                return(AuditLogStrings.ResourceManager.GetString(
                           b ? @"LogMessage_LocalizeValue_True" : @"LogMessage_LocalizeValue_False", cultureUI)); // Don't quote
            }
            else if (int.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out int i))
            {
                result = i.ToString(cultureUI);
            }
            else if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out double d))
            {
                result = d.ToString(cultureUI);
            }

            return(Quote(result));
        }
Пример #21
0
            public void AttemptChangeModeUI(SrmDocument.DOCUMENT_TYPE new_uimode)
            {
                var doc               = Program.ActiveDocument;
                var hasPeptides       = doc != null && doc.DocumentType != SrmDocument.DOCUMENT_TYPE.none && doc.DocumentType != SrmDocument.DOCUMENT_TYPE.small_molecules;
                var hasSmallMolecules = doc != null && doc.DocumentType != SrmDocument.DOCUMENT_TYPE.none && doc.DocumentType != SrmDocument.DOCUMENT_TYPE.proteomic;

                string message = null;

                if (new_uimode == SrmDocument.DOCUMENT_TYPE.proteomic && hasSmallMolecules)
                {
                    message = Resources.ModeUIAwareFormHelper_EnableNeededButtonsForModeUI_Cannot_switch_to_proteomics_interface_because_the_current_document_contains_small_molecules_data_;
                }
                else if (new_uimode == SrmDocument.DOCUMENT_TYPE.small_molecules && hasPeptides)
                {
                    message = Resources.ModeUIAwareFormHelper_EnableNeededButtonsForModeUI_Cannot_switch_to_molecule_interface_because_the_current_document_contains_proteomics_data_;
                }

                if (message != null)
                {
                    message = TextUtil.LineSeparate(message, @" ", Resources.ModeUIAwareFormHelper_EnableNeededButtonsForModeUI_Would_you_like_to_create_a_new_document_);
                    using (var alert = new AlertDlg(message, MessageBoxButtons.YesNo))
                    {
                        if (alert.ShowAndDispose(_modeUIToolBarDropDownButton.GetCurrentParent()) == DialogResult.Yes)
                        {
                            Program.MainWindow.NewDocument();
                        }
                    }
                    if (Program.ActiveDocument.DocumentType != SrmDocument.DOCUMENT_TYPE.none)
                    {
                        return; // User canceled out of NewDocument, no change to UI mode
                    }
                }

                ModeUI = new_uimode;

                UpdateButtonImageForModeUI();

                Settings.Default.UIMode = ModeUI.ToString();
            }
Пример #22
0
            protected override string GetConfirmRemoveMessage(SrmDocument.DOCUMENT_TYPE docType, int peakCount, int nodeCount)
            {
                bool proteomic = docType == SrmDocument.DOCUMENT_TYPE.proteomic;

                if (peakCount == 1)
                {
                    return(proteomic
                            ? Resources.RemovePeptides_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_this_peptide_peak_
                            : Resources.RemovePeptides_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_this_molecule_peak_);
                }

                if (nodeCount == 1)
                {
                    return(string.Format(proteomic
                        ? Resources.RemovePeptides_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_these__0__peaks_from_one_peptide_
                        : Resources.RemovePeptides_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_these__0__peaks_from_one_molecule_, peakCount));
                }

                return(string.Format(proteomic
                    ? Resources
                                     .RemovePeptides_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_these__0__peaks_from__1__peptides_
                    : Resources.RemovePeptides_GetConfirmRemoveMessage_Are_you_sure_you_want_to_remove_these__0__peaks_from__1__molecules_, peakCount, nodeCount));
            }
Пример #23
0
        private void TestUIModesClickAction(SrmDocument.DOCUMENT_TYPE initalModeUI,
                                            SrmDocument.DOCUMENT_TYPE clickWhat,
                                            bool expectNewDocument)
        {
            var docType = SkylineWindow.Document.DocumentType;

            RunUI(() =>
            {
                SkylineWindow.NewDocument();
                SkylineWindow.SetUIMode(initalModeUI);
                var docName = initalModeUI == SrmDocument.DOCUMENT_TYPE.proteomic ? "Proteomic.sky" :
                              initalModeUI == SrmDocument.DOCUMENT_TYPE.small_molecules ? "SmallMol.sky" :
                              "Mixed.sky";
                VerifyButtonStates();
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath(docName));
                VerifyButtonStates();
                docType = SkylineWindow.DocumentUI.DocumentType;
            });
            if (initalModeUI != clickWhat && clickWhat != SrmDocument.DOCUMENT_TYPE.mixed && clickWhat != docType)
            {
                // Can't force a loaded document to be another type, so we offer to create a new one
                RunDlg <AlertDlg>(() => SkylineWindow.SetUIMode(clickWhat), dlg => dlg.ClickYes());
                RunUI(() => Assume.IsFalse(SkylineWindow.DocumentUI.MoleculeGroups.Any()));
            }
            else
            {
                RunUI(() => SkylineWindow.SetUIMode(clickWhat));
                Assume.IsFalse(expectNewDocument);
            }
            RunUI(() =>
            {
                SkylineWindow.SetUIMode(clickWhat);
                VerifyButtonStates();
                var actualModeUI = SkylineWindow.ModeUI;
                Assert.AreEqual(clickWhat, actualModeUI);
            });
        }
Пример #24
0
 public ElementDiffNode(Property property, PropertyPath propertyPath, object element, object elementKey, bool removed, SrmDocument.DOCUMENT_TYPE docType, IEnumerable <DiffNode> nodes = null, bool expanded = false)
     : base(property, propertyPath, docType, nodes, expanded)
 {
     Element    = element;
     ElementKey = elementKey;
     Removed    = removed;
 }
Пример #25
0
 public ElementPropertyDiffNode(Property property, PropertyPath propertyPath, ObjectPair <object> value, object elementKey, SrmDocument.DOCUMENT_TYPE docType, IEnumerable <DiffNode> nodes = null, bool expanded = false)
     : base(property, propertyPath, value, docType, nodes, expanded)
 {
     ElementKey = elementKey;
 }
Пример #26
0
 public PropertyDiffNode(Property property, PropertyPath propertyPath, ObjectPair <object> value, SrmDocument.DOCUMENT_TYPE docType, IEnumerable <DiffNode> nodes = null, bool expanded = false)
     : base(property, propertyPath, docType, nodes, expanded)
 {
     Value = value;
 }
Пример #27
0
 public AnnotationTargetItem(AnnotationDef.AnnotationTarget annotationTarget, SrmDocument.DOCUMENT_TYPE modeUI)
 {
     AnnotationTarget = annotationTarget;
     ModeUI           = modeUI;
 }
Пример #28
0
            public PeptideToMoleculeTextMapper(SrmDocument.DOCUMENT_TYPE modeUI, ModeUIExtender extender)
            {
                // Japanese has a set of characters that are easily swapped between Hiragana and Katakana
                // One orginally appeared in about 2% of the translations of the word "peptide"
//                const char jaHeHiragana = 'へ';
//                const char jaHeKatakana = 'ヘ';
//                const char jaBeHiragana = 'べ';
//                const char jaBeKatakana = 'ベ';
                const char jaPeHiragana = 'ぺ';  // Used as a typo in "peptide"
                const char jaPeKatakana = 'ペ';  // Used in "peptide"

                // The basic replacements (not L10N to pick up not-yet-localized UI - maintain the list below in concert with this one)
                var dict = new Dictionary <string, string>
                {
                    // ReSharper disable LocalizableElement
                    { "Peptide", "Molecule" },
                    { "Peptides", "Molecules" },
                    { "Protein", "Molecule List" },
                    { "Proteins", "Molecule Lists" },
                    { "Modified Sequence", "Molecule" },
                    { "Peptide Sequence", "Molecule" },
                    { "Modified Peptide Sequence", "Molecule" },
                    { "Ion Charges", "Ion adducts" }
                    // ReSharper restore LocalizableElement
                };

                // Handle lower case as well
                foreach (var kvp in dict.ToArray())
                {
                    dict.Add(kvp.Key.ToLowerInvariant(), kvp.Value.ToLowerInvariant());
                    // Also handle combinations of upper/lower case (eg "Modified peptide sequence")
                    var space = kvp.Key.IndexOf(' ');
                    if (space > 0)
                    {
                        dict.Add(kvp.Key.Substring(0, space) + kvp.Key.Substring(space).ToLowerInvariant(), kvp.Value);
                    }
                }

                ModeUI = modeUI == SrmDocument.DOCUMENT_TYPE.none ? SrmDocument.DOCUMENT_TYPE.proteomic : modeUI; // SrmDocument.DOCUMENT_TYPE.none would be unusual, but would still mean no translation

                // Handle keyboard accelerators where possible: P&eptide => Mol&ecule
                var set = new HashSet <KeyValuePair <string, string> >();

                foreach (var kvp in dict)
                {
                    var pep = kvp.Key.ToLowerInvariant();
                    var mol = kvp.Value.ToLowerInvariant();
                    foreach (var c in pep.Distinct().Where(c => Char.IsLetterOrDigit(c) && mol.Contains(c)))
                    {
                        var positionP = pep.IndexOf(c);
                        var positionM = mol.IndexOf(c);
                        // Prefer to map "Peptide &List" to "Molecule &List" rather than "Mo&lecule List"
                        if (Char.IsUpper(kvp.Key[positionP]))
                        {
                            var positionU = kvp.Value.IndexOf(kvp.Key[positionP]);
                            if (positionU >= 0)
                            {
                                positionM = positionU;
                            }
                        }

                        var amp = @"&";
                        set.Add(new KeyValuePair <string, string>(kvp.Key.Insert(positionP, amp), kvp.Value.Insert(positionM, amp)));
                    }
                    set.Add(kvp);
                }

                // Add localized versions, if any
                // NB this assumes that localized versions of Skyline are non-western, and don't attempt to embed keyboard accelerators in control texts
                var currentUICulture = Thread.CurrentThread.CurrentUICulture;
                var cultureNames     = (extender == null) // This is only true in the case where we're constructing our static object
                    ? new[] { @"zh-CHS", @"ja" }  // Culture can change in lifetime of a static object in our test system, so include all
                    : new[] { currentUICulture.Name };

                foreach (var cultureName in cultureNames)
                {
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
                    var setL10N = new HashSet <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Peptide,
                                                          Resources.PeptideToMoleculeText_Molecule),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Peptides,
                                                          Resources.PeptideToMoleculeText_Molecules),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Protein,
                                                          Resources.PeptideToMoleculeText_Molecule_List),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Proteins,
                                                          Resources.PeptideToMoleculeText_Molecule_Lists),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Peptide_Sequence,
                                                          Resources.PeptideToMoleculeText_Molecule),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Modified_Sequence,
                                                          Resources.PeptideToMoleculeText_Molecule),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Modified_Peptide_Sequence,
                                                          Resources.PeptideToMoleculeText_Molecule),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Peptide_List,
                                                          Resources.PeptideToMoleculeText_Molecule_List),
                        new KeyValuePair <string, string>(Resources.PeptideToMoleculeText_Ion_charges,
                                                          Resources.PeptideToMoleculeText_Ion_adducts)
                    };
                    foreach (var kvp in setL10N.Where(kp => !dict.ContainsKey(kp.Key))) // Avoids adding not-yet-translated keys
                    {
                        set.Add(kvp);
                        set.Add(new KeyValuePair <string, string>(kvp.Key.ToLower(), kvp.Value.ToLower()));
                        // As protection, just in case the Hiragana "Pe" ever shows up in our translations again
                        if (cultureName.Equals(@"ja") && kvp.Key.Contains(jaPeKatakana))
                        {
                            set.Add(new KeyValuePair <string, string>(kvp.Key.Replace(jaPeKatakana, jaPeHiragana), kvp.Value));
                        }
                    }
                }
                Thread.CurrentThread.CurrentUICulture = currentUICulture;

                // Sort so we look for longer replacements first
                var list = set.ToList();

                list.Sort((a, b) => b.Key.Length.CompareTo(a.Key.Length));
                TRANSLATION_TABLE         = new List <KeyValuePair <string, string> >(list);
                InUseKeyboardAccelerators = new HashSet <char>();
                ToolTip           = null;
                HandledComponents = extender == null ? new Dictionary <IComponent, ModeUIExtender.MODE_UI_HANDLING_TYPE>() : extender.GetHandledComponents();
            }
Пример #29
0
 public override string GetMenuItemText(SrmDocument.DOCUMENT_TYPE docType)
 {
     return(Resources.RemoveTransitions_MenuItemText_Remove_Transition_Peaks___);
 }
Пример #30
0
 public override string GetMenuItemText(SrmDocument.DOCUMENT_TYPE docType)
 {
     return(Resources.RemovePrecursors_MenuItemText_Remove_Precursor_Peaks___);
 }