コード例 #1
0
ファイル: NewFileDialog.cs プロジェクト: moscrif/ide
        //Table tblAtributes;
        public NewFileDialog()
        {
            this.TransientFor = MainClass.MainWindow;
            this.Build();
            notebook1.ShowTabs = false;
            btnBack.Sensitive = false;
            //tvItem1.AppendColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
            tvItem1.AppendColumn(MainClass.Languages.Translate("template"), new Gtk.CellRendererText(), "text", 0);
            tvItem1.AppendColumn(MainClass.Languages.Translate("description"), new Gtk.CellRendererText(), "text", 1);

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

                fileListStore.Clear();
                if(Directory.Exists(MainClass.Paths.FileTemplateDir)){

                    string typeFile = GetSelectedTypFile();
                    typeFile = String.Format("*{0}",typeFile);
                    FileInfo[] fis = new DirectoryInfo(MainClass.Paths.FileTemplateDir).GetFiles(typeFile);

                    fileListStore.AppendValues(MainClass.Languages.Translate("empty_file"),MainClass.Languages.Translate("empty_file"),"",null);

                    foreach (FileInfo fi in fis){
                                FileTemplate t = new FileTemplate(fi,true);
                                //if (String.Compare(t.TemplateType, "moscrif source code", true) != 0) continue;
                                    //templates.Items.Add(t);
                        fileListStore.AppendValues(t.Name,t.Description,fi.FullName,t);
                    }
                }
                tvItem1.Model = fileListStore;
                tvItem1.Selection.SelectPath(new TreePath("0"));
                //cbFileTemplates.Model = fileListStore;
                //cbFileTemplates.Active = 0;
            };
            FillType();
        }
コード例 #2
0
ファイル: AttributeEntry.cs プロジェクト: moscrif/ide
        public AttributeEntry(FileTemplate.Attribute attribute)
        {
            this.attribute = attribute;

            Label lblApp = new Label(attribute.Name.Replace("_","__")+": ");
            lblApp.Xalign = 1;
            lblApp.Yalign = 0.5F;
            lblApp.WidthRequest = 115;
            Entry entr = new Entry();
            entr.Name = "entr";
            if (attribute.Value != null)
                entr.Text = attribute.Value.ToString();

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

                if (!String.IsNullOrEmpty(attribute.ValidateExpr)){
                    Regex regex = new Regex(attribute.ValidateExpr, RegexOptions.Compiled);
                    if (regex.IsMatch(entr.Text)){
                        this.attribute.Value = (object)entr.Text;
                    } else {
                        if (attribute.Value != null)
                        entr.Text = attribute.Value.ToString();
                    }

                } else
                    this.attribute.Value = (object)entr.Text;
            };

            this.PackStart(lblApp,false,false,2);
            this.PackEnd(entr,true,true,2);
        }
コード例 #3
0
ファイル: AttributeCheckBox.cs プロジェクト: moscrif/ide
        public AttributeCheckBox(FileTemplate.Attribute attribute)
        {
            this.attribute = attribute;

            Label lblApp = new Label(attribute.Name.Replace("_","__")+": ");
            lblApp.Xalign = 1;
            lblApp.Yalign = 0.5F;
            lblApp.WidthRequest = 115;
            CheckButton chb = new CheckButton();
            chb.Label = "";

            bool defValue = false;
            if(attribute.Value!= null){
                Boolean.TryParse(attribute.Value.ToString(), out defValue);
            }
            chb.Active = defValue;

            chb.Toggled += delegate(object sender, EventArgs e) {
                this.attribute.Value = (object)chb.Active;
            };

            this.PackStart(lblApp,false,false,2);
            this.PackEnd(chb,true,true,2);
        }
コード例 #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
ファイル: NewFileDialog.cs プロジェクト: moscrif/ide
 private void GenerateEntry(ref Table table, FileTemplate.Attribute attribute,int xPos)
 {
     AttributeEntry ae = new AttributeEntry(attribute);
     table.Attach(ae,0,1,(uint)(xPos-1),(uint)xPos,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0);
     //table.Attach(entr,1,2,(uint)(xPos-1),(uint)xPos,AttachOptions.Fill,AttachOptions.Shrink,3,3);
 }
コード例 #6
0
ファイル: NewFileDialog.cs プロジェクト: moscrif/ide
 private void GenerateCheckBox(ref Table table,  FileTemplate.Attribute attribute,int xPos)
 {
     AttributeCheckBox achb = new AttributeCheckBox(attribute);
     table.Attach(achb,0,1,(uint)(xPos-1),(uint)xPos,AttachOptions.Expand|AttachOptions.Fill,AttachOptions.Fill,0,0);
     //table.Attach(chb,1,2,(uint)(xPos-1),(uint)xPos,AttachOptions.Fill,AttachOptions.Shrink,3,3);
 }
コード例 #7
0
ファイル: NewFileDialog.cs プロジェクト: moscrif/ide
        //int pageCount = 1;
        protected virtual void OnButtonOkClicked(object sender, System.EventArgs e)
        {
            if(notebook1.Page == 0){
                btnBack.Sensitive = true;

                TreeSelection ts = tvItem.Selection;
                TreeIter ti = new TreeIter();
                ts.GetSelected(out ti);

                TreePath[] tp = ts.GetSelectedRows();

                fileName = entrName.Text;

                if (tp.Length <= 0 )  return;
                if (String.IsNullOrEmpty(fileName) )  return;

                fileExtension = tvItem.Model.GetValue(ti, 1).ToString();

                notebook1.Page = 1;
                //pageCount =2;
                entrName2.Text = entrName.Text;
                //}
            }
            else if(notebook1.Page == 1){
                FileTemplate  ft = GetSelectedTemplate();

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

                if(ft == null){
                    content = "";
                    this.Respond(ResponseType.Ok);
                    return;
                }
                while (tblAtributes.Children.Length > 0)
                    tblAtributes.Remove(tblAtributes.Children[0]);

                tblAtributes.NRows = (uint)ft.Attributes.Count+3;
                tblAtributes.NColumns =3;
                tblAtributes.BorderWidth = 10;
                tblAtributes.WidthRequest = 200;
                //tblAtributes.BorderWidth = 2;

                //vbox3.PackStart(tblAtributes,true,true,2);
                int i =1;
                foreach (FileTemplate.Attribute attr in ft.Attributes) {
                    if(attr.Type=="bool"){
                        bool defValue = false;
                        if(attr.Value!= null){
                            Boolean.TryParse(attr.Value.ToString(), out defValue);
                        }
                        GenerateCheckBox(ref tblAtributes,attr,i);
                    } else {
                        GenerateEntry(ref tblAtributes,attr,i);
                    }
                    i++;
                };
                tblAtributes.ShowAll();
                this.ShowAll();
                notebook1.Page = 2;
                //pageCount =3;
            }
            else if(notebook1.Page == 2){

                FileTemplate  ft = GetSelectedTemplate();
                fileTemplate = ft;
                if (ft  == null){
                    content = "";
                } else {
                    content = FileTemplateUtilities.Apply(fileTemplate.Content, fileTemplate.GetAttributesAsDictionary());
                }
                this.Respond(ResponseType.Ok);
            }
        }