예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
        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);
        }
예제 #5
0
        public NewProjectWizzard_New(Window parent)
        {
            if (parent != null)
            {
                this.TransientFor = parent;
            }
            else
            {
                this.TransientFor = MainClass.MainWindow;
            }

            this.Build();

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

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

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

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

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

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


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

            CellRendererText rendererSelectTyp = new CellRendererText();

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

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

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

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

                string          descr = name;
                ProjectTemplate pt    = null;

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

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


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

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

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

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

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

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

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

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

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

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

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


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


            CellRendererText rendererWorkspace = new CellRendererText();

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

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

            string currentWorkspace = "";

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

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

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

            if (!String.IsNullOrEmpty(currentWorkspace))
            {
                cbeWorkspace.Active = 0;
            }
            else
            {
                feLocation.DefaultPath = MainClass.Paths.WorkDir;
                cbeWorkspace.SetActiveIter(tiNewW);
                //storeWorkspace.AppendValues(worksDefaultName,MainClass.Paths.WorkDir,2);
            }
            prjDefaultName       = "Project" + MainClass.Settings.ProjectCount.ToString();
            entrProjectName.Text = prjDefaultName;
            cbeWorkspace.ShowAll();
            feLocation.ShowAll();


            CellRendererText rendererTemplate = new CellRendererText();

            cbTemplate.PackStart(rendererTemplate, true);

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

            cbTemplate.Changed += delegate(object sender, EventArgs e) {
                if (cbTemplate.Active < 0)
                {
                    return;
                }

                if (cbTemplate.ActiveText != KEY_CUSTOM)
                {
                    tblLibraries.Sensitive        = false;
                    tblScreens.Sensitive          = false;
                    ivSelectOrientation.Sensitive = false;
                }
                else
                {
                    ivSelectOrientation.Sensitive = true;
                    tblLibraries.Sensitive        = true;
                    tblScreens.Sensitive          = true;
                }

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

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

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

                    Widget[] widgets = tblLibraries.Children;
                    foreach (Widget w in widgets)
                    {
                        int indx = libs.FindIndex(x => x == w.Name);
                        if (indx > -1)
                        {
                            (w as CheckButton).Active = true;
                        }
                        else
                        {
                            (w as CheckButton).Active = false;
                        }
                    }
                }
            };
            btnBack.Sensitive = false;
        }