private void Form1_Load(object sender, EventArgs e) { AllSamples samples = null; string path = "FlexRadarIntro.Resources.config.xml"; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path)) { var ser = new XmlSerializer(typeof(AllSamples)); samples = ser.Deserialize(stream) as AllSamples; } Debug.Assert(samples != null); if (samples != null) { InitSamples(samples); } }
void InitSamples(AllSamples samples) { pnlSamples.Controls.Clear(); pnlSamples.RowCount = 0; pnlSamples.RowStyles.Clear(); Sample first = null; foreach (var g in samples.Groups) { var lbl = new Label() { Text = g.Name }; SetGroupStyle(lbl); pnlSamples.RowCount++; pnlSamples.RowStyles.Add(new RowStyle() { SizeType = SizeType.Absolute, Height = 36 }); pnlSamples.SetRow(lbl, pnlSamples.RowCount - 1); pnlSamples.Controls.Add(lbl); foreach (var s in g.Samples) { var ll = new LinkLabel() { Text = s.Name, Tag = s }; ll.LinkClicked += SampleLinkClicked; SetSampleStyle(ll); if (first == null) { first = s; _current = ll; ll.LinkBehavior = LinkBehavior.AlwaysUnderline; } pnlSamples.RowCount++; pnlSamples.RowStyles.Add(new RowStyle() { SizeType = SizeType.Absolute, Height = 24 }); pnlSamples.SetRow(ll, pnlSamples.RowCount - 1); pnlSamples.Controls.Add(ll); } } pnlSamples.RowCount++; pnlSamples.RowStyles.Add(new RowStyle() { SizeType = SizeType.Absolute, Height = 24 }); //pnlSamples.SetRow(ll, pnlSamples.RowCount - 1); //pnlSamples.Controls.Add(ll); if (first != null) { ShowSample(first); } }