internal static void RefreshList() { list.Clear(); IOTAProjectGroup _ProjectGroup = OtaUtils.GetCurrentProjectGroup(); if (_ProjectGroup != null) { for (int j= 0; j < _ProjectGroup.ProjectCount; j++) { IOTAProject _Project = _ProjectGroup[j]; for (int k = 0; k < _Project.ModuleCount; k++) { IOTAModuleInfo _ModuleInfo = _Project.GetModuleInfo(k); // TODO: what if the file is required by a certain project? not only the first project including it. if (!IsValidModuleInfo(_ModuleInfo)) { continue; } string key = _ModuleInfo.FileName.ToUpperInvariant(); if (list.ContainsKey(key)) { list[key].ProjectFileName += ";" + _Project.FileName; } else { ModuleFileInfo _ModuleFileInfo = new ModuleFileInfo(); _ModuleFileInfo.ProjectFileName = _Project.FileName; //_ModuleFileInfo.IsPartOfActiveProject = _Project == _ProjectGroup.ActiveProject; _ModuleFileInfo.Tag = _ModuleInfo; list.Add(_ModuleInfo.FileName.ToUpperInvariant(), _ModuleFileInfo); } } } } }
internal override bool IsSatisfiedBy(ModuleFileInfo file) { if (String.IsNullOrEmpty(name)) { return true; } else { return Path.GetFileName(file.FileName).IndexOf(name, StringComparison.OrdinalIgnoreCase) > -1; } }
internal override bool IsSatisfiedBy(ModuleFileInfo file) { if (project == AnyProject) { return true; } else if (project == ActiveProject) { return file.IsPartOfActiveProject; } else { return file.ProjectFileName.Contains(project); } }
private static bool IsForm(ModuleFileInfo file) { #region Approach One: fails because of an OTA bug. // this approach cannot show all files. Some forms and user controls give null, too. // IOTAModuleInfo info = (IOTAModuleInfo)file.Tag; // LoggingService.Info(file.FileName + " gives " + // info.DesignClassName); // if (String.IsNullOrEmpty(info.DesignClassName)) // { // return false; // } else { // return true; // } #endregion #region Approach Two: too slow. /* if (IsAssembly(file)) { // prevent them from opening. return false; } // method 1 will open the module: // IOTAModule module = info.OpenModule(); // method 2 will open the file and make it invisible. IOTAModule module = OTAUtils.GetModuleServices().OpenModule(file.FileName); if (module == null) { return false; } IOTADotNetModule dotNet = module.GetService(typeof(IOTADotNetModule)) as IOTADotNetModule; if (dotNet == null) { return false; // not .NET module. } if (dotNet.HasDesignableType) { return true; } return false; //*/ #endregion // if .resx exists and a source file with the same name, it may be a Form or User Controls. // There might be few exceptions. string ext = Path.GetExtension(file.FileName); if (String.IsNullOrEmpty(ext) || ext.ToUpperInvariant() == ".RESX") { return false; } string resxFileName = Path.ChangeExtension(file.FileName, ".resx"); string nfmFileName = Path.ChangeExtension(file.FileName, ".nfm"); string dfmFileName = Path.ChangeExtension(file.FileName, ".dfm"); if (File.Exists(resxFileName) || File.Exists(nfmFileName) || File.Exists(dfmFileName)) { return true; } else { return false; } }
internal override bool IsSatisfiedBy(ModuleFileInfo file) { if (!File.Exists(file.FileName)) { return false; } switch (type) { case ModuleType.All: return true; case ModuleType.Assemblies: return IsAssembly(file); case ModuleType.Forms: return IsForm(file); case ModuleType.Sources: return IsSource(file); default: return false; } }
private static bool IsAssembly(ModuleFileInfo file) { return Path.GetExtension(file.FileName).ToUpperInvariant() == ".DLL"; }
private static bool IsSource(ModuleFileInfo file) { return OtaUtils.IsSourceFile(file.FileName); }
internal abstract bool IsSatisfiedBy(ModuleFileInfo file);
internal override bool IsSatisfiedBy(ModuleFileInfo file) { return spec1.IsSatisfiedBy(file) && spec2.IsSatisfiedBy(file); }
private static ListViewItem CreateListViewItem(ModuleFileInfo item) { ModuleFileInfo _ModuleFileInfo = item; IOTAModuleInfo _ModuleInfo = (IOTAModuleInfo) _ModuleFileInfo.Tag; ListViewItem _ListViewItem = new ListViewItem(); _ListViewItem.Text = Path.GetExtension(_ModuleInfo.FileName); _ListViewItem.SubItems.Add(Path.GetFileName(_ModuleInfo.FileName)); _ListViewItem.SubItems.Add(Path.GetDirectoryName(_ModuleInfo.FileName)); _ListViewItem.ImageIndex = _ModuleFileInfo.ImageIndex; _ListViewItem.Tag = item; return _ListViewItem; }
private static void NavigateTo(ModuleFileInfo item) { IOTAModuleInfo _ModuleInfo = (IOTAModuleInfo)item.Tag; IOTAModule _Module = _ModuleInfo.OpenModule(); if (_Module != null) { _Module.ShowFileName(_ModuleInfo.FileName); } }