Winform Surface Designer 如何从组件序列化器生成 resx 文件

问题描述

我目前正在使用 System.ComponentModel.Design.Serialization 命名空间来生成 C# 代码。此代码稍后由另一个应用程序编译。

        var manager = new DesignerSerializationManager(host);
        using (manager.CreateSession())
        {
            var serializer = (TypeCodeDomSerializer)manager.GetSerializer(root.GetType(),typeof(TypeCodeDomSerializer));

            type = serializer.Serialize(manager,root,host.Container.Components);
....
        }

这将生成如下 C# 代码

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestForm));
        this.SuspendLayout();
        // 
        // TestForm
        // 
        this.AutoScaleDimensions = new System.Drawing.Sizef(6F,13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BackgroundImage = ((System.Drawing.Image)(resources.Getobject("$this.BackgroundImage")));
        this.ClientSize = new System.Drawing.Size(800,450);
        this.Name = "TestForm";
        this.Text = "Form1";
        this.ResumeLayout(false);

    }

现在我想看看我是否可以创建一个 resx 文件来补充生成代码。 正如您所看到的:

this.BackgroundImage = ((System.Drawing.Image)(resources.Getobject("$this.BackgroundImage")));

这引用了 resx 文件,但如果您尝试编译此行,则会丢失一个 resx 文件。 我一直在寻找用于执行此操作的设计图面的序列化程序,但我找不到一次。

如果有人对此有任何了解,也许可以为我指明正确的方向?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)