Exemple #1
0
        public void SetAsStartup(string filename, string appFilePath)
        {
            if (String.IsNullOrEmpty(appFilePath))
            {
                return;
            }

            Project prj = FindProject_byApp(appFilePath, true);

            if (prj == null)
            {
                return;
            }

            if (!String.IsNullOrEmpty(filename))
            {
                if (!String.IsNullOrEmpty(prj.StartFile))
                {
                    // change old file
                    Gtk.TreeIter tiOld = MainClass.MainWindow.WorkspaceTree.GetStartUpIter(GetFullPath(prj.StartFile));
                    MainClass.MainWindow.WorkspaceTree.UpdateIter(tiOld, String.Empty, String.Empty, (int)TypeFile.SourceFile);
                }
                AppFile appFile = prj.AppFile;
                appFile.Main = System.IO.Path.GetFileName(filename);
                try{
                    appFile.Save();
                } catch (Exception ex) {
                    MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                    ms.ShowDialog();
                }

                //prj.AppFile.Main = System.IO.Path.GetFileName(filename);
                //prj.AppFile.Save();
            }
            prj.StartFile = GetRelativePath(filename);
            SaveProject(prj);
        }
Exemple #2
0
        private Project ImportProject(string appPath, string projectName,string newLibs, string newOrientation)
        {
            //TreeIter ti =  AddMessage("Create Project ","....",null);
            if(entrPage2PrjName.Text == prjDefaultName)
                MainClass.Settings.ProjectCount = MainClass.Settings.ProjectCount +1;

            string oldName = System.IO.Path.GetFileNameWithoutExtension(appPath);

            if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)) return null;

            string destinationDir = System.IO.Path.GetDirectoryName(appPath); // aka workspace from
            string projectDir = System.IO.Path.Combine(destinationDir,oldName); // aka project dir from

            string mspPath =  System.IO.Path.Combine(destinationDir,oldName+".msp");

            if (!File.Exists(appPath) || !File.Exists(mspPath)){
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"),MainClass.Languages.Translate("invalid_zip"),null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("invalid_zip"));
                return null;
            }
            if(!System.IO.Directory.Exists(projectDir)){
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"),MainClass.Languages.Translate("invalid_project"),null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("invalid_project"));
                return null;
            }

            string newApp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,projectName+".app");
            string newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,projectName+".msp");

            if(File.Exists(newApp) || File.Exists(newMsp)){
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"),MainClass.Languages.Translate("project_exist"),null);

                //UpdateMessage(ti,1,MainClass.Languages.Translate("project_exist"));
                return null;
            }

            FileInfo fi = new FileInfo(appPath);
            FileTemplate ft= new FileTemplate(fi,false);
            atrApplication.Value = projectName;
            ft.Attributes.Add(atrApplication);

            string contentApp = FileTemplateUtilities.Apply(ft.Content, ft.GetAttributesAsDictionary());

            string contentMsp="";
            if(System.IO.File.Exists(mspPath)){
                try {
                    using (StreamReader file = new StreamReader(mspPath)) {
                        string text = file.ReadToEnd();
                        contentMsp = text;
                    }
                } catch {
                }
            }
            contentMsp = Regex.Replace(contentMsp,oldName,System.IO.Path.GetFileNameWithoutExtension(newApp));

            Project prj = null;
            try {
                FileUtility.CreateFile(newApp,contentApp);
                AppFile app = null;
                if(!String.IsNullOrEmpty(newLibs)){
                    app = new AppFile(newApp);
                    app.Uses = newLibs;
                    app.Orientation = newOrientation;
                    app.Save();
                }

                FileUtility.CreateFile(newMsp,contentMsp);

                string newPrjDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,projectName);

                TreeIter ti = AddMessage(MainClass.Languages.Translate("wizzard_copying"),"....",null);

                MainClass.Tools.CopyDirectory(projectDir,newPrjDir,true,true);
                //string[] dirNew = System.IO.Directory.GetDirectories(newPrjDir,"*.*",SearchOption.AllDirectories);

                string[] filesNew = System.IO.Directory.GetFiles(newPrjDir,"*.ms",SearchOption.AllDirectories);
                foreach (string file in filesNew){

                    FileInfo fiNew = new FileInfo(file);
                    FileTemplate ftNew= new FileTemplate(fiNew,false);
                    atrApplication.Value = projectName;
                    ftNew.Attributes.Add(atrApplication);

                    string contentNew = FileTemplateUtilities.Apply(ftNew.Content, ftNew.GetAttributesAsDictionary());

                    try{
                        using (StreamWriter fileSW = new StreamWriter(file)) {
                            fileSW.Write(contentNew);
                            fileSW.Close();
                            fileSW.Dispose();
                        }

                    }catch(Exception ex){
                        Tool.Logger.Error(ex.Message);
                        continue;
                    }
                }
                UpdateMessage(ti,1,"OK");

                prj = MainClass.Workspace.OpenProject(newMsp,false,true); //Project.OpenProject(newMsp,false,true);

                LoggingInfo log = new LoggingInfo();
                log.LoggWebThread(LoggingInfo.ActionId.IDENewProject,prj.ProjectName);

            } catch {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"),MainClass.Languages.Translate("error_creating_project"),null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("error_creating_project"));
                return null;
            }
            AddMessage(MainClass.Languages.Translate("wizzard_create_project"),"OK",null);
            //UpdateMessage(ti,1,"OK");
            return prj;
        }
Exemple #3
0
        public Project CreateProject(string filename, string projectName, string projectLocation, string projectDir, string aplicationFile,string skin, string theme)
        {
            Project p = FindProject(filename);
            if (p == null) {
                p = new Project();
                if (!System.IO.File.Exists(filename)) {
                    string projectWorkingDir = System.IO.Path.Combine(projectLocation, projectDir);

                    if (!System.IO.File.Exists(aplicationFile)) {
                        AppFile appFile = new AppFile(aplicationFile, projectName);//, projectDir);
                        appFile.Uses = "core ui uix uix-skin media sqlite net game2d crypto box2d graphics sensor";
                        appFile.Main = "main.ms";
                        appFile.Author = "Generated by Moscrif-Ide";
                        appFile.Title = projectName;
                        appFile.Copyright = " ";
                        appFile.Version = "1.0";
                        appFile.Orientation = "portrait";
                        try{
                            appFile.Save();
                        } catch(Exception ex){
                            throw new Exception(MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile)+"\n"+ ex.Message);
                            /*MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                            ms.ShowDialog();
                            return null;*/
                        }
                    }

                    string mainFile = System.IO.Path.Combine(projectWorkingDir,"main.ms");
                    try {
                        Directory.CreateDirectory(projectWorkingDir);

                        using (StreamWriter file = new StreamWriter(mainFile)) {
                            file.Write("// TODO: Add your code here.");
                            file.Close();
                            file.Dispose();
                        }
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "core"));
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "ui"));
                    } catch {
                    }

                    p = new Project(filename);
                    //p.ProjectDir = GetRelativePath(projectWorkingDir);
                    //p.ProjectName = projectName;
                    p.AppFilePath = GetRelativePath(aplicationFile);
                    p.StartFile = GetRelativePath(mainFile);

                    p.NewSkin=true;
                    p.GenerateDevices(skin,theme);

                    SaveProject(p);
                    Projects.Add(p);
                    ProjectsFile.Add(GetRelativePath(filename));

                    LoggingInfo log = new LoggingInfo();
                    log.LoggWebThread(LoggingInfo.ActionId.IDENewProject,p.ProjectName);

                    return p;
                } else {
                    throw new Exception(MainClass.Languages.Translate("project_is_exist",filename));
                    /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist",filename), "", Gtk.MessageType.Error);
                    md.ShowDialog();
                    return null;*/
                }
            } else {
                throw new Exception(MainClass.Languages.Translate("project_is_opened",p.ProjectName));
                /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened",p.ProjectName), null, Gtk.MessageType.Error);
                md.ShowDialog();
                return null;*/
            }
        }
Exemple #4
0
        public Project CreateProject(Project prj, AppFile appFile,string skin, string theme,string[] fonts)
        {
            string projectLocation = this.RootDirectory;
            string projectDir = System.IO.Path.GetFileNameWithoutExtension(prj.FilePath);

            Project p = FindProject(prj.FilePath);
            if (p == null) {
                p = new Project();
                if (!System.IO.File.Exists(prj.FilePath)) {
                    string projectWorkingDir = System.IO.Path.Combine(projectLocation, projectDir);

                    if (!System.IO.File.Exists(appFile.ApplicationFile)) {

                        try{
                            appFile.Save();
                        } catch(Exception ex){
                            MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                            ms.ShowDialog();
                            return null;

                        }
                    }

                    string mainFile = System.IO.Path.Combine(projectWorkingDir,"main.ms");
                    try {
                        Directory.CreateDirectory(projectWorkingDir);

                        using (StreamWriter file = new StreamWriter(mainFile)) {
                            file.Write("// TODO: Add your code here.");
                            file.Close();
                            file.Dispose();
                        }
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "core"));
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "ui"));
                    } catch {
                    }

                    //p = new Project(prj.FilePath);
                    prj.NewSkin=true;
                    //p = new Project(filename);
                    //p.ProjectDir = GetRelativePath(projectWorkingDir);
                    //p.ProjectName = projectName;
                    prj.AppFilePath = GetRelativePath(appFile.ApplicationFile);
                    prj.StartFile = GetRelativePath(mainFile);

                    prj.GenerateDevices(skin,theme,fonts);

                    SaveProject(prj);
                    Projects.Add(prj);
                    ProjectsFile.Add(GetRelativePath(prj.FilePath));
                    return prj;
                } else {
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist",prj.FilePath), "", Gtk.MessageType.Error);
                    md.ShowDialog();
                    return null;
                }
            } else {
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened",p.ProjectName), null, Gtk.MessageType.Error);
                md.ShowDialog();
                return null;
            }
        }
Exemple #5
0
        public Project CreateProject(string filename, string projectName, string projectLocation, string projectDir, string aplicationFile, string skin, string theme)
        {
            Project p = FindProject(filename);

            if (p == null)
            {
                p = new Project();
                if (!System.IO.File.Exists(filename))
                {
                    string projectWorkingDir = System.IO.Path.Combine(projectLocation, projectDir);

                    if (!System.IO.File.Exists(aplicationFile))
                    {
                        AppFile appFile = new AppFile(aplicationFile, projectName);                        //, projectDir);
                        appFile.Uses        = "core ui uix uix-skin media sqlite net game2d crypto box2d graphics sensor";
                        appFile.Main        = "main.ms";
                        appFile.Author      = "Generated by Moscrif-Ide";
                        appFile.Title       = projectName;
                        appFile.Copyright   = " ";
                        appFile.Version     = "1.0";
                        appFile.Orientation = "portrait";
                        try{
                            appFile.Save();
                        } catch (Exception ex) {
                            throw new Exception(MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile) + "\n" + ex.Message);

                            /*MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                             * ms.ShowDialog();
                             * return null;*/
                        }
                    }

                    string mainFile = System.IO.Path.Combine(projectWorkingDir, "main.ms");
                    try {
                        Directory.CreateDirectory(projectWorkingDir);

                        using (StreamWriter file = new StreamWriter(mainFile)) {
                            file.Write("// TODO: Add your code here.");
                            file.Close();
                            file.Dispose();
                        }
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "core"));
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "ui"));
                    } catch {
                    }

                    p = new Project(filename);
                    //p.ProjectDir = GetRelativePath(projectWorkingDir);
                    //p.ProjectName = projectName;
                    p.AppFilePath = GetRelativePath(aplicationFile);
                    p.StartFile   = GetRelativePath(mainFile);

                    p.NewSkin = true;
                    p.GenerateDevices(skin, theme);

                    SaveProject(p);
                    Projects.Add(p);
                    ProjectsFile.Add(GetRelativePath(filename));

                    LoggingInfo log = new LoggingInfo();
                    log.LoggWebThread(LoggingInfo.ActionId.IDENewProject, p.ProjectName);

                    return(p);
                }
                else
                {
                    throw new Exception(MainClass.Languages.Translate("project_is_exist", filename));

                    /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist",filename), "", Gtk.MessageType.Error);
                     * md.ShowDialog();
                     * return null;*/
                }
            }
            else
            {
                throw new Exception(MainClass.Languages.Translate("project_is_opened", p.ProjectName));

                /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened",p.ProjectName), null, Gtk.MessageType.Error);
                 * md.ShowDialog();
                 * return null;*/
            }
        }
Exemple #6
0
        public Project CreateProject(Project prj, AppFile appFile, string skin, string theme, string[] fonts)
        {
            string projectLocation = this.RootDirectory;
            string projectDir      = System.IO.Path.GetFileNameWithoutExtension(prj.FilePath);

            Project p = FindProject(prj.FilePath);

            if (p == null)
            {
                p = new Project();
                if (!System.IO.File.Exists(prj.FilePath))
                {
                    string projectWorkingDir = System.IO.Path.Combine(projectLocation, projectDir);

                    if (!System.IO.File.Exists(appFile.ApplicationFile))
                    {
                        try{
                            appFile.Save();
                        } catch (Exception ex) {
                            MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                            ms.ShowDialog();
                            return(null);
                        }
                    }

                    string mainFile = System.IO.Path.Combine(projectWorkingDir, "main.ms");
                    try {
                        Directory.CreateDirectory(projectWorkingDir);

                        using (StreamWriter file = new StreamWriter(mainFile)) {
                            file.Write("// TODO: Add your code here.");
                            file.Close();
                            file.Dispose();
                        }
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "core"));
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "ui"));
                    } catch {
                    }

                    //p = new Project(prj.FilePath);
                    prj.NewSkin = true;
                    //p = new Project(filename);
                    //p.ProjectDir = GetRelativePath(projectWorkingDir);
                    //p.ProjectName = projectName;
                    prj.AppFilePath = GetRelativePath(appFile.ApplicationFile);
                    prj.StartFile   = GetRelativePath(mainFile);

                    prj.GenerateDevices(skin, theme, fonts);

                    SaveProject(prj);
                    Projects.Add(prj);
                    ProjectsFile.Add(GetRelativePath(prj.FilePath));
                    return(prj);
                }
                else
                {
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist", prj.FilePath), "", Gtk.MessageType.Error);
                    md.ShowDialog();
                    return(null);
                }
            }
            else
            {
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened", p.ProjectName), null, Gtk.MessageType.Error);
                md.ShowDialog();
                return(null);
            }
        }