public EditorFile(ProjectFile file) : base(file.Path, file.Role) { if (file.TextCache != null) TextCache = file.TextCache; IsChanged = file.IsChanged; Open(DockState.Document); var projectIndex = ProjectFile.All.FindIndex(i => i.Path == Path); if (projectIndex >= 0) ProjectFile.All[projectIndex] = this; }
void AddReference(ProjectFile reference, TreeNode node = null) { var refNode = node.Nodes.Add(reference.FileName, reference.FileName, 1); refNode.Tag = reference; refNode.ToolTipText = reference.Path; if (reference.References != null && reference.References.Count > 0) { reference.References.ForEach(i => AddReference(i, refNode)); refNode.Expand(); } }
internal ProjectPanel(ProjectFile file) { SuspendLayout(); Font = _defaultFont; CloseButton = false; CloseButtonVisible = false; Project = file; Text = Messages.Scenery; Tree = new ProjectTree() { Name = Text, Dock = DockStyle.Fill, LabelEdit = true }; Root = Tree.Nodes.Add(Project.FileName, Project.FileName, 0); Root.Tag = Project; Project.GetReferences(); Project.ReferencesResolved += file_ReferencesResolved; ReloadScheme(); Controls.Add(Tree); DockPanel = Main.DockPanel; DockPanel.DockRightPortion = 300; Show(DockPanel, DockState.DockRightAutoHide); Tree.Sort(); ResumeLayout(); }
private void GetReferences(Roles role, Regex r, string[] ignore = null, string[] allow = null, string defaultExt = null) { var input = !Role.HasFlag(Roles.Description) ? new ScnSyntax.Comment().Replace(Text, "") : Text; foreach (Match m in r.Matches(input)) { if (ignore != null && ignore.Contains(m.Value)) continue; var path = ((role == Roles.Description ? BaseDirectory : SceneryDirectory) + "\\" + m.Value).Replace('/', '\\'); var ext = System.IO.Path.GetExtension(m.Value); if (defaultExt != null && ext == "") { ext = defaultExt; path += ext; } if (System.IO.File.Exists(path)) { if (allow != null && !allow.Contains(ext)) continue; if (!References.Any(p => p.Path == path)) { var reference = new ProjectFile(path, role); References.Add(reference); reference.GetReferences(); } } } }
private static void GetScenery(ProjectFile f) { if (f.Role != Roles.Main) throw new InvalidOperationException("Main scenery file expected."); if (Main.Instance.TrackMap != null) { Main.Instance.TrackMap.Close(); Main.Instance.TrackMap.Dispose(); Main.Instance.TrackMap = null; } All = new List<ProjectFile>(); All.Add(f); }
/// <summary> /// Tries to open a relative filename within the current project /// </summary> /// <param name="context"></param> /// <param name="name"></param> /// <returns></returns> public static bool TryOpen(ProjectFile context, string name) { string b = context.BaseDirectory, s = context.SceneryDirectory, n = name, l = "\\", i = ".inc", t = ".txt"; var searchPath = new string[] { b + l + n, b + l + n + i, b + l + n + t, s + l + n, s + l + n + i, s + l + n + t, }; foreach (var path in searchPath) { if (System.IO.File.Exists(path)) { new EditorFile(path); return true; } } return false; }