internal static void InternalLoadSettings(Control owner) { //owner内のToolStripPanelを探す List <Control> toolStripPanels = new List <Control>(); FindControls(typeof(ToolStripPanel), owner.Controls, ref toolStripPanels); foreach (ToolStripPanel tsp in toolStripPanels) { if (string.IsNullOrEmpty(tsp.Name)) { continue; } //ToolStripPanelの情報を読み込む string skey = owner.GetType().FullName + "." + tsp.Name; ToolStripSettings settings = new ToolStripSettings(skey); List <List <ToolStripInfo> > rowsList = settings.Rows; //ToolStripPanel内のToolStripを一時的にすべて削除する Dictionary <string, SpeechCast.Controls.MyToolStrip> toolstrips = new Dictionary <string, SpeechCast.Controls.MyToolStrip>(); foreach (Control c in tsp.Controls) { toolstrips.Add(c.Name, (SpeechCast.Controls.MyToolStrip)c); } tsp.Controls.Clear(); for (int i = 0; i < rowsList.Count; i++) { foreach (ToolStripInfo info in rowsList[i]) { //位置を設定するToolStripを探す SpeechCast.Controls.MyToolStrip ts = null; if (toolstrips.ContainsKey(info.Name)) { ts = toolstrips[info.Name]; } else { Control[] tss = owner.Controls.Find(info.Name, true); if ((tss != null) && (tss.Length == 1) && (tss[0] is ToolStrip)) { ts = (SpeechCast.Controls.MyToolStrip)tss[0]; } } //ToolStripの位置を変更する if (ts != null) { tsp.Join(ts, info.Location); } } } } }
public ToolStripInfo(SpeechCast.Controls.MyToolStrip ts) { this.Name = ts.Name; this.Location = ts.Location; }