Exemplo n.º 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;
        }
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            base.Load(iterator, parser);
            MpeLog.Debug("MpeCheckBox.Load()");
            this.parser = parser;
            label.Load(iterator, parser);
            label.Enabled = false;
            tags.Remove("label");
            tags.Remove("align");
            tags.Remove("textcolor");
            tags.Remove("disabledcolor");
            tags.Remove("font");
            // Textures
            Texture = parser.GetImageFile(iterator, "textureCheckmarkNoFocus", Texture);
            tags.Remove("textureCheckmarkNoFocus");
            TextureChecked = parser.GetImageFile(iterator, "textureCheckmark", TextureChecked);
            tags.Remove("textureCheckmark");
            int w = parser.GetInt(iterator, "MarkWidth", TextureSize.Width);

            tags.Remove("MarkWidth");
            int h = parser.GetInt(iterator, "MarkHeight", TextureSize.Height);

            tags.Remove("MarkHeight");
            TextureSize = new Size(w, h);
            Modified    = false;
        }
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
     MpeLog.Debug("MpeButton.Load()");
     base.Load(iterator, parser);
     this.parser = parser;
     if (Text != null && Text.Equals("-"))
     {
         Text = "";
     }
     AutoSize     = false;
     TextureFocus = parser.GetImageFile(iterator, "textureFocus", TextureFocus);
     tags.Remove("textureFocus");
     TextureNoFocus = parser.GetImageFile(iterator, "textureNoFocus", TextureNoFocus);
     tags.Remove("textureNoFocus");
     if (TextureNoFocusImage != null)
     {
         if (TextureNoFocusImage.Width == Width && TextureNoFocusImage.Height == Height)
         {
             MpeLog.Debug("TextureNoFocus = " + TextureNoFocusImage.Size + " AutoSize enabled");
             AutoSize = true;
         }
     }
     else if (TextureNoFocusImage == null && TextureFocusImage != null)
     {
         if (TextureFocusImage.Width == Width && TextureFocusImage.Height == Height)
         {
             MpeLog.Debug("TextureFocus = " + TextureFocusImage.Size + " AutoSize enabled");
             AutoSize = true;
         }
     }
     Padding.Left = Padding.Right = parser.GetInt(iterator, "textXOff", Padding.Left);
     Padding.Top  = Padding.Bottom = parser.GetInt(iterator, "textYOff", Padding.Top);
     Hyperlink    = parser.GetInt(iterator, "hyperlink", 0);
     tags.Remove("textXOff");
     tags.Remove("textYOff");
     tags.Remove("hyperlink");
     PrepareControl();
     Modified = false;
 }
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeSelectButton.Load()");
            base.Load(iterator, parser);
            this.parser = parser;
            // Regular Button Properties
            label.Load(iterator, parser);
            label.AutoSize     = false;
            label.Size         = new Size(parser.GetInt(iterator, "width", Width), parser.GetInt(iterator, "height", Height));
            offset             = new Point(parser.GetInt(iterator, "textXOff2", offset.X), parser.GetInt(iterator, "textYOff2", offset.Y));
            TextureButton      = parser.GetImageFile(iterator, "textureNoFocus", TextureButton);
            TextureButtonFocus = parser.GetImageFile(iterator, "textureFocus", TextureButton);
            tags.Remove("align");
            tags.Remove("font");
            tags.Remove("textcolor");
            tags.Remove("disabledcolor");
            tags.Remove("label");
            tags.Remove("textXOff");
            tags.Remove("textYOff");
            tags.Remove("textureFocus");
            tags.Remove("textureNoFocus");
            // Select Button Properties
            int x = parser.GetInt(iterator, "textXOff", TexturePadding.Width);

            TextureSize =
                new Size(parser.GetInt(iterator, "textureWidth", textureSize.Width),
                         parser.GetInt(iterator, "textureHeight", textureSize.Height));
            TexturePadding    = new MpeControlPadding(x / 2, (Height - textureSize.Height) / 2);
            TextureBackground = parser.GetImageFile(iterator, "texturebg", TextureBack);
            TextureLeft       = parser.GetImageFile(iterator, "textureLeft", TextureLeft);
            TextureLeftFocus  = parser.GetImageFile(iterator, "textureLeftFocus", TextureLeftFocus);
            TextureRight      = parser.GetImageFile(iterator, "textureRight", TextureRight);
            TextureRightFocus = parser.GetImageFile(iterator, "textureRightFocus", TextureRightFocus);
            tags.Remove("texturebg");
            tags.Remove("textureLeft");
            tags.Remove("textureLeftFocus");
            tags.Remove("textureRight");
            tags.Remove("textureRightFocus");
            tags.Remove("textureWidth");
            tags.Remove("textureHeight");
            tags.Remove("textXOff2");
            tags.Remove("textYOff2");
            // Get SubItems
            items.Values.Clear();
            XPathNodeIterator i = iterator.Current.Select("subitems/subitem");

            while (i.MoveNext())
            {
                MpeItem item = new MpeItem();
                item.Value = i.Current.Value;
                items.Values.Add(item);
            }
            Prepare();
            Modified = false;
        }
Exemplo n.º 5
0
        public virtual void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeControl.Load()");
            this.parser = parser;
            if (iterator != null)
            {
                // First load tags
                XPathNodeIterator i = iterator.Current.SelectChildren("", "");
                while (i.MoveNext())
                {
                    if (i.Current.Name != null && i.Current.Value != null)
                    {
                        XPathNodeIterator ci = i.Current.SelectChildren("", "");
                        if (ci.Count == 0)
                        {
                            if (i.Current.Name == "animation")
                            {
                                int pos = -1;
                                switch (i.Current.Value)
                                {
                                case "WindowOpen":
                                    pos = 0;
                                    break;

                                case "WindowClose":
                                    pos = 1;
                                    break;

                                case "Hidden":
                                    pos = 2;
                                    break;

                                case "Focus":
                                    pos = 3;
                                    break;

                                case "Unfocus":
                                    pos = 4;
                                    break;

                                case "VisibleChange":
                                    pos = 5;
                                    break;
                                }
                                if (pos >= 0)
                                {
                                    Animation.Animation[pos].Enabled = true;
                                    string efect = i.Current.GetAttribute("effect", String.Empty);
                                    switch (efect)
                                    {
                                    case "fade":
                                        Animation.Animation[pos].Efect = MpeAnimationEfect.fade;
                                        break;

                                    case "slide":
                                        Animation.Animation[pos].Efect = MpeAnimationEfect.slide;
                                        break;

                                    case "rotate":
                                        Animation.Animation[pos].Efect = MpeAnimationEfect.rotate;
                                        break;

                                    case "rotatex":
                                        Animation.Animation[pos].Efect = MpeAnimationEfect.rotatex;
                                        break;

                                    case "rotatey":
                                        Animation.Animation[pos].Efect = MpeAnimationEfect.rotatey;
                                        break;

                                    case "zoom":
                                        Animation.Animation[pos].Efect = MpeAnimationEfect.zoom;
                                        break;
                                    }
                                    int  parami = 0;
                                    bool paramb = false;
                                    int.TryParse(i.Current.GetAttribute("time", String.Empty), out parami);
                                    Animation.Animation[pos].Time = parami;
                                    parami = 0;
                                    int.TryParse(i.Current.GetAttribute("delay", String.Empty), out parami);
                                    Animation.Animation[pos].Delay = parami;
                                    Animation.Animation[pos].Start = i.Current.GetAttribute("start", String.Empty);
                                    Animation.Animation[pos].End   = i.Current.GetAttribute("end", String.Empty);
                                    parami = 0;
                                    int.TryParse(i.Current.GetAttribute("acceleration", String.Empty), out parami);
                                    Animation.Animation[pos].Acceleration = parami;
                                    string center = i.Current.GetAttribute("center", String.Empty);
                                    if (center.Contains(","))
                                    {
                                        int.TryParse(center.Substring(0, center.IndexOf(',')), out parami);
                                        int paramy = 0;
                                        int.TryParse(center.Substring(center.IndexOf(',') + 1), out paramy);
                                        Animation.Animation[pos].Center = new Point(parami, paramy);
                                    }
                                    Animation.Animation[pos].Condition = i.Current.GetAttribute("condition", String.Empty);
                                    bool.TryParse(i.Current.GetAttribute("reversible", String.Empty), out paramb);
                                    Animation.Animation[pos].Reversible = paramb;
                                    paramb = false;
                                    bool.TryParse(i.Current.GetAttribute("pulse", String.Empty), out paramb);
                                    Animation.Animation[pos].Pulse = paramb;
                                    switch (i.Current.GetAttribute("tween", String.Empty))
                                    {
                                    case "elastic":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.elastic;
                                        break;

                                    case "bounce":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.bounce;
                                        break;

                                    case "circle":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.circle;
                                        break;

                                    case "back":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.back;
                                        break;

                                    case "sine":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.sine;
                                        break;

                                    case "cubic":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.cubic;
                                        break;

                                    case "quadratic":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.quadratic;
                                        break;

                                    case "linear":
                                        Animation.Animation[pos].Tween = MpeAnimationTween.linear;
                                        break;
                                    }
                                    switch (i.Current.GetAttribute("easing", String.Empty))
                                    {
                                    case "out":
                                        Animation.Animation[pos].Easing = MpeAnimationEasing.Out;
                                        break;

                                    case "in":
                                        Animation.Animation[pos].Easing = MpeAnimationEasing.In;
                                        break;

                                    case "inout":
                                        Animation.Animation[pos].Easing = MpeAnimationEasing.inout;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                tags.Add(i.Current.Name, i.Current.Value, false);
                            }
                        }
                    }
                }
                tags.Remove("type");
                Id = parser.GetInt(iterator, "id", Id);
                tags.Remove("id");
                Description = parser.GetString(iterator, "description", Description);
                tags.Remove("description");
                // The position must be converted from absolute to relative
                int          x = parser.GetInt(iterator, "posX", Left);
                int          y = parser.GetInt(iterator, "posY", Top);
                MpeContainer c = MpeParent;
                while (c != null && c.Type != MpeControlType.Screen)
                {
                    x -= c.Left;
                    y -= c.Top;
                    c  = c.MpeParent;
                }
                Left = x;
                Top  = y;
                tags.Remove("posX");
                tags.Remove("posY");
                // Load the rest of the properties
                Width = parser.GetInt(iterator, "width", Width);
                tags.Remove("width");
                Height = parser.GetInt(iterator, "height", Height);
                tags.Remove("height");
                Padding = parser.GetPadding(iterator, "padding", Padding);
                Visible = parser.GetString(iterator, "visible", Visible);
                tags.Remove("visible");
                DiffuseColor = parser.GetColor(iterator, "colordiffuse", DiffuseColor);
                tags.Remove("colordiffuse");
                DimColor = parser.GetColor(iterator, "dimColor", DimColor);
                tags.Remove("dimColor");
                OnLeft = parser.GetInt(iterator, "onleft", OnLeft);
                tags.Remove("onleft");
                OnRight = parser.GetInt(iterator, "onright", OnRight);
                tags.Remove("onright");
                OnUp = parser.GetInt(iterator, "onup", OnUp);
                tags.Remove("onup");
                OnDown = parser.GetInt(iterator, "ondown", OnDown);
                tags.Remove("ondown");
            }
            if (reference)
            {
                Id = 1;
            }
        }
Exemplo n.º 6
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   base.Load(iterator, parser);
   MpeLog.Debug("MpeCheckBox.Load()");
   this.parser = parser;
   label.Load(iterator, parser);
   label.Enabled = false;
   tags.Remove("label");
   tags.Remove("align");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("font");
   // Textures
   Texture = parser.GetImageFile(iterator, "textureCheckmarkNoFocus", Texture);
   tags.Remove("textureCheckmarkNoFocus");
   TextureChecked = parser.GetImageFile(iterator, "textureCheckmark", TextureChecked);
   tags.Remove("textureCheckmark");
   int w = parser.GetInt(iterator, "MarkWidth", TextureSize.Width);
   tags.Remove("MarkWidth");
   int h = parser.GetInt(iterator, "MarkHeight", TextureSize.Height);
   tags.Remove("MarkHeight");
   TextureSize = new Size(w, h);
   Modified = false;
 }
Exemplo n.º 7
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("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;
        }
Exemplo n.º 9
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeSelectButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   // Regular Button Properties
   label.Load(iterator, parser);
   label.AutoSize = false;
   label.Size = new Size(parser.GetInt(iterator, "width", Width), parser.GetInt(iterator, "height", Height));
   offset = new Point(parser.GetInt(iterator, "textXOff2", offset.X), parser.GetInt(iterator, "textYOff2", offset.Y));
   TextureButton = parser.GetImageFile(iterator, "textureNoFocus", TextureButton);
   TextureButtonFocus = parser.GetImageFile(iterator, "textureFocus", TextureButton);
   tags.Remove("align");
   tags.Remove("font");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("label");
   tags.Remove("textXOff");
   tags.Remove("textYOff");
   tags.Remove("textureFocus");
   tags.Remove("textureNoFocus");
   // Select Button Properties
   int x = parser.GetInt(iterator, "textXOff", TexturePadding.Width);
   TextureSize =
     new Size(parser.GetInt(iterator, "textureWidth", textureSize.Width),
              parser.GetInt(iterator, "textureHeight", textureSize.Height));
   TexturePadding = new MpeControlPadding(x/2, (Height - textureSize.Height)/2);
   TextureBackground = parser.GetImageFile(iterator, "texturebg", TextureBack);
   TextureLeft = parser.GetImageFile(iterator, "textureLeft", TextureLeft);
   TextureLeftFocus = parser.GetImageFile(iterator, "textureLeftFocus", TextureLeftFocus);
   TextureRight = parser.GetImageFile(iterator, "textureRight", TextureRight);
   TextureRightFocus = parser.GetImageFile(iterator, "textureRightFocus", TextureRightFocus);
   tags.Remove("texturebg");
   tags.Remove("textureLeft");
   tags.Remove("textureLeftFocus");
   tags.Remove("textureRight");
   tags.Remove("textureRightFocus");
   tags.Remove("textureWidth");
   tags.Remove("textureHeight");
   tags.Remove("textXOff2");
   tags.Remove("textYOff2");
   // Get SubItems
   items.Values.Clear();
   XPathNodeIterator i = iterator.Current.Select("subitems/subitem");
   while (i.MoveNext())
   {
     MpeItem item = new MpeItem();
     item.Value = i.Current.Value;
     items.Values.Add(item);
   }
   Prepare();
   Modified = false;
 }
Exemplo n.º 10
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   if (Text != null && Text.Equals("-"))
   {
     Text = "";
   }
   AutoSize = false;
   TextureFocus = parser.GetImageFile(iterator, "textureFocus", TextureFocus);
   tags.Remove("textureFocus");
   TextureNoFocus = parser.GetImageFile(iterator, "textureNoFocus", TextureNoFocus);
   tags.Remove("textureNoFocus");
   if (TextureNoFocusImage != null)
   {
     if (TextureNoFocusImage.Width == Width && TextureNoFocusImage.Height == Height)
     {
       MpeLog.Debug("TextureNoFocus = " + TextureNoFocusImage.Size + " AutoSize enabled");
       AutoSize = true;
     }
   }
   else if (TextureNoFocusImage == null && TextureFocusImage != null)
   {
     if (TextureFocusImage.Width == Width && TextureFocusImage.Height == Height)
     {
       MpeLog.Debug("TextureFocus = " + TextureFocusImage.Size + " AutoSize enabled");
       AutoSize = true;
     }
   }
   Padding.Left = Padding.Right = parser.GetInt(iterator, "textXOff", Padding.Left);
   Padding.Top = Padding.Bottom = parser.GetInt(iterator, "textYOff", Padding.Top);
   Hyperlink = parser.GetInt(iterator, "hyperlink", 0);
   tags.Remove("textXOff");
   tags.Remove("textYOff");
   tags.Remove("hyperlink");
   PrepareControl();
   Modified = false;
 }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
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;
        }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
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;
    }
Exemplo n.º 15
0
 public virtual void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeControl.Load()");
   this.parser = parser;
   if (iterator != null)
   {
     // First load tags
     XPathNodeIterator i = iterator.Current.SelectChildren("", "");
     while (i.MoveNext())
     {
       if (i.Current.Name != null && i.Current.Value != null)
       {
         XPathNodeIterator ci = i.Current.SelectChildren("", "");
         if (ci.Count == 0)
         {
           if (i.Current.Name == "animation")
           {
             int pos = -1;
             switch (i.Current.Value)
             {
               case "WindowOpen":
                 pos = 0;
                 break;
               case "WindowClose":
                 pos = 1;
                 break;
               case "Hidden":
                 pos = 2;
                 break;
               case "Focus":
                 pos = 3;
                 break;
               case "Unfocus":
                 pos = 4;
                 break;
               case "VisibleChange":
                 pos = 5;
                 break;
             }
             if (pos >= 0)
             {
               Animation.Animation[pos].Enabled = true;
               string efect = i.Current.GetAttribute("effect", String.Empty);
               switch (efect)
               {
                 case "fade":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.fade;
                   break;
                 case "slide":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.slide;
                   break;
                 case "rotate":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.rotate;
                   break;
                 case "rotatex":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.rotatex;
                   break;
                 case "rotatey":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.rotatey;
                   break;
                 case "zoom":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.zoom;
                   break;
               }
               int parami = 0;
               bool paramb = false;
               int.TryParse(i.Current.GetAttribute("time",String.Empty ),out parami);
               Animation.Animation[pos].Time = parami;
               parami = 0;
               int.TryParse(i.Current.GetAttribute("delay", String.Empty), out parami);
               Animation.Animation[pos].Delay = parami;
               Animation.Animation[pos].Start = i.Current.GetAttribute("start", String.Empty);
               Animation.Animation[pos].End = i.Current.GetAttribute("end", String.Empty);
               parami = 0;
               int.TryParse(i.Current.GetAttribute("acceleration", String.Empty), out parami);
               Animation.Animation[pos].Acceleration = parami;
               string center = i.Current.GetAttribute("center", String.Empty);
               if (center.Contains(","))
               {
                 int.TryParse(center.Substring(0, center.IndexOf(',')), out parami);
                 int paramy = 0;
                 int.TryParse(center.Substring(center.IndexOf(',')+1), out paramy);
                 Animation.Animation[pos].Center = new Point(parami, paramy);
               }
               Animation.Animation[pos].Condition = i.Current.GetAttribute("condition", String.Empty);
               bool.TryParse(i.Current.GetAttribute("reversible", String.Empty), out paramb);
               Animation.Animation[pos].Reversible = paramb;
               paramb = false;
               bool.TryParse(i.Current.GetAttribute("pulse", String.Empty), out paramb);
               Animation.Animation[pos].Pulse = paramb;
               switch (i.Current.GetAttribute("tween", String.Empty))
               {
                 case "elastic":
                   Animation.Animation[pos].Tween = MpeAnimationTween.elastic;
                   break;
                 case "bounce":
                   Animation.Animation[pos].Tween = MpeAnimationTween.bounce;
                   break;
                 case "circle":
                   Animation.Animation[pos].Tween = MpeAnimationTween.circle;
                   break;
                 case "back":
                   Animation.Animation[pos].Tween = MpeAnimationTween.back;
                   break;
                 case "sine":
                   Animation.Animation[pos].Tween = MpeAnimationTween.sine;
                   break;
                 case "cubic":
                   Animation.Animation[pos].Tween = MpeAnimationTween.cubic;
                   break;
                 case "quadratic":
                   Animation.Animation[pos].Tween = MpeAnimationTween.quadratic;
                   break;
                 case "linear":
                   Animation.Animation[pos].Tween = MpeAnimationTween.linear;
                   break;
               }
               switch (i.Current.GetAttribute("easing", String.Empty))
               {
                 case "out":
                   Animation.Animation[pos].Easing = MpeAnimationEasing.Out;
                   break;
                 case "in":
                   Animation.Animation[pos].Easing = MpeAnimationEasing.In;
                   break;
                 case "inout":
                   Animation.Animation[pos].Easing = MpeAnimationEasing.inout;
                   break;
               }
             }
           }
           else
           {
             tags.Add(i.Current.Name, i.Current.Value, false);
           }
         }
       }
     }
     tags.Remove("type");
     Id = parser.GetInt(iterator, "id", Id);
     tags.Remove("id");
     Description = parser.GetString(iterator, "description", Description);
     tags.Remove("description");
     // The position must be converted from absolute to relative
     int x = parser.GetInt(iterator, "posX", Left);
     int y = parser.GetInt(iterator, "posY", Top);
     MpeContainer c = MpeParent;
     while (c != null && c.Type != MpeControlType.Screen)
     {
       x -= c.Left;
       y -= c.Top;
       c = c.MpeParent;
     }
     Left = x;
     Top = y;
     tags.Remove("posX");
     tags.Remove("posY");
     // Load the rest of the properties
     Width = parser.GetInt(iterator, "width", Width);
     tags.Remove("width");
     Height = parser.GetInt(iterator, "height", Height);
     tags.Remove("height");
     Padding = parser.GetPadding(iterator, "padding", Padding);
     Visible = parser.GetString(iterator, "visible", Visible);
     tags.Remove("visible");
     DiffuseColor = parser.GetColor(iterator, "colordiffuse", DiffuseColor);
     tags.Remove("colordiffuse");
     DimColor = parser.GetColor(iterator, "dimColor", DimColor);
     tags.Remove("dimColor");
     OnLeft = parser.GetInt(iterator, "onleft", OnLeft);
     tags.Remove("onleft");
     OnRight = parser.GetInt(iterator, "onright", OnRight);
     tags.Remove("onright");
     OnUp = parser.GetInt(iterator, "onup", OnUp);
     tags.Remove("onup");
     OnDown = parser.GetInt(iterator, "ondown", OnDown);
     tags.Remove("ondown");
   }
   if (reference)
   {
     Id = 1;
   }
 }
Exemplo n.º 16
0
        public void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeFont.Load()");
            textureWorkDir = parser.FontDir.FullName;
            name           = parser.GetString(iterator, "name", name);
            string    family = parser.GetString(iterator, "filename", Family);
            int       height = parser.GetInt(iterator, "height", Size);
            string    style  = parser.GetString(iterator, "style", "");
            FontStyle fs     = FontStyle.Regular;

            if (style.IndexOf("Bold") >= 0)
            {
                fs |= FontStyle.Bold;
            }
            if (style.IndexOf("Italic") >= 0)
            {
                fs |= FontStyle.Italic;
            }
            if (style.IndexOf("Underline") >= 0)
            {
                fs |= FontStyle.Underline;
            }
            if (style.IndexOf("Strikeout") >= 0)
            {
                fs |= FontStyle.Strikeout;
            }
            systemFont = new Font(family, (float)height, fs);
            startChar  = parser.GetInt(iterator, "start", startChar);
            if (startChar < 32)
            {
                startChar = 32;
            }
            endChar = parser.GetInt(iterator, "end", endChar) + 1;
            if (endChar > 256)
            {
                endChar = 256;
            }
            // Setup Texture Files
            if (textureWorkDir != null)
            {
                textureFile     = new FileInfo(textureWorkDir + "\\" + name + "_" + height + ".png");
                textureDataFile = new FileInfo(textureFile.FullName + ".xml");
                bool loaded = false;
                if (textureFile.Exists)
                {
                    Bitmap b = null;
                    try
                    {
                        b       = new Bitmap(textureFile.FullName);
                        texture = new Bitmap(b);
                        loaded  = true;
                    }
                    catch (Exception e)
                    {
                        MpeLog.Warn(e);
                    }
                    finally
                    {
                        if (b != null)
                        {
                            b.Dispose();
                        }
                    }
                }
                if (loaded && textureDataFile.Exists)
                {
                    loaded = false;
                    Stream r = null;
                    try
                    {
                        r = File.Open(textureDataFile.FullName, FileMode.Open, FileAccess.Read);
                        textureCoordinates = (float[, ]) new SoapFormatter().Deserialize(r);
                        spacingPerChar     = (int)textureCoordinates[endChar - startChar, 0];
                        ConvertTextureData();
                        loaded = true;
                    }
                    catch (Exception e)
                    {
                        MpeLog.Warn(e);
                    }
                    finally
                    {
                        if (r != null)
                        {
                            r.Close();
                        }
                    }
                }
                if (loaded)
                {
                    MpeLog.Info("Loaded font texture and data [" + name + "]");
                }
                else
                {
                    GenerateTexture();
                }
            }
        }
Exemplo n.º 17
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeTextArea.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   Controls.Clear();
   Padding = parser.GetPadding(iterator, "mpe/padding", Padding);
   Spacing = parser.GetInt(iterator, "mpe/spacing", Spacing);
   Left -= Padding.Left;
   Top -= Padding.Top;
   label = (MpeLabel) parser.CreateControl(MpeControlType.Label);
   if (label != null)
   {
     label.Lookup = false;
     label.Embedded = true;
     label.AutoSize = false;
     label.Font = parser.GetFont(iterator, "font", label.Font);
     label.DisabledColor = parser.GetColor(iterator, "disabledcolor", label.DisabledColor);
     label.TextColor = parser.GetColor(iterator, "textcolor", label.TextColor);
     label.Text = parser.GetString(iterator, "text", label.Text);
     Controls.Add(label);
   }
   spinButton = (MpeSpinButton) parser.CreateControl(MpeControlType.SpinButton);
   if (spinButton != null)
   {
     spinButton.Embedded = true;
     spinButton.Color = parser.GetColor(iterator, "SpinColor", spinButton.Color);
     int w = parser.GetInt(iterator, "SpinWidth", spinButton.TextureSize.Width);
     int h = parser.GetInt(iterator, "SpinHeight", spinButton.TextureSize.Height);
     spinButton.TextureSize = new Size(w, h);
     spinButton.TextureUp = parser.GetImageFile(iterator, "textureUp", spinButton.TextureUp);
     spinButton.TextureUpFocus = parser.GetImageFile(iterator, "textureUpFocus", spinButton.TextureUpFocus);
     spinButton.TextureDown = parser.GetImageFile(iterator, "textureDown", spinButton.TextureDown);
     spinButton.TextureDownFocus = parser.GetImageFile(iterator, "textureDownFocus", spinButton.TextureDownFocus);
     SpinAlign = parser.GetAlignment(iterator, "SpinAlign", SpinAlign);
     Controls.Add(spinButton);
   }
   Width += Padding.Width;
   Height += Padding.Height + Spacing + spinButton.Height;
   // Remove known tags
   tags.Remove("align");
   tags.Remove("font");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("text");
   tags.Remove("textureDown");
   tags.Remove("textureDownFocus");
   tags.Remove("textureUp");
   tags.Remove("textureUpFocus");
   tags.Remove("spinAlign");
   tags.Remove("spinColor");
   tags.Remove("spinWidth");
   tags.Remove("spinHeight");
   tags.Remove("spinPosX");
   tags.Remove("spinPosY");
   tags.Remove("SpinAlign");
   tags.Remove("SpinColor");
   tags.Remove("SpinWidth");
   tags.Remove("SpinHeight");
   tags.Remove("SpinPosX");
   tags.Remove("SpinPosY");
   Modified = false;
 }
Exemplo n.º 18
0
 public void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeFont.Load()");
   textureWorkDir = parser.FontDir.FullName;
   name = parser.GetString(iterator, "name", name);
   string family = parser.GetString(iterator, "filename", Family);
   int height = parser.GetInt(iterator, "height", Size);
   string style = parser.GetString(iterator, "style", "");
   FontStyle fs = FontStyle.Regular;
   if (style.IndexOf("Bold") >= 0)
   {
     fs |= FontStyle.Bold;
   }
   if (style.IndexOf("Italic") >= 0)
   {
     fs |= FontStyle.Italic;
   }
   if (style.IndexOf("Underline") >= 0)
   {
     fs |= FontStyle.Underline;
   }
   if (style.IndexOf("Strikeout") >= 0)
   {
     fs |= FontStyle.Strikeout;
   }
   systemFont = new Font(family, (float) height, fs);
   startChar = parser.GetInt(iterator, "start", startChar);
   if (startChar < 32)
   {
     startChar = 32;
   }
   endChar = parser.GetInt(iterator, "end", endChar) + 1;
   if (endChar > 256)
   {
     endChar = 256;
   }
   // Setup Texture Files
   if (textureWorkDir != null)
   {
     textureFile = new FileInfo(textureWorkDir + "\\" + name + "_" + height + ".png");
     textureDataFile = new FileInfo(textureFile.FullName + ".xml");
     bool loaded = false;
     if (textureFile.Exists)
     {
       Bitmap b = null;
       try
       {
         b = new Bitmap(textureFile.FullName);
         texture = new Bitmap(b);
         loaded = true;
       }
       catch (Exception e)
       {
         MpeLog.Warn(e);
       }
       finally
       {
         if (b != null)
         {
           b.Dispose();
         }
       }
     }
     if (loaded && textureDataFile.Exists)
     {
       loaded = false;
       Stream r = null;
       try
       {
         r = File.Open(textureDataFile.FullName, FileMode.Open, FileAccess.Read);
         textureCoordinates = (float[,]) new SoapFormatter().Deserialize(r);
         spacingPerChar = (int) textureCoordinates[endChar - startChar, 0];
         ConvertTextureData();
         loaded = true;
       }
       catch (Exception e)
       {
         MpeLog.Warn(e);
       }
       finally
       {
         if (r != null)
         {
           r.Close();
         }
       }
     }
     if (loaded)
     {
       MpeLog.Info("Loaded font texture and data [" + name + "]");
     }
     else
     {
       GenerateTexture();
     }
   }
 }
Exemplo n.º 19
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;
    }
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
     MpeLog.Debug("MpeTextArea.Load()");
     base.Load(iterator, parser);
     this.parser = parser;
     Controls.Clear();
     Padding = parser.GetPadding(iterator, "mpe/padding", Padding);
     Spacing = parser.GetInt(iterator, "mpe/spacing", Spacing);
     Left   -= Padding.Left;
     Top    -= Padding.Top;
     label   = (MpeLabel)parser.CreateControl(MpeControlType.Label);
     if (label != null)
     {
         label.Lookup        = false;
         label.Embedded      = true;
         label.AutoSize      = false;
         label.Font          = parser.GetFont(iterator, "font", label.Font);
         label.DisabledColor = parser.GetColor(iterator, "disabledcolor", label.DisabledColor);
         label.TextColor     = parser.GetColor(iterator, "textcolor", label.TextColor);
         label.Text          = parser.GetString(iterator, "text", label.Text);
         Controls.Add(label);
     }
     spinButton = (MpeSpinButton)parser.CreateControl(MpeControlType.SpinButton);
     if (spinButton != null)
     {
         spinButton.Embedded = true;
         spinButton.Color    = parser.GetColor(iterator, "SpinColor", spinButton.Color);
         int w = parser.GetInt(iterator, "SpinWidth", spinButton.TextureSize.Width);
         int h = parser.GetInt(iterator, "SpinHeight", spinButton.TextureSize.Height);
         spinButton.TextureSize      = new Size(w, h);
         spinButton.TextureUp        = parser.GetImageFile(iterator, "textureUp", spinButton.TextureUp);
         spinButton.TextureUpFocus   = parser.GetImageFile(iterator, "textureUpFocus", spinButton.TextureUpFocus);
         spinButton.TextureDown      = parser.GetImageFile(iterator, "textureDown", spinButton.TextureDown);
         spinButton.TextureDownFocus = parser.GetImageFile(iterator, "textureDownFocus", spinButton.TextureDownFocus);
         SpinAlign = parser.GetAlignment(iterator, "SpinAlign", SpinAlign);
         Controls.Add(spinButton);
     }
     Width  += Padding.Width;
     Height += Padding.Height + Spacing + spinButton.Height;
     // Remove known tags
     tags.Remove("align");
     tags.Remove("font");
     tags.Remove("textcolor");
     tags.Remove("disabledcolor");
     tags.Remove("text");
     tags.Remove("textureDown");
     tags.Remove("textureDownFocus");
     tags.Remove("textureUp");
     tags.Remove("textureUpFocus");
     tags.Remove("spinAlign");
     tags.Remove("spinColor");
     tags.Remove("spinWidth");
     tags.Remove("spinHeight");
     tags.Remove("spinPosX");
     tags.Remove("spinPosY");
     tags.Remove("SpinAlign");
     tags.Remove("SpinColor");
     tags.Remove("SpinWidth");
     tags.Remove("SpinHeight");
     tags.Remove("SpinPosX");
     tags.Remove("SpinPosY");
     Modified = false;
 }