コード例 #1
0
        internal static string BindToClass(MonoDevelop.Projects.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.GetAllTypesInMainAssembly())
            {
                if (IsValidClass(cls))
                {
                    list.Add(cls.GetFullName());
                }
            }

            // 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));
        }