Ejemplo n.º 1
0
        public ApplicationWidget(Project project,Gtk.Window parent)
        {
            parentWindow =parent;
            this.Build();
            this.project = project;

            cbType = new ComboBox();

            ListStore projectModel = new ListStore(typeof(string), typeof(string));
            CellRendererText textRenderer = new CellRendererText();
            cbType.PackStart(textRenderer, true);
            cbType.AddAttribute(textRenderer, "text", 0);

            cbType.Model= projectModel;

            TreeIter ti = new TreeIter();
            foreach(SettingValue ds in MainClass.Settings.ApplicationType){// MainClass.Settings.InstallLocations){
                if(ds.Value == this.project.ApplicationType){
                    ti = projectModel.AppendValues(ds.Display,ds.Value);
                    cbType.SetActiveIter(ti);
                } else  projectModel.AppendValues(ds.Display,ds.Value);
            }
            if(cbType.Active <0)
                cbType.Active =0;

            tblGlobal.Attach(cbType, 1, 2, 0,1, AttachOptions.Fill|AttachOptions.Expand, AttachOptions.Fill|AttachOptions.Expand, 0, 0);

            afc = new ApplicationFileControl(project.AppFile,ApplicationFileControl.Mode.EditNoSaveButton,parentWindow);
            vbox2.PackEnd(afc, true, true, 0);
        }
Ejemplo n.º 2
0
        public FileConditionsWidget(FilePropertisData fcd)
        {
            this.Build();
            project = fcd.Project;
            filepath = fcd.Filename;

            fi_old = project.FilesProperty.Find(x => x.SystemFilePath == filepath);

            conditionRules = new List<ConditionRule>();
            conditionRules_Old = new List<ConditionRule>();

            if (fi_old != null)
            if (fi_old.ConditionValues != null)
                conditionRules_Old = fi_old.ConditionValues;

            int rowCount = project.ConditoinsDefine.Count;
            //Table tableSystem = new Table((uint)(2),(uint)2,false);
            Table table = new Table((uint)(rowCount + 3),(uint)2,false);

            GenerateContent(ref table, MainClass.Settings.Platform.Name, 1, MainClass.Settings.Platform,false);//tableSystem
            GenerateContent(ref table, MainClass.Settings.Resolution.Name, 2,MainClass.Settings.Resolution,true); //project.Resolution);//tableSystem
            int i = 3;//1;

            foreach (Condition cd in project.ConditoinsDefine) {

                GenerateContent(ref table, cd.Name, i, cd,false);

                i++;
            }
            vbox2.PackEnd(table, true, true, 0);
            this.ShowAll();
        }
Ejemplo n.º 3
0
        public CreateThemeDialog(Project project )
        {
            this.Build();
            cbSkin.Model = skinListStore;
            skinDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, "skin");
            themeDir = System.IO.Path.Combine(project.AbsolutProjectDir, MainClass.Settings.ThemeDir);

            FillSkinCombo(skinDir);
        }
Ejemplo n.º 4
0
        public DirPropertyWidget(FilePropertisData fpd)
        {
            project = fpd.Project;
            fiOld = project.FilesProperty.Find(x => x.SystemFilePath == fpd.Filename);
            if (fiOld == null){
                fiOld =new FileItem(fpd.Filename,false);
                fiOld.IsDirectory = true;
                project.FilesProperty.Add(fiOld);
            }
            if (fiOld.ConditionValues == null)
                fiOld.ConditionValues = new System.Collections.Generic.List<ConditionRule>();

            Table mainTable = new Table(2,1,false);
            Table propertyTable = new Table(5,2,false);

            Label lblFN =GetLabel(System.IO.Path.GetFileName(fiOld.SystemFilePath)); // new Label(System.IO.Path.GetFileName(fiOld.SystemFilePath));

            Entry entr = new Entry(fiOld.SystemFilePath);
            entr.IsEditable = false;

            Entry entrFullPath = new Entry(MainClass.Workspace.GetFullPath(fiOld.SystemFilePath));
            entrFullPath.IsEditable = false;

            Label lblPrj = GetLabel(project.ProjectName); //new Label(project.ProjectName);

            AddControl(ref propertyTable,0,lblFN,"Name ");
            AddControl(ref propertyTable,1,entr,"Relative Path ");
            AddControl(ref propertyTable,2,entrFullPath,"Full Path ");
            AddControl(ref propertyTable,3,lblPrj,"Project ");

            int rowCount = project.ConditoinsDefine.Count;
            Table conditionsTable = new Table((uint)(rowCount + 3),(uint)2,false);

            GenerateContent(ref conditionsTable, MainClass.Settings.Platform.Name, 1, MainClass.Settings.Platform,false);//tableSystem
            GenerateContent(ref conditionsTable, MainClass.Settings.Resolution.Name, 2,MainClass.Settings.Resolution,true); //project.Resolution);//tableSystem
            int i = 3;
            foreach (Condition cd in project.ConditoinsDefine) {
                GenerateContent(ref conditionsTable, cd.Name, i, cd,false);
                i++;
            }
            Expander exp1 = new Expander("General");
            exp1.Expanded = true;
            exp1.Add(propertyTable);

            Expander exp2 = new Expander("Conditions");
            exp2.Expanded = true;
            exp2.Add(conditionsTable);

            mainTable.Attach(exp1,0,1,0,1,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0);
            mainTable.Attach(exp2,0,1,1,2,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0);

            this.PackStart(mainTable,true,true,0);
            this.ShowAll();
        }
Ejemplo n.º 5
0
        public DirGeneralWidget(FilePropertisData fpd)
        {
            this.Build();

            this.fpd = fpd;
            project = this.fpd.Project;
            filepath = this.fpd.Filename;

            fi_old = project.FilesProperty.Find(x => x.SystemFilePath == filepath);
            if (fi_old == null){
                fi_old =new FileItem(filepath,false);
                project.FilesProperty.Add(fi_old);
            }

            lblName.LabelProp = System.IO.Path.GetFileName(filepath);
            lblRelativePath.LabelProp = filepath;
            lblProject.LabelProp =project.ProjectName;
            lblFullPath.LabelProp = MainClass.Workspace.GetFullPath(filepath);
        }
Ejemplo n.º 6
0
        public void RefreshProject(Project project, TreeIter tiParent)
        {
            store.SetValue(tiParent,1,project.ProjectName);
            store.SetValue(tiParent,2,project.AbsolutAppFilePath);

            RemoveAllChildren(store, tiParent);
            getChild(tiParent, project.AbsolutProjectDir, store, project);
        }
Ejemplo n.º 7
0
 public void RefreshDir(string dir, Project project, TreeIter tiParent)
 {
     RemoveAllChildren(store, tiParent);
     getChild(tiParent, dir, store, project);
 }
Ejemplo n.º 8
0
 public void LoadProject(Project project)
 {
     TreeIter iter = store.AppendValues(MainClass.Tools.GetIconFromStock("project-folder.png", IconSize.SmallToolbar), project.ProjectName, project.AbsolutAppFilePath, TypeFile.AppFile);
     getChild(iter, project.AbsolutProjectDir, store, project);
     //this.ExpandAll();
 }
Ejemplo n.º 9
0
        public GeneralWidget(Project project,Gtk.Window parent)
        {
            parentWindow =parent;
            this.Build();

            feOutput = new FileMaskEntry(MainClass.Settings.WorkspaceMaskDirectory,this.project,parentWindow);
            feOutput.IsFolder = true;

            Pango.FontDescription fd = PangoContext.FontDescription.Copy();
            fd.Weight = Pango.Weight.Bold;

            //Pango.FontDescription customFont = Pango.FontDescription.FromString("Courier 16");//Pango.FontDescription.FromString(MainClass.Settings.ConsoleTaskFont);
            //customFont.Weight = Pango.Weight.Bold;

            //checkbutton1.ModifyFont(customFont );

            this.project = project;
            if(MainClass.Workspace !=null){
                worksName.LabelProp =MainClass.Workspace.Name;
                worksDir.LabelProp= MainClass.Workspace.RootDirectory;

                prjName.LabelProp =this.project.ProjectName;
                prjDir.LabelProp = this.project.RelativeAppFilePath;
                prjFullPath.LabelProp  = this.project.AbsolutProjectDir;

            }
            if(!this.project.NewSkin){
                foreach (Devices.Device d in this.project.DevicesSettings){
                    d.Includes.Skin.Name="";
                    d.Includes.Skin.Theme="";
                }
                this.project.NewSkin =true;
            }
            //checkbutton1.Active =this.project.NewSkin;
            //checkbutton1.Visible =false;
            //checkbutton1.HideAll();//ShowAll()
            Gdk.Pixbuf default_pixbuf = null;
            string file = System.IO.Path.Combine(MainClass.Paths.ResDir, "stock-menu.png");
            popupCondition = new Gtk.Menu();

            if (System.IO.File.Exists(file)) {
                default_pixbuf = new Gdk.Pixbuf(file);

                btnPopUp = new Gtk.Button(new Gtk.Image(default_pixbuf));
                btnPopUp.TooltipText = MainClass.Languages.Translate("insert_condition_name");
                btnPopUp.Relief = Gtk.ReliefStyle.None;
                btnPopUp.CanFocus = false;
                btnPopUp.WidthRequest = btnPopUp.HeightRequest = 22;

                btnPopUp.Clicked += delegate {
                    popupCondition.Popup(null,null, new Gtk.MenuPositionFunc (GetPosition) ,3,Gtk.Global.CurrentEventTime);
                    //popupCondition.Popup();
                };
                hbox1.PackEnd(btnPopUp,false,false,0);
                //table1.Attach(btnPopUp,2, 3, 3, 4, AttachOptions.Shrink, AttachOptions.Shrink,0,0);
            }
            ReloadPanel();

            /*AddMenuItem(MainClass.Settings.Platform.Name);
            AddMenuItem(MainClass.Settings.Resolution.Name);

            if (project.ConditoinsDefine != null){
                foreach (Condition cd in project.ConditoinsDefine) {

                    AddMenuItem(cd.Name);
                }
            }

            popupCondition.ShowAll();*/

            table1.Attach(feOutput, 1, 3, 4,5, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            if (String.IsNullOrEmpty(project.ProjectOutput)){
                if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory)){
                    string fullOutput = MainClass.Workspace.OutputMaskToFullPath;

                    if (!System.IO.Directory.Exists(fullOutput)){
                        try {
                            System.IO.Directory.CreateDirectory(fullOutput);
                        }catch{	}
                    }

                    feOutput.DefaultPath  = fullOutput;
                    feOutput.VisiblePath  = MainClass.Workspace.OutputDirectory;
                }
                else feOutput.DefaultPath  = project.AbsolutProjectDir;
            } else {
                string fullProjectOutput = project.OutputMaskToFullPath;
                feOutput.DefaultPath  = fullProjectOutput;
                feOutput.VisiblePath  = project.ProjectOutput;
            }

            if (String.IsNullOrEmpty(project.ProjectArtefac)) {

                string name = System.IO.Path.GetFileNameWithoutExtension(project.RelativeAppFilePath);
                projectArtefact = String.Format("{0}_$({1})_$({2})", name, MainClass.Settings.Platform.Name, MainClass.Settings.Resolution.Name);
                project.ProjectArtefac = projectArtefact;

            } else
                projectArtefact = project.ProjectArtefac;

            entrName.Text= projectArtefact;
            entrFacebookApi.Text= project.FacebookAppID ;
            entrFacebookApi.KeyPressEvent+= delegate(object o, KeyPressEventArgs args) {

                if(!MainClass.LicencesSystem.CheckFunction("facebook",parentWindow)){
                    entrFacebookApi.Text= project.FacebookAppID ;
                    return;
                }
            };

            entrName.Changed+= delegate(object sender, EventArgs e) {
                if(checkChange)
                    CheckMessage();
            };
        }
Ejemplo n.º 10
0
        public bool ExecuteTask()
        {
            if (MainClass.Workspace.ActualProject == null) {
                SetError(MainClass.Languages.Translate("no_project_selected"));
                return false;
            }

            project = MainClass.Workspace.ActualProject;

            if (String.IsNullOrEmpty(project.ProjectOutput)){

                if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory)){
                    project.ProjectOutput  = MainClass.Workspace.OutputDirectory;

                } else project.ProjectOutput  = project.AbsolutProjectDir;
            }

            if(!Directory.Exists(project.OutputMaskToFullPath)){
                try{
                    Directory.CreateDirectory(project.OutputMaskToFullPath);
                }catch
                {
                    SetError(MainClass.Languages.Translate("cannot_create_output"));
                return false;
                }
            }

            stateTask = StateEnum.OK;

            //################ uvodne kontroly
            if (MainClass.MainWindow.RunningEmulator) {
                SetError(MainClass.Languages.Translate("emulator_is_running"));
                return false;
            }

            string cmd = Path.Combine(MainClass.Settings.EmulatorDirectory, "moscrif.exe");

            if(MainClass.Platform.IsMac){
                //Console.WriteLine("EmulatorDirectory --> {0}",MainClass.Settings.EmulatorDirectory);

                //cmd = "open";// + MainClass.Settings.EmulatorDirectory,  "moscrif.app");
                string file = System.IO.Path.Combine( MainClass.Settings.EmulatorDirectory,  "Moscrif.app");//.app
                file = System.IO.Path.Combine(file,  "Contents");
                file = System.IO.Path.Combine(file,  "MacOS");
                file = System.IO.Path.Combine(file,  "Moscrif");
                cmd = file;
                Tool.Logger.LogDebugInfo(String.Format("command compile MAC ->{0}",cmd),null);
            }

            if(MainClass.Platform.IsWindows){

                if (!System.IO.File.Exists(cmd)) {
                    SetError(MainClass.Languages.Translate("emulator_not_found"));
                    return false;
                }
            }

            string tempDir =  MainClass.Paths.TempPublishDir;//System.IO.Path.Combine(MainClass.Settings.PublishDirectory,"_temp");

            if (!Directory.Exists(tempDir)){

                try{
                    Directory.CreateDirectory(tempDir);
                } catch{
                    SetError(MainClass.Languages.Translate("cannot_create_temp_f1"));
                    return false;
                }
            }

            if ((listCombinePublish == null) || (listCombinePublish.Count <1)){
                SetError(MainClass.Languages.Translate("publish_list_is_empty"));
                return false;
                //project.GeneratePublishCombination();
            }

            bool cancelled = false;
            bool isAndroid = false;

            foreach(CombinePublish ccc in  listCombinePublish){
                CombineCondition crPlatform = ccc.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Platform.Id);
                if(crPlatform != null){

                    if ((crPlatform.RuleId == (int)DeviceType.Android_1_6)||
                        (crPlatform.RuleId == (int)DeviceType.Android_2_2)){
                        Console.WriteLine("ANDROID FOUND");
                        CheckJava();
                    }
                }
            }

            if(!isJavaInstaled && isAndroid){
                MessageDialogsUrl md = new MessageDialogsUrl(MessageDialogsUrl.DialogButtonType.Ok,MainClass.Languages.Translate("java_missing"), MainClass.Languages.Translate("java_missing_title"),"http://moscrif.com/java-requirement", Gtk.MessageType.Error,ParentWindow);
                md.ShowDialog();
            }

            project = MainClass.Workspace.ActualProject;

            if((MainClass.User == null) || (string.IsNullOrEmpty(MainClass.User.Token))){
                SetError(MainClass.Languages.Translate("invalid_login"));
                return false;
            }

            //########################## kompilovanie
            progressDialog = new ProgressDialog(MainClass.Languages.Translate("compiling"),ProgressDialog.CancelButtonType.None,listCombinePublish.Count,ParentWindow);//MainClass.MainWindow		//#################### kompilovanie
            try {
                List<string> list = new List<string>();

                GetComands(project.AbsolutProjectDir, ref list,true);
                string[] libs = project.AppFile.Libs;

                foreach (string lib in libs){
                    if(string.IsNullOrEmpty(lib)) continue;
                    string pathLib = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,lib);
                    GetComands(pathLib, ref list,true);
                }

                if (list.Count > 0) {
                    double step = 1 / (list.Count * 1.0);
                        MainClass.MainWindow.ProgressStart(step, MainClass.Languages.Translate("compiling"));
                    progressDialog.Reset(list.Count,MainClass.Languages.Translate("compiling"));
                }

                foreach (string f in list) {
                    if (exitCompile) { // chyba koncim
                        MainClass.MainWindow.ProgressEnd();
                        progressDialog.Destroy();

                        SetError(MainClass.Languages.Translate("compiling_failed"));
                        return false;
                    }

                    string fileUpdate = FileUtility.AbsoluteToRelativePath(MainClass.Workspace.RootDirectory ,f);

                    if ( project.FilesProperty != null){

                        FileItem fi =  project.FilesProperty.Find(x => x.SystemFilePath == fileUpdate);
                        if (fi != null)
                        {
                            if (fi.IsExcluded) continue;
                        }
                    }

                    string fdir = System.IO.Path.GetDirectoryName(f);
                    string fname = System.IO.Path.GetFileName(f);

                    string args = String.Format("/d \"{0}\" /c {1} /o console", fdir, fname);

                    if(MainClass.Platform.IsMac){

                        args = String.Format("-d {0} -c {1} -o console", fdir, fname);

                            /*Process []pArry = Process.GetProcesses();
                            foreach(Process p in pArry)
                            {
                                if(p != null){
                                    try {
                                        if(p.ProcessName == "Moscrif"){
                                            p.Kill();
                                            MainClass.MainWindow.RunningEmulator= false;
                                        }
                                        //string s = p.ProcessName;
                                        //s = s.ToLower();
                                        //Console.WriteLine("\t"+s);
                                    } catch (Exception ex){
                                        Console.WriteLine(ex.Message);
                                    }
                                }
                            }*/
                    }

                    string a = args;
                    //output.Add(new TaskMessage("args>>" + a));

                    ProcessService ps = new ProcessService();

                    MainClass.MainWindow.ProgressStep();
                    progressDialog.Update(f);

                    ProcessWrapper pw = ps.StartProcess(cmd, a, fdir, ProcessOutputChange, ProcessOutputChange);
                    pw.WaitForExit();
                    //pw.WaitForOutput();

                    pw.Exited += delegate(object sender, EventArgs e) {
                        //Console.WriteLine("pw.Exited");
                        ParseOutput(MainClass.Languages.Translate("exit_compiling"),pw.StartInfo.WorkingDirectory);
                    };

                }

            } catch (Exception ex) {
                MainClass.MainWindow.ProgressEnd();
                progressDialog.Destroy();
                SetError(MainClass.Languages.Translate("compiling_failed"),ex.Message);

                return false;
            } finally {
            }

            if(stateTask != StateEnum.OK){

                MainClass.MainWindow.ProgressEnd();
                progressDialog.Destroy();

                SetError(MainClass.Languages.Translate("compiling_failed"));

                return false;
            }

            //#################### regenerate app file, backup, hash
            parentTask = new TaskMessage("OK",MainClass.Languages.Translate("compiling"),null);
            output.Add(parentTask);

            List<string> filesList = new List<string>();
            GetAllFiles(ref filesList,project.AbsolutProjectDir );

            progressDialog.Reset(filesList.Count,MainClass.Languages.Translate("generate_app"));

            string bakAppPath =project.AbsolutAppFilePath+".bak";
            string hashAppPath =project.AbsolutAppFilePath+".hash";

            if(System.IO.File.Exists(bakAppPath)){
                try{
                    File.Delete(bakAppPath);
                } catch {
                    progressDialog.Destroy();
                    SetError(MainClass.Languages.Translate("cannot_create_backup"));

                    return false;
                }
            }
            if(System.IO.File.Exists(hashAppPath)){
                try{
                    File.Delete(hashAppPath);
                } catch {
                    progressDialog.Destroy();
                    SetError(MainClass.Languages.Translate("cannot_create_hash"));
                    return false;
                }
            }

            try{
                File.Copy(project.AbsolutAppFilePath,bakAppPath);
                File.Copy(project.AbsolutAppFilePath,hashAppPath);
            } catch {
                progressDialog.Destroy();
                SetError(MainClass.Languages.Translate("cannot_create_backup"));
                return false;
            }

            using (StreamWriter stream = File.AppendText(hashAppPath)) {
                stream.WriteLine();

                foreach(string file in filesList){

                    if (System.IO.Path.GetExtension(file)==".ms") continue;

                    string fileUpdate = FileUtility.AbsoluteToRelativePath(project.AbsolutProjectDir,file);
                    fileUpdate = FileUtility.TrimStartingDotCharacter(fileUpdate);
                    fileUpdate = FileUtility.TrimStartingDirectorySeparator(fileUpdate);
            /*
                    stream.WriteLine("file : {0}",fileUpdate);

                    string fileNameHash = Cryptographer.SHA1HashBase64(fileUpdate);
                    stream.WriteLine("hash : {0}",fileNameHash);
                    */
                    progressDialog.Update(MainClass.Languages.Translate("create_app"));
                    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)) {
                        int size = (int)fs.Length;
                        byte[] data = new byte[size];
                        fs.Read(data, 0, size);
                        fs.Close();
                        stream.WriteLine("file: {0}",fileUpdate);
                        stream.WriteLine("hash: {0}", Cryptographer.SHA1HashBase64(data));
                    }
                }

                stream.Flush();
                stream.Close();
                stream.Dispose();
            }

            //#################### podpisovanie

            progressDialog.Reset(0,MainClass.Languages.Translate("sign_app_f1"));
            progressDialog.SetLabel (MainClass.Languages.Translate("sign_app_f1") );

            SignApp sa = new SignApp();
            string newAppdata = "";

            try{
                if(!sa.PostFile(hashAppPath,MainClass.User.Token,out newAppdata)){
                    //timer.Stop();
                    progressDialog.Destroy();
                    RestoreBackup(hashAppPath,bakAppPath);

                    //SetError(MainClass.Languages.Translate("expired_licence"),newAppdata);
                    output.Add(new TaskMessage(newAppdata,MainClass.Languages.Translate("expired_licence"),null));
                    stateTask = StateEnum.ERROR;

                    LicenceExpiredDialog md = new LicenceExpiredDialog(MainClass.Languages.Translate("expired_licence"));
                    md.Run();
                    md.Destroy();
                    return false;
                }

                if(String.IsNullOrEmpty(newAppdata)){
                    //timer.Stop();
                    progressDialog.Destroy();
                    RestoreBackup(hashAppPath,bakAppPath);
                    SetError(MainClass.Languages.Translate("sign_app_failed"));
                    return false;
                }

                using (StreamWriter file = new StreamWriter(project.AbsolutAppFilePath)) {
                    file.Write(newAppdata);
                    file.Flush();
                    file.Close();
                }

            }catch(Exception ex){
                //timer.Stop();
                progressDialog.Destroy();

                SetError(MainClass.Languages.Translate("sign_app_failed"), ex.Message);
                //Console.WriteLine(ex.Message);
                RestoreBackup(hashAppPath,bakAppPath);
                return false;
            }

            //timer.Stop();
            parentTask = new TaskMessage("OK",MainClass.Languages.Translate("sign"),null);
            output.Add(parentTask);

            //#################### publish
            //if (listCombinePublish.Count > 0) {
                //List<CombinePublish> lst =project.CombinePublish.FindAll(x=>x.IsSelected==true);
                double step2 = 1 / (listCombinePublish.Count * 1.0);
                MainClass.MainWindow.ProgressStart(step2, MainClass.Languages.Translate("publish"));
                //progressDialog = new ProgressDialog(MainClass.Languages.Translate("publishing"),ProgressDialog.CancelButtonType.Cancel,listCombinePublish.Count,MainClass.MainWindow);
                progressDialog.Reset(listCombinePublish.Count,MainClass.Languages.Translate("publishing"));
            //}

            foreach(CombinePublish ccc in  listCombinePublish){//listCC ){
                //if (!ccc.IsSelected) continue;
                //Console.WriteLine(ccc.ToString());

                if (cancelled) break;

                if(String.IsNullOrEmpty(project.ProjectArtefac) ){
                    project.ProjectArtefac = System.IO.Path.GetFileNameWithoutExtension(project.RelativeAppFilePath);
                }
                string fileName =  project.ProjectArtefac;

                List<ConditionDevice> condList = new List<ConditionDevice>();

                foreach(CombineCondition cr in ccc.combineRule){
                    ConditionDevice cd = new ConditionDevice (cr.ConditionName,cr.RuleName);
                    //condList.Add(new ConditionDevice(cr.ConditionName,cr.RuleName));
                    if(cr.ConditionId == MainClass.Settings.Resolution.Id){
                        Rule rl = MainClass.Settings.Resolution.Rules.Find(x=>x.Id == cr.RuleId);
                        if(rl!= null){
                            cd.Height = rl.Height;
                            cd.Width = rl.Width;
                        }

                    }
                    condList.Add(cd);

                    fileName = fileName.Replace(String.Format("$({0})",cr.ConditionName),cr.RuleName);
                }

                parentTask = new TaskMessage(MainClass.Languages.Translate("publishing"),fileName,null);
                devicePublishError = false;

                if (progressDialog != null)
                     progressDialog.SetLabel (fileName );

                if (Directory.Exists(tempDir)) {
                    try{
                        DirectoryInfo di = new DirectoryInfo(tempDir);
                        foreach (DirectoryInfo d in di.GetDirectories()){
                            d.Delete(true);
                        }
                        foreach (FileInfo f in di.GetFiles()){
                            f.Delete();
                        }

                    } catch {
                    }
                }

                CombineCondition crPlatform = ccc.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Platform.Id);
                CombineCondition crRsolution = ccc.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Resolution.Id);

                if (crPlatform == null) {
                    SetError(MainClass.Languages.Translate("platform_not_found", MainClass.Settings.Platform.Name), parentTask);
                    continue;
                }

                Device dvc = project.DevicesSettings.Find(x=>x.TargetPlatformId == crPlatform.RuleId);

                if (dvc == null) {
                    SetError(MainClass.Languages.Translate("device_not_found", crPlatform.ConditionName, crPlatform.RuleName), parentTask);
                    continue;
                }

                //if ((crPlatform.RuleId == (int)DeviceType.Android_1_6) && (!isJavaInstaled)){
                if (((crPlatform.RuleId == (int)DeviceType.Android_1_6) ||
                  (crPlatform.RuleId == (int)DeviceType.Android_2_2))
                    && (!isJavaInstaled)){
                    SetError(MainClass.Languages.Translate("java_missing"), parentTask);
                    continue;
                }

                string dirPublish = MainClass.Tools.GetPublishDirectory(dvc.Platform.Specific);//System.IO.Path.Combine(MainClass.Settings.PublishDirectory,dvc.Platform.Specific);//crPlatform.RuleName);

                if (!Directory.Exists(dirPublish)){
                    SetError(MainClass.Languages.Translate("publish_tool_not_found"), parentTask);
                    continue;
                }

                if (String.IsNullOrEmpty(dirPublish)) {

                    SetError(MainClass.Languages.Translate("publish_tool_not_found_f1"), parentTask);
                    continue;
                }

                dvc.Application = project.AppFile.Name;

                if (String.IsNullOrEmpty(project.ProjectOutput)){

                    if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory)){

                        project.ProjectOutput  = MainClass.Workspace.OutputDirectory;

                    } else project.ProjectOutput  = project.AbsolutProjectDir;
                }

                dvc.Output_Dir = project.OutputMaskToFullPath;

                dvc.Temp = tempDir;

                dvc.Temp = LastSeparator(dvc.Temp);
                dvc.Publish = LastSeparator(MainClass.Settings.PublishDirectory);
                dvc.Root = LastSeparator(MainClass.Workspace.RootDirectory);
                dvc.Output_Dir = LastSeparator(dvc.Output_Dir);
                dvc.Conditions =condList.ToArray();

                List<int> mergeResolutions = new List<int>();
                string resolution = crRsolution.RuleName;
                mergeResolutions.Add(crRsolution.RuleId);

                // Ak je zaskrtnute Merge All Resolution
                // Najdem vsetky publishovatelne combinacie danej platformy (napr. vsetky publishovane andrroidy)
                // a vytiahnem z nich rezolution a spojim do do string odeleneho &
                if(dvc.Includes.Skin != null){
                    dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution;
                    if(!String.IsNullOrEmpty(dvc.Includes.Skin.Name)){
                        if(project.IncludeAllResolution){
                            resolution = "";
                            foreach(CombinePublish cp in  listCombinePublish){
                                CombineCondition crPlatform2 = cp.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Platform.Id && x.RuleId== crPlatform.RuleId);
                                if(crPlatform2 != null){
                                    CombineCondition crResolution2 = cp.combineRule.Find(x=>x.ConditionId==MainClass.Settings.Resolution.Id );
                                    if(crResolution2!= null){
                                        resolution =resolution+crResolution2.RuleName+"&";
                                    }
                                }

                            }
                            resolution = resolution.Remove(resolution.Length - 1, 1);
                            ConditionDevice cd = condList.Find(x=>x.Name == MainClass.Settings.Resolution.Name);
                            if(cd != null){
                                cd.Value = resolution;
                                dvc.Conditions =condList.ToArray();
                            }

                        }
                    }
                }

                List<string> filesForPublish = new List<string>();

                foreach(string file in filesList){
                    //if (System.IO.Path.GetExtension(file)==".msc") continue;
                    if (System.IO.Path.GetExtension(file)==".ms") continue;

                    string checkFile =file;

                    if (System.IO.Path.GetExtension(file)==".msc")
                        checkFile = System.IO.Path.ChangeExtension(file,".ms");

                    string fileUpdate = FileUtility.AbsoluteToRelativePath(MainClass.Workspace.RootDirectory ,checkFile);

                    if ( project.FilesProperty != null){

                        // vyhldam property suborov a pozriem ci nemam nejake conditiony nastavene
                        FileItem fi =  project.FilesProperty.Find(x => x.SystemFilePath == fileUpdate);
                        if (fi != null)
                        {
                            if (fi.IsExcluded) continue;
                            if(fi.ConditionValues == null)continue;
                            foreach(CombineCondition cr in ccc.combineRule){

                                ConditionRule conRile = fi.ConditionValues.Find(x=>x.ConditionId == cr.ConditionId);
                                if (conRile != null){
                                    //if ((conRile.RuleId != cr.RuleId)) // subor ma condition daneho typu, ale nastavenu na inu hodnotu
                                    //goto nav;

                                    int resolutionId = -1;

                                    if(conRile.ConditionId == MainClass.Settings.Resolution.Id){
                                        resolutionId=mergeResolutions.FindIndex(x=>x == conRile.RuleId);
                                        //continue;
                                    }

                                    // mam merge resolution a subor patri do niektoreho mergnuteho resolution
                                    if((conRile.ConditionId == MainClass.Settings.Resolution.Id) && (resolutionId>-1)){
                                        goto nav1;
                                    }

                                    // subor ma condition daneho typu, ale nastavenu na inu hodnotu
                                    if ((conRile.RuleId != cr.RuleId)){
                                        goto nav;
                                    }
                                }
                            }
                        }
                    }
                    nav1:
                    fileUpdate = FileUtility.AbsoluteToRelativePath(project.AbsolutProjectDir,file);
                    fileUpdate = FileUtility.TrimStartingDotCharacter(fileUpdate);
                    fileUpdate = FileUtility.TrimStartingDirectorySeparator(fileUpdate);
                    filesForPublish.Add(fileUpdate);

                    nav:;
                }

                dvc.Includes.Files = filesForPublish.ToArray();
                dvc.Output_Name = fileName;

                dvc.PublishPropertisFull = new List<PublishProperty>();
                foreach(PublishProperty pp in dvc.PublishPropertisMask){
                    PublishProperty ppFull = new PublishProperty(pp.PublishName);
                    ppFull.PublishValue = project.ConvertProjectMaskPathToFull(pp.PublishValue);

                    dvc.PublishPropertisFull.Add(ppFull);
                }

                /*if(dvc.Includes.Skin != null){
                    dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution;
                    if(!String.IsNullOrEmpty(dvc.Includes.Skin.Name)){
                        if(project.IncludeAllResolution){
                            dvc.Includes.Skin.ResolutionJson = "*";
                        }
                    }
                }*/

                //dvc.Includes.Files
                dvc.LogDebug = MainClass.Settings.LogPublish;
                dvc.ApplicationType = project.ApplicationType;
                dvc.FacebookAppID = project.FacebookAppID;
                if(String.IsNullOrEmpty(project.FacebookAppID))
                    dvc.FacebookAppID ="";

                string path = System.IO.Path.Combine(dirPublish,"settings.mso");//fileName+".mso"); //dvc.TargetPlatform + "_settings.mso");
                string json = dvc.GenerateJson();//GenerateJson(dvc);

                if(String.IsNullOrEmpty(json)){
                    SetError(MainClass.Languages.Translate("cannot_generate_mso"),parentTask);
                    continue;
                }

                try {
                    using (StreamWriter file = new StreamWriter(path)) {
                        file.Write(json);
                        file.Close();
                    }

                } catch {
                    SetError(MainClass.Languages.Translate("cannot_generate_mso"), parentTask);
                    //isPublishError = true;
                    continue;
                }

                //var platformRule = MainClass.Settings.Platform.Rules.Find(x => x.Id == dvc.TargetPlatformId);

                string appFile =dvc.Platform.Specific+ ".app"; /*dvc.TargetPlatform*///platformRule.Specific + ".app";
                string fullAppPath = System.IO.Path.Combine(MainClass.Settings.PublishDirectory,appFile);

                if (!System.IO.File.Exists(fullAppPath) ){
                    SetError(MainClass.Languages.Translate("publish_tool_not_found_f2"), parentTask);
                    continue;
                }

                RunPublishTool(appFile,parentTask);

                if(MainClass.Platform.IsMac){
                    ExitPublish(null,null);
                }

                if(devicePublishError){
                    allPublishError = true;
                    parentTask.Message =MainClass.Languages.Translate("publish_error");
                    //Console.WriteLine(parentTask.Child.Message);
                    output.Add(parentTask);
                    stateTask = StateEnum.ERROR;
                }
                else{
                    parentTask.Message = MainClass.Languages.Translate("publish_successfully_done");
                    output.Add(parentTask);
                }

                /*if (RunPublishTool(appFile,parentTask) ){
                    parentTask.Message =MainClass.Languages.Translate("publish_successfully_done");
                    output.Add(parentTask);

                    //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_successfully_done"),dvc.Platform.Specific,null));
                } else {
                    parentTask.Message =MainClass.Languages.Translate("publish_error");
                    Console.WriteLine(parentTask.Child.Message);
                    output.Add(parentTask);
                    stateTask = StateEnum.ERROR;
                    isPublishError = true;
                    //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_error"),dvc.Platform.Specific,null));
                }*/

                MainClass.MainWindow.ProgressStep();
                if (progressDialog != null)
                    cancelled = progressDialog.Update (fileName );
            }

            MainClass.MainWindow.ProgressEnd();

            if (progressDialog != null){
                progressDialog.Destroy();
            }

            RestoreBackup(hashAppPath,bakAppPath);

            if(allPublishError){
                this.stateTask = StateEnum.ERROR;
                string s = allErrors.ToString();
                if(s.Length > 120){
                    s = s.Substring(0,120);
                    s= s+ " ... and more.";
                }

                ShowError(MainClass.Languages.Translate("publish_error"), s);
                return false;
            } else {
                this.stateTask = StateEnum.OK;
                ShowInfo(MainClass.Languages.Translate("publish_successfully_done"), "");

                if(MainClass.Settings.OpenOutputAfterPublish){
                    if (!String.IsNullOrEmpty(project.ProjectOutput)){
                        MainClass.Tools.OpenFolder(project.OutputMaskToFullPath);
                    }
                }

                return true;
            }

            /*if(this.stateTask == StateEnum.ERROR){

                string s = allErrors.ToString();
                if(s.Length > 120){
                    s = s.Substring(0,120);
                    s= s+ " ... and more.";
                }

                ShowError(MainClass.Languages.Translate("publish_error"), s);
                return false;
            } else {
                ShowInfo(MainClass.Languages.Translate("publish_successfully_done"), "");

                if(MainClass.Settings.OpenOutputAfterPublish){
                    if (!String.IsNullOrEmpty(project.ProjectOutput)){
                        MainClass.Tools.OpenFolder(project.OutputMaskToFullPath);
                    }
                }

                return true;
            }*/
        }
Ejemplo n.º 11
0
        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;
            }
        }
Ejemplo n.º 12
0
        public ProjectConditionsWidget(Project project,Gtk.Window parent)
        {
            parentWindow = parent;
            this.Build();
            this.project = project;

            tvConditions.AppendColumn(MainClass.Languages.Translate("id"), new Gtk.CellRendererText(), "text", 0);
            tvConditions.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 1);

            tvRules.AppendColumn(MainClass.Languages.Translate("id"), new Gtk.CellRendererText(), "text", 0);
            tvRules.AppendColumn(MainClass.Languages.Translate("name"), new Gtk.CellRendererText(), "text", 1);

            /*if(project.SelectResolution != null)
                resolutions = new List<int>( project.SelectResolution);
            else
                resolutions = new List<int>();*/

            tvConditions.Model = conditionStore;
            tvRules.Model = ruleStore;
            //tvResolution.Selection.Mode  = Gtk.SelectionMode.Multiple;

            if ( project.ConditoinsDefine == null) return;

            this.conditions = new List<Condition>();

            //this.resolution = project.Resolution.Clone();
            //foreach (Rule rl in MainClass.Settings.Resolution.Rules ){

                //Gtk.TreeIter tir = resolStore.AppendValues(rl.Id,rl.Name,rl.Specific,rl);
                //if (this.project.Resolution != null) {
                //	int indx = MainClass.Settings.Resolution.Rules.FindIndex(x=> x.Id == rl.Id);

                    //if (indx > -1)
                    //	tvResolution.Selection.SelectIter(tir);
                //}
            //}

            //conditions = new List<Condition>(project.ConditoinsDefine.ToArray());
            conditions =MainClass.Tools.Clone(project.ConditoinsDefine);

            TreeIter ti = new TreeIter();

            foreach (Condition cd in conditions){
                     ti = conditionStore.AppendValues(cd.Id,cd.Name,cd);
                    if (maxCond < cd.Id) maxCond = cd.Id;
            }

            tvConditions.Selection.Changed += delegate(object sender, EventArgs e)
            {
                ruleStore.Clear();
                Condition cd =GetSelected();
                if (cd == null ) return;

                foreach (Rule rl in cd.Rules){
                    ruleStore.AppendValues(rl.Id,rl.Name,rl);
                }
            };
            if (conditions.Count>0)
                tvConditions.Selection.SelectIter(ti);
            //project.ConditoinsDefine

            /*tvResolution.Selection.Changed+= delegate(object sender, EventArgs e) {

                generatePublishList = true;
            };*/
        }
Ejemplo n.º 13
0
        public ProjectPropertyWidget(Project project)
        {
            this.project = project;

            Table mainTable = new Table(2,1,false);
            Table propertyTable = new Table(5,2,false);

            Label lblFN = new Label(System.IO.Path.GetFileName(project.ProjectName));
            lblFN.UseUnderline = false;
            lblFN.Selectable = true;
            lblFN.Xalign = 0;

            /*prjDir.LabelProp = this.project.RelativeAppFilePath;
            prjFullPath.LabelProp  = this.project.AbsolutProjectDir;*/

            Entry entr = new Entry(this.project.RelativeAppFilePath);
            entr.ModifyBg(StateType.Normal,this.Style.Background(StateType.Normal));
            entr.IsEditable = false;

            Entry entrFullPath = new Entry(this.project.AbsolutProjectDir);
            entrFullPath.IsEditable = false;

            Entry entrFacebookApi = new Entry(this.project.FacebookAppID);
            entrFacebookApi.Changed+= delegate(object sender, EventArgs e)
            {
                this.project.FacebookAppID = entrFacebookApi.Text;
            };

            Entry entrTitle = new Entry(this.project.AppFile.Title);
            entrTitle.Changed+= delegate(object sender, EventArgs e)
            {
                try{
                    this.project.AppFile.Title = entrTitle.Text;
                } catch (Exception ex){
                    Moscrif.IDE.Tool.Logger.Error(ex.Message);
                }
            };

            ComboBox cbType = new ComboBox();
            ListStore projectModel = new ListStore(typeof(string), typeof(string));
            CellRendererText textRenderer = new CellRendererText();
            cbType.PackStart(textRenderer, true);
            cbType.AddAttribute(textRenderer, "text", 0);
            cbType.Model= projectModel;
            TreeIter ti = new TreeIter();
            foreach(SettingValue ds in MainClass.Settings.ApplicationType){// MainClass.Settings.InstallLocations){
                if(ds.Value == this.project.ApplicationType){
                    ti = projectModel.AppendValues(ds.Display,ds.Value);
                    cbType.SetActiveIter(ti);
                } else  projectModel.AppendValues(ds.Display,ds.Value);
            }
            if(cbType.Active <0)
                cbType.Active =0;
            cbType.Changed+= delegate(object sender, EventArgs e) {
                TreeIter tiSelect = new TreeIter();
                cbType.GetActiveIter(out tiSelect);
                string text = cbType.Model.GetValue(tiSelect,1).ToString();
                project.ApplicationType =text;
            };

            AddControl(ref propertyTable,0,lblFN,"Project ");
            AddControl(ref propertyTable,1,entr,"Project App ");
            AddControl(ref propertyTable,2,entrFullPath,"Project Path ");
            AddControl(ref propertyTable,3,entrTitle,"Title ");
            AddControl(ref propertyTable,4,cbType,"Type ");
            AddControl(ref propertyTable,5,entrFacebookApi,"Facebook ID ");

            mainTable.Attach(propertyTable,0,1,0,1,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0);

            /*int rowCount = project.ConditoinsDefine.Count;
            Table conditionsTable = new Table((uint)(rowCount + 3),(uint)2,false);

            GenerateContent(ref conditionsTable, MainClass.Settings.Platform.Name, 1, MainClass.Settings.Platform,false);//tableSystem
            GenerateContent(ref conditionsTable, MainClass.Settings.Resolution.Name, 2,MainClass.Settings.Resolution,true); //project.Resolution);//tableSystem
            int i = 3;
            foreach (Condition cd in project.ConditoinsDefine) {
                GenerateContent(ref conditionsTable, cd.Name, i, cd,false);
                i++;
            }
            mainTable.Attach(conditionsTable,0,1,1,2,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0);
            */
            this.PackStart(mainTable,true,true,0);
            this.ShowAll();
        }
Ejemplo n.º 14
0
        private static void getChild(TreeIter parent, string path, TreeStore rootStore, Project project)
        {
            if (!Directory.Exists(path))
                return;

            DirectoryInfo di = new DirectoryInfo(path);

            foreach (DirectoryInfo d in di.GetDirectories()){
                int indx = -1;
                indx = MainClass.Settings.IgnoresFolders.FindIndex(x => x.Folder == d.Name && x.IsForIde);

                //if (!d.Name.StartsWith(".")) {
                if(indx<0){
                    string ico = "folder.png";
                    if (d.Name == MainClass.Settings.ThemeDir)//".themes")
                        ico= "themes.png";

                    TreeIter iter = rootStore.AppendValues(parent, MainClass.Tools.GetIconFromStock(ico, Gtk.IconSize.SmallToolbar), d.Name, d.FullName, TypeFile.Directory);
                    getChild(iter, d.FullName, rootStore, project);
                }
            }

            foreach (FileInfo f in di.GetFiles()){

                int indx = -1;
                indx = MainClass.Settings.IgnoresFiles.FindIndex(x => x.Folder == f.Name && x.IsForIde);
                if(indx >-1)continue;

                if (!MainClass.Tools.IsIgnoredExtension(f.Extension)) {

                    string stockIcon = MainClass.Tools.GetIconForExtension(f.Extension);
                    if (project != null) {
                        if (f.FullName == MainClass.Workspace.GetFullPath(project.StartFile)) {
                            rootStore.AppendValues(parent, MainClass.Tools.GetIconFromStock(stockIcon, Gtk.IconSize.SmallToolbar), f.Name, f.FullName, TypeFile.StartFile);
                            continue;
                        }

                        FileItem fi = project.FilesProperty.Find(x => MainClass.Workspace.GetFullPath(x.FilePath) == f.FullName);
                        if ((fi != null) && (fi.IsExcluded)){
                            rootStore.AppendValues(parent, MainClass.Tools.GetIconFromStock("file-exclude.png", Gtk.IconSize.SmallToolbar), f.Name, f.FullName, TypeFile.ExcludetFile);
                            continue;
                        }
                    }

                    rootStore.AppendValues(parent, MainClass.Tools.GetIconFromStock(stockIcon, Gtk.IconSize.SmallToolbar), f.Name, f.FullName, TypeFile.SourceFile);
                }
            }
        }
Ejemplo n.º 15
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;
            }
        }
Ejemplo n.º 16
0
        public bool ExecuteTask()
        {
            stateTask = StateEnum.OK;

            if (MainClass.MainWindow.RunningEmulator) {
            output.Add(new TaskMessage(MainClass.Languages.Translate("emulator_is_running")));
            Tool.Logger.Error(MainClass.Languages.Translate("emulator_is_running"),null);
            stateTask = StateEnum.ERROR;
            return false;
            }

            string cmd = Path.Combine(MainClass.Settings.EmulatorDirectory,"moscrif.exe");
            if (MainClass.Platform.IsMac) {

            string file = System.IO.Path.Combine(MainClass.Settings.EmulatorDirectory,  "Moscrif.app");//.app

            if(!System.IO.Directory.Exists(file) ){
                output.Add(new TaskMessage(MainClass.Languages.Translate("emulator_not_found")));
                stateTask = StateEnum.ERROR;
                Tool.Logger.Error(MainClass.Languages.Translate("emulator_not_found"),null);
                return false;
            }

            file = System.IO.Path.Combine(file,  "Contents");
            file = System.IO.Path.Combine(file,  "MacOS");
            file = System.IO.Path.Combine(file,  "Moscrif");
            cmd = file;

            Tool.Logger.LogDebugInfo(String.Format("command MAC ->{0}",cmd),null);
            if(!System.IO.File.Exists(file) ){
                output.Add(new TaskMessage(MainClass.Languages.Translate("emulator_not_found")));
                stateTask = StateEnum.ERROR;
                Tool.Logger.Error(MainClass.Languages.Translate("emulator_not_found"),null);
                return false;
            }

            } else {
            Tool.Logger.LogDebugInfo(String.Format("command WIN ->{0}",cmd),null);
            if (!System.IO.File.Exists(cmd)) {
                output.Add(new TaskMessage(MainClass.Languages.Translate("emulator_not_found")));
                stateTask = StateEnum.ERROR;
                return false;
            }
            }

            if (MainClass.Workspace.ActualProject == null) {
                output.Add(new TaskMessage(MainClass.Languages.Translate("emulator_not_found")));
                stateTask = StateEnum.ERROR;
                return false;
            }
            project = MainClass.Workspace.ActualProject;
            try {
                List<string> list = new List<string>();
                GetComands(project.AbsolutProjectDir, ref list);

                if (list.Count > 0) {
                    double step = 1 / (list.Count * 1.0);
                    MainClass.MainWindow.ProgressStart(step, MainClass.Languages.Translate("compiling"));
                }

                foreach (string f in list) {

                    if (exitCompile) {
                        MainClass.MainWindow.ProgressEnd();
                        return false;
                    }

                    string fdir = System.IO.Path.GetDirectoryName(f);
                    string fname = System.IO.Path.GetFileName(f);

                    string args = String.Format("/d \"{0}\" /c {1} /o console", fdir, fname);

                    if (MainClass.Platform.IsMac){
                        args = String.Format("-d \"{0}\" -c {1} -o console", fdir, fname);
                    }

                    string a = args;
                    ProcessService ps = new ProcessService();
                    ProcessWrapper pw = ps.StartProcess(cmd, a, fdir, ProcessOutputChange, ProcessOutputChange);

                    MainClass.MainWindow.ProgressStep();

                    //pw.WaitForOutput();
                    pw.Exited += delegate(object sender, EventArgs e) {
                        //Console.WriteLine("pw.Exited");
                        ParseOutput("Exit Compilation",pw.StartInfo.WorkingDirectory);
                    };
                    //return true;
                }
                //output.Add(file);

            } catch (Exception ex) {
                output.Add(new TaskMessage(">>" + ex.Message));
                stateTask = StateEnum.ERROR;
                return false;
            } finally {
                MainClass.MainWindow.ProgressEnd();
            }
            //Console.WriteLine("0 >>"+stateTask);
            return true;
        }
Ejemplo n.º 17
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;*/
            }
        }
Ejemplo n.º 18
0
        public PublishDialogWizzard()
        {
            project  = MainClass.Workspace.ActualProject;
            this.TransientFor = MainClass.MainWindow;
            this.Build();

            ciDeviceTesting = new DropDownButton.ComboItem(MainClass.Languages.Translate("device_testing"),0);
            ciDeviceDistribution = new DropDownButton.ComboItem(MainClass.Languages.Translate("market_distribution"),1);

            btnResetMatrix.Label = MainClass.Languages.Translate("reset_matrix");

            chbSignApp= new CheckButton( MainClass.Languages.Translate("sign_app"));
            chbSignApp.Active = MainClass.Workspace.SignApp;
            chbSignApp.Toggled += new EventHandler(OnChbSignAppToggled);
            chbSignApp.Sensitive = true;//MainClass.Settings.SignAllow;

            notebook1.ShowTabs = false;
            notebook1.ShowBorder = false;
            notebook1.Page = 0;

            Table tblHeader = new Table(1,4,false);

            ddbTypPublish = new DropDownRadioButton();
            ddbTypPublish.Changed+= delegate(object sender, DropDownButton.ChangedEventArgs e)
            {
                if(e.Item !=null){
                    int selTyp = (int)e.Item;
                    if(selTyp == 0){
                        lblRemote.Visible = true;
                        ddbTypRemote.Visible = true;
                        chbSignApp.Sensitive= false;
                    } else {
                        if(!MainClass.LicencesSystem.CheckFunction("marketdistribution",this)){
                            ddbTypPublish.SelectItem(publishItems,ciDeviceTesting);
                            return;
                        }

                        lblRemote.Visible = false;
                        ddbTypRemote.Visible = false;
                        chbSignApp.Sensitive= true;
                    }

                    MainClass.Workspace.ActualProject.TypPublish = selTyp;
                }
            };
            ddbTypPublish.WidthRequest = 175;
            ddbTypPublish.SetItemSet(publishItems);

            ddbTypRemote = new DropDownRadioButton();
            ddbTypRemote.Changed+= delegate(object sender, DropDownButton.ChangedEventArgs e)
            {
                if(e.Item !=null){
                    string ipAdress = (string)e.Item;
                    MainClass.Settings.RemoteIpAdress = ipAdress;
                }
            };

            ddbTypRemote.WidthRequest = 175;
            ddbTypRemote.SetItemSet(remoteItems);

            publishItems.Add(ciDeviceTesting);
            publishItems.Add(ciDeviceDistribution);

            ddbTypPublish.SelectItem(publishItems,ciDeviceTesting);
            /*if(MainClass.Workspace.ActualProject.TypPublish ==1)
                ddbTypPublish.SelectItem(publishItems,ciDeviceDistribution);
            else
                ddbTypPublish.SelectItem(publishItems,ciDeviceTesting);*/

            DropDownButton.ComboItem addRemote0 = new DropDownButton.ComboItem(MainClass.Languages.Translate("remote_none"),"0");
            remoteItems.Add(addRemote0);

            bool findSelect = false;
            List<string> listIp = Moscrif.IDE.Tool.Network.GetIpAdress();
            foreach (string ip in listIp){
                DropDownButton.ComboItem addIP = new DropDownButton.ComboItem(ip,ip);
                remoteItems.Add(addIP);
                /*if(ip== MainClass.Settings.RemoteIpAdress){
                    ddbTypRemote.SelectItem(remoteItems,addIP);
                    findSelect = true;
                }*/
            }
            if(!findSelect){
                ddbTypRemote.SelectItem(remoteItems,addRemote0);;
            }

            tblHeader.Attach(new Label("Publish: "),0,1,0,1,AttachOptions.Fill,AttachOptions.Fill,5,0);
            tblHeader.Attach(ddbTypPublish,1,2,0,1,AttachOptions.Fill,AttachOptions.Fill,0,0);

            tblHeader.Attach(lblRemote,2,3,0,1,AttachOptions.Fill,AttachOptions.Fill,5,0);
            tblHeader.Attach(ddbTypRemote,3,4,0,1,AttachOptions.Fill,AttachOptions.Fill,0,0);

            this.vbox2.PackStart(tblHeader,false,false,0);

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

            nvOutput.Model = storeOutput;
            Gtk.CellRendererText collumnRenderer = new Gtk.CellRendererText();

            //nvOutput.AppendColumn ("", new Gtk.CellRendererPixbuf (), "pixbuf", 2);
            nvOutput.AppendColumn ("", collumnRenderer, "text", 0);
            nvOutput.AppendColumn ("", collumnRenderer, "text", 1);
            nvOutput.Columns[0].FixedWidth = 200;
            nvOutput.Columns[1].Expand = true;

            //nvOutput.Columns[0].SetCellDataFunc(collumnRenderer, new Gtk.TreeCellDataFunc(RenderOutput));
            //nvOutput.Columns[1].SetCellDataFunc(collumnRenderer, new Gtk.TreeCellDataFunc(RenderOutput));

            this.Title = MainClass.Languages.Translate("publish_title" , project.ProjectName);

            if(project.ProjectUserSetting.CombinePublish == null || project.ProjectUserSetting.CombinePublish.Count==0){
                project.GeneratePublishCombination();
            }

            if(project.DevicesSettings == null || project.DevicesSettings.Count == 0)
                project.GenerateDevices();

            foreach (Rule rl in MainClass.Settings.Platform.Rules){

                if( (rl.Tag == -1 ) && !MainClass.Settings.ShowUnsupportedDevices) continue;
                if( (rl.Tag == -2 ) && !MainClass.Settings.ShowDebugDevices) continue;

                Device dvc = project.DevicesSettings.Find(x => x.TargetPlatformId == rl.Id);
                if (dvc == null) {
                    Console.WriteLine("generate device -{0}",rl.Id);
                    dvc = new Device();
                    dvc.TargetPlatformId = rl.Id;
                    dvc.PublishPropertisMask = project.GeneratePublishPropertisMask(rl.Id);
                    project.DevicesSettings.Add(dvc);
                }
            }

            project.Save();
            notebook = new Notebook();
            GenerateNotebookPages();

            this.vbox2.PackStart(notebook,true,true,0);//PackEnd

            VBox vbox1 = new VBox();

            chbOpenOutputDirectory = new CheckButton( MainClass.Languages.Translate("open_open_directory_after_publish"));
            chbOpenOutputDirectory.Toggled += new EventHandler(OnChbOpenOutputDirectoryToggled);

            chbIncludeAllResolution = new CheckButton( MainClass.Languages.Translate("include_all_resolution"));
            chbIncludeAllResolution.Active = project.IncludeAllResolution;
            chbIncludeAllResolution.Sensitive = false;
            chbIncludeAllResolution.Toggled+= delegate {
                project.IncludeAllResolution =chbIncludeAllResolution.Active;
            };

            vbox1.PackStart(chbIncludeAllResolution,false,false,0);
            vbox3.PackEnd(chbOpenOutputDirectory,false,false,0);

            chbDebugLog = new Gtk.CheckButton(MainClass.Languages.Translate("debug_log_publish"));
            chbDebugLog.Active = MainClass.Settings.LogPublish;
            chbDebugLog.Toggled+= delegate {
                MainClass.Settings.LogPublish =  chbDebugLog.Active;
            };

            vbox1.PackEnd(chbDebugLog,false,false,0);

            this.vbox2.PackEnd(vbox1,false,false,0);

            VBox hbox = new VBox();
            hbox.PackStart(chbSignApp,false,false,0);

            this.vbox2.PackEnd(hbox,false,false,0);

            this.ShowAll();

            int cpage = project.ProjectUserSetting.PublishPage;

            notebook.SwitchPage += delegate(object o, SwitchPageArgs args) {
                project.ProjectUserSetting.PublishPage = notebook.CurrentPage;

                NotebookLabel nl = (NotebookLabel)notebook.GetTabLabel(notebook.CurrentPageWidget);
                chbIncludeAllResolution.Sensitive = false;

                if(nl.Tag == null) return;

                Device d = project.DevicesSettings.Find(x=>(int)x.Devicetype==(int)nl.Tag);
                if(d!=null){
                    if(d.Includes != null){
                        if(d.Includes.Skin!=null){
                            if(!String.IsNullOrEmpty(d.Includes.Skin.Name))
                                chbIncludeAllResolution.Sensitive = true;
                        }
                    }
                }
            };

            chbOpenOutputDirectory.Active = MainClass.Settings.OpenOutputAfterPublish;

            notebook.CurrentPage =cpage;
            btnNext.GrabFocus();
        }
Ejemplo n.º 19
0
        public bool RenameProject(Project prj, string newName)
        {
            string newDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newName);
            string newApp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newName+".app");
            string newPrj = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,newName+".msp");
            string oldPrjName =prj.ProjectName;

            if(File.Exists(newApp) || File.Exists(newPrj) || Directory.Exists(newDir)){
                MessageDialogs md =
                new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_rename_project",prj.ProjectName),MainClass.Languages.Translate("project_exist"), Gtk.MessageType.Error);
                md.ShowDialog();
                return false;
            }

            string oldPrjFile =prj.FilePath;

            System.IO.File.Move(prj.AbsolutAppFilePath, newApp);
            System.IO.File.Move(prj.FilePath ,newPrj);
            System.IO.Directory.Move(prj.AbsolutProjectDir,newDir);

            prj.AppFilePath = GetRelativePath(newApp);
            prj.FilePath =newPrj;

            foreach(FileItem fi in prj.FilesProperty){
                fi.FilePath = fi.FilePath.Replace("./"+oldPrjName+"/","./"+newName+"/");
                fi.FilePath = fi.FilePath.Replace(".\\"+oldPrjName+"\\",".\\"+newName+"\\");
                //MainClass.Workspace.GetRelativePath(d.FullName);
            }

            SaveProject(prj);

            ProjectsFile.Remove(GetRelativePath(oldPrjFile));
            ProjectsFile.Add(GetRelativePath(prj.FilePath));

            Devices.Device dev = prj.DevicesSettings.Find(x=>x.Devicetype == DeviceType.iOS_5_0);
            if(dev != null){
                Devices.PublishProperty pp =  dev.PublishPropertisMask.Find(x=>x.PublishName == Project.KEY_BUNDLEIDENTIFIER);
                if(pp != null)
                    pp.PublishValue.Replace(oldPrjName,newName);
            }
            return true;
        }
Ejemplo n.º 20
0
 public override void Initialize(PreferencesDialog dialog, object dataObject)
 {
     base.Initialize(dialog, dataObject);
     if (dataObject.GetType() == typeof(Project))
         project = (Project)dataObject;
 }
Ejemplo n.º 21
0
        internal void SaveProject(Project p)
        {
            try {
                /*XmlWriterSettings xmlSettings = new XmlWriterSettings();

                xmlSettings.NewLineChars = "\n";//Environment.NewLine;
                xmlSettings.Indent = true;
                xmlSettings.CloseOutput = true;

                XmlSerializer x_serial = new XmlSerializer( typeof( Project ) );
                using (XmlWriter wr = XmlWriter.Create( p.FilePath, xmlSettings )) {
                    x_serial.Serialize( wr, p );
                }

                XmlSerializer x_serial_PU = new XmlSerializer( typeof( ProjectUserFile ) );
                using (XmlWriter wr = XmlWriter.Create( p.ProjectUserSetting.FilePath, xmlSettings )) {
                    x_serial_PU.Serialize( wr, p.ProjectUserSetting );
                }*/
                p.Save();
            } catch (Exception ex) {
                MessageDialogs md =
                new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_saving"), ex.Message, Gtk.MessageType.Error);
                md.ShowDialog();
            }
        }
Ejemplo n.º 22
0
 public void Initialize(object dataObject)
 {
     if (dataObject.GetType() == typeof(Project) ){
         project = (Project)dataObject;
     }
 }
Ejemplo n.º 23
0
        public PublishDialog()
        {
            project  = MainClass.Workspace.ActualProject;

            this.TransientFor = MainClass.MainWindow;
            this.Build();

            btnResetMatrix.Label = MainClass.Languages.Translate("reset_matrix");
            this.Title = MainClass.Languages.Translate("publish_title" , project.ProjectName);

            if(project.ProjectUserSetting.CombinePublish == null || project.ProjectUserSetting.CombinePublish.Count==0){
                project.GeneratePublishCombination();
            }

            if(project.DevicesSettings == null || project.DevicesSettings.Count == 0)
                project.GenerateDevices();

            foreach (Rule rl in MainClass.Settings.Platform.Rules){

                if( (rl.Tag == -1 ) && !MainClass.Settings.ShowUnsupportedDevices) continue;
                if( (rl.Tag == -2 ) && !MainClass.Settings.ShowDebugDevices) continue;

                Device dvc = project.DevicesSettings.Find(x => x.TargetPlatformId == rl.Id);
                if (dvc == null) {
                    Console.WriteLine("generate device -{0}",rl.Id);
                    dvc = new Device();
                    dvc.TargetPlatformId = rl.Id;
                    dvc.PublishPropertisMask = project.GeneratePublishPropertisMask(rl.Id);
                    project.DevicesSettings.Add(dvc);
                }
            }
            project.Save();
            notebook = new Notebook();
            GenerateNotebookPages();

            this.vbox2.PackStart(notebook,true,true,0);//PackEnd

            VBox vbox1 = new VBox();

            chbOpenOutputDirectory = new CheckButton( MainClass.Languages.Translate("open_open_directory_after_publish"));
            chbOpenOutputDirectory.Toggled += new EventHandler(OnChbOpenOutputDirectoryToggled);

            chbIncludeAllResolution = new CheckButton( MainClass.Languages.Translate("include_all_resolution"));
            chbIncludeAllResolution.Active = project.IncludeAllResolution;
            chbIncludeAllResolution.Sensitive = false;
            chbIncludeAllResolution.Toggled+= delegate {
                project.IncludeAllResolution =chbIncludeAllResolution.Active;
            };

            vbox1.PackStart(chbIncludeAllResolution,false,false,0);
            vbox1.PackEnd(chbOpenOutputDirectory,false,false,0);

            chbDebugLog = new Gtk.CheckButton(MainClass.Languages.Translate("debug_log_publish"));
            //MainClass.Settings.LogPublish =false;
            chbDebugLog.Active = MainClass.Settings.LogPublish;
            chbDebugLog.Toggled+= delegate {
                MainClass.Settings.LogPublish =  chbDebugLog.Active;
            };

            vbox1.PackEnd(chbDebugLog,false,false,0);

            this.vbox2.PackEnd(vbox1,false,false,0);
            //this.vbox2.PackEnd(chbOpenOutputDirectory,false,false,0);//

            chbSignApp= new CheckButton( MainClass.Languages.Translate("sign_app"));
            chbSignApp.Toggled += new EventHandler(OnChbSignAppToggled);
            chbSignApp.Sensitive = true;//MainClass.Settings.SignAllow;
            //this.vbox2.PackEnd(chbSignApp,false,false,0);//

            VBox hbox = new VBox();
            hbox.PackStart(chbSignApp,false,false,0);

            this.vbox2.PackEnd(hbox,false,false,0);

            this.ShowAll();

            int cpage = project.ProjectUserSetting.PublishPage;

            notebook.SwitchPage += delegate(object o, SwitchPageArgs args) {
                project.ProjectUserSetting.PublishPage = notebook.CurrentPage;

                NotebookLabel nl = (NotebookLabel)notebook.GetTabLabel(notebook.CurrentPageWidget);
                chbIncludeAllResolution.Sensitive = false;

                if(nl.Tag == null) return;

                Device d = project.DevicesSettings.Find(x=>(int)x.Devicetype==(int)nl.Tag);
                if(d!=null){
                    if(d.Includes != null){
                        if(d.Includes.Skin!=null){
                            if(!String.IsNullOrEmpty(d.Includes.Skin.Name))
                                chbIncludeAllResolution.Sensitive = true;
                        }
                    }
                }
            };

            chbOpenOutputDirectory.Active = MainClass.Settings.OpenOutputAfterPublish;
            chbSignApp.Active = MainClass.Workspace.SignApp;

            notebook.CurrentPage =cpage;
            buttonOk.GrabFocus();
        }