Exemplo n.º 1
0
 public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
 {
     try
     {
         if (fFirstShow != 0)
         {
             IVsProject project = null;
             uint       itemref = 0;
             string     path    = null;
             GetDocumentInfo(docCookie, ref project, ref itemref, ref path);
             if (project != null && !string.IsNullOrEmpty(path))
             {
                 if (project.IsIceBuilderGeneratedItem(path))
                 {
                     ProjectItem item = project.GetProjectItem(itemref);
                     if (item != null)
                     {
                         item.Document.ReadOnly = true;
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
         // Could happend with some document types
     }
     return(0);
 }
Exemplo n.º 2
0
 public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
 {
     ThreadHelper.JoinableTaskFactory.Run(async() =>
     {
         await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
         try
         {
             if (fFirstShow != 0)
             {
                 IVsProject project = null;
                 uint itemref       = 0;
                 string path        = null;
                 GetDocumentInfo(docCookie, ref project, ref itemref, ref path);
                 if (project != null && !string.IsNullOrEmpty(path) &&
                     (path.EndsWith(".cs", StringComparison.CurrentCultureIgnoreCase) ||
                      path.EndsWith(".cpp", StringComparison.CurrentCultureIgnoreCase) ||
                      path.EndsWith(".h", StringComparison.CurrentCultureIgnoreCase)))
                 {
                     if (project.IsIceBuilderGeneratedItem(path))
                     {
                         ProjectItem item = project.GetProjectItem(itemref);
                         if (item != null)
                         {
                             item.Document.ReadOnly = true;
                         }
                     }
                 }
             }
         }
         catch (Exception)
         {
             // Could happend with some document types
         }
     });
     return(0);
 }