コード例 #1
0
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeImage.Load()");
            this.parser = parser;
            AutoSize    = false;
            base.Load(iterator, parser);
            Texture = parser.GetImageFile(iterator, "texture", Texture);
            tags.Remove("texture");
            if (parser.GetInt(iterator, "width", -1) < 0 || parser.GetInt(iterator, "height", -1) < 0)
            {
                if (Texture == null)
                {
                    AutoSize = false;
                    Size     = new Size(64, 64);
                }
                else
                {
                    AutoSize = true;
                }
            }
            Centered = parser.GetBoolean(iterator, "centered", Centered);
            tags.Remove("centered");
            Filtered = parser.GetBoolean(iterator, "filtered", Filtered);
            tags.Remove("filtered");
            KeepAspectRatio = parser.GetBoolean(iterator, "keepaspectratio", KeepAspectRatio);
            tags.Remove("keepaspectratio");
            ColorKey = parser.GetInt(iterator, "colorkey", ColorKey);
            tags.Remove("colorkey");

            Modified = false;
        }
コード例 #2
0
ファイル: MpeGroup.cs プロジェクト: arangas/MediaPortal-1
    public override void Load(XPathNodeIterator iterator, MpeParser parser)
    {
      MpeLog.Debug("MpeGroup.Load()");
      base.Load(iterator, parser);
      this.parser = parser;
      //Animation = parser.GetAnimation(iterator, "animation", Animation);
      //tags.Remove("animation");

      // Mpe Specific Tags
      bool firstLoad = false;
      if (parser.GetString(iterator, "mpe/layout", null) == null)
      {
        MpeLog.Debug("This is a group that has never been opened with MPE!");
        firstLoad = true;
        Left = 0;
        Top = 0;
      }
      LayoutStyle = parser.GetLayout(iterator, "mpe/layout", LayoutStyle);
      Spring = parser.GetBoolean(iterator, "mpe/spring", Spring);
      Spacing = parser.GetInt(iterator, "mpe/spacing", Spacing);
      Padding = parser.GetPadding(iterator, "mpe/padding", Padding);
      // Child Controls
      XPathNodeIterator i = iterator.Current.Select("control");
      bool firstControl = true;
      int x = int.MaxValue;
      int y = int.MaxValue;
      int r = 0;
      int b = 0;
      while (i.MoveNext())
      {
        XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
        if (typeIterator.MoveNext())
        {
          MpeControlType ctype = MpeControlType.Create(typeIterator.Current.Value);
          if (firstControl && ctype == MpeControlType.Image)
          {
            firstControl = false;
            backImage.Load(i, parser);
          }
          else
          {
            MpeControl c = parser.CreateControl(ctype);
            Controls.Add(c);
            c.Load(i, parser);
            c.BringToFront();
            if (firstLoad)
            {
              if (c.Left < x)
              {
                x = c.Left;
              }
              if (c.Top < y)
              {
                y = c.Top;
              }
              if ((c.Left + c.Width) > r)
              {
                r = c.Left + c.Width;
              }
              if ((c.Top + c.Height) > b)
              {
                b = c.Top + c.Height;
              }
            }
          }
        }
      }
      if (firstLoad)
      {
        MpeLog.Info("x=" + x + " y=" + y);
        Left = x - 4;
        Top = y - 4;
        for (int a = 0; a < Controls.Count; a++)
        {
          if (Controls[a] is MpeControl)
          {
            Controls[a].Left -= x - 4;
            Controls[a].Top -= y - 4;
          }
        }
        Width = r - x + 8;
        Height = b - y + 8;
      }

      if (Spring)
      {
        Width = parser.GetInt(iterator, "width", Width);
        Height = parser.GetInt(iterator, "height", Height);
      }
      Modified = false;
    }
コード例 #3
0
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeSpinButton.Load()");
            base.Load(iterator, parser);
            this.parser = parser;
            label.Load(iterator, parser);
            TextureUp        = parser.GetImageFile(iterator, "textureUp", TextureUp);
            TextureUpFocus   = parser.GetImageFile(iterator, "textureUpFocus", TextureUpFocus);
            TextureDown      = parser.GetImageFile(iterator, "textureDown", TextureDown);
            TextureDownFocus = parser.GetImageFile(iterator, "textureDownFocus", TextureDownFocus);
            int w = parser.GetInt(iterator, "width", TextureSize.Width);
            int h = parser.GetInt(iterator, "height", TextureSize.Height);

            TextureSize = new Size(w, h);
            string s = parser.GetString(iterator, "orientation", "");

            if (s.Equals("vertical"))
            {
                Orientation = MpeControlOrientation.Vertical;
            }
            else
            {
                Orientation = MpeControlOrientation.Horizontal;
            }
            Reverse   = parser.GetBoolean(iterator, "reverse", Reverse);
            ShowRange = parser.GetBoolean(iterator, "showrange", ShowRange);
            // Load SubItems
            s = parser.GetString(iterator, "subtype", "");
            if (s.Equals("integer"))
            {
                items.Type     = MpeItemType.Integer;
                items.First    = parser.GetString(iterator, "subitems/first", items.First);
                items.Last     = parser.GetString(iterator, "subitems/last", items.Last);
                items.Digits   = parser.GetString(iterator, "subitems/digits", items.Digits);
                items.Interval = parser.GetString(iterator, "subitems/interval", items.Interval);
            }
            else if (s.Equals("float"))
            {
                items.Type     = MpeItemType.Float;
                items.First    = parser.GetString(iterator, "subitems/first", items.First);
                items.Last     = parser.GetString(iterator, "subitems/last", items.Last);
                items.Digits   = parser.GetString(iterator, "subitems/digits", items.Digits);
                items.Interval = parser.GetString(iterator, "subitems/interval", items.Interval);
            }
            // Remove known tags
            tags.Remove("align");
            tags.Remove("font");
            tags.Remove("textcolor");
            tags.Remove("disabledcolor");
            tags.Remove("label");
            tags.Remove("orientation");
            tags.Remove("reverse");
            tags.Remove("showrange");
            tags.Remove("subtype");
            tags.Remove("textureDown");
            tags.Remove("textureDownFocus");
            tags.Remove("textureUp");
            tags.Remove("textureUpFocus");
            SetLabel();
            Prepare();
            Modified = false;
        }
コード例 #4
0
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeGroup.Load()");
            base.Load(iterator, parser);
            this.parser = parser;
            //Animation = parser.GetAnimation(iterator, "animation", Animation);
            //tags.Remove("animation");

            // Mpe Specific Tags
            bool firstLoad = false;

            if (parser.GetString(iterator, "mpe/layout", null) == null)
            {
                MpeLog.Debug("This is a group that has never been opened with MPE!");
                firstLoad = true;
                Left      = 0;
                Top       = 0;
            }
            LayoutStyle = parser.GetLayout(iterator, "mpe/layout", LayoutStyle);
            Spring      = parser.GetBoolean(iterator, "mpe/spring", Spring);
            Spacing     = parser.GetInt(iterator, "mpe/spacing", Spacing);
            Padding     = parser.GetPadding(iterator, "mpe/padding", Padding);
            // Child Controls
            XPathNodeIterator i = iterator.Current.Select("control");
            bool firstControl   = true;
            int  x = int.MaxValue;
            int  y = int.MaxValue;
            int  r = 0;
            int  b = 0;

            while (i.MoveNext())
            {
                XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
                if (typeIterator.MoveNext())
                {
                    MpeControlType ctype = MpeControlType.Create(typeIterator.Current.Value);
                    if (firstControl && ctype == MpeControlType.Image)
                    {
                        firstControl = false;
                        backImage.Load(i, parser);
                    }
                    else
                    {
                        MpeControl c = parser.CreateControl(ctype);
                        Controls.Add(c);
                        c.Load(i, parser);
                        c.BringToFront();
                        if (firstLoad)
                        {
                            if (c.Left < x)
                            {
                                x = c.Left;
                            }
                            if (c.Top < y)
                            {
                                y = c.Top;
                            }
                            if ((c.Left + c.Width) > r)
                            {
                                r = c.Left + c.Width;
                            }
                            if ((c.Top + c.Height) > b)
                            {
                                b = c.Top + c.Height;
                            }
                        }
                    }
                }
            }
            if (firstLoad)
            {
                MpeLog.Info("x=" + x + " y=" + y);
                Left = x - 4;
                Top  = y - 4;
                for (int a = 0; a < Controls.Count; a++)
                {
                    if (Controls[a] is MpeControl)
                    {
                        Controls[a].Left -= x - 4;
                        Controls[a].Top  -= y - 4;
                    }
                }
                Width  = r - x + 8;
                Height = b - y + 8;
            }

            if (Spring)
            {
                Width  = parser.GetInt(iterator, "width", Width);
                Height = parser.GetInt(iterator, "height", Height);
            }
            Modified = false;
        }
コード例 #5
0
ファイル: MpeScreen.cs プロジェクト: arangas/MediaPortal-1
    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;
    }
コード例 #6
0
ファイル: MpeImage.cs プロジェクト: arangas/MediaPortal-1
    public override void Load(XPathNodeIterator iterator, MpeParser parser)
    {
      MpeLog.Debug("MpeImage.Load()");
      this.parser = parser;
      AutoSize = false;
      base.Load(iterator, parser);
      Texture = parser.GetImageFile(iterator, "texture", Texture);
      tags.Remove("texture");
      if (parser.GetInt(iterator, "width", -1) < 0 || parser.GetInt(iterator, "height", -1) < 0)
      {
        if (Texture == null)
        {
          AutoSize = false;
          Size = new Size(64, 64);
        }
        else
        {
          AutoSize = true;
        }
      }
      Centered = parser.GetBoolean(iterator, "centered", Centered);
      tags.Remove("centered");
      Filtered = parser.GetBoolean(iterator, "filtered", Filtered);
      tags.Remove("filtered");
      KeepAspectRatio = parser.GetBoolean(iterator, "keepaspectratio", KeepAspectRatio);
      tags.Remove("keepaspectratio");
      ColorKey = parser.GetInt(iterator, "colorkey", ColorKey);
      tags.Remove("colorkey");

      Modified = false;
    }
コード例 #7
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeSpinButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   label.Load(iterator, parser);
   TextureUp = parser.GetImageFile(iterator, "textureUp", TextureUp);
   TextureUpFocus = parser.GetImageFile(iterator, "textureUpFocus", TextureUpFocus);
   TextureDown = parser.GetImageFile(iterator, "textureDown", TextureDown);
   TextureDownFocus = parser.GetImageFile(iterator, "textureDownFocus", TextureDownFocus);
   int w = parser.GetInt(iterator, "width", TextureSize.Width);
   int h = parser.GetInt(iterator, "height", TextureSize.Height);
   TextureSize = new Size(w, h);
   string s = parser.GetString(iterator, "orientation", "");
   if (s.Equals("vertical"))
   {
     Orientation = MpeControlOrientation.Vertical;
   }
   else
   {
     Orientation = MpeControlOrientation.Horizontal;
   }
   Reverse = parser.GetBoolean(iterator, "reverse", Reverse);
   ShowRange = parser.GetBoolean(iterator, "showrange", ShowRange);
   // Load SubItems
   s = parser.GetString(iterator, "subtype", "");
   if (s.Equals("integer"))
   {
     items.Type = MpeItemType.Integer;
     items.First = parser.GetString(iterator, "subitems/first", items.First);
     items.Last = parser.GetString(iterator, "subitems/last", items.Last);
     items.Digits = parser.GetString(iterator, "subitems/digits", items.Digits);
     items.Interval = parser.GetString(iterator, "subitems/interval", items.Interval);
   }
   else if (s.Equals("float"))
   {
     items.Type = MpeItemType.Float;
     items.First = parser.GetString(iterator, "subitems/first", items.First);
     items.Last = parser.GetString(iterator, "subitems/last", items.Last);
     items.Digits = parser.GetString(iterator, "subitems/digits", items.Digits);
     items.Interval = parser.GetString(iterator, "subitems/interval", items.Interval);
   }
   // Remove known tags
   tags.Remove("align");
   tags.Remove("font");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("label");
   tags.Remove("orientation");
   tags.Remove("reverse");
   tags.Remove("showrange");
   tags.Remove("subtype");
   tags.Remove("textureDown");
   tags.Remove("textureDownFocus");
   tags.Remove("textureUp");
   tags.Remove("textureUpFocus");
   SetLabel();
   Prepare();
   Modified = false;
 }
コード例 #8
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;
        }