예제 #1
0
 public MpeScreen(MpeScreen window) : base(window)
 {
     MpeLog.Debug("MpeScreen(window)");
     AllowDrop      = true;
     allowOverlay   = window.allowOverlay;
     defaultControl = window.defaultControl;
     screenSize     = window.screenSize;
 }
예제 #2
0
 public MpeScreen() : base()
 {
     MpeLog.Debug("MpeScreen()");
     Type                  = MpeControlType.Screen;
     MpeScreen             = this;
     AllowDrop             = true;
     backImage.Description = "Default Image - Window Background";
     backImage.Id          = 1;
     backImage.MpeScreen   = this;
     backImage.Embedded    = true;
     screenSize            = MpeScreenSize.PAL;
     defaultControl        = 0;
     allowOverlay          = true;
     screenType            = MpeScreenType.Window;
     controlLock.Location  = true;
     controlLock.Size      = true;
 }
예제 #3
0
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeScreen.Load()");
            this.parser = parser;
            XPathNodeIterator i = null;

            if (iterator == null)
            {
                throw new MpeParserException("The given iterator is invalid.");
            }
            if (iterator.Current.Name == "controls")
            {
                Width      = parser.GetInt(iterator, "skin/width", Width);
                Height     = parser.GetInt(iterator, "skin/height", Height);
                ScreenSize = MpeScreenSize.FromResolution(Width, Height);
                i          = iterator.Current.Select("control[type='image']");
                if (i.MoveNext())
                {
                    backImage.Load(i, parser);
                }
                Id = 0;
            }
            else if (iterator.Current.Name == "window")
            {
                string stype = parser.GetString(iterator, "type", "");
                if (stype == MpeScreenType.Dialog.ToString().ToLower())
                {
                    screenType = MpeScreenType.Dialog;
                }
                else if (stype == MpeScreenType.OnScreenDisplay.ToString().ToLower())
                {
                    screenType = MpeScreenType.OnScreenDisplay;
                }
                else
                {
                    screenType = MpeScreenType.Window;
                }

                Id             = parser.GetInt(iterator, "id", Id);
                AllowOverlay   = parser.GetBoolean(iterator, "allowoverlay", AllowOverlay);
                AutohideTopbar = parser.GetBoolean(iterator, "autohidetopbar", AutohideTopbar);
                DefaultControl = parser.GetInt(iterator, "defaultcontrol", DefaultControl);

                if (screenType == MpeScreenType.Dialog)
                {
                    // Initialize the default screen
                    MpeScreen defaultScreen = (MpeScreen)parser.GetControl(MpeControlType.Screen);
                    if (defaultScreen == null)
                    {
                        throw new MpeParserException("Reference screen was never initialized and loaded");
                    }
                    TextureBack = defaultScreen.TextureBack;
                    Size        = defaultScreen.Size;
                    AllowDrop   = false;
                    // First create the dialog group

                    MpeGroup dialog = (MpeGroup)parser.CreateControl(MpeControlType.Group);
                    dialog.Id          = DialogGroupId;
                    dialog.LayoutStyle = MpeLayoutStyle.Grid;
                    dialog.Parser      = Parser;
                    Controls.Add(dialog);

                    // Add all the controls
                    i = iterator.Current.Select("controls/control");
                    bool first = true;
                    while (i.MoveNext())
                    {
                        string s = parser.GetString(i, "type", "");
                        if (first && s == MpeControlType.Image.ToString())
                        {
                            first = false;
                            dialog.TextureBackImage.Load(i, parser);
                            dialog.Size     = dialog.TextureBackImage.Size;
                            dialog.Location = dialog.TextureBackImage.Location;
                        }
                        else
                        {
                            XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
                            if (typeIterator.MoveNext())
                            {
                                MpeControlType type = MpeControlType.Create(typeIterator.Current.Value);
                                MpeControl     c    = parser.CreateControl(type);
                                dialog.Controls.Add(c);
                                c.Load(i, parser);
                                c.BringToFront();
                            }
                        }
                    }
                }
                else
                {
                    AllowDrop = true;
                    i         = iterator.Current.Select("controls/control");
                    bool first = true;
                    while (i.MoveNext())
                    {
                        string s = parser.GetString(i, "type", "");
                        if (first && s == MpeControlType.Image.ToString())
                        {
                            backImage.Load(i, parser);
                        }
                        else
                        {
                            XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
                            if (typeIterator.MoveNext())
                            {
                                MpeControlType type = MpeControlType.Create(typeIterator.Current.Value);
                                MpeControl     c    = parser.CreateControl(type);
                                Controls.Add(c);
                                c.Load(i, parser);
                                c.BringToFront();
                            }
                        }
                        first = false;
                    }
                }
            }
            Modified = false;
        }