public MpeGroup(MpeGroup group) : base(group) { MpeLog.Debug("MpeGroup(group)"); Type = MpeControlType.Group; AllowDrop = true; //animation = group.animation; }
public MpeSpinButton(MpeSpinButton spinner) : base(spinner) { MpeLog.Debug("MpeSpinButton(spinner)"); orientation = spinner.orientation; reverse = spinner.reverse; showRange = spinner.showRange; textureUp = spinner.textureUp; textureUpFocus = spinner.textureUpFocus; textureDown = spinner.textureDown; textureDownFocus = spinner.textureDownFocus; label = new MpeLabel(spinner.label); imageUp = new MpeImage(spinner.imageUp); imageDown = new MpeImage(spinner.imageDown); imageGroup = new MpeGroup(spinner.imageGroup); items = new MpeItemManager(spinner.items); items.TypeChanging += new MpeItemManager.TypeChangingHandler(OnItemTypeChanging); items.Values.ItemInserted += new MpeItemCollection.ItemInsertedHandler(OnItemInserted); items.Values.ItemRemoved += new MpeItemCollection.ItemRemovedHandler(OnItemRemoved); items.Values.ItemSet += new MpeItemCollection.ItemSetHandler(OnItemSet); items.Values.ItemsCleared += new MpeItemCollection.ItemsClearedHandler(OnItemsCleared); SetLabel(); Prepare(); }
public MpeSpinButton() : base() { MpeLog.Debug("MpeSpinButton()"); Type = MpeControlType.SpinButton; orientation = MpeControlOrientation.Horizontal; alignment = MpeControlAlignment.Right; reverse = false; spacing = 5; layoutStyle = MpeLayoutStyle.HorizontalFlow; alignment = MpeControlAlignment.Left; autoSize = true; controlLock.Size = true; // Label label = new MpeLabel(); label.Embedded = true; // Images imageGroup = new MpeGroup(); imageGroup.Embedded = true; imageGroup.ShowBorder = false; imageGroup.LayoutStyle = MpeLayoutStyle.VerticalFlow; imageUp = new MpeImage(); imageUp.Embedded = true; imageUp.Size = new Size(16, 16); imageDown = new MpeImage(); imageDown.Embedded = true; imageDown.Size = new Size(16, 16); // Items items = new MpeItemManager(); items.Type = MpeItemType.Integer; items.TypeChanging += new MpeItemManager.TypeChangingHandler(OnItemTypeChanging); items.Values.ItemInserted += new MpeItemCollection.ItemInsertedHandler(OnItemInserted); items.Values.ItemRemoved += new MpeItemCollection.ItemRemovedHandler(OnItemRemoved); items.Values.ItemSet += new MpeItemCollection.ItemSetHandler(OnItemSet); items.Values.ItemsCleared += new MpeItemCollection.ItemsClearedHandler(OnItemsCleared); SetLabel(); Prepare(); }
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 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; }