コード例 #1
0
ファイル: BindingListSource.cs プロジェクト: zrolfs/pwiz
 public void SetViewContext(IViewContext viewContext, ViewInfo viewInfo)
 {
     ViewContext = viewContext;
     if (null == viewInfo)
     {
         BindingListView.ViewInfo = null;
     }
     else
     {
         IRowSource rowSource   = null;
         bool       viewChanged = true;
         if (null != ViewInfo)
         {
             if (ViewInfo.RowSourceName == viewInfo.RowSourceName)
             {
                 rowSource = RowSource;
                 if (ViewInfo.Name == viewInfo.Name)
                 {
                     viewChanged = false;
                 }
             }
         }
         rowSource = rowSource ?? viewContext.GetRowSource(viewInfo);
         BindingListView.SetViewAndRows(viewInfo, rowSource);
         if (viewChanged)
         {
             BindingListView.ClearTransformStack();
         }
         if (ViewContext != null && viewInfo.ViewGroup != null)
         {
             var viewLayoutList = ViewContext.GetViewLayoutList(viewInfo.ViewGroup.Id.ViewName(viewInfo.Name));
             if (null != viewLayoutList)
             {
                 var defaultLayout = viewLayoutList.FindLayout(viewLayoutList.DefaultLayoutName);
                 if (defaultLayout != null)
                 {
                     ApplyLayout(defaultLayout);
                 }
             }
         }
     }
     OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
 }