Example #1
0
	/// <summary>
	/// Shows "Open" dialog to select an existing workspace.
	/// On OK loads the selected workspace and returns FilesModel. On Cancel return null.
	/// </summary>
	public FilesModel ZLoadAnotherWorkspace()
	{
		var d = new OpenFileDialog { Title = "Open workspace", Filter = "files.xml|files.xml" };
		if(d.ShowDialog(this) != DialogResult.OK) return null;
		var filesXml = d.FileName;
		if(!APath.GetFileName(filesXml).Eqi("files.xml")) {
			ADialog.ShowError("Must be files.xml");
			return null;
		}
		return ZLoadWorkspace(APath.GetDirectoryPath(filesXml));
	}
Example #2
0
        /// <summary>
        /// Extracts meta comments from a single C# file.
        /// </summary>
        /// <param name="f"></param>
        /// <param name="isMain">If false, it is a file added through meta option 'c'.</param>
        void _ParseFile(FileNode f, bool isMain)
        {
            //var p1 = APerf.Create();
            string code = f.GetText(cache: true);
            //p1.Next();
            bool isScript = f.IsScript;

            if (_isMain = isMain)
            {
                Name     = APath.GetFileName(f.Name, true);
                IsScript = isScript;

                Optimize     = DefaultOptimize;
                WarningLevel = DefaultWarningLevel;
                NoWarnings   = DefaultNoWarnings != null ? new List <string>(DefaultNoWarnings) : new List <string>();
                Defines      = new List <string>();
                Role         = DefaultRole(isScript);

                CodeFiles  = new List <MetaCodeFile>();
                References = new MetaReferences();
            }

            CodeFiles.Add(new MetaCodeFile(f, code));

            _fn   = f;
            _code = code;

            int endOf = FindMetaComments(code);

            if (endOf > 0)
            {
                if (isMain)
                {
                    EndOfMeta = endOf;
                }

                foreach (var t in EnumOptions(code, endOf))
                {
                    //var p1 = APerf.Create();
                    _ParseOption(t.Name(), t.Value(), t.nameStart, t.valueStart);
                    //p1.Next(); var t1 = p1.TimeTotal; if(t1 > 5) AOutput.Write(t1, t.Name(), t.Value());
                }
            }
            //p1.NW();
        }
Example #3
0
    bool _GetGrid()
    {
        var g = _grid;

        //test script
        FileNode fts = null;

        if (g.ZGetValue("testScript", out var sts, true, true))
        {
            fts = _f.FindRelative(sts, false);
            if (fts == null)
            {
                ADialog.ShowInfo("testScript file not found", "Must be path relative to this file or path in worspace like \\file or \\folder\\file.", owner: this); return(false);
            }
        }
        _f.TestScript = fts;

        //info: _Get returns null if hidden

        _meta.runMode     = _Get("runMode");
        _meta.ifRunning   = _Get("ifRunning");
        _meta.ifRunning2  = _Get("ifRunning2");
        _meta.uac         = _Get("uac");
        _meta.prefer32bit = _Get("prefer32bit");

        _meta.optimize     = _Get("optimize");
        _meta.warningLevel = _Get("warningLevel");
        _meta.noWarnings   = _Get("noWarnings");
        _meta.define       = _Get("define");
        _meta.preBuild     = _Get("preBuild");
        _meta.postBuild    = _Get("postBuild");

        _meta.outputPath = _Get("outputPath");
        _meta.console    = _Get("console");
        _meta.icon       = _Get("icon");
        _meta.manifest   = _Get("manifest");
        _meta.resFile    = _Get("resFile");
        _meta.sign       = _Get("sign");
        _meta.xmlDoc     = _Get("xmlDoc");

        _meta.role = null;
        if (_role != ERole.classFile)
        {
            if (_isClass || _role != ERole.miniProgram)
            {
                _meta.role = _role.ToString();
            }
            switch (_role)
            {
            case ERole.exeProgram:
            case ERole.classLibrary:
                if (_meta.outputPath.NE())
                {
                    _meta.outputPath = _role == ERole.exeProgram ? @"%AFolders.Workspace%\bin" : @"%AFolders.ThisApp%\Libraries";
                }
                break;
            }
            var name = APath.GetFileName(_f.Name, true);
            if (_meta.xmlDoc == "")
            {
                _meta.xmlDoc = name + ".xml";
            }
            if (_meta.manifest == "")
            {
                _meta.manifest = name + ".exe.manifest";
            }
        }

        return(true);
    }
Example #4
0
File: Run.cs Project: alexfordc/Au
    static void _SciLink_RunClassFile(string s)
    {
        int action = s.ToInt();         //1 add meta role miniProgram, 2 create Script project, 3 create new test script and set "run" attribute
        var f      = Program.Model.Find(s.Substring(2), null); if (f == null)
        {
            return;
        }
        FileNode f2 = null;

        if (action == 1)          //add meta role exeProgram
        {
            if (!Program.Model.SetCurrentFile(f))
            {
                return;
            }
            Program.Model.Properties();
        }
        else
        {
            if (action == 2)              //create project
            {
                if (!_NewItem(out f2, @"New Project\@Script"))
                {
                    return;
                }
                f.FileMove(f2, Aga.Controls.Tree.NodePosition.After);
            }
            else                 //create test script
            {
                s = "test " + APath.GetFileName(f.Name, true);
                if (!_NewItem(out f2, "Script.cs", s))
                {
                    return;
                }
                f.TestScript = f2;
            }

            //Creates new item above f or f's project folder.
            bool _NewItem(out FileNode ni, string template, string name = null)
            {
                bool isProject = f.FindProject(out var target, out _);

                if (!isProject)
                {
                    target = f;
                }

                var text = new EdNewFileText();

                if (action == 2)
                {
                    text.text = "Class1.Function1();\r\n";
                }
                else
                {
                    text.meta = $"/*/ {(isProject ? "pr" : "c")} {f.ItemPath} /*/ ";
                    text.text = $"{(isProject ? "Library." : "")}Class1.Function1();\r\n";
                }

                ni = Program.Model.NewItem(target, Aga.Controls.Tree.NodePosition.Before, template, name, text: text);
                return(ni != null);
            }
        }
    }