Exemplo n.º 1
0
        public static void DisableProject(Project project)
        {
            if (HasDesignedObjects(project))
            {
                return;
            }

            GtkDesignInfo    info      = FromProject(project);
            StringCollection saveFiles = new StringCollection();

            saveFiles.AddRange(new string[] { info.ObjectsFile, info.SteticFile });
            info.CleanGtkFolder(saveFiles);
            project.Files.Remove(info.ObjectsFile);
            project.Files.Remove(info.SteticFile);

            var ext = project.GetService <GtkProjectServiceExtension> ();

            if (ext != null)
            {
                ext.DesignInfo = null;
            }
            info.Dispose();

            ProjectNodeBuilder.OnSupportChanged(project);
        }
        static void OnReferenceRemoved(object o, ProjectReferenceEventArgs args)
        {
            if (updating || !IsGtkReference(args.ProjectReference))
            {
                return;
            }

            DotNetProject dnp = args.Project as DotNetProject;

            if (MessageService.Confirm(GettextCatalog.GetString("The Gtk# User Interface designer will be disabled by removing the gtk-sharp reference."), new AlertButton(GettextCatalog.GetString("Disable Designer"))))
            {
                GtkDesignInfo.DisableProject(dnp);
            }
            else
            {
                dnp.References.Add(new ProjectReference(ReferenceType.Package, args.ProjectReference.StoredReference));
            }
        }
Exemplo n.º 3
0
        static void OnReferenceRemoved(object o, ProjectReferenceEventArgs args)
        {
            if (updating || !IsGtkReference(args.ProjectReference))
            {
                return;
            }

            DotNetProject dnp = args.Project as DotNetProject;

            if (MessageService.Confirm(GettextCatalog.GetString("The Gtk# User Interface designer will be disabled by removing the gtk-sharp reference."), new AlertButton(GettextCatalog.GetString("Disable Designer"))))
            {
                dnp.ExtendedProperties ["GtkReferenceExists"] = false;
                GtkDesignInfo.DisableProject(dnp);
            }
            else
            {
                dnp.References.Add(ProjectReference.CreateAssemblyReference(args.ProjectReference.StoredReference));
            }
        }
Exemplo n.º 4
0
        public static GtkDesignInfo FromProject(Project project)
        {
            if (!(project is DotNetProject))
            {
                return(new GtkDesignInfo());
            }

            IExtendedDataItem item = (IExtendedDataItem)project;
            GtkDesignInfo     info = item.ExtendedProperties ["GtkDesignInfo"] as GtkDesignInfo;

            if (info == null)
            {
                info = new GtkDesignInfo((DotNetProject)project);
            }
            else
            {
                info.Project = (DotNetProject)project;
            }
            return(info);
        }
Exemplo n.º 5
0
        public static void DisableProject(Project project)
        {
            if (HasDesignedObjects(project))
            {
                return;
            }

            GtkDesignInfo    info      = FromProject(project);
            StringCollection saveFiles = new StringCollection();

            saveFiles.AddRange(new string[] { info.ObjectsFile, info.SteticFile });
            info.CleanGtkFolder(saveFiles);
            project.Files.Remove(info.ObjectsFile);
            project.Files.Remove(info.SteticFile);
            IExtendedDataItem item = (IExtendedDataItem)project;

            item.ExtendedProperties.Remove("GtkDesignInfo");
            info.Dispose();
            ProjectNodeBuilder.OnSupportChanged(project);
        }
        bool Update(string assm_version)
        {
            if (assm_version == null)
            {
                throw new ArgumentException(assm_version);
            }

            bool changed = false;

            updating = true;

            bool gdk = false, gtk = false, posix = false;

            foreach (ProjectReference r in new List <ProjectReference> (project.References))
            {
                if (r.ReferenceType != ReferenceType.Package)
                {
                    continue;
                }
                string name = GetReferenceName(r);
                if (name == "gdk-sharp")
                {
                    gdk = true;
                }
                if (name == "gtk-sharp")
                {
                    gtk = true;
                }
                else if (name == "Mono.Posix")
                {
                    posix = true;
                }

                // Is a gtk-sharp-2.0 assembly?
                if (Array.IndexOf(gnome_assemblies, name) == -1)
                {
                    continue;
                }

                string sr      = r.StoredReference;
                string version = sr.Substring(sr.IndexOf(",") + 1).Trim();
                if (version != assm_version)
                {
                    project.References.Remove(r);
                    if (name == "gnome-sharp" && assm_version == "Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f")
                    {
                        project.References.Add(new ProjectReference(ReferenceType.Package, name + ", Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"));
                    }
                    else
                    {
                        project.References.Add(new ProjectReference(ReferenceType.Package, name + ", " + assm_version));
                    }
                    changed = true;
                }
            }

            if (!gtk)
            {
                project.References.Add(new ProjectReference(ReferenceType.Package, "gtk-sharp" + ", " + assm_version));
                changed = true;
            }

            if (!GtkDesignInfo.HasDesignedObjects(project))
            {
                return(changed);
            }

            GtkDesignInfo info = GtkDesignInfo.FromProject(project);

            if (!gdk)
            {
                project.References.Add(new ProjectReference(ReferenceType.Package, "gdk-sharp" + ", " + assm_version));
                changed = true;
            }

            if (!posix && info.GenerateGettext && info.GettextClass == "Mono.Unix.Catalog")
            {
                // Add a reference to Mono.Posix. Use the version for the selected project's runtime version.
                string aname = project.AssemblyContext.FindInstalledAssembly("Mono.Posix, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756", null, project.TargetFramework);
                aname = project.AssemblyContext.GetAssemblyNameForVersion(aname, project.TargetFramework);
                project.References.Add(new ProjectReference(ReferenceType.Package, aname));
                changed = true;
            }
            updating = false;
            return(changed);
        }
		public static GtkDesignInfo FromProject (Project project)
		{
			if (!(project is DotNetProject))
				return new GtkDesignInfo ();

			IExtendedDataItem item = (IExtendedDataItem) project;
			GtkDesignInfo info = item.ExtendedProperties ["GtkDesignInfo"] as GtkDesignInfo;
			if (info == null)
				info = new GtkDesignInfo ((DotNetProject) project);
			else
				info.Project = (DotNetProject) project;
			return info;
		}
Exemplo n.º 8
0
        public override async Task <bool> AddToProjectAsync(SolutionFolderItem policyParent, Project project, string language, string directory, string name)
        {
            if (!GtkDesignInfo.SupportsDesigner(project))
            {
                ReferenceManager mgr = new ReferenceManager(project as DotNetProject);
                mgr.GtkPackageVersion = mgr.DefaultGtkVersion;
                mgr.Dispose();
            }

            GtkDesignInfo info = GtkDesignInfo.FromProject((DotNetProject)project);

            GuiBuilderProject gproject = info.GuiBuilderProject;

            string fileName = fileTemplate.GetFileName(policyParent, project, language, directory, name);
            await fileTemplate.AddToProjectAsync(policyParent, project, language, directory, name);

            DotNetProject netProject = project as DotNetProject;
            string        ns         = netProject != null?netProject.GetDefaultNamespace(fileName) : "";

            string cname    = Path.GetFileNameWithoutExtension(fileName);
            string fullName = ns.Length > 0 ? ns + "." + cname : cname;

            string[,] tags =
            {
                { "Name",      cname    },
                { "Namespace", ns       },
                { "FullName",  fullName }
            };

            XmlElement widgetElem = steticTemplate ["widget"];

            if (widgetElem != null)
            {
                string content = widgetElem.OuterXml;
                content = StringParserService.Parse(content, tags);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                gproject.AddNewComponent(doc.DocumentElement);
                gproject.SaveAll(false);
                IdeApp.ProjectOperations.SaveAsync(project).Ignore();
                return(true);
            }

            widgetElem = steticTemplate ["action-group"];
            if (widgetElem != null)
            {
                string content = widgetElem.OuterXml;
                content = StringParserService.Parse(content, tags);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                gproject.SteticProject.AddNewActionGroup(doc.DocumentElement);
                gproject.SaveAll(false);
                IdeApp.ProjectOperations.SaveAsync(project).Ignore();
                return(true);
            }

            throw new InvalidOperationException("<widget> or <action-group> element not found in widget template.");
        }
Exemplo n.º 9
0
 public override bool SupportsProject(Project project, string projectPath)
 {
     return((project is DotNetProject) && GtkDesignInfo.SupportsRefactoring(project as DotNetProject));
 }