void HandleButtons(GuiConfigDB conf) { if (conf.HideAllButtons.IsExplicit() && conf.HideAllButtons) { HideAllButtons(); } // apply default style if exists GuiControlStyle defbutstl = conf.GetControlStyle("DefaultButton"); if (defbutstl != null) { DefaultButtonStyle = defbutstl; } GuiControlStyle deftitstl = conf.GetControlStyle("DefaultTitle"); foreach (KeyValuePair <String, ctlImageButton> pair in Buttons) { ctlImageButton butt = pair.Value; if (butt is ctlTitle) { if (deftitstl != null) { butt.ApplyStyle(deftitstl); } } else { if (defbutstl != null) { butt.ApplyStyle(defbutstl); } } } foreach (KeyValuePair <string, GuiButton> pair in conf.GuiButtonsDict) { HandleButton(conf, pair.Value); } }
void HandleButtonStyle(XmlNode xnode) { string name = GetStrParam(xnode, "name", "DefaultButton"); ControlStyle bt = GetControlStyle(name); if (bt == null) { bt = new ControlStyle(); bt.Name = name; ControlStyles[name] = bt; bt.SetDefault(); } UpdateStyle(xnode, bt); if (name == "DefaultButton") { foreach (KeyValuePair <String, ctlImageButton> pair in Buttons) { ctlImageButton butt = pair.Value; butt.ApplyStyle(bt); } } }
void HandleButton(XmlNode buttnode) { string name = GetStrParam(buttnode, "name", null); if (name == null) { return; } if (!Buttons.ContainsKey(name)) { // create a new empty button AddButton(name, new ctlImageButton()); Buttons[name].BringToFront(); } ctlImageButton butt = Buttons[name]; // butt.Visible = true; butt.Visible = GetBoolParam(buttnode, "visible", true); butt.GuiAnchor = FixDockingVal(GetStrParam(buttnode, "dock", butt.GuiAnchor)); butt.Gapx = GetIntParam(buttnode, "x", butt.Gapx); butt.Gapy = GetIntParam(buttnode, "y", butt.Gapy); butt.Width = GetIntParam(buttnode, "w", butt.Width); butt.Height = GetIntParam(buttnode, "h", butt.Height); butt.StyleName = GetStrParam(buttnode, "style", butt.StyleName); butt.OnClickCallback = GetStrParam(buttnode, "click", butt.OnClickCallback); ControlStyle bstl = GetControlStyle(butt.StyleName); if (bstl != null) { butt.GLVisible = bstl.glMode; butt.ApplyStyle(bstl); } //butt.GLVisible = GetBoolParam(buttnode, "gl", butt.GLVisible); string imgname = GetStrParam(buttnode, "image", null); if (imgname != null) { butt.GLImage = imgname; butt.Image = GetImageParam(buttnode, "image", null); } butt.CheckImage = GetImageParam(buttnode, "check", butt.CheckImage); // add the ability to add buttons in various named parents // this will allow adding buttons to toolbar from plugins string action = GetStrParam(buttnode, "action", "none"); // telling something to happen to this control if (action.Contains("remove")) // this handles removing a control from it's parent { // remove this control from it's parent if (butt.Parent != null) { butt.Parent.Controls.Remove(butt); butt.Parent = null; } } else if (action.Contains("addto")) // this handles adding a new control to a parent control { // Get the name of the parent string parentname = GetStrParam(buttnode, "parent", ""); if (parentname == null) { return; } if (parentname.Length == 0) { return; } //find the parent Control ctlParent = Controls[parentname]; if (ctlParent == null) { DebugLogger.Instance().LogWarning("Button parent now found: " + parentname); return; } { ctlParent.Controls.Add(butt); } } }