views:

142

answers:

0

I seem to be caught between the vs2008 settings wizard and the ToolStripManager. Here is what I want to do... During development I locate about seven toolbars each in one of three toolstrippanels in a layout that is easy for the user. Those settings are recorded in the user.config in my development folder. The ToolStripManager reads and writes those locations from and to said user.config while I develop.

When I want to deploy, how do I make those locations persist as the default upon install such that the user initially sees my chosen layout?

I've tried copying the XML from the development user.config into app.exe.config but the wizard appears to be taking the settings in the project and rewriting the app.exe.config to include only those settings. Do I really have to add all the ToolStripManager settings by hand into the application scope settings wizard?

I've read M Sorens where I learned about ToolStripManager and Upgrade; but he just misses describing this scenario.

Here's some code I use:

    private void Form1_Load(object sender, EventArgs e)
    {
        // preserve user settings from prior version
        if (Properties.Settings.Default.FirstRun)
        {
            Properties.Settings.Default.Upgrade();
            Properties.Settings.Default.FirstRun = false;
        }
        ToolStripManager.LoadSettings(this);

        // ok.  yes.  maybe this is hacky
        foreach (ToolStrip t in Strips.TopToolStripPanel.Controls)
        {
            System.Drawing.Point p = t.Location;
            p.Y = 1;
            t.Location = p;
        }
    }

    private void Strips_TopToolStripPanel_DoubleClick(object sender, EventArgs e)
    {
        if (Strips.TopToolStripPanel.Locked)
        {
            Strips.TopToolStripPanel.Locked = false;
            Strips.LeftToolStripPanel.Locked = false;
            Strips.RightToolStripPanel.Locked = false;
        }
        else
        {
            Strips.TopToolStripPanel.Locked = true;
            Strips.LeftToolStripPanel.Locked = true;
            Strips.RightToolStripPanel.Locked = true;

            ToolStripManager.SaveSettings(this);
        }
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (!Strips.TopToolStripPanel.Locked)
        {
            ToolStripManager.SaveSettings(this);
        }
    }

It seems like this is the main use case for settings on toolbars but I can't find a description anywhere.

Guy