示例#1
0
 void HandleButtonCreation(GuiConfigDB conf)
 {
     foreach (KeyValuePair <string, GuiButton> pair in conf.GuiButtonsDict)
     {
         GuiButton gbtn = pair.Value;
         if (!Buttons.ContainsKey(gbtn.name))
         {
             // create a new empty button
             ctlImageButton btn = new ctlImageButton();
             btn.Name = gbtn.name;
             AddButton(btn);
             btn.BringToFront();
         }
     }
 }
示例#2
0
 void HandleButtonCreation(GuiConfigDB conf)
 {
     foreach (KeyValuePair<string, GuiButton> pair in conf.GuiButtonsDict)
     {
         GuiButton gbtn = pair.Value;
         if (!Buttons.ContainsKey(gbtn.name))
         {
             // create a new empty button
             ctlImageButton btn = new ctlImageButton();
             btn.Name = gbtn.name;
             AddButton(btn);
             btn.BringToFront();
         }
     }
 }
示例#3
0
        Control CreateTabItem(GuiLayout gl, FlowLayoutPanel flp)
        {
            Control shownControl = null;

            if (gl.subLayouts.Count == 1)
            {
                shownControl = CreateLayoutRecurse(gl.subLayouts[0]);
            }
            else
            {
                shownControl      = new Panel();
                shownControl.Name = gl.name + "Content";
                //AddControl(shownControl);
                Controls[shownControl.Name] = shownControl;
                CreateSublayouts(gl, shownControl);
            }
            if (shownControl == null)
            {
                return(null);
            }

            shownControl.Dock    = DockStyle.Fill;
            shownControl.Visible = gl.isSelected.IsExplicit() && gl.isSelected;

            Control tabctl = null;

            if (gl.control.IsExplicit())
            {
                tabctl = GetControlOrButton(gl.control);
            }
            if (tabctl == null)
            {
                string cmd = String.Format("GMActivateTab {0} {1}", gl.name, shownControl.Name);
                if (!gl.text.IsExplicit())
                {
                    // if no text, create image button
                    AddButton(gl.name, new ctlImageButton());
                    ctlImageButton butt = Buttons[gl.name];
                    butt.BringToFront();
                    if (gl.image.IsExplicit())
                    {
                        butt.GLImage = gl.image;
                        butt.Image   = guiConf.GetImage(gl.image, null);
                    }
                    butt.OnClickCallback = cmd;
                    tabctl = butt;
                }
                else
                {
                    // text valid, create title control
                    ctlTitle ttl = new ctlTitle();
                    ttl.Image           = guiConf.GetImage(gl.image, null);
                    ttl.Text            = gl.text;
                    ttl.Name            = gl.name;
                    ttl.OnClickCallback = cmd;
                    ttl.CheckImage      = guiConf.GetImage("buttChecked", null);
                    ttl.Size            = new Size(180, 40);
                    Controls[gl.name]   = ttl;
                    tabctl = ttl;
                }
                CheckTab(tabctl, gl.isSelected.IsExplicit() && gl.isSelected);
            }
            flp.Controls.Add(tabctl);
            return(shownControl);
        }
        void HandleButton(GuiConfigDB conf, GuiButton gbtn)
        {
            if (!Buttons.ContainsKey(gbtn.name))
            {
                return; // should not happen!
            }
            ctlImageButton butt = Buttons[gbtn.name];

//            butt.Visible = true;
            butt.Visible         = gbtn.visible.GetIfExplicit(true);
            butt.GuiAnchor       = gbtn.dock.GetIfExplicit(butt.GuiAnchor);
            butt.Gapx            = gbtn.x.GetIfExplicit(butt.Gapx);
            butt.Gapy            = gbtn.y.GetIfExplicit(butt.Gapy);
            butt.Width           = gbtn.w.GetIfExplicit(butt.Width);
            butt.Height          = gbtn.h.GetIfExplicit(butt.Height);
            butt.StyleName       = gbtn.style.GetIfExplicit(butt.StyleName);
            butt.OnClickCallback = gbtn.onClickCmd.GetIfExplicit(butt.OnClickCallback);
            GuiControlStyle bstl = conf.GetControlStyle(butt.StyleName);

            if (gbtn.checkState.IsExplicit())
            {
                butt.Checked = gbtn.checkState;
            }
            if (bstl != null)
            {
                butt.GLVisible = bstl.glMode;
            }
            if (gbtn.image.IsExplicit())
            {
                //butt.GLImage = gbtn.image;
                butt.Image = conf.GetImage(gbtn.image, null);
            }
            butt.CheckImage = conf.GetImage(gbtn.checkImage, butt.CheckImage);


            // add the ability to add buttons in various named parents
            // this will allow adding buttons to toolbar from plugins
            if (gbtn.action.IsExplicit())
            {
                string action = gbtn.action;
                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 = gbtn.parent;
                    if (gbtn.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            AddControlToParent(butt, ctlParent);
                            butt.BringToFront();
                        }
                        else
                        {
                            DebugLogger.Instance()
                            .LogWarning(
                                UVDLPApp.Instance()
                                .resman.GetString("ButtonParentNotFound", UVDLPApp.Instance().cul) + parentname);
                        }
                    }
                }
            }
        }