Beispiel #1
0
        public void Load()
        {
            if (File.Exists("toolbarsettings.xml"))
            {
                using (Stream s = File.OpenRead("toolbarsettings.xml"))
                {
                    ToolbarSettings tbs = SER.Deserialize(s) as ToolbarSettings;

                    if (tbs != null)
                    {
                        toolbar.TopToolStripPanel.SuspendLayout();
                        foreach (ToolbarSetting tbss in tbs.Settings)
                        {
                            foreach (ToolStrip ts in toplevel)
                            {
                                if (ts.Name == tbss.Name)
                                {
                                    ts.Size     = tbss.Bounds.Size;
                                    ts.Location = tbss.Bounds.Location;
                                    //ts.Bounds = tbss.Bounds;
                                }
                            }
                        }
                        toolbar.TopToolStripPanel.ResumeLayout();
                    }
                }
            }
        }
Beispiel #2
0
        public void Save()
        {
            ToolbarSettings tbs = new ToolbarSettings();

            foreach (ToolStrip ts in toplevel)
            {
                ToolbarSetting tbss = new ToolbarSetting();
                if (ts.Visible)
                {
                    tbss.Name   = ts.Name;
                    tbss.Bounds = ts.Bounds;
                    tbs.Settings.Add(tbss);
                }
            }

            using (Stream s = File.Create("toolbarsettings.xml"))
            {
                SER.Serialize(s, tbs);
            }
        }