public string GetComponentFile(string componentName) { IType type = GuiBuilderProject.FindClass(componentName); if (type != null) { foreach (IType part in type.Parts) { string componentFile = part.CompilationUnit.FileName.FullPath; if (componentFile.Contains(BuildFileExtension)) { componentFile = componentFile.Replace(BuildFileExtension, string.Empty); } return(componentFile); } } //If ProjectDom does not exist, assume that project is being created //and return component file path that is located in the project root folder ProjectDom ctx = ProjectDomService.GetProjectDom(project); if (ctx == null) { string componentFile = Path.Combine(project.BaseDirectory, componentName + langExtension); if (File.Exists(componentFile)) { return(componentFile); } } return(null); }
public bool UpdateGtkFolder() { if (!SupportsDesigner(project)) { return(false); } // This method synchronizes the current gtk project configuration info // with the needed support files in the gtk-gui folder. FileService.CreateDirectory(GtkGuiFolder); bool projectModified = false; bool initialGeneration = false; if (!File.Exists(SteticFile)) { initialGeneration = true; StreamWriter sw = new StreamWriter(SteticFile); sw.WriteLine("<stetic-interface />"); sw.Close(); FileService.NotifyFileChanged(SteticFile); } if (!project.IsFileInProject(SteticFile)) { ProjectFile pf = project.AddFile(SteticFile, BuildAction.EmbeddedResource); pf.ResourceId = "gui.stetic"; projectModified = true; } StringCollection files = GuiBuilderProject.GenerateFiles(GtkGuiFolder); DateTime generatedTime = File.GetLastWriteTime(SteticFile).Subtract(TimeSpan.FromSeconds(2)); foreach (string filename in files) { if (initialGeneration) { // Ensure that the generation date of this file is < the date of the .stetic file // In this way the code will be properly regenerated when building the project. File.SetLastWriteTime(filename, generatedTime); } if (!project.IsFileInProject(filename)) { project.AddFile(filename, BuildAction.Compile); projectModified = true; } } UpdateObjectsFile(); files.Add(ObjectsFile); files.Add(SteticFile); if (CleanGtkFolder(files)) { projectModified = true; } return(ReferenceManager.Update() || projectModified); }
public WindowsFolder(Project project) { this.project = project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); gproject = info.GuiBuilderProject; gproject.Changed += OnUpdateFiles; }
protected void OnEditIcons() { Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GuiBuilderProject gp = GtkDesignInfo.FromProject(project).GuiBuilderProject; Stetic.Project sp = gp.SteticProject; sp.EditIcons(); gp.SaveProject(true); }
protected void OnGenerateCode() { ProjectFile pf = CurrentNode.DataItem as ProjectFile; Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); GuiBuilderProject gproject = info.GuiBuilderProject; gproject.GenerateCode(pf.FilePath); }
internal GuiBuilderWindow (GuiBuilderProject fproject, Stetic.Project gproject, Stetic.WidgetInfo rootWidget) { this.fproject = fproject; this.rootWidget = rootWidget; this.gproject = gproject; name = rootWidget.Name; gproject.ProjectReloaded += OnProjectReloaded; rootWidget.Changed += OnChanged; }
// public string GetBuildFileFromDesigner (string gtkxFile) // { // string buildFile = gtkxFile.Replace (DesignerFileExtension, BuildFileExtension + langExtension); // return buildFile; // } public string GetComponentFolder(string componentName) { IType type = GuiBuilderProject.FindClass(componentName); if (type != null) { FilePath folder = type.CompilationUnit.FileName.ParentDirectory; return(folder.FullPath.ToString()); } return(null); }
public bool UpdateGtkFolder() { if (!SupportsDesigner(project)) { return(false); } // This method synchronizes the current gtk project configuration info // with the needed support files in the gtk-gui folder. FileService.CreateDirectory(SteticFolder); bool projectModified = false; foreach (string filename in GetDesignerFiles()) { ProjectFile pf = project.AddFile(filename, BuildAction.EmbeddedResource); pf.ResourceId = Path.GetFileName(filename); string componentFile = GetComponentFileFromDesigner(filename); if (componentFile != null && File.Exists(componentFile)) { pf.DependsOn = componentFile; string buildFile = GetBuildFileFromComponent(componentFile); if (buildFile != null && File.Exists(buildFile)) { ProjectFile pf2 = project.AddFile(buildFile, BuildAction.Compile); pf2.ResourceId = Path.GetFileName(buildFile); pf2.DependsOn = componentFile; } } projectModified = true; } StringCollection files = GuiBuilderProject.GenerateFiles(SteticFolder); foreach (string filename in files) { if (!project.IsFileInProject(filename)) { project.AddFile(filename, BuildAction.Compile); projectModified = true; } } UpdateObjectsFile(); return(ReferenceManager.Update() || projectModified); }
public override void ActivateItem() { StockIconsNode node = (StockIconsNode)CurrentNode.DataItem; GtkDesignInfo info = GtkDesignInfo.FromProject(node.Project); GuiBuilderProject gp = info.GuiBuilderProject; Stetic.Project sp = gp.SteticProject; sp.ImagesRootPath = FileService.AbsoluteToRelativePath(info.GtkGuiFolder, gp.Project.BaseDirectory); sp.ImportFileCallback = delegate(string file) { return(GuiBuilderService.ImportFile(gp.Project, file)); }; sp.EditIcons(); gp.Save(true); }
public void Dispose() { if (resourceProvider != null) { System.Runtime.Remoting.RemotingServices.Disconnect(resourceProvider); } resourceProvider = null; if (builderProject != null) { builderProject.Dispose(); } builderProject = null; if (referenceManager != null) { referenceManager.Dispose(); } referenceManager = null; Project = null; }
protected void OnReloadDesigner() { ProjectFile pf = CurrentNode.DataItem as ProjectFile; Project project = CurrentNode.GetParentDataItem(typeof(Project), true) as Project; GtkDesignInfo info = GtkDesignInfo.FromProject(project); GuiBuilderProject gproject = info.GuiBuilderProject; Document doc = IdeApp.Workbench.GetDocument(pf.FilePath); if (doc != null) { gproject.ReloadFile(pf.FilePath); GuiBuilderView view = doc.ActiveView as GuiBuilderView; if (view != null) { view.ReloadDesigner(project); } } }
public override void DeleteItem() { // Don't allow deleting action groups local to a window GuiBuilderWindow w = (GuiBuilderWindow)CurrentNode.GetParentDataItem(typeof(GuiBuilderWindow), false); if (w != null) { return; } Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), false); Stetic.ActionGroupInfo group = (Stetic.ActionGroupInfo)CurrentNode.DataItem; GuiBuilderProject gproject = GtkDesignInfo.FromProject(project).GuiBuilderProject; string sfile = gproject.GetSourceCodeFile(group); if (sfile != null) { using (ConfirmWindowDeleteDialog dialog = new ConfirmWindowDeleteDialog(group.Name, sfile, group)) { if (dialog.Run() == (int)Gtk.ResponseType.Yes) { if (dialog.DeleteFile) { ProjectFile file = project.GetProjectFile(sfile); if (file != null) { project.Files.Remove(file); } } gproject.RemoveActionGroup(group); gproject.SaveProject(false); IdeApp.ProjectOperations.Save(project); } } } }
public string[] GetComponentFolders() { List <string> folders = new List <string> (); ProjectDom ctx = GuiBuilderProject.GetParserContext(); if (ctx != null) { foreach (IType type in ctx.Types) { foreach (IType part in type.Parts) { FilePath folder = part.CompilationUnit.FileName.ParentDirectory; string folderName = folder.FullPath.ToString(); if (!folders.Contains(folderName)) { folders.Add(folder); } } } } return(folders.ToArray()); }
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."); }
public DesignerPage (GuiBuilderProject gproject) { this.gproject = gproject; }