void HandleControlStyle(XmlNode xnode)
        {
            string       name = GetStrParam(xnode, "name", "DefaultControl");
            ControlStyle ct   = GetControlStyle(name);

            if (ct == null)
            {
                ct                  = new ControlStyle();
                ct.Name             = name;
                ControlStyles[name] = ct;
                ct.SetDefault();
            }
            UpdateStyle(xnode, ct);
            if (name == "DefaultControl")
            {
                //foreach (KeyValuePair<String, ctlUserPanel> pair in Controls)
                foreach (KeyValuePair <String, Control> pair in Controls)
                {
                    if (pair.Value is ctlUserPanel)
                    {
                        ctlUserPanel ctl = (ctlUserPanel)pair.Value;
                        ctl.ApplyStyle(DefaultControlStyle);
                    }
                    else
                    {
                        // apply the style by recursing through the object
                        ApplyStyleRecurse(pair.Value, DefaultControlStyle);
                    }
                }
            }
        }
Esempio n. 2
0
        void HandleControls(GuiConfigDB conf)
        {
            if (conf.HideAllControls.IsExplicit() && conf.HideAllControls)
            {
                HideAllControls();
            }
            // apply default style if exists
            GuiControlStyle stl = conf.GetControlStyle("DefaultControl");

            if (stl != null)
            {
                DefaultControlStyle = stl;
                foreach (KeyValuePair <String, Control> pair in Controls)
                {
                    if (pair.Value is ctlUserPanel)
                    {
                        ctlUserPanel ctl = (ctlUserPanel)pair.Value;
                        ctl.ApplyStyle(stl);
                    }
                    else
                    {
                        // apply the style by recursing through the object
                        ApplyStyleRecurse(pair.Value, stl);
                    }
                }
            }

            foreach (KeyValuePair <string, GuiControl> pair in conf.GuiControlsDict)
            {
                HandleControl(conf, pair.Value);
            }
        }
 void LayoutControls(int w, int h)
 {
     foreach (KeyValuePair <String, Control> pair in Controls)
     {
         if (pair.Value is ctlUserPanel)
         {
             ctlUserPanel ctl = (ctlUserPanel)pair.Value;
             if (ctl.GuiAnchor == null)
             {
                 continue;
             }
             int px = GetPosition(0, w, ctl.Width, ctl.Gapx, ctl.GuiAnchor[1]);
             int py = GetPosition(0, h, ctl.Height, ctl.Gapy, ctl.GuiAnchor[0]);
             ctl.Location = new System.Drawing.Point(px, py);
         }
         else
         {
         }
     }
 }
        void HandleControl(XmlNode ctlnode)
        {
            string name = GetStrParam(ctlnode, "name", null);

            if (name == null)
            {
                return;
            }
            if (!Controls.ContainsKey(name))
            {
                return;
            }

            //ctlUserPanel ctl = Controls[name];
            Control ct = Controls[name];

            if (ctlnode.Attributes.GetNamedItem("visible") != null)
            {
                ct.Visible = GetBoolParam(ctlnode, "visible", ct.Visible);
            }
            ct.Width  = GetIntParam(ctlnode, "w", ct.Width);
            ct.Height = GetIntParam(ctlnode, "h", ct.Height);
            //load some control locations as well,
            int px, py;

            px = GetIntParam(ctlnode, "px", ct.Location.X);
            py = GetIntParam(ctlnode, "py", ct.Location.Y);
            Point pt = new Point(px, py);

            ct.Location = pt;
            // load docking style


            string action = GetStrParam(ctlnode, "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 (ct.Parent != null)
                {
                    ct.Parent.Controls.Remove(ct);
                    ct.Parent = null;
                }
            }
            else if (action.Contains("hide")) // this handles hiding
            {
                // hide this control
                ct.Hide();
            }
            else if (action.Contains("addto")) // this handles adding a new control to a parent control
            {
                // Get the name of the parent
                string parentname = GetStrParam(ctlnode, "parent", "");
                if (parentname == null)
                {
                    return;
                }
                if (parentname.Length == 0)
                {
                    return;
                }
                //find the parent
                Control ctlParent = Controls[parentname];
                if (ctlParent == null)
                {
                    DebugLogger.Instance().LogWarning("Control parent now found: " + parentname);
                    return;
                }
                {
                    ctlParent.Controls.Add(ct);
                }
            }
            String       styleName = GetStrParam(ctlnode, "style", null);
            ControlStyle style     = GetControlStyle(styleName);

            if (ct is ctlUserPanel)
            {
                ctlUserPanel ctl = (ctlUserPanel)ct;
                ctl.GuiAnchor = FixDockingVal(GetStrParam(ctlnode, "dock", ctl.GuiAnchor));
                ctl.Gapx      = GetIntParam(ctlnode, "x", ctl.Gapx);
                ctl.Gapy      = GetIntParam(ctlnode, "y", ctl.Gapy);
                if (styleName != null)
                {
                    ctl.StyleName = styleName;
                    if (style != null)
                    {
                        ctl.GLVisible = style.glMode;
                        ctl.ApplyStyle(style);
                    }
                }
                //ctl.GLVisible = GetBoolParam(ctlnode, "gl", false);
                if (ctl.GLVisible)
                {
                    ctl.GLBackgroundImage = GetStrParam(ctlnode, "shape", ctl.GLBackgroundImage);
                }
                else
                {
                    ctl.bgndPanel.imageName = GetStrParam(ctlnode, "shape", ctl.bgndPanel.imageName);
                }
            }
            else
            {
                if (style != null)
                {
                    ApplyStyleRecurse(ct, style);
                }
            }
        }
Esempio n. 5
0
        void HandleControl(GuiConfigDB conf, GuiControl gctl)
        {
            if (!Controls.ContainsKey(gctl.name))
            {
                return;
            }

            Control ct = Controls[gctl.name]; // find the existing control

            if (gctl.visible.IsExplicit())
            {
                ct.Visible = gctl.visible.GetVal();
            }
            ct.Width  = gctl.w.GetIfExplicit(ct.Width);
            ct.Height = gctl.h.GetIfExplicit(ct.Height);
            //load some control locations as well,

            if (gctl.px.IsExplicit() || gctl.py.IsExplicit())
            {
                int px, py;
                px = gctl.px.GetIfExplicit(ct.Location.X);
                py = gctl.py.GetIfExplicit(ct.Location.Y);
                Point pt = new Point(px, py);
                ct.Location = pt;
            }

            // load docking style
            if (gctl.action.IsExplicit())
            {
                string action = gctl.action;   // 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 (ct.Parent != null)
                    {
                        ct.Parent.Controls.Remove(ct);
                        ct.Parent = null;
                    }
                }
                else if (action.Contains("hide")) // this handles hiding
                {
                    // hide this control, do not remove it from the parent
                    ct.Hide();
                }
                else if (action.Contains("show")) // this handles showing
                {
                    // show this control
                    ct.Show();
                }
                else if (action.Contains("addto")) // this handles adding a new/existing control to a parent control
                {
                    // Get the name of the parent
                    // Get the name of the parent
                    string parentname = gctl.parent;
                    if (gctl.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            AddControlToParent(ct, ctlParent);
                        }
                        else
                        {
                            DebugLogger.Instance().LogWarning("Control parent not found: " + parentname);
                        }
                    }
                }
            }

            String          styleName = gctl.style.GetIfValid(null);
            GuiControlStyle style     = conf.GetControlStyle(styleName);

            if (ct is ctlUserPanel)
            {
                ctlUserPanel ctl = (ctlUserPanel)ct;
                ctl.GuiAnchor = gctl.dock.GetIfExplicit(ctl.GuiAnchor);
                ctl.Gapx      = gctl.x.GetIfExplicit(ctl.Gapx);
                ctl.Gapy      = gctl.y.GetIfExplicit(ctl.Gapy);
                if (styleName != null)
                {
                    ctl.StyleName = styleName;
                    if (style != null)
                    {
                        ctl.GLVisible = style.glMode;
                        ctl.ApplyStyle(style);
                    }
                }
                //ctl.GLVisible = GetBoolParam(ctlnode, "gl", false);
                if (ctl.GLVisible)
                {
                    ctl.GLBackgroundImage = gctl.BorderShape.GetIfExplicit(ctl.GLBackgroundImage);
                }
                else
                {
                    ctl.bgndPanel.imageName = gctl.BorderShape.GetIfExplicit(ctl.bgndPanel.imageName);
                }
            }
            else
            {
                if (style != null)
                {
                    ApplyStyleRecurse(ct, style);
                }
            }
        }
Esempio n. 6
0
 public void AddControl(string name, ctlUserPanel ctl)
 {
     Controls[name] = ctl;
     if ((ctl.Parent == null) && (mTopLevelControl != null))
         mTopLevelControl.Controls.Add(ctl);
 }
 public void AddControl(string name, ctlUserPanel ctl)
 {
     Controls[name] = ctl;
 }