Beispiel #1
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;
    }
        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;
        }