private void UpdateViewContext()
 {
     RememberActiveView();
     IList rowSource = null;
     Type rowType = null;
     string builtInViewName = null;
     if (_selectedIdentityPaths.Count == 1)
     {
         var identityPath = _selectedIdentityPaths[0];
         if (identityPath.Length == 2)
         {
             rowSource = new PeptideResultList(new Peptide(_dataSchema, identityPath));
             rowType = typeof (PeptideResult);
             builtInViewName = "Peptide Results"; // Not L10N
         }
         else if (identityPath.Length == 3)
         {
             rowSource = new PrecursorResultList(new Precursor(_dataSchema, identityPath));
             rowType = typeof (PrecursorResult);
             builtInViewName = "Precursor Results"; // Not L10N
         }
         else if (identityPath.Length == 4)
         {
             rowSource = new TransitionResultList(new Transition(_dataSchema, identityPath));
             rowType = typeof (TransitionResult);
             builtInViewName = "Transition Results"; // Not L10N
         }
     }
     else
     {
         var pathLengths = _selectedIdentityPaths.Select(path => path.Length).Distinct().ToArray();
         if (pathLengths.Length == 1)
         {
             var pathLength = pathLengths[0];
             if (pathLength == 3)
             {
                 rowSource = new MultiPrecursorResultList(_dataSchema,
                     _selectedIdentityPaths.Select(idPath => new Precursor(_dataSchema, idPath)));
                 rowType = typeof (MultiPrecursorResult);
                 builtInViewName = "Multiple Precursor Results"; // Not L10N
             }
             if (pathLength == 4)
             {
                 rowSource = new MultiTransitionResultList(_dataSchema,
                     _selectedIdentityPaths.Select(idPath => new Transition(_dataSchema, idPath)));
                 rowType = typeof (MultiTransitionResult);
                 builtInViewName = "Multiple Transition Results"; // Not L10N
             }
         }
     }
     if (rowSource == null)
     {
         rowSource = new ReplicateList(_dataSchema);
         rowType = typeof (Replicate);
         builtInViewName = "Replicates"; // Not L10N
     }
     var parentColumn = ColumnDescriptor.RootColumn(_dataSchema, rowType);
     var builtInViewSpec = SkylineViewContext.GetDefaultViewInfo(parentColumn).GetViewSpec()
         .SetName(builtInViewName).SetRowType(rowType);
     if (null == BindingListSource.ViewContext ||
         !BindingListSource.ViewContext.GetViewSpecList(ViewGroup.BUILT_IN.Id).ViewSpecs.Contains(builtInViewSpec))
     {
         var oldViewContext = BindingListSource.ViewContext as ResultsGridViewContext;
         if (null != oldViewContext)
         {
             oldViewContext.RememberColumnWidths(DataGridView);
         }
         Debug.Assert(null != builtInViewName);
         var builtInView = new ViewInfo(parentColumn, builtInViewSpec).ChangeViewGroup(ViewGroup.BUILT_IN);
         var rowSourceInfo = new RowSourceInfo(rowSource, builtInView);
         var viewContext = new ResultsGridViewContext(_dataSchema,
             new[] {rowSourceInfo});
         ViewInfo activeView = null;
         string activeViewName;
         if (Settings.Default.ResultsGridActiveViews.TryGetValue(rowSourceInfo.Name, out activeViewName))
         {
             activeView = viewContext.GetViewInfo(ViewName.Parse(activeViewName));
         }
         activeView = activeView ?? builtInView;
         BindingListSource.SetViewContext(viewContext, activeView);
     }
     BindingListSource.RowSource = rowSource;
 }
Exemple #2
0
        private void UpdateViewContext()
        {
            RememberActiveView();
            IRowSource rowSource       = null;
            Type       rowType         = null;
            string     builtInViewName = null;

            if (_selectedIdentityPaths.Count == 1)
            {
                var identityPath = _selectedIdentityPaths[0];
                if (identityPath.Length == 2)
                {
                    rowSource       = new PeptideResultList(new Peptide(_dataSchema, identityPath));
                    rowType         = typeof(PeptideResult);
                    builtInViewName = "Peptide Results"; // Not L10N
                }
                else if (identityPath.Length == 3)
                {
                    rowSource       = new PrecursorResultList(new Precursor(_dataSchema, identityPath));
                    rowType         = typeof(PrecursorResult);
                    builtInViewName = "Precursor Results"; // Not L10N
                }
                else if (identityPath.Length == 4)
                {
                    rowSource       = new TransitionResultList(new Transition(_dataSchema, identityPath));
                    rowType         = typeof(TransitionResult);
                    builtInViewName = "Transition Results"; // Not L10N
                }
            }
            else
            {
                // ReSharper disable PossibleMultipleEnumeration
                var pathLengths = _selectedIdentityPaths.Select(path => path.Length).Distinct().ToArray();
                if (pathLengths.Length == 1)
                {
                    var pathLength = pathLengths[0];
                    if (pathLength == 3)
                    {
                        rowSource = new MultiPrecursorResultList(_dataSchema,
                                                                 _selectedIdentityPaths.Select(idPath => new Precursor(_dataSchema, idPath)));
                        rowType         = typeof(MultiPrecursorResult);
                        builtInViewName = "Multiple Precursor Results"; // Not L10N
                    }
                    if (pathLength == 4)
                    {
                        rowSource = new MultiTransitionResultList(_dataSchema,
                                                                  _selectedIdentityPaths.Select(idPath => new Transition(_dataSchema, idPath)));
                        rowType         = typeof(MultiTransitionResult);
                        builtInViewName = "Multiple Transition Results"; // Not L10N
                    }
                }
                // ReSharper restore PossibleMultipleEnumeration
            }
            if (rowSource == null)
            {
                rowSource       = new ReplicateList(_dataSchema);
                rowType         = typeof(Replicate);
                builtInViewName = "Replicates"; // Not L10N
            }
            var parentColumn    = ColumnDescriptor.RootColumn(_dataSchema, rowType);
            var builtInViewSpec = SkylineViewContext.GetDefaultViewInfo(parentColumn).GetViewSpec()
                                  .SetName(builtInViewName).SetRowType(rowType);

            if (null == BindingListSource.ViewContext ||
                !BindingListSource.ViewContext.GetViewSpecList(ViewGroup.BUILT_IN.Id).ViewSpecs.Contains(builtInViewSpec))
            {
                var oldViewContext = BindingListSource.ViewContext as ResultsGridViewContext;
                if (null != oldViewContext)
                {
                    oldViewContext.RememberColumnWidths(DataGridView);
                }
                Debug.Assert(null != builtInViewName);
                var builtInView   = new ViewInfo(parentColumn, builtInViewSpec).ChangeViewGroup(ViewGroup.BUILT_IN);
                var rowSourceInfo = new RowSourceInfo(rowSource, builtInView);
                var viewContext   = new ResultsGridViewContext(_dataSchema,
                                                               new[] { rowSourceInfo });
                ViewInfo activeView = null;
                string   activeViewName;
                if (Settings.Default.ResultsGridActiveViews.TryGetValue(rowSourceInfo.Name, out activeViewName))
                {
                    activeView = viewContext.GetViewInfo(ViewName.Parse(activeViewName));
                }
                activeView = activeView ?? builtInView;
                BindingListSource.SetViewContext(viewContext, activeView);
            }
            BindingListSource.RowSource = rowSource;
        }