protected override void OnActivated() { base.OnActivated(); 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); } nwd.Destroy(); }
protected override void OnActivated() { base.OnActivated(); string projectName = String.Empty; if (String.IsNullOrEmpty(MainClass.Workspace.FilePath)) { NewWorkspaceDialog nwd = new NewWorkspaceDialog(true); 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; //projectName = nwd.ProjectName; projectName = MainClass.Tools.RemoveDiacritics(nwd.ProjectName).Replace(" ","_"); string workspaceFile = System.IO.Path.Combine(workspaceRoot, workspaceName + ".msw"); MainClass.MainWindow.CreateWorkspace(workspaceFile,workspaceName,workspaceOutput,workspaceRoot,copyLibs); if (!String.IsNullOrEmpty(projectName)) CreateProject(projectName,nwd.Skin,nwd.Theme); } nwd.Destroy(); } else { NewProjectDialog npd = new NewProjectDialog(); int result = npd.Run(); if (result == (int)ResponseType.Ok){ if (!String.IsNullOrEmpty(npd.ProjectName) ){ //projectName = npd.ProjectName; projectName = MainClass.Tools.RemoveDiacritics(npd.ProjectName).Replace(" ","_"); CreateProject(projectName,npd.Skin,npd.Theme); } } npd.Destroy(); /*EntryDialog ed = new EntryDialog("",MainClass.Languages.Translate("new_project_name")); int result = ed.Run(); if (result == (int)ResponseType.Ok){ if (!String.IsNullOrEmpty(ed.TextEntry) ){ projectName = ed.TextEntry; CreateProject(projectName); } } ed.Destroy();*/ } //projectName /* NewProjectDialog nfd = new NewProjectDialog(); int result = nfd.Run(); if (result == (int)ResponseType.Ok) { string projectName = nfd.ProjectName; string projectDir = MainClass.Tools.RemoveDiacritics(nfd.ProjectName).Replace(" ","_"); //string projectLocat = MainClass.Tools.RemoveDiacritics(nfd.ProjectName).Replace(" ","_"); string projectLocat = MainClass.Workspace.RootDirectory; string projectFile = System.IO.Path.Combine(projectLocat, projectName + ".msp"); string appFile = System.IO.Path.Combine(projectLocat, projectName + ".app"); MainClass.Workspace.CreateProject(projectFile,projectName,projectLocat,projectDir,appFile); //MainClass.MainWindow.CreateProject(projectName); } nfd.Destroy();*/ }
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); }