public override void Load(XPathNodeIterator iterator, MpeParser parser) { MpeLog.Debug("MpeLabel.Load()"); base.Load(iterator, parser); this.parser = parser; Text = parser.GetString(iterator, "label", "label"); tags.Remove("label"); Alignment = parser.GetAlignment(iterator, "align", Alignment); tags.Remove("align"); if (Alignment == MpeControlAlignment.Right) { Left = Left - Width; } TextColor = parser.GetColor(iterator, "textcolor", TextColor); tags.Remove("textcolor"); DisabledColor = parser.GetColor(iterator, "disabledcolor", DisabledColor); tags.Remove("disabledcolor"); Font = parser.GetFont(iterator, "font", Font); tags.Remove("font"); if (Type == MpeControlType.Label || Type == MpeControlType.FadeLabel) { AutoSize = true; } Prepare(); 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; }
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; }
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(); } } }
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; }
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(); } } }
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 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; }
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; } }