Visual Studio 2010扩展:解析代码,渲染结果

本文关键字:代码 结果 Studio 2010 扩展 Visual | 更新日期: 2023-09-27 17:49:53

我目前正在做一个项目,它使用自定义渲染引擎,构建在XNA之上,绘制UI元素,如:按钮,标签,面板等。

发动机结构相对简单。有一个屏幕管理器,可以容纳多个游戏屏幕。游戏屏幕的实现扩展了一个叫做GameView的引擎基类。GameView类负责处理UI元素层次结构。

开发者可以在游戏视图中添加一些UI控件的方法非常简单,其逻辑受到ASP的启发。. NET控制层次结构。你必须重写LoadControls()方法,创建你想要的控件实例,并将它们添加到GameView控件集合中。

下面是一个例子:

    public override void LoadControls()
    {
        ImageFrame titleImage = new ImageFrame();
        titleImage.ID = "TitleImage";
        titleImage.Move(GameUI.Location(ViewLocation.CenterTop, -332, 4));
    titleImage.Width = 664;
    titleImage.Height = 166;
        titleImage.Image = "image_title";
        this.UI.Controls.Add(titleImage);
        ImageFrame freeImage = new ImageFrame();
        freeImage.ID = "FreeImage";
        freeImage.Move(GameUI.Location(ViewLocation.CenterTop, 160, 95));
        freeImage.Width = 170;
        freeImage.Height = 76;
        freeImage.Image = "image_free";
        freeImage.IsVisible = GameContext.Current.IsTrialMode;
        this.UI.Controls.Add(freeImage);
        Button playButton = new Button();
        playButton.ID = "PlayGameButton";
        playButton.Width = 216;
        playButton.Height = 96;
        playButton.Move(GameUI.Location(ViewLocation.CenterTop, -108, 130));
        playButton.Text = GameContext.Current.Dictionary[StringKeys.PlayGameButtonText];
        playButton.Font = FontNames.Floraless1;
        playButton.FontScale = 1.3f;
        playButton.FontPressedColor = Color.White * .8f;
        playButton.Click += new EventHandler<EventArgs>(PlayGameButton_Click);
        this.UI.Controls.Add(playButton);
    }

用代码创建UI真的很容易,但是当你需要创建复杂的布局时,很难弄清楚结果。我想知道是否有可能为VS2010开发一个自定义扩展,渲染我的GameView控件层次结构的结果"视图"。我不需要创建UI设计器。我只需要在代码编辑器中阅读一些手写的代码,并实时渲染结果,而我还在visual studio(不运行应用程序)。

简而言之,它是有可能扩展visual studio 2010创建一个自定义的"设计器"解析。cs代码在实时结束产生渲染输出?

Visual Studio 2010扩展:解析代码,渲染结果

创建自定义Visual Studio设计器