Beispiel #1
0
        internal static string BindToClass(Project project, Stetic.ActionGroupInfo group)
        {
            GuiBuilderProject gproject = GtkDesignInfo.FromProject(project).GuiBuilderProject;
            string            file     = gproject.GetSourceCodeFile(group);

            if (file != null)
            {
                return(file);
            }

            // Find the classes that could be bound to this design

            ArrayList list = new ArrayList();
            var       ctx  = gproject.GetParserContext();

            foreach (var cls in ctx.MainAssembly.GetAllTypeDefinitions())
            {
                if (IsValidClass(cls))
                {
                    list.Add(cls.FullName);
                }
            }

            // Ask what to do

            using (BindDesignDialog dialog = new BindDesignDialog(group.Name, list, project.BaseDirectory))
            {
                if (!dialog.Run())
                {
                    return(null);
                }

                if (dialog.CreateNew)
                {
                    CreateClass(project, (Stetic.ActionGroupComponent)group.Component, dialog.ClassName, dialog.Namespace, dialog.Folder);
                }

                string fullName = dialog.Namespace.Length > 0 ? dialog.Namespace + "." + dialog.ClassName : dialog.ClassName;
                group.Name = fullName;
            }
            return(gproject.GetSourceCodeFile(group));
        }
        public static async Task <ActionGroupView> OpenActionGroup(Project project, Stetic.ActionGroupInfo group)
        {
            GuiBuilderProject p    = GtkDesignInfo.FromProject(project).GuiBuilderProject;
            string            file = p != null?p.GetSourceCodeFile(group) : null;

            if (file == null)
            {
                file = ActionGroupDisplayBinding.BindToClass(project, group);
            }

            Document doc = await IdeApp.Workbench.OpenDocument(file, null, true);

            if (doc != null)
            {
                ActionGroupView view = doc.GetContent <ActionGroupView> ();
                if (view != null)
                {
                    view.ShowDesignerView();
                    return(view);
                }
            }
            return(null);
        }