dotnet/winforms

Incorrect toolbar location when restored via `ToolStripManager.LoadSettings`

Open

#4,449 建立於 2021年1月10日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)C# (922 fork)batch import
:beetle: bugarea-Layoutarea-controls-StripControlshelp wantedtenet-compatibility

倉庫指標

Star
 (4,100 star)
PR 合併指標
 (平均合併 14天 22小時) (30 天內合併 56 個 PR)

描述

Presumably all versions:

  • .NET Framework: 4.6.1 (tested)
  • .NET Version: 5.0 (tested)

Problem description:

Originally reported in https://github.com/gitextensions/gitextensions/issues/8680.

If an application has multiple toolbars, and those are placed at an arbitrary location and persisted via ToolStripManager.SaveSettings, not all toolbars will be correctly located once ToolStripManager.LoadSettings is called. E.g. on save: image

On load: image

Expected behavior:

The location of the toolbars persisted in the config must be preserved.

Minimal repro:

  1. clone https://github.com/RussKie/Test-ToolStripLoad
  2. Run the app, align both toolbars to the left one under another.
  3. Stop the app.
  4. Open the user.config file, located somethere at C:\Users\<user>\AppData\Local\ToolstripLoad\ToolstripLoad_Url_<random string>\1.0.0.0, check that both toolbars' locations are like this:
        <System.Windows.Forms.ToolStripSettings.toolsettings.ToolStripFilters>
            <setting name="Name" serializeAs="String">
                <value>ToolStripFilters</value>
            </setting>
            <setting name="Location" serializeAs="String">
                <value>7, 25</value>
            </setting>
        </System.Windows.Forms.ToolStripSettings.toolsettings.ToolStripFilters>
        <System.Windows.Forms.ToolStripSettings.toolsettings.ToolStripMain>
            <setting name="Name" serializeAs="String">
                <value>ToolStripMain</value>
            </setting>
            <setting name="Location" serializeAs="String">
                <value>7, 0</value>
            </setting>
        </System.Windows.Forms.ToolStripSettings.toolsettings.ToolStripMain>
  1. Run the app again and observe the bottom toolbar shifted by few pixels to the right.
  2. Close the app and see that the location value for ToolStripFilters has changed.

貢獻者指南