public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeButton button = null; if (reference != null) { button = (MpeButton)reference; } // Size if (button == null || button.Size != Size) { parser.SetInt(doc, node, "width", Width); parser.SetInt(doc, node, "height", Height); } // hyperlink if (button == null || button.Hyperlink != Hyperlink) { parser.SetInt(doc, node, "hyperlink", Hyperlink); } // DiffuseColor if (button == null || button.DiffuseColor != DiffuseColor) { parser.SetColor(doc, node, "colordiffuse", DiffuseColor); } // TextOffsetX if (button == null || button.Padding.Left != Padding.Left) { parser.SetInt(doc, node, "textXOff", Padding.Left); } // TextOffsetY if (button == null || button.Padding.Top != Padding.Top) { parser.SetInt(doc, node, "textYOff", Padding.Top); } // TextureFocus if (button == null || button.TextureFocus == null || button.TextureFocus.Equals(TextureFocus) == false) { if (TextureFocus == null) { parser.SetValue(doc, node, "textureFocus", "-"); } else { parser.SetValue(doc, node, "textureFocus", TextureFocus.Name); } } // TextureNoFocus if (button == null || button.TextureNoFocus == null || button.TextureNoFocus.Equals(TextureNoFocus) == false) { if (TextureNoFocus == null) { parser.SetValue(doc, node, "textureNoFocus", "-"); } else { parser.SetValue(doc, node, "textureNoFocus", TextureNoFocus.Name); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (doc != null && node != null) { base.Save(doc, node, parser, reference); //parser.SetValue(doc, node, "animation", Animation.ToString()); XmlElement mpenode = doc.CreateElement("mpe"); node.AppendChild(mpenode); parser.SetValue(doc, mpenode, "layout", LayoutStyle.ToString()); parser.SetValue(doc, mpenode, "spring", Spring ? "yes" : "no"); parser.SetInt(doc, mpenode, "spacing", Spacing); parser.SetPadding(doc, mpenode, "padding", Padding); if (backImage != null && backImage.Texture != null) { XmlElement image = doc.CreateElement("control"); backImage.Location = AbsoluteLocation; backImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); backImage.Location = Point.Empty; node.AppendChild(image); } if (reference != null) { for (int i = Controls.Count - 1; i >= 0; i--) { if (Controls[i] is MpeControl) { MpeControl control = (MpeControl)Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); node.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (doc != null && node != null) { base.Save(doc, node, parser, reference); if (AutoSize) { parser.RemoveNode(node, "width"); parser.RemoveNode(node, "height"); } MpeImage image = null; if (reference != null && reference is MpeImage) { image = (MpeImage)reference; } // For the reference image, the texture should be set to the default screen background if (IsReference) { parser.SetValue(doc, node, "texture", (MpeScreen.TextureBack != null ? MpeScreen.TextureBack.Name : "-")); } else { parser.SetValue(doc, node, "texture", (Texture != null ? Texture.Name : "-")); } if (image == null || image.Centered != Centered) { parser.SetValue(doc, node, "centered", Centered ? "yes" : "no"); } if (image == null || image.Filtered != Filtered) { parser.SetValue(doc, node, "filtered", Filtered ? "yes" : "no"); } if (image == null || image.KeepAspectRatio != KeepAspectRatio) { parser.SetValue(doc, node, "keepaspectratio", KeepAspectRatio ? "yes" : "no"); } if (image == null || image.ColorKey != ColorKey) { parser.SetInt(doc, node, "colorkey", ColorKey); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeLabel label = null; if (reference != null && reference is MpeLabel) { label = (MpeLabel)reference; } // Fix the Left Position if (Alignment == MpeControlAlignment.Right) { parser.SetInt(doc, node, "posX", Right); } // Fix the Width and Height parser.RemoveNode(node, "width"); parser.RemoveNode(node, "height"); // Text parser.SetValue(doc, node, "label", Text); // Font if (label == null || !label.Font.Name.Equals(Font.Name)) { parser.SetValue(doc, node, "font", Font.Name); } // Alignment if (label == null || label.Alignment != Alignment) { parser.SetValue(doc, node, "align", Alignment.ToString().ToLower()); } // Color if (label == null || label.TextColor != TextColor) { parser.SetColor(doc, node, "textcolor", TextColor); } // DisabledColor if (label == null || label.DisabledColor != DisabledColor) { parser.SetColor(doc, node, "disabledcolor", DisabledColor); } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeToggleButton toggle = null; if (reference != null && reference is MpeToggleButton) { toggle = (MpeToggleButton)reference; } // TextureFocus if (toggle == null || toggle.AlternateTextureFocus == null || toggle.AlternateTextureFocus.Equals(AlternateTextureFocus) == false) { if (AlternateTextureFocus == null) { parser.SetValue(doc, node, "AltTextureFocus", "-"); } else { parser.SetValue(doc, node, "AltTextureFocus", AlternateTextureFocus.Name); } } // AlternateTextureNoFocus if (toggle == null || toggle.AlternateTextureNoFocus == null || toggle.AlternateTextureNoFocus.Equals(AlternateTextureNoFocus) == false) { if (AlternateTextureNoFocus == null) { parser.SetValue(doc, node, "AltTextureNoFocus", "-"); } else { parser.SetValue(doc, node, "AltTextureNoFocus", AlternateTextureNoFocus.Name); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); // Remove Width and Height parser.RemoveNode(node, "width"); parser.RemoveNode(node, "height"); MpeCheckBox checkbox = null; if (reference != null && reference is MpeCheckBox) { checkbox = (MpeCheckBox)reference; } // Label label.Save(doc, node, parser, checkbox != null ? checkbox.label : null); parser.SetValue(doc, node, "type", Type.ToString()); // TextureChecked if (checkbox == null || checkbox.TextureChecked == null || checkbox.TextureChecked.Equals(TextureChecked) == false ) { if (TextureChecked == null) { parser.SetValue(doc, node, "textureCheckmark", "-"); } else { parser.SetValue(doc, node, "textureCheckmark", TextureChecked.Name); } } // Texture if (checkbox == null || checkbox.Texture == null || checkbox.Texture.Equals(Texture) == false) { if (Texture == null) { parser.SetValue(doc, node, "textureCheckmarkNoFocus", "-"); } else { parser.SetValue(doc, node, "textureCheckmarkNoFocus", Texture.Name); } } // TextureSize if (checkbox == null || checkbox.TextureSize != TextureSize) { parser.SetInt(doc, node, "MarkWidth", TextureSize.Width); parser.SetInt(doc, node, "MarkHeight", TextureSize.Height); } // Shadow parser.SetValue(doc, node, "shadow", "no"); // Save Correct Type //parser.SetValue(doc, node, "type", parser.ControlTypeToXmlString(Type)); //parser.SetValue(doc, node, "type", Type.ToString()); }
public void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { MpeLog.Debug("MpeFont.Save()"); textureWorkDir = parser.FontDir.FullName; parser.SetValue(doc, node, "name", Name); parser.SetValue(doc, node, "filename", Family); parser.SetInt(doc, node, "height", Size); parser.SetValue(doc, node, "style", Style); parser.SetInt(doc, node, "start", StartCharacter); parser.SetInt(doc, node, "end", EndCharacter - 1); // Setup Texture Files if (textureWorkDir != null) { int size = Size; string sTexture = textureWorkDir + "\\" + name + "_" + size + ".png"; string sData = sTexture + ".xml"; if (textureFile != null && textureFile.Exists && textureFile.FullName.Equals(sTexture) == false) { MpeLog.Info("Moving texture file..."); textureFile.MoveTo(sTexture); textureFile.Refresh(); } else { textureFile = new FileInfo(sTexture); } if (textureDataFile != null && textureDataFile.Exists && textureDataFile.FullName.Equals(sData) == false) { MpeLog.Info("Moving texture data file..."); textureDataFile.MoveTo(sData); textureDataFile.Refresh(); } else { textureDataFile = new FileInfo(sData); } } // Save Texture try { textureFile.Delete(); texture.Save(textureFile.FullName); textureFile.Refresh(); } catch (Exception e) { MpeLog.Error(e); throw new MpeParserException("Error saving font. Could not write to texture file."); } // Save Texture Data Stream s = null; try { textureDataFile.Delete(); s = File.Open(textureDataFile.FullName, FileMode.CreateNew, FileAccess.ReadWrite); SoapFormatter b = new SoapFormatter(); b.Serialize(s, (object)textureCoordinates); textureDataFile.Refresh(); } catch (Exception e) { MpeLog.Debug(e); throw new MpeParserException("Error saving font. Could not write to texture data file."); } finally { if (s != null) { s.Close(); } } }
public virtual void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (doc != null && node != null) { // Type parser.SetValue(doc, node, "type", type.ToString()); // Description string s1 = Description != null ? Description : Type.ToString(); string s2 = (reference != null && reference.Description != null) ? reference.Description : Type.ToString(); if (reference == null || (!s1.Equals(s2))) { parser.SetValue(doc, node, "description", s1); } // Id parser.SetInt(doc, node, "id", Id); // Location - Absolute Positioning Point p = AbsoluteLocation; parser.SetInt(doc, node, "posX", p.X); parser.SetInt(doc, node, "posY", p.Y); // Size if (reference == null || reference.Width != Width) { parser.SetInt(doc, node, "width", Width); } // Height if (reference == null || reference.Height != Height) { parser.SetInt(doc, node, "height", Height); } // DiffuseColor if (reference == null || reference.DiffuseColor != DiffuseColor) { parser.SetColor(doc, node, "colordiffuse", DiffuseColor); } // DimColor if (reference == null || reference.DimColor != DimColor) { parser.SetColor(doc, node, "dimColor", DimColor); } // Animation Animation.Save(doc, node, parser); // Visible //if (Visible == false) //{ parser.SetValue(doc, node, "visible", Visible); //} // Actions if (OnLeft > 0) { parser.SetInt(doc, node, "onleft", OnLeft); } if (OnRight > 0) { parser.SetInt(doc, node, "onright", OnRight); } if (OnUp > 0) { parser.SetInt(doc, node, "onup", OnUp); } if (OnDown > 0) { parser.SetInt(doc, node, "ondown", OnDown); } string[] keys = tags.Keys; for (int i = 0; i < keys.Length; i++) { parser.SetValue(doc, node, keys[i], tags[keys[i]].Value); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeButton button = null; if (reference != null) { button = (MpeButton) reference; } // Size if (button == null || button.Size != Size) { parser.SetInt(doc, node, "width", Width); parser.SetInt(doc, node, "height", Height); } // hyperlink if (button == null || button.Hyperlink != Hyperlink) { parser.SetInt(doc, node, "hyperlink", Hyperlink); } // DiffuseColor if (button == null || button.DiffuseColor != DiffuseColor) { parser.SetColor(doc, node, "colordiffuse", DiffuseColor); } // TextOffsetX if (button == null || button.Padding.Left != Padding.Left) { parser.SetInt(doc, node, "textXOff", Padding.Left); } // TextOffsetY if (button == null || button.Padding.Top != Padding.Top) { parser.SetInt(doc, node, "textYOff", Padding.Top); } // TextureFocus if (button == null || button.TextureFocus == null || button.TextureFocus.Equals(TextureFocus) == false) { if (TextureFocus == null) { parser.SetValue(doc, node, "textureFocus", "-"); } else { parser.SetValue(doc, node, "textureFocus", TextureFocus.Name); } } // TextureNoFocus if (button == null || button.TextureNoFocus == null || button.TextureNoFocus.Equals(TextureNoFocus) == false) { if (TextureNoFocus == null) { parser.SetValue(doc, node, "textureNoFocus", "-"); } else { parser.SetValue(doc, node, "textureNoFocus", TextureNoFocus.Name); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeSpinButton spin = null; if (reference != null && reference is MpeSpinButton) { spin = (MpeSpinButton) reference; } // Fix the Width and Height to be the texture size parser.SetInt(doc, node, "width", TextureSize.Width); parser.SetInt(doc, node, "height", TextureSize.Height); // Font if (spin == null || !spin.Font.Name.Equals(Font.Name)) { parser.SetValue(doc, node, "font", Font.Name); } // Alignment if (spin == null || spin.Alignment != Alignment) { parser.SetValue(doc, node, "align", Alignment.ToString().ToLower()); } // Color if (spin == null || spin.Color != Color) { parser.SetColor(doc, node, "textcolor", Color); } // DisabledColor if (spin == null || spin.DisabledColor != DisabledColor) { parser.SetColor(doc, node, "disabledcolor", DisabledColor); } // Orientation if (spin == null || spin.Orientation != Orientation) { parser.SetValue(doc, node, "orientation", Orientation.ToString().ToLower()); } // Reverse if (spin == null || spin.Reverse != Reverse) { parser.SetValue(doc, node, "reverse", Reverse ? "yes" : "no"); } // ShowRange if (spin == null || spin.ShowRange != ShowRange) { parser.SetValue(doc, node, "showrange", ShowRange ? "yes" : "no"); } // Textures if (spin == null || spin.TextureUp == null || spin.TextureUp.Equals(TextureUp) == false) { if (TextureUp == null) { parser.SetValue(doc, node, "textureUp", "-"); } else { parser.SetValue(doc, node, "textureUp", TextureUp.Name); } } if (spin == null || spin.TextureUpFocus == null || spin.TextureUpFocus.Equals(TextureUpFocus) == false) { if (TextureUpFocus == null) { parser.SetValue(doc, node, "textureUpFocus", "-"); } else { parser.SetValue(doc, node, "textureUpFocus", TextureUpFocus.Name); } } if (spin == null || spin.TextureDown == null || spin.TextureDown.Equals(TextureDown) == false) { if (TextureDown == null) { parser.SetValue(doc, node, "textureDown", "-"); } else { parser.SetValue(doc, node, "textureDown", TextureDown.Name); } } if (spin == null || spin.TextureDownFocus == null || spin.TextureDownFocus.Equals(TextureDownFocus) == false) { if (TextureDownFocus == null) { parser.SetValue(doc, node, "textureDownFocus", "-"); } else { parser.SetValue(doc, node, "textureDownFocus", TextureDownFocus.Name); } } // Items parser.SetValue(doc, node, "subtype", items.Type.ToString().ToLower()); XmlElement subitems = doc.CreateElement("subitems"); parser.SetValue(doc, subitems, "type", items.Type.ToString().ToLower()); parser.SetValue(doc, subitems, "first", items.First); parser.SetValue(doc, subitems, "last", items.Last); parser.SetValue(doc, subitems, "interval", items.Interval); parser.SetValue(doc, subitems, "digits", items.Digits); node.AppendChild(subitems); }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (reference == null) { // Update reference.xml file if (node.Name != "controls") { throw new MpeParserException("Invalid root node <" + node.Name + "> provided."); } // Update the skin node XmlNode skin = node.SelectSingleNode("skin"); if (skin == null) { throw new MpeParserException( "Invalid reference.xml file. The <skin> element must be the first child in the document."); } skin.RemoveAll(); parser.SetValue(doc, skin, "width", Width.ToString()); parser.SetValue(doc, skin, "height", Height.ToString()); // Update the image control node that defines the window background XmlNode image = skin.NextSibling; if (image == null || image.Name.Equals("control") == false) { throw new MpeParserException( "Invalid reference.xml file. A <control> element of type image must follow the <skin> element."); } XmlNode test = image.SelectSingleNode("type"); if (test == null || test.InnerXml.Equals("image") == false) { throw new MpeParserException( "Invalid reference.xml file. A <control> element of type image must follow the <skin> element."); } image.RemoveAll(); backImage.Save(doc, image, parser, null); } else { // Update screen.xml file if (node == null || node.Name.Equals("window") == false) { throw new MpeParserException("Invalid root node <" + node.Name + "> provided. Looking for a <window> element."); } node.RemoveAll(); if (screenType != MpeScreenType.Window) { parser.SetValue(doc, node, "type", screenType.ToString().ToLower()); } parser.SetValue(doc, node, "id", Id.ToString()); parser.SetValue(doc, node, "defaultcontrol", DefaultControl.ToString()); parser.SetValue(doc, node, "allowoverlay", AllowOverlay ? "yes" : "no"); parser.SetValue(doc, node, "autohidetopbar", AutohideTopbar ? "yes" : "no"); XmlElement controls = doc.CreateElement("controls"); node.AppendChild(controls); if (ScreenType == MpeScreenType.Dialog) { MpeGroup dg = DialogGroup; //if (dg.TextureBack != null) { XmlElement image = doc.CreateElement("control"); dg.TextureBackImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); controls.AppendChild(image); //} for (int i = dg.Controls.Count - 1; i >= 0; i--) { if (dg.Controls[i] is MpeControl) { MpeControl control = (MpeControl)dg.Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); controls.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } else { if (TextureBack != null) { XmlElement image = doc.CreateElement("control"); backImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); controls.AppendChild(image); } for (int i = Controls.Count - 1; i >= 0; i--) { if (Controls[i] is MpeControl) { MpeControl control = (MpeControl)Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); controls.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (doc != null && node != null) { base.Save(doc, node, parser, reference); //parser.SetValue(doc, node, "animation", Animation.ToString()); XmlElement mpenode = doc.CreateElement("mpe"); node.AppendChild(mpenode); parser.SetValue(doc, mpenode, "layout", LayoutStyle.ToString()); parser.SetValue(doc, mpenode, "spring", Spring ? "yes" : "no"); parser.SetInt(doc, mpenode, "spacing", Spacing); parser.SetPadding(doc, mpenode, "padding", Padding); if (backImage != null && backImage.Texture != null) { XmlElement image = doc.CreateElement("control"); backImage.Location = AbsoluteLocation; backImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); backImage.Location = Point.Empty; node.AppendChild(image); } if (reference != null) { for (int i = Controls.Count - 1; i >= 0; i--) { if (Controls[i] is MpeControl) { MpeControl control = (MpeControl) Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); node.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeTextArea textarea = null; if (reference != null && reference is MpeTextArea) { textarea = (MpeTextArea)reference; } // Label Properties Point p = label.AbsoluteLocation; parser.SetInt(doc, node, "posX", p.X); parser.SetInt(doc, node, "posY", p.Y); parser.SetInt(doc, node, "width", label.Width); parser.SetInt(doc, node, "height", label.Height); parser.SetValue(doc, node, "text", Text); if (textarea == null || !textarea.Font.Name.Equals(Font.Name)) { parser.SetValue(doc, node, "font", Font.Name); } if (textarea == null || textarea.Color != Color) { parser.SetColor(doc, node, "textcolor", Color); } if (textarea == null || textarea.DisabledColor != DisabledColor) { parser.SetColor(doc, node, "disabledcolor", DisabledColor); } // SpinButton Properties p = spinButton.AbsoluteLocation; parser.SetInt(doc, node, "SpinPosX", p.X); parser.SetInt(doc, node, "SpinPosY", p.Y); if (textarea == null || textarea.SpinAlign != SpinAlign) { parser.SetValue(doc, node, "SpinAlign", SpinAlign.ToString().ToLower()); } if (textarea == null || textarea.SpinSize != SpinSize) { parser.SetInt(doc, node, "SpinWidth", SpinSize.Width); parser.SetInt(doc, node, "SpinHeight", SpinSize.Height); } if (textarea == null || textarea.SpinColor != SpinColor) { parser.SetColor(doc, node, "SpinColor", SpinColor); } if (textarea == null || textarea.TextureUp == null || textarea.TextureUp.Equals(TextureUp) == false) { if (TextureUp == null) { parser.SetValue(doc, node, "textureUp", "-"); } else { parser.SetValue(doc, node, "textureUp", TextureUp.Name); } } if (textarea == null || textarea.TextureUpFocus == null || textarea.TextureUpFocus.Equals(TextureUpFocus) == false ) { if (TextureUpFocus == null) { parser.SetValue(doc, node, "textureUpFocus", "-"); } else { parser.SetValue(doc, node, "textureUpFocus", TextureUpFocus.Name); } } if (textarea == null || textarea.TextureDown == null || textarea.TextureDown.Equals(TextureDown) == false) { if (TextureDown == null) { parser.SetValue(doc, node, "textureDown", "-"); } else { parser.SetValue(doc, node, "textureDown", TextureDown.Name); } } if (textarea == null || textarea.TextureDownFocus == null || textarea.TextureDownFocus.Equals(TextureDownFocus) == false) { if (TextureDownFocus == null) { parser.SetValue(doc, node, "textureDownFocus", "-"); } else { parser.SetValue(doc, node, "textureDownFocus", TextureDownFocus.Name); } } // Mpe if (Spacing != 0 || Padding.None == false) { XmlElement mpenode = doc.CreateElement("mpe"); node.AppendChild(mpenode); if (Spacing != 0) { parser.SetInt(doc, mpenode, "spacing", Spacing); } if (Padding.None == false) { parser.SetPadding(doc, mpenode, "padding", Padding); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); // Remove Width and Height parser.RemoveNode(node, "width"); parser.RemoveNode(node, "height"); MpeCheckBox checkbox = null; if (reference != null && reference is MpeCheckBox) { checkbox = (MpeCheckBox) reference; } // Label label.Save(doc, node, parser, checkbox != null ? checkbox.label : null); parser.SetValue(doc, node, "type", Type.ToString()); // TextureChecked if (checkbox == null || checkbox.TextureChecked == null || checkbox.TextureChecked.Equals(TextureChecked) == false ) { if (TextureChecked == null) { parser.SetValue(doc, node, "textureCheckmark", "-"); } else { parser.SetValue(doc, node, "textureCheckmark", TextureChecked.Name); } } // Texture if (checkbox == null || checkbox.Texture == null || checkbox.Texture.Equals(Texture) == false) { if (Texture == null) { parser.SetValue(doc, node, "textureCheckmarkNoFocus", "-"); } else { parser.SetValue(doc, node, "textureCheckmarkNoFocus", Texture.Name); } } // TextureSize if (checkbox == null || checkbox.TextureSize != TextureSize) { parser.SetInt(doc, node, "MarkWidth", TextureSize.Width); parser.SetInt(doc, node, "MarkHeight", TextureSize.Height); } // Shadow parser.SetValue(doc, node, "shadow", "no"); // Save Correct Type //parser.SetValue(doc, node, "type", parser.ControlTypeToXmlString(Type)); //parser.SetValue(doc, node, "type", Type.ToString()); }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeSpinButton spin = null; if (reference != null && reference is MpeSpinButton) { spin = (MpeSpinButton)reference; } // Fix the Width and Height to be the texture size parser.SetInt(doc, node, "width", TextureSize.Width); parser.SetInt(doc, node, "height", TextureSize.Height); // Font if (spin == null || !spin.Font.Name.Equals(Font.Name)) { parser.SetValue(doc, node, "font", Font.Name); } // Alignment if (spin == null || spin.Alignment != Alignment) { parser.SetValue(doc, node, "align", Alignment.ToString().ToLower()); } // Color if (spin == null || spin.Color != Color) { parser.SetColor(doc, node, "textcolor", Color); } // DisabledColor if (spin == null || spin.DisabledColor != DisabledColor) { parser.SetColor(doc, node, "disabledcolor", DisabledColor); } // Orientation if (spin == null || spin.Orientation != Orientation) { parser.SetValue(doc, node, "orientation", Orientation.ToString().ToLower()); } // Reverse if (spin == null || spin.Reverse != Reverse) { parser.SetValue(doc, node, "reverse", Reverse ? "yes" : "no"); } // ShowRange if (spin == null || spin.ShowRange != ShowRange) { parser.SetValue(doc, node, "showrange", ShowRange ? "yes" : "no"); } // Textures if (spin == null || spin.TextureUp == null || spin.TextureUp.Equals(TextureUp) == false) { if (TextureUp == null) { parser.SetValue(doc, node, "textureUp", "-"); } else { parser.SetValue(doc, node, "textureUp", TextureUp.Name); } } if (spin == null || spin.TextureUpFocus == null || spin.TextureUpFocus.Equals(TextureUpFocus) == false) { if (TextureUpFocus == null) { parser.SetValue(doc, node, "textureUpFocus", "-"); } else { parser.SetValue(doc, node, "textureUpFocus", TextureUpFocus.Name); } } if (spin == null || spin.TextureDown == null || spin.TextureDown.Equals(TextureDown) == false) { if (TextureDown == null) { parser.SetValue(doc, node, "textureDown", "-"); } else { parser.SetValue(doc, node, "textureDown", TextureDown.Name); } } if (spin == null || spin.TextureDownFocus == null || spin.TextureDownFocus.Equals(TextureDownFocus) == false) { if (TextureDownFocus == null) { parser.SetValue(doc, node, "textureDownFocus", "-"); } else { parser.SetValue(doc, node, "textureDownFocus", TextureDownFocus.Name); } } // Items parser.SetValue(doc, node, "subtype", items.Type.ToString().ToLower()); XmlElement subitems = doc.CreateElement("subitems"); parser.SetValue(doc, subitems, "type", items.Type.ToString().ToLower()); parser.SetValue(doc, subitems, "first", items.First); parser.SetValue(doc, subitems, "last", items.Last); parser.SetValue(doc, subitems, "interval", items.Interval); parser.SetValue(doc, subitems, "digits", items.Digits); node.AppendChild(subitems); }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeTextArea textarea = null; if (reference != null && reference is MpeTextArea) { textarea = (MpeTextArea) reference; } // Label Properties Point p = label.AbsoluteLocation; parser.SetInt(doc, node, "posX", p.X); parser.SetInt(doc, node, "posY", p.Y); parser.SetInt(doc, node, "width", label.Width); parser.SetInt(doc, node, "height", label.Height); parser.SetValue(doc, node, "text", Text); if (textarea == null || !textarea.Font.Name.Equals(Font.Name)) { parser.SetValue(doc, node, "font", Font.Name); } if (textarea == null || textarea.Color != Color) { parser.SetColor(doc, node, "textcolor", Color); } if (textarea == null || textarea.DisabledColor != DisabledColor) { parser.SetColor(doc, node, "disabledcolor", DisabledColor); } // SpinButton Properties p = spinButton.AbsoluteLocation; parser.SetInt(doc, node, "SpinPosX", p.X); parser.SetInt(doc, node, "SpinPosY", p.Y); if (textarea == null || textarea.SpinAlign != SpinAlign) { parser.SetValue(doc, node, "SpinAlign", SpinAlign.ToString().ToLower()); } if (textarea == null || textarea.SpinSize != SpinSize) { parser.SetInt(doc, node, "SpinWidth", SpinSize.Width); parser.SetInt(doc, node, "SpinHeight", SpinSize.Height); } if (textarea == null || textarea.SpinColor != SpinColor) { parser.SetColor(doc, node, "SpinColor", SpinColor); } if (textarea == null || textarea.TextureUp == null || textarea.TextureUp.Equals(TextureUp) == false) { if (TextureUp == null) { parser.SetValue(doc, node, "textureUp", "-"); } else { parser.SetValue(doc, node, "textureUp", TextureUp.Name); } } if (textarea == null || textarea.TextureUpFocus == null || textarea.TextureUpFocus.Equals(TextureUpFocus) == false ) { if (TextureUpFocus == null) { parser.SetValue(doc, node, "textureUpFocus", "-"); } else { parser.SetValue(doc, node, "textureUpFocus", TextureUpFocus.Name); } } if (textarea == null || textarea.TextureDown == null || textarea.TextureDown.Equals(TextureDown) == false) { if (TextureDown == null) { parser.SetValue(doc, node, "textureDown", "-"); } else { parser.SetValue(doc, node, "textureDown", TextureDown.Name); } } if (textarea == null || textarea.TextureDownFocus == null || textarea.TextureDownFocus.Equals(TextureDownFocus) == false) { if (TextureDownFocus == null) { parser.SetValue(doc, node, "textureDownFocus", "-"); } else { parser.SetValue(doc, node, "textureDownFocus", TextureDownFocus.Name); } } // Mpe if (Spacing != 0 || Padding.None == false) { XmlElement mpenode = doc.CreateElement("mpe"); node.AppendChild(mpenode); if (Spacing != 0) { parser.SetInt(doc, mpenode, "spacing", Spacing); } if (Padding.None == false) { parser.SetPadding(doc, mpenode, "padding", Padding); } } }
public void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { MpeLog.Debug("MpeFont.Save()"); textureWorkDir = parser.FontDir.FullName; parser.SetValue(doc, node, "name", Name); parser.SetValue(doc, node, "filename", Family); parser.SetInt(doc, node, "height", Size); parser.SetValue(doc, node, "style", Style); parser.SetInt(doc, node, "start", StartCharacter); parser.SetInt(doc, node, "end", EndCharacter - 1); // Setup Texture Files if (textureWorkDir != null) { int size = Size; string sTexture = textureWorkDir + "\\" + name + "_" + size + ".png"; string sData = sTexture + ".xml"; if (textureFile != null && textureFile.Exists && textureFile.FullName.Equals(sTexture) == false) { MpeLog.Info("Moving texture file..."); textureFile.MoveTo(sTexture); textureFile.Refresh(); } else { textureFile = new FileInfo(sTexture); } if (textureDataFile != null && textureDataFile.Exists && textureDataFile.FullName.Equals(sData) == false) { MpeLog.Info("Moving texture data file..."); textureDataFile.MoveTo(sData); textureDataFile.Refresh(); } else { textureDataFile = new FileInfo(sData); } } // Save Texture try { textureFile.Delete(); texture.Save(textureFile.FullName); textureFile.Refresh(); } catch (Exception e) { MpeLog.Error(e); throw new MpeParserException("Error saving font. Could not write to texture file."); } // Save Texture Data Stream s = null; try { textureDataFile.Delete(); s = File.Open(textureDataFile.FullName, FileMode.CreateNew, FileAccess.ReadWrite); SoapFormatter b = new SoapFormatter(); b.Serialize(s, (object) textureCoordinates); textureDataFile.Refresh(); } catch (Exception e) { MpeLog.Debug(e); throw new MpeParserException("Error saving font. Could not write to texture data file."); } finally { if (s != null) { s.Close(); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (doc != null && node != null) { base.Save(doc, node, parser, reference); if (AutoSize) { parser.RemoveNode(node, "width"); parser.RemoveNode(node, "height"); } MpeImage image = null; if (reference != null && reference is MpeImage) { image = (MpeImage) reference; } // For the reference image, the texture should be set to the default screen background if (IsReference) { parser.SetValue(doc, node, "texture", (MpeScreen.TextureBack != null ? MpeScreen.TextureBack.Name : "-")); } else { parser.SetValue(doc, node, "texture", (Texture != null ? Texture.Name : "-")); } if (image == null || image.Centered != Centered) { parser.SetValue(doc, node, "centered", Centered ? "yes" : "no"); } if (image == null || image.Filtered != Filtered) { parser.SetValue(doc, node, "filtered", Filtered ? "yes" : "no"); } if (image == null || image.KeepAspectRatio != KeepAspectRatio) { parser.SetValue(doc, node, "keepaspectratio", KeepAspectRatio ? "yes" : "no"); } if (image == null || image.ColorKey != ColorKey) { parser.SetInt(doc, node, "colorkey", ColorKey); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeSelectButton button = null; if (reference != null && reference is MpeSelectButton) { button = (MpeSelectButton) reference; } // Regular Button Properties parser.SetValue(doc, node, "label", label.Text); if (button == null || button.label.Font.Name.Equals(label.Font.Name) == false) { parser.SetValue(doc, node, "font", label.Font.Name); } if (button == null || button.label.Alignment != label.Alignment) { parser.SetValue(doc, node, "align", label.Alignment.ToString().ToLower()); } if (button == null || button.label.TextColor != label.TextColor) { parser.SetColor(doc, node, "textcolor", label.TextColor); } if (button == null || button.label.DisabledColor != label.DisabledColor) { parser.SetColor(doc, node, "disabledcolor", label.DisabledColor); } if (button == null || button.TextureButton == null || button.TextureButton.Equals(TextureButton) == false) { if (TextureButton == null) { parser.SetValue(doc, node, "textureNoFocus", "-"); } else { parser.SetValue(doc, node, "textureNoFocus", TextureButton.Name); } } if (button == null || button.TextureButtonFocus == null || button.TextureButtonFocus.Equals(TextureButtonFocus) == false) { if (TextureButtonFocus == null) { parser.SetValue(doc, node, "textureFocus", "-"); } else { parser.SetValue(doc, node, "textureFocus", TextureButtonFocus.Name); } } if (button == null || button.LabelPadding.Left != LabelPadding.Left) { parser.SetInt(doc, node, "textXOff2", LabelPadding.Left); } if (button == null || button.LabelPadding.Top != LabelPadding.Top) { parser.SetInt(doc, node, "textYOff2", LabelPadding.Top); } // Select Button Specific Properties if (button == null || button.TexturePadding.Width != TexturePadding.Width) { parser.SetInt(doc, node, "textXOff", TexturePadding.Width); } if (button == null || button.LabelPadding.Top != LabelPadding.Top) { parser.SetInt(doc, node, "textYOff", LabelPadding.Top); } if (button == null || button.textureSize != textureSize) { parser.SetInt(doc, node, "textureWidth", textureSize.Width); parser.SetInt(doc, node, "textureHeight", textureSize.Height); } if (button == null || button.TextureBackground == null || button.TextureBackground.Equals(TextureBackground) == false) { if (TextureBackground == null) { parser.SetValue(doc, node, "texturebg", "-"); } else { parser.SetValue(doc, node, "texturebg", TextureBackground.Name); } } if (button == null || button.TextureLeft == null || button.TextureLeft.Equals(TextureLeft) == false) { if (TextureLeft == null) { parser.SetValue(doc, node, "textureLeft", "-"); } else { parser.SetValue(doc, node, "textureLeft", TextureLeft.Name); } } if (button == null || button.TextureLeftFocus == null || button.TextureLeftFocus.Equals(TextureLeftFocus) == false ) { if (TextureLeftFocus == null) { parser.SetValue(doc, node, "textureLeftFocus", "-"); } else { parser.SetValue(doc, node, "textureLeftFocus", TextureLeftFocus.Name); } } if (button == null || button.TextureRight == null || button.TextureRight.Equals(TextureRight) == false) { if (TextureRight == null) { parser.SetValue(doc, node, "textureRight", "-"); } else { parser.SetValue(doc, node, "textureRight", TextureRight.Name); } } if (button == null || button.TextureRightFocus == null || button.TextureRightFocus.Equals(TextureRightFocus) == false) { if (TextureRightFocus == null) { parser.SetValue(doc, node, "textureRightFocus", "-"); } else { parser.SetValue(doc, node, "textureRightFocus", TextureRightFocus.Name); } } XmlElement subitems = doc.CreateElement("subitems"); for (int i = 0; items != null && items.Values != null && i < items.Values.Count; i++) { XmlElement subitem = doc.CreateElement("subitem"); subitem.AppendChild(doc.CreateTextNode(items.Values[i].Value)); subitems.AppendChild(subitem); } node.AppendChild(subitems); //parser.SetValue(doc, node, "type", parser.ControlTypeToXmlString(Type)); }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { if (reference == null) { // Update reference.xml file if (node.Name != "controls") { throw new MpeParserException("Invalid root node <" + node.Name + "> provided."); } // Update the skin node XmlNode skin = node.SelectSingleNode("skin"); if (skin == null) { throw new MpeParserException( "Invalid reference.xml file. The <skin> element must be the first child in the document."); } skin.RemoveAll(); parser.SetValue(doc, skin, "width", Width.ToString()); parser.SetValue(doc, skin, "height", Height.ToString()); // Update the image control node that defines the window background XmlNode image = skin.NextSibling; if (image == null || image.Name.Equals("control") == false) { throw new MpeParserException( "Invalid reference.xml file. A <control> element of type image must follow the <skin> element."); } XmlNode test = image.SelectSingleNode("type"); if (test == null || test.InnerXml.Equals("image") == false) { throw new MpeParserException( "Invalid reference.xml file. A <control> element of type image must follow the <skin> element."); } image.RemoveAll(); backImage.Save(doc, image, parser, null); } else { // Update screen.xml file if (node == null || node.Name.Equals("window") == false) { throw new MpeParserException("Invalid root node <" + node.Name + "> provided. Looking for a <window> element."); } node.RemoveAll(); if (screenType != MpeScreenType.Window) { parser.SetValue(doc, node, "type", screenType.ToString().ToLower()); } parser.SetValue(doc, node, "id", Id.ToString()); parser.SetValue(doc, node, "defaultcontrol", DefaultControl.ToString()); parser.SetValue(doc, node, "allowoverlay", AllowOverlay ? "yes" : "no"); parser.SetValue(doc, node, "autohidetopbar", AutohideTopbar ? "yes" : "no"); XmlElement controls = doc.CreateElement("controls"); node.AppendChild(controls); if (ScreenType == MpeScreenType.Dialog) { MpeGroup dg = DialogGroup; //if (dg.TextureBack != null) { XmlElement image = doc.CreateElement("control"); dg.TextureBackImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); controls.AppendChild(image); //} for (int i = dg.Controls.Count - 1; i >= 0; i--) { if (dg.Controls[i] is MpeControl) { MpeControl control = (MpeControl) dg.Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); controls.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } else { if (TextureBack != null) { XmlElement image = doc.CreateElement("control"); backImage.Save(doc, image, parser, parser.GetControl(MpeControlType.Image)); controls.AppendChild(image); } for (int i = Controls.Count - 1; i >= 0; i--) { if (Controls[i] is MpeControl) { MpeControl control = (MpeControl) Controls[i]; try { XmlElement element = doc.CreateElement("control"); MpeControl referenceControl = parser.GetControl(control.Type); control.Save(doc, element, parser, referenceControl); controls.AppendChild(element); } catch (Exception e) { MpeLog.Debug(e); MpeLog.Error(e); throw new MpeParserException(e.Message); } } } } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeToggleButton toggle = null; if (reference != null && reference is MpeToggleButton) { toggle = (MpeToggleButton) reference; } // TextureFocus if (toggle == null || toggle.AlternateTextureFocus == null || toggle.AlternateTextureFocus.Equals(AlternateTextureFocus) == false) { if (AlternateTextureFocus == null) { parser.SetValue(doc, node, "AltTextureFocus", "-"); } else { parser.SetValue(doc, node, "AltTextureFocus", AlternateTextureFocus.Name); } } // AlternateTextureNoFocus if (toggle == null || toggle.AlternateTextureNoFocus == null || toggle.AlternateTextureNoFocus.Equals(AlternateTextureNoFocus) == false) { if (AlternateTextureNoFocus == null) { parser.SetValue(doc, node, "AltTextureNoFocus", "-"); } else { parser.SetValue(doc, node, "AltTextureNoFocus", AlternateTextureNoFocus.Name); } } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeLabel label = null; if (reference != null && reference is MpeLabel) { label = (MpeLabel) reference; } // Fix the Left Position if (Alignment == MpeControlAlignment.Right) { parser.SetInt(doc, node, "posX", Right); } // Fix the Width and Height parser.RemoveNode(node, "width"); parser.RemoveNode(node, "height"); // Text parser.SetValue(doc, node, "label", Text); // Font if (label == null || !label.Font.Name.Equals(Font.Name)) { parser.SetValue(doc, node, "font", Font.Name); } // Alignment if (label == null || label.Alignment != Alignment) { parser.SetValue(doc, node, "align", Alignment.ToString().ToLower()); } // Color if (label == null || label.TextColor != TextColor) { parser.SetColor(doc, node, "textcolor", TextColor); } // DisabledColor if (label == null || label.DisabledColor != DisabledColor) { parser.SetColor(doc, node, "disabledcolor", DisabledColor); } }
public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference) { base.Save(doc, node, parser, reference); MpeSelectButton button = null; if (reference != null && reference is MpeSelectButton) { button = (MpeSelectButton)reference; } // Regular Button Properties parser.SetValue(doc, node, "label", label.Text); if (button == null || button.label.Font.Name.Equals(label.Font.Name) == false) { parser.SetValue(doc, node, "font", label.Font.Name); } if (button == null || button.label.Alignment != label.Alignment) { parser.SetValue(doc, node, "align", label.Alignment.ToString().ToLower()); } if (button == null || button.label.TextColor != label.TextColor) { parser.SetColor(doc, node, "textcolor", label.TextColor); } if (button == null || button.label.DisabledColor != label.DisabledColor) { parser.SetColor(doc, node, "disabledcolor", label.DisabledColor); } if (button == null || button.TextureButton == null || button.TextureButton.Equals(TextureButton) == false) { if (TextureButton == null) { parser.SetValue(doc, node, "textureNoFocus", "-"); } else { parser.SetValue(doc, node, "textureNoFocus", TextureButton.Name); } } if (button == null || button.TextureButtonFocus == null || button.TextureButtonFocus.Equals(TextureButtonFocus) == false) { if (TextureButtonFocus == null) { parser.SetValue(doc, node, "textureFocus", "-"); } else { parser.SetValue(doc, node, "textureFocus", TextureButtonFocus.Name); } } if (button == null || button.LabelPadding.Left != LabelPadding.Left) { parser.SetInt(doc, node, "textXOff2", LabelPadding.Left); } if (button == null || button.LabelPadding.Top != LabelPadding.Top) { parser.SetInt(doc, node, "textYOff2", LabelPadding.Top); } // Select Button Specific Properties if (button == null || button.TexturePadding.Width != TexturePadding.Width) { parser.SetInt(doc, node, "textXOff", TexturePadding.Width); } if (button == null || button.LabelPadding.Top != LabelPadding.Top) { parser.SetInt(doc, node, "textYOff", LabelPadding.Top); } if (button == null || button.textureSize != textureSize) { parser.SetInt(doc, node, "textureWidth", textureSize.Width); parser.SetInt(doc, node, "textureHeight", textureSize.Height); } if (button == null || button.TextureBackground == null || button.TextureBackground.Equals(TextureBackground) == false) { if (TextureBackground == null) { parser.SetValue(doc, node, "texturebg", "-"); } else { parser.SetValue(doc, node, "texturebg", TextureBackground.Name); } } if (button == null || button.TextureLeft == null || button.TextureLeft.Equals(TextureLeft) == false) { if (TextureLeft == null) { parser.SetValue(doc, node, "textureLeft", "-"); } else { parser.SetValue(doc, node, "textureLeft", TextureLeft.Name); } } if (button == null || button.TextureLeftFocus == null || button.TextureLeftFocus.Equals(TextureLeftFocus) == false ) { if (TextureLeftFocus == null) { parser.SetValue(doc, node, "textureLeftFocus", "-"); } else { parser.SetValue(doc, node, "textureLeftFocus", TextureLeftFocus.Name); } } if (button == null || button.TextureRight == null || button.TextureRight.Equals(TextureRight) == false) { if (TextureRight == null) { parser.SetValue(doc, node, "textureRight", "-"); } else { parser.SetValue(doc, node, "textureRight", TextureRight.Name); } } if (button == null || button.TextureRightFocus == null || button.TextureRightFocus.Equals(TextureRightFocus) == false) { if (TextureRightFocus == null) { parser.SetValue(doc, node, "textureRightFocus", "-"); } else { parser.SetValue(doc, node, "textureRightFocus", TextureRightFocus.Name); } } XmlElement subitems = doc.CreateElement("subitems"); for (int i = 0; items != null && items.Values != null && i < items.Values.Count; i++) { XmlElement subitem = doc.CreateElement("subitem"); subitem.AppendChild(doc.CreateTextNode(items.Values[i].Value)); subitems.AppendChild(subitem); } node.AppendChild(subitems); //parser.SetValue(doc, node, "type", parser.ControlTypeToXmlString(Type)); }