Esempio n. 1
0
        private void compileMenu_Click(object sender, EventArgs e)
        {
            //Tear down and setup the bin directory
            if (!IsProjectOpen)
            {
                if (editorTabs.SelectedTab.Text.TrimStart('*').Trim().StartsWith("new"))
                {
                    MessageBox.Show("Please save this file before trying to compile it");
                    return;
                }
                else
                {
                    Directory.SetCurrentDirectory(Path.GetDirectoryName(DocumentManager.GetFileName(editorTabs.SelectedTab.Text)));
                }
            }

            var path = Directory.GetCurrentDirectory() + "\\bin";

            try
            {
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }
                Directory.CreateDirectory(path);
            }
            catch (Exception)
            {
                MessageBox.Show("Compilation failed -- it's probable that the bin directory or something in it is locked");
                return;
            }

            AssemblyName[] a = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            foreach (AssemblyName an in a)
            {
                if (an.FullName.ToLower().Contains("shiro"))
                {
                    if (File.Exists(path + "\\Shiro.Lang.dll"))
                    {
                        File.Delete(path + "\\Shiro.Lang.dll");
                    }

                    var shiroPath = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
                    File.Copy(shiroPath + "\\Shiro.Lang.dll", path + "\\Shiro.Lang.dll");
                }
            }

            foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory()))
            {
                if (file.EndsWith(".dll"))
                {
                    File.Copy(file, file.Replace(Directory.GetCurrentDirectory(), path));
                }
            }

            //Now do the compile
            System.CodeDom.Compiler.CompilerError ce = null;
            if (!IsProjectOpen)
            {
                //Single file compile, nice and easy
                var c = new Compiler(editorTabs.SelectedTab.Text.TrimStart('*').Trim());
                c.AddShiroModule(editorTabs.SelectedTab.Text.TrimStart('*').Trim(), editor.Text);
                c.Compile(editorTabs.SelectedTab.Text.Split('.')[0] + ".exe", path, out ce);
            }
            else
            {
                //Project compile.  Slightly trickier
                var pt = ProjectTree;
            }

            if (ce == null)
            {
                SafeWrite("Compile success");
            }
            else
            {
                SafeWrite("Compile failed: " + ce.ErrorText);
            }
        }
Esempio n. 2
0
 private void newMenu_Click(object sender, EventArgs e)
 {
     editorTabs.TabPages.Add(new TabPage(DocumentManager.AddDocument("new")));
     _suppressTabChanged      = true;
     editorTabs.SelectedIndex = editorTabs.TabPages.Count - 1;
 }