static public FileTool LoadFile(UniFile file, FileTypePlugin plugin) { if (!AllowOpeningFilesTwice && s_openTools.ContainsKey(file.FilePath)) return s_openTools[file.FilePath]; FileTool tool; try { tool = plugin.LoadFile(file); } catch { UIHelper.ShowError("Can't open the selected file " + file.FileName + " using " + plugin.PluginName + ", version: " + plugin.Version + "."); return null; } tool.OnSaved += FileTool_OnSaved; if (s_openTools.ContainsKey(file.FilePath)) s_openTools.Add(file.FilePath, tool); if (FileLoaded != null) FileLoaded(file, tool); return tool; }
static public FileTool LoadFile(string path, FileTypePlugin plugin) { if (!File.Exists(path)) return null; var file = new UniFile(path); return LoadFile(file, plugin); }