コード例 #1
0
ファイル: ApplicationFileControl.cs プロジェクト: moscrif/ide
        public ApplicationFileControl(AppFile appFile,Mode mode,Gtk.Window parent )
        {
            parentWindow = parent;
            this.Build();
            this.mode = mode;
            this.appFile = appFile;

            CellRendererText textRenderer = new CellRendererText();
            cbOrientation.PackStart(textRenderer, true);
            //cbOrientation.AddAttribute(textRenderer, "text", 0);

            //cbOrientation.AppendValues("Landscape Left");
            //cbOrientation.AppendValues("Landscape Right");

            cbOrientation.Model = orientationModel;

            FillControl();
        }
コード例 #2
0
ファイル: Workspace.cs プロジェクト: anthrax3/ide-1
        public Project ConvertAppToProject(AppFile aplicationFile)
        {
            string mspDir   = System.IO.Path.GetDirectoryName(aplicationFile.ApplicationFile);
            string filename = System.IO.Path.Combine(mspDir, aplicationFile.Name + ".msp");

            Project p = FindProject(filename);

            if (p == null)
            {
                p = new Project();
                if (!System.IO.File.Exists(filename))
                {
                    p = new Project(filename);

                    //p.ProjectDir = GetRelativePath(projectDir);
                    //p.ProjectName = aplicationFile.Name;
                    p.AppFilePath = GetRelativePath(aplicationFile.ApplicationFile);
                    p.NewSkin     = true;
                    p.GenerateDevices("", "");
                    SaveProject(p);
                    Projects.Add(p);
                    ProjectsFile.Add(GetRelativePath(p.FilePath));
                    return(p);
                }
                else
                {
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist", filename), "", 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);
            }
        }
コード例 #3
0
ファイル: Workspace.cs プロジェクト: anthrax3/ide-1
        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);
        }
コード例 #4
0
ファイル: NewProjectWizzard_New.cs プロジェクト: moscrif/ide
        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;
        }
コード例 #5
0
ファイル: NewProjectWizzard_New.cs プロジェクト: moscrif/ide
        private void GenerateCustomTemplate(List<string> customTemplate)
        {
            int x = 0;
            RadioButton rbGroup = new RadioButton("test");

            foreach(string appPath in customTemplate){
                string dir = System.IO.Path.GetDirectoryName(appPath);
                DirectoryInfo di = new DirectoryInfo(dir);

                string name = System.IO.Path.GetFileNameWithoutExtension(di.FullName);

                AppFile app = new AppFile(appPath);
                RadioButton rb = new RadioButton(name);
                rb.Group = rbGroup.Group;
                rb.Name = name;

                if(String.IsNullOrEmpty(app.Description)){
                    rb.Label = app.Title;
                }else {
                    rb.Label = app.Description;
                }

                rb.TooltipMarkup = appPath;
                rb.Events = Gdk.EventMask.AllEventsMask;

                rb.Clicked+= delegate(object sndr, EventArgs evt) {
                    if(File.Exists(appPath)){
                        //AppFile app = new AppFile(appPath);
                        List<string> libs = new List<string>(app.Libs);
                        Widget[] widgets = tblLibraries.Children;

                        foreach (Widget w in widgets ){
                            int indx = libs.FindIndex(y=>y==w.Name);
                            if(indx>-1) {
                                (w as CheckButton).Active = true;
                            } else {
                                (w as CheckButton).Active = false;
                            }
                        }
                    }
                };
                rb.Active = true;
                tblScreens.Attach(rb,0,1,(uint)x,(uint)(x+1),AttachOptions.Fill,AttachOptions.Fill,0,0);
                x++;
            }
            tblScreens.ShowAll();
        }
コード例 #6
0
ファイル: NewProjectWizzard_New.cs プロジェクト: moscrif/ide
        public NewProjectWizzard_New(Window parent)
        {
            if (parent != null)
                this.TransientFor =parent;
            else
                this.TransientFor = MainClass.MainWindow;

            this.Build();

            atrApplication = new FileTemplate.Attribute();
            atrApplication.Name = "application";
            atrApplication.Type = "text";

            this.DefaultHeight = 390 ;
            this.Title = MainClass.Languages.Translate("moscrif_ide_title_f1");
            ntbWizzard.ShowTabs = false;

            Pango.FontDescription customFont = lblNewProject.Style.FontDescription.Copy();//  Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont);
            customFont.Size = customFont.Size+(int)(customFont.Size/2);
            customFont.Weight = Pango.Weight.Bold;
            lblNewProject.ModifyFont(customFont);

            storeTyp = new ListStore (typeof (string), typeof (string), typeof (Gdk.Pixbuf), typeof (string),typeof(ProjectTemplate),typeof (bool));
            storeOrientation = new ListStore (typeof (string), typeof (string), typeof (Gdk.Pixbuf), typeof (string));

            storeOutput = new ListStore (typeof (string), typeof (string), typeof (Gdk.Pixbuf));

            nvOutput.Model = storeOutput;
            nvOutput.AppendColumn ("", new Gtk.CellRendererText (), "text", 0);
            nvOutput.AppendColumn ("", new Gtk.CellRendererText (), "text", 1);
            nvOutput.AppendColumn ("", new Gtk.CellRendererPixbuf (), "pixbuf", 2);
            nvOutput.Columns[1].Expand = true;

            ivSelectTyp.Model = storeTyp;
            ivSelectTyp.SelectionMode = SelectionMode.Single;
            ivSelectTyp.Orientation = Orientation.Horizontal;

            CellRendererText rendererSelectTyp = new CellRendererText();
            rendererSelectTyp.Ypad =0;
            ivSelectTyp.PackEnd(rendererSelectTyp,false);
            ivSelectTyp.SetCellDataFunc(rendererSelectTyp, new Gtk.CellLayoutDataFunc(RenderTypProject));
            ivSelectTyp.PixbufColumn = COL_PIXBUF;
            ivSelectTyp.TooltipColumn = COL_DISPLAY_TEXT;
            ivSelectTyp.AddAttribute(rendererSelectTyp, "sensitive", 5);

            Gdk.Pixbuf icon0 = MainClass.Tools.GetIconFromStock("project.png",IconSize.LargeToolbar);
            storeTyp.AppendValues ("New Empty Project", "Create empty application", icon0, "", null,true);

            DirectoryInfo[] diTemplates = GetDirectory(MainClass.Paths.FileTemplateDir);
            foreach (DirectoryInfo di in diTemplates) {

                string name = di.Name;

                string iconFile = System.IO.Path.Combine(di.FullName,"icon.png");
                string descFile = System.IO.Path.Combine(di.FullName,"description.xml");
                if(!File.Exists(iconFile) || !File.Exists(descFile))
                    continue;

                string descr = name;
                ProjectTemplate pt = null;

                if(File.Exists(descFile)){
                    pt = ProjectTemplate.OpenProjectTemplate(descFile);
                    if((pt!= null))
                        descr = pt.Description;
                }
                Gdk.Pixbuf icon = new Gdk.Pixbuf(iconFile);
                DirectoryInfo[] templates = di.GetDirectories();
                bool sensitive = true;

                if(templates.Length<1)
                    sensitive = false;
                else
                    sensitive = true;

                storeTyp.AppendValues (name, descr, icon, di.FullName,pt,sensitive);
            }

            ivSelectTyp.SelectionChanged+= delegate(object sender, EventArgs e)
            {
                Gtk.TreePath[] selRow = ivSelectTyp.SelectedItems;
                if(selRow.Length<1){
                    lblHint.Text = " ";
                    btnNext.Sensitive = false;
                    return;
                }

                Gtk.TreePath tp = selRow[0];
                TreeIter ti = new TreeIter();
                storeTyp.GetIter(out ti,tp);

                if(tp.Equals(TreeIter.Zero))return;

                //string typ = storeTyp.GetValue (ti, 3).ToString();
                string text1 = (string) storeTyp.GetValue (ti, 0);
                string text2 = (string) storeTyp.GetValue (ti, 1);
                bool sensitive = Convert.ToBoolean(storeTyp.GetValue (ti, 5));
                if(!sensitive){
                    ivSelectTyp.SelectPath(selectedTypPrj);
                    return;
                }
                selectedTypPrj = selRow[0];

                lblHint.Text = text1+" - "+text2;
                btnNext.Sensitive = true;
            };
            CellRendererText rendererOrientation = new CellRendererText();

            selectedTypPrj = new TreePath("0");
            ivSelectTyp.SelectPath(selectedTypPrj);

            ivSelectOrientation.Model = storeOrientation;
            ivSelectOrientation.SelectionMode = SelectionMode.Single;
            ivSelectOrientation.Orientation = Orientation.Horizontal;

            ivSelectOrientation.PackEnd(rendererOrientation,false);
            ivSelectOrientation.SetCellDataFunc(rendererOrientation, new Gtk.CellLayoutDataFunc(RenderOrientationProject));
            ivSelectOrientation.PixbufColumn = COL_PIXBUF;
            ivSelectOrientation.TooltipColumn = COL_DISPLAY_TEXT;

            foreach(SettingValue ds in MainClass.Settings.DisplayOrientations){
                storeOrientation.AppendValues (ds.Display,ds.Display,null,ds.Value);
            }
            ivSelectOrientation.SelectPath(new TreePath("0"));
            storeWorkspace = new ListStore(typeof(string), typeof(string), typeof(int));
            cbeWorkspace = new ComboBoxEntry();
            cbeWorkspace.Model = storeWorkspace;
            cbeWorkspace.TextColumn = 0;
            cbeWorkspace.Changed+= OnCbeWorkspaceChanged;

            this.feLocation = new FileEntry();
            this.table3.Attach (this.feLocation,1,2,2,3);
            Gtk.Table.TableChild w9 = ((Gtk.Table.TableChild)(this.table3 [this.feLocation]));
            w9.XOptions = ((Gtk.AttachOptions)(4));
            w9.YOptions = ((Gtk.AttachOptions)(4));

            table3.Attach(cbeWorkspace,1,2,1,2,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill,0,0);

            CellRendererText rendererWorkspace = new CellRendererText();
            cbeWorkspace.PackStart(rendererWorkspace, true);
            cbeWorkspace.SetCellDataFunc(rendererWorkspace, new Gtk.CellLayoutDataFunc(RenderWorkspacePath));
            cbeWorkspace.WidthRequest = 125;

            cbeWorkspace.SetCellDataFunc(cbeWorkspace.Cells[0], new Gtk.CellLayoutDataFunc(RenderWorkspaceName));

            string currentWorkspace ="";
            if((MainClass.Workspace!= null) && !string.IsNullOrEmpty(MainClass.Workspace.FilePath))
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(MainClass.Workspace.FilePath);
                storeWorkspace.AppendValues (name,MainClass.Workspace.FilePath,1);
                currentWorkspace = MainClass.Workspace.FilePath;
            }
            IList<RecentFile> lRecentProjects = MainClass.Settings.RecentFiles.GetWorkspace();

            foreach(RecentFile rf in lRecentProjects){

                if(rf.FileName == currentWorkspace) continue;
                if(File.Exists(rf.FileName)){
                    string name = System.IO.Path.GetFileNameWithoutExtension(rf.FileName);
                    storeWorkspace.AppendValues(name,rf.FileName,0);
                }
            }
                //storeWorkspace.AppendValues("","-------------",-1);

            worksDefaultName = "Workspace"+MainClass.Settings.WorkspaceCount.ToString();
            TreeIter tiNewW = storeWorkspace.AppendValues(worksDefaultName,MainClass.Paths.WorkDir,2);

            if(!String.IsNullOrEmpty(currentWorkspace)){
                cbeWorkspace.Active =0;
            }
            else {
                feLocation.DefaultPath = MainClass.Paths.WorkDir;
                cbeWorkspace.SetActiveIter(tiNewW);
                //storeWorkspace.AppendValues(worksDefaultName,MainClass.Paths.WorkDir,2);

            }
            prjDefaultName = "Project"+MainClass.Settings.ProjectCount.ToString();
            entrProjectName.Text = prjDefaultName;
            cbeWorkspace.ShowAll();
            feLocation.ShowAll();

            CellRendererText rendererTemplate = new CellRendererText();
            cbTemplate.PackStart(rendererTemplate, true);

            storeTemplate = new ListStore(typeof(string), typeof(string), typeof(string));
            cbTemplate.Model = storeTemplate;

            cbTemplate.Changed+= delegate(object sender, EventArgs e) {

                if(cbTemplate.Active <0) return;

                if(cbTemplate.ActiveText != KEY_CUSTOM){

                    tblLibraries.Sensitive = false;
                    tblScreens.Sensitive = false;
                    ivSelectOrientation.Sensitive = false;
                } else {
                    ivSelectOrientation.Sensitive = true;
                    tblLibraries.Sensitive = true;
                    tblScreens.Sensitive = true;
                }

                TreeIter tiChb = new TreeIter();
                cbTemplate.GetActiveIter(out tiChb);

                if(tiChb.Equals(TreeIter.Zero))return;

                string appPath = storeTemplate.GetValue(tiChb, 2).ToString();
                if(File.Exists(appPath)){
                    AppFile app = new AppFile(appPath);
                    List<string> libs = new List<string>(app.Libs);

                    Widget[] widgets = tblLibraries.Children;
                    foreach (Widget w in widgets ){
                        int indx = libs.FindIndex(x=>x==w.Name);
                        if(indx>-1) {
                            (w as CheckButton).Active = true;
                        } else {
                            (w as CheckButton).Active = false;
                        }
                    }
                }
            };
            btnBack.Sensitive = false;
        }
コード例 #7
0
ファイル: Workspace.cs プロジェクト: moscrif/ide
        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;*/
            }
        }
コード例 #8
0
ファイル: Workspace.cs プロジェクト: moscrif/ide
        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;
            }
        }
コード例 #9
0
ファイル: Workspace.cs プロジェクト: moscrif/ide
        public Project ConvertAppToProject(AppFile aplicationFile)
        {
            string mspDir = System.IO.Path.GetDirectoryName(aplicationFile.ApplicationFile);
            string filename = System.IO.Path.Combine(mspDir, aplicationFile.Name + ".msp");

            Project p = FindProject(filename);
            if (p == null) {
                p = new Project();
                if (!System.IO.File.Exists(filename)) {
                    p = new Project(filename);

                    //p.ProjectDir = GetRelativePath(projectDir);
                    //p.ProjectName = aplicationFile.Name;
                    p.AppFilePath = GetRelativePath(aplicationFile.ApplicationFile);
                    p.NewSkin=true;
                    p.GenerateDevices("","");
                    SaveProject(p);
                    Projects.Add(p);
                    ProjectsFile.Add(GetRelativePath(p.FilePath));
                    return p;
                } else {
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist",filename), "", 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;
            }
        }
コード例 #10
0
ファイル: Workspace.cs プロジェクト: anthrax3/ide-1
        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;*/
            }
        }
コード例 #11
0
ファイル: Workspace.cs プロジェクト: anthrax3/ide-1
        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);
            }
        }
コード例 #12
0
ファイル: MainWindow.cs プロジェクト: moscrif/ide
    public void ImportProject(string destinationFile, bool isZipFile)
    {
        if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){

            NewWorkspaceDialog nwd = new NewWorkspaceDialog(false);
            int result = nwd.Run();

            if (result == (int)ResponseType.Ok) {
                string workspaceName = nwd.WorkspaceName;
                string workspaceOutput = nwd.WorkspaceOutput;
                string workspaceRoot =nwd.WorkspaceRoot;
                bool copyLibs = nwd.CopyLibs;

                string workspaceFile = System.IO.Path.Combine(workspaceRoot, workspaceName + ".msw");
                MainClass.MainWindow.CreateWorkspace(workspaceFile,workspaceName,workspaceOutput,workspaceRoot,copyLibs);

            } else {
                nwd.Destroy();
                return ;
            }
            nwd.Destroy();
        }

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

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

        if(isZipFile){
            string tempDir =  System.IO.Path.Combine(MainClass.Paths.TempDir,fileName);
            MainClass.Tools.UnzipFile(destinationFile,tempDir);
            destinationDir =tempDir;

            string[] fis1 = System.IO.Directory.GetFiles(destinationDir,"*.app",SearchOption.TopDirectoryOnly);
            if ((fis1 == null) || (fis1.Length<1)){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_zip"), "", Gtk.MessageType.Error);
                md.ShowDialog();
                return ;
            }
            fileName = System.IO.Path.GetFileNameWithoutExtension(fis1[0]);
            projectDir = System.IO.Path.Combine(destinationDir,fileName);
        }

        string[] fis = System.IO.Directory.GetFiles(destinationDir,fileName+".app",SearchOption.TopDirectoryOnly);
        string[] fisMsp = System.IO.Directory.GetFiles(destinationDir,fileName+".msp",SearchOption.TopDirectoryOnly);

        if ((fis == null) || (fis.Length<1)){
            MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_zip"), "", Gtk.MessageType.Error);
            md.ShowDialog();
            return;
        }

        if(!System.IO.Directory.Exists(projectDir)){
            MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_project"), "", Gtk.MessageType.Error);
            md.ShowDialog();
            return ;
        }

        string fileExistApp = System.IO.Path.GetFileNameWithoutExtension(fis[0]);

        string[] fiExist = Directory.GetFiles(MainClass.Workspace.RootDirectory,"*.app",SearchOption.TopDirectoryOnly);

        if((fiExist != null) || (fiExist.Length>0)){
            List<string> existApp = new List<string>(fiExist);

            int findIndex = existApp.FindIndex(x=> System.IO.Path.GetFileNameWithoutExtension(x) == fileExistApp);
            if(findIndex>-1){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok,  MainClass.Languages.Translate("project_exist"), "", Gtk.MessageType.Error);
                md.ShowDialog();
                return ;
            }
        }

        string newApp = System.IO.Path.GetFileName(fis[0]);
        newApp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newApp);

        if(isZipFile){
            // zkopirujem vsetko co bolo v zipe
            MainClass.Tools.CopyDirectory(destinationDir,MainClass.Workspace.RootDirectory,false,true);
        } else {
            // zkopirujem len veci k projektu app,msp a dir
            System.IO.File.Copy(fis[0],newApp);

            if( (fis != null) && (fisMsp.Length >0) && ( !string.IsNullOrEmpty(fisMsp[0]) )){
                string newMsp = System.IO.Path.GetFileName(fisMsp[0]);
                newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newMsp);
                System.IO.File.Copy(fisMsp[0],newMsp);
            }
            string newPrjDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,fileName);

            MainClass.Tools.CopyDirectory(projectDir,newPrjDir,true,true);

        }

        if (!System.IO.File.Exists(newApp) ){
            MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("import_failed"), "", Gtk.MessageType.Error);
            md.ShowDialog();
            //fc.Destroy();
            return;
        }

        AppFile appFile= new AppFile(newApp);

        if( (fisMsp.Length <1) || ( string.IsNullOrEmpty(fisMsp[0]) )){
            ConvertAppToProject(appFile);

        } else {
            string newMsp = System.IO.Path.GetFileName(fisMsp[0]);
            newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newMsp);
            OpenProject(newMsp,true);
        }
        LoggingInfo log = new LoggingInfo();
        log.LoggWebThread(LoggingInfo.ActionId.IDEImportProject,appFile.Name);

        SetActualProject(newApp);
        WorkspaceTree.SetSelectedFile(newApp);
    }
コード例 #13
0
ファイル: MainWindow.cs プロジェクト: moscrif/ide
 public void ConvertAppToProject(AppFile aplicationFile)
 {
     Project p = MainClass.Workspace.ConvertAppToProject(aplicationFile);
     AddAndShowProject(p,true,true);
 }
コード例 #14
0
ファイル: OpenProjectDialog.cs プロジェクト: moscrif/ide
        private void OpenProject()
        {
            TreeSelection ts = tvFiles.Selection;

            TreeIter ti = new TreeIter();
            ts.GetSelected(out ti);

            TreePath[] tp = ts.GetSelectedRows();
            if (tp.Length < 1)
                return ;

            //string fileState = tvFiles.Model.GetValue(ti, 2).ToString();
            string filePath = tvFiles.Model.GetValue(ti, 3).ToString();
            string prjName = tvFiles.Model.GetValue(ti, 1).ToString();
            int fileStat = (int)tvFiles.Model.GetValue(ti, 4);

            if (fileStat == (int)StatEnum.Open ){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened", prjName), null, Gtk.MessageType.Error);
                md.ShowDialog();
                return ;
            } else if (fileStat == (int)StatEnum.Close ){
                MainClass.MainWindow.OpenProject(filePath,true);
                this.Respond(ResponseType.Ok);

            } else if (fileStat == (int)StatEnum.Not_Create ){

                AppFile appFile= new AppFile(filePath);

                string projectDir = appFile.Directory;
                if (!Directory.Exists(projectDir) )
                {
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("application_foldes_not_exist"), projectDir, Gtk.MessageType.Error);
                    md.ShowDialog();
                    return ;
                }

                MainClass.MainWindow.ConvertAppToProject(appFile);

                this.Respond(ResponseType.Ok);
            }

            this.Respond(ResponseType.Ok);
        }