コード例 #1
0
ファイル: MyComputerProject.cs プロジェクト: ikvm/webmatrix
 private void OnCommandFileOpen()
 {
     IDocumentTypeManager service = (IDocumentTypeManager) base.GetService(typeof(IDocumentTypeManager));
     if (service != null)
     {
         OpenFileDialog dialog = new OpenFileDialog();
         dialog.Filter = service.OpenFilters;
         dialog.ShowReadOnly = true;
         dialog.Multiselect = true;
         dialog.CheckFileExists = true;
         dialog.Title = "Open Files";
         IDocumentManager manager2 = (IDocumentManager) base.GetService(typeof(IDocumentManager));
         if (manager2 != null)
         {
             Document activeDocument = manager2.ActiveDocument;
             if ((activeDocument != null) && (activeDocument.ProjectItem.Project == this))
             {
                 dialog.InitialDirectory = Path.GetDirectoryName(activeDocument.DocumentPath);
             }
         }
         ICommandManager manager3 = (ICommandManager) base.GetService(typeof(ICommandManager));
         if (manager3 != null)
         {
             manager3.SuspendCommandUpdate();
         }
         try
         {
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 string[] fileNames = dialog.FileNames;
                 bool readOnlyChecked = dialog.ReadOnlyChecked;
                 for (int i = 0; i < fileNames.Length; i++)
                 {
                     string path = fileNames[i];
                     try
                     {
                         MiscFileProjectItem projectItem = new MiscFileProjectItem(Path.GetFileName(path), path, this);
                         bool readOnly = readOnlyChecked || ((File.GetAttributes(path) & FileAttributes.ReadOnly) != 0);
                         this.OpenProjectItem(projectItem, readOnly, DocumentViewType.Default);
                     }
                     catch
                     {
                     }
                 }
             }
         }
         finally
         {
             if (manager3 != null)
             {
                 manager3.ResumeCommandUpdate();
             }
         }
     }
 }
コード例 #2
0
ファイル: MyComputerProject.cs プロジェクト: ikvm/webmatrix
 public override Document OpenProjectItem(DocumentProjectItem item, bool readOnly, DocumentViewType initialView)
 {
     IDocumentManager service = (IDocumentManager) base.GetService(typeof(IDocumentManager));
     if (service == null)
     {
         return null;
     }
     MiscFileProjectItem projectItem = item as MiscFileProjectItem;
     if ((projectItem == null) || (projectItem.Project != this))
     {
         projectItem = new MiscFileProjectItem(item.Caption, item.Path, this);
     }
     Document document = service.OpenDocument(projectItem, readOnly, initialView);
     this.AddMruEntry(item);
     return document;
 }
コード例 #3
0
ファイル: MyComputerProject.cs プロジェクト: ikvm/webmatrix
 private void OnCommandFileFileMRU(int index)
 {
     string path = this.MruList[index];
     MiscFileProjectItem projectItem = new MiscFileProjectItem(Path.GetFileName(path), path, this);
     try
     {
         this.OpenProjectItem(projectItem, false, DocumentViewType.Default);
     }
     catch
     {
         ((IMxUIService) base.ServiceProvider.GetService(typeof(IMxUIService))).ReportError("The file '" + path + "' could not be opened.\r\nIt will be removed from the recent files list.", "Unable to open the selected file.", true);
         this.MruList.RemoveEntry(path);
     }
 }
コード例 #4
0
ファイル: FileSystemProject.cs プロジェクト: ikvm/webmatrix
 public override DocumentProjectItem GetSaveAsProjectItem(DocumentProjectItem item)
 {
     DocumentProjectItem item2 = null;
     IDocumentTypeManager service = (IDocumentTypeManager) base.GetService(typeof(IDocumentTypeManager));
     if (service == null)
     {
         return null;
     }
     string openFilters = service.OpenFilters;
     SaveFileDialog dialog = new SaveFileDialog();
     dialog.Filter = openFilters;
     dialog.AddExtension = true;
     dialog.CheckPathExists = true;
     dialog.DefaultExt = item.DocumentType.Extension;
     dialog.FileName = Path.GetFileNameWithoutExtension(item.Caption);
     dialog.InitialDirectory = Path.GetDirectoryName(item.Path);
     dialog.OverwritePrompt = true;
     dialog.Title = "Save Document As";
     openFilters = openFilters.ToUpper(CultureInfo.InvariantCulture);
     int num = openFilters.LastIndexOf("." + item.DocumentType.Extension + "|");
     if (num == -1)
     {
         num = openFilters.LastIndexOf("." + item.DocumentType.Extension + ";");
     }
     if (num != -1)
     {
         int num2 = -1;
         int num3 = 0;
         while (num3 != -1)
         {
             int index = openFilters.IndexOf('|', num3 + 1);
             if (index != -1)
             {
                 num3 = openFilters.IndexOf('|', index + 1);
             }
             if (num3 == -1)
             {
                 num2 = -1;
                 break;
             }
             num2++;
             if (num3 > num)
             {
                 break;
             }
         }
         if (num2 != -1)
         {
             num2++;
             dialog.FilterIndex = num2;
         }
     }
     ICommandManager manager2 = (ICommandManager) base.GetService(typeof(ICommandManager));
     if (manager2 != null)
     {
         manager2.SuspendCommandUpdate();
     }
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         item2 = new MiscFileProjectItem(Path.GetFileName(dialog.FileName), dialog.FileName, this);
     }
     if (manager2 != null)
     {
         manager2.ResumeCommandUpdate();
     }
     return item2;
 }