public void Build(Object sender, EventArgs e) { XmlTextReader reader; reader = new XmlTextReader(mToolbarFile); reader.WhitespaceHandling = WhitespaceHandling.None; reader.MoveToContent(); bool shouldBuildNewRow = true; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case "toolstrip": // The next <toolbar/> we encounter should be created on a new row. shouldBuildNewRow = true; break; case "toolbar": String[] tbvalues = new String[4] { "", "", "", "" }; String[] tbnames = new String[4] { "id", "label", "description", "visible" }; for (int i = 0; i < tbnames.Length; ++i) { if (reader.MoveToAttribute(tbnames[i]) && reader.ReadAttributeValue()) { tbvalues[i] = reader.Value; // XXX need to handle entities } reader.MoveToElement(); } String key = tbvalues[0]; String label = tbvalues[1]; bool visible = tbvalues[3] == "true"; // Create and add a new toolbar. mToolBar.Appearance = ToolBarAppearance.Flat; mToolBar.ButtonClick += new ToolBarButtonClickEventHandler(this.OnCommand); mForm.Controls.Add(mToolBar); //mCoolBar.Bands.Add(-1, key, label, new Object(), true, mToolBar, true); shouldBuildNewRow = false; break; case "toolbarseparator": { if (mToolBar != null) { ToolBarButton button = new ToolBarButton(); button.Style = ToolBarButtonStyle.Separator; mToolBar.Buttons.Add(button); } break; } case "toolbarbutton": { if (mToolBar != null) { String[] tbbvalues = new String[3] { "", "", "" }; String[] tbbnames = new String[3] { "label", "icon", "command" }; for (int i = 0; i < tbbnames.Length; ++i) { if (reader.MoveToAttribute(tbbnames[i]) && reader.ReadAttributeValue()) { tbbvalues[i] = reader.Value; // XXX need to handle entities } reader.MoveToElement(); } ToolBarButton button = new CommandButtonItem(tbbvalues[1]); button.Text = tbbvalues[0]; mToolBar.Buttons.Add(button); } break; } } } } }
public void Build(Object sender, EventArgs e) { XmlTextReader reader; reader = new XmlTextReader(mToolbarFile); reader.WhitespaceHandling = WhitespaceHandling.None; reader.MoveToContent(); bool shouldBuildNewRow = true; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case "toolstrip": // The next <toolbar/> we encounter should be created on a new row. shouldBuildNewRow = true; break; case "toolbar": String[] tbvalues = new String[4] {"", "", "", ""}; String[] tbnames = new String[4] {"id", "label", "description", "visible"}; for (int i = 0; i < tbnames.Length; ++i) { if (reader.MoveToAttribute(tbnames[i]) && reader.ReadAttributeValue()) tbvalues[i] = reader.Value; // XXX need to handle entities reader.MoveToElement(); } String key = tbvalues[0]; String label = tbvalues[1]; bool visible = tbvalues[3] == "true"; // Create and add a new toolbar. mToolBar.Appearance = ToolBarAppearance.Flat; mToolBar.ButtonClick += new ToolBarButtonClickEventHandler(this.OnCommand); mForm.Controls.Add(mToolBar); //mCoolBar.Bands.Add(-1, key, label, new Object(), true, mToolBar, true); shouldBuildNewRow = false; break; case "toolbarseparator": { if (mToolBar != null) { ToolBarButton button = new ToolBarButton(); button.Style = ToolBarButtonStyle.Separator; mToolBar.Buttons.Add(button); } break; } case "toolbarbutton": { if (mToolBar != null) { String[] tbbvalues = new String[3] {"", "", ""}; String[] tbbnames = new String[3] {"label", "icon", "command"}; for (int i = 0; i < tbbnames.Length; ++i) { if (reader.MoveToAttribute(tbbnames[i]) && reader.ReadAttributeValue()) tbbvalues[i] = reader.Value; // XXX need to handle entities reader.MoveToElement(); } ToolBarButton button = new CommandButtonItem(tbbvalues[1]); button.Text = tbbvalues[0]; mToolBar.Buttons.Add(button); } break; } } } } }