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("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; }
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; }
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; } }
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; } }