Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
 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();
 }
Esempio n. 4
0
 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();
             }
         }
     }
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 /// <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;
 }