Example #1
0
 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 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 Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeImage.Load()");
            this.parser = parser;
            AutoSize    = false;
            base.Load(iterator, parser);
            Texture = parser.GetImageFile(iterator, "texture", Texture);
            tags.Remove("texture");
            if (parser.GetInt(iterator, "width", -1) < 0 || parser.GetInt(iterator, "height", -1) < 0)
            {
                if (Texture == null)
                {
                    AutoSize = false;
                    Size     = new Size(64, 64);
                }
                else
                {
                    AutoSize = true;
                }
            }
            Centered = parser.GetBoolean(iterator, "centered", Centered);
            tags.Remove("centered");
            Filtered = parser.GetBoolean(iterator, "filtered", Filtered);
            tags.Remove("filtered");
            KeepAspectRatio = parser.GetBoolean(iterator, "keepaspectratio", KeepAspectRatio);
            tags.Remove("keepaspectratio");
            ColorKey = parser.GetInt(iterator, "colorkey", ColorKey);
            tags.Remove("colorkey");

            Modified = false;
        }
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            base.Load(iterator, parser);
            MpeLog.Debug("MpeCheckBox.Load()");
            this.parser = parser;
            label.Load(iterator, parser);
            label.Enabled = false;
            tags.Remove("label");
            tags.Remove("align");
            tags.Remove("textcolor");
            tags.Remove("disabledcolor");
            tags.Remove("font");
            // Textures
            Texture = parser.GetImageFile(iterator, "textureCheckmarkNoFocus", Texture);
            tags.Remove("textureCheckmarkNoFocus");
            TextureChecked = parser.GetImageFile(iterator, "textureCheckmark", TextureChecked);
            tags.Remove("textureCheckmark");
            int w = parser.GetInt(iterator, "MarkWidth", TextureSize.Width);

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

            tags.Remove("MarkHeight");
            TextureSize = new Size(w, h);
            Modified    = false;
        }
        public override void 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 Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeSelectButton.Load()");
            base.Load(iterator, parser);
            this.parser = parser;
            // Regular Button Properties
            label.Load(iterator, parser);
            label.AutoSize     = false;
            label.Size         = new Size(parser.GetInt(iterator, "width", Width), parser.GetInt(iterator, "height", Height));
            offset             = new Point(parser.GetInt(iterator, "textXOff2", offset.X), parser.GetInt(iterator, "textYOff2", offset.Y));
            TextureButton      = parser.GetImageFile(iterator, "textureNoFocus", TextureButton);
            TextureButtonFocus = parser.GetImageFile(iterator, "textureFocus", TextureButton);
            tags.Remove("align");
            tags.Remove("font");
            tags.Remove("textcolor");
            tags.Remove("disabledcolor");
            tags.Remove("label");
            tags.Remove("textXOff");
            tags.Remove("textYOff");
            tags.Remove("textureFocus");
            tags.Remove("textureNoFocus");
            // Select Button Properties
            int x = parser.GetInt(iterator, "textXOff", TexturePadding.Width);

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

            while (i.MoveNext())
            {
                MpeItem item = new MpeItem();
                item.Value = i.Current.Value;
                items.Values.Add(item);
            }
            Prepare();
            Modified = false;
        }
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
     MpeLog.Debug("MpeToggleButton.Load()");
     base.Load(iterator, parser);
     this.parser             = parser;
     AlternateTextureFocus   = parser.GetImageFile(iterator, "AltTextureFocus", AlternateTextureFocus);
     AlternateTextureNoFocus = parser.GetImageFile(iterator, "AltTextureNoFocus", AlternateTextureNoFocus);
     tags.Remove("AltTextureFocus");
     tags.Remove("AltTextureNoFocus");
     Modified = false;
 }
        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);
                            }
                        }
                    }
                }
            }
        }
Example #9
0
 public MpeControl()
 {
     MpeLog.Debug("MpeControl()");
     preparing = true;
     SetStyle(ControlStyles.SupportsTransparentBackColor, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.ResizeRedraw, true);
     Animation                = new MpeAnimationType();
     BackColor                = Color.Transparent;
     Size                     = new Size(64, 64);
     Location                 = new Point(8, 8);
     alignment                = MpeControlAlignment.Left;
     autoSize                 = false;
     borderPen                = new Pen(Color.FromArgb(128, 255, 255, 255), 1.0f);
     borderPen.DashStyle      = DashStyle.Dash;
     controlLock              = new MpeControlLock();
     controlLock.LockChanged += new MpeControlLock.LockChangedHandler(OnLockChanged);
     description              = "";
     diffuseColor             = Color.FromArgb(255, 255, 255, 255);
     dimColor                 = Color.FromArgb(0x60ffffff);
     embedded                 = false;
     enabled                  = true;
     focused                  = false;
     id       = 0;
     masked   = false;
     modified = false;
     onLeft   = 0;
     onRight  = 0;
     onUp     = 0;
     onDown   = 0;
     padding  = new MpeControlPadding(0);
     padding.PaddingChanged += new MpeControlPadding.PaddingChangedHandler(OnPaddingChanged);
     parser           = null;
     textBrush        = new SolidBrush(Color.Black);
     type             = MpeControlType.Empty;
     visible          = "true";
     screen           = null;
     tags             = new MpeTagCollection();
     tags.TagAdded   += new MpeTagCollection.TagAddedHandler(OnTagCollectionChanged);
     tags.TagChanged += new MpeTagCollection.TagChangedHandler(OnTagCollectionChanged);
     tags.TagRemoved += new MpeTagCollection.TagRemovedHandler(OnTagCollectionChanged);
     preparing        = false;
     reference        = false;
 }
        public MpeAnimationEditorForm(MpeAnimationType currentValue, MpeParser parser, IWindowsFormsEditorService editorService)
        {
            InitializeComponent();
            MpeAnimationBaseType mp = new MpeAnimationBaseType();

            _anim = currentValue;
            comboBox1.SelectedIndex      = 0;
            propertyGrid1.SelectedObject = _anim.Animation[comboBox1.SelectedIndex];
            if (_anim.Animation[comboBox1.SelectedIndex].Enabled)
            {
                checkBox1.Checked     = true;
                propertyGrid1.Enabled = true;
            }
            else
            {
                checkBox1.Checked     = false;
                propertyGrid1.Enabled = false;
            }
        }
 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);
         }
     }
 }
Example #12
0
        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 MpeAnimationEditorForm(MpeAnimationType currentValue, MpeParser parser, IWindowsFormsEditorService editorService)
    {
      InitializeComponent();
      MpeAnimationBaseType mp = new MpeAnimationBaseType();
      _anim = currentValue;
      comboBox1.SelectedIndex = 0;
      propertyGrid1.SelectedObject = _anim.Animation[comboBox1.SelectedIndex];
      if (_anim.Animation[comboBox1.SelectedIndex].Enabled)
      {
        checkBox1.Checked = true;
        propertyGrid1.Enabled = true;
      }
      else
      {
        checkBox1.Checked = false;
        propertyGrid1.Enabled = false;
      }


    }
 public MpeImageEditorForm(FileInfo currentValue, MpeParser skinParser, IWindowsFormsEditorService editorService)
 {
   InitializeComponent();
   this.skinParser = skinParser;
   this.editorService = editorService;
   imageList.SelectionMode = SelectionMode.One;
   imageList.Items.Add("(none)");
   for (int i = 0; i < skinParser.ImageFiles.Length; i++)
   {
     imageList.Items.Add(skinParser.ImageFiles[i]);
     if (skinParser.ImageFiles[i].Equals(currentValue))
     {
       imageList.SelectedIndex = (i + 1);
     }
   }
   MpeScreen window = (MpeScreen) skinParser.GetControl(MpeControlType.Screen);
   if (window.TextureBack != null)
   {
     thumbPanel.BackgroundImage = new Bitmap(window.TextureBack.FullName);
   }
   imageList.MouseWheel += new MouseEventHandler(imageList_MouseWheel);
 }
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
     MpeLog.Debug("MpeButton.Load()");
     base.Load(iterator, parser);
     this.parser = parser;
     if (Text != null && Text.Equals("-"))
     {
         Text = "";
     }
     AutoSize     = false;
     TextureFocus = parser.GetImageFile(iterator, "textureFocus", TextureFocus);
     tags.Remove("textureFocus");
     TextureNoFocus = parser.GetImageFile(iterator, "textureNoFocus", TextureNoFocus);
     tags.Remove("textureNoFocus");
     if (TextureNoFocusImage != null)
     {
         if (TextureNoFocusImage.Width == Width && TextureNoFocusImage.Height == Height)
         {
             MpeLog.Debug("TextureNoFocus = " + TextureNoFocusImage.Size + " AutoSize enabled");
             AutoSize = true;
         }
     }
     else if (TextureNoFocusImage == null && TextureFocusImage != null)
     {
         if (TextureFocusImage.Width == Width && TextureFocusImage.Height == Height)
         {
             MpeLog.Debug("TextureFocus = " + TextureFocusImage.Size + " AutoSize enabled");
             AutoSize = true;
         }
     }
     Padding.Left = Padding.Right = parser.GetInt(iterator, "textXOff", Padding.Left);
     Padding.Top  = Padding.Bottom = parser.GetInt(iterator, "textYOff", Padding.Top);
     Hyperlink    = parser.GetInt(iterator, "hyperlink", 0);
     tags.Remove("textXOff");
     tags.Remove("textYOff");
     tags.Remove("hyperlink");
     PrepareControl();
     Modified = false;
 }
Example #16
0
 public MpeControl(MpeControl control) : this()
 {
     MpeLog.Debug("MpeControl(control)");
     preparing                = true;
     Size                     = control.Size;
     Location                 = control.Location;
     alignment                = control.alignment;
     autoSize                 = control.autoSize;
     borderPen                = control.borderPen;
     controlLock              = new MpeControlLock(control.controlLock);
     controlLock.LockChanged += new MpeControlLock.LockChangedHandler(OnLockChanged);
     description              = control.description;
     diffuseColor             = control.diffuseColor;
     dimColor                 = control.dimColor;
     animation                = control.animation;
     embedded                 = control.embedded;
     enabled                  = control.enabled;
     focused                  = control.focused;
     id       = control.id;
     masked   = control.masked;
     modified = control.modified;
     onLeft   = control.onLeft;
     onRight  = control.onRight;
     onUp     = control.onUp;
     onDown   = control.onDown;
     padding  = new MpeControlPadding(control.padding);
     padding.PaddingChanged += new MpeControlPadding.PaddingChangedHandler(OnPaddingChanged);
     parser           = control.parser;
     textBrush        = (SolidBrush)control.textBrush.Clone();
     type             = control.type;
     visible          = control.visible;
     screen           = control.screen;
     tags             = new MpeTagCollection(control.tags);
     tags.TagAdded   += new MpeTagCollection.TagAddedHandler(OnTagCollectionChanged);
     tags.TagChanged += new MpeTagCollection.TagChangedHandler(OnTagCollectionChanged);
     tags.TagRemoved += new MpeTagCollection.TagRemovedHandler(OnTagCollectionChanged);
     preparing        = false;
 }
        public MpeImageEditorForm(FileInfo currentValue, MpeParser skinParser, IWindowsFormsEditorService editorService)
        {
            InitializeComponent();
            this.skinParser         = skinParser;
            this.editorService      = editorService;
            imageList.SelectionMode = SelectionMode.One;
            imageList.Items.Add("(none)");
            for (int i = 0; i < skinParser.ImageFiles.Length; i++)
            {
                imageList.Items.Add(skinParser.ImageFiles[i]);
                if (skinParser.ImageFiles[i].Equals(currentValue))
                {
                    imageList.SelectedIndex = (i + 1);
                }
            }
            MpeScreen window = (MpeScreen)skinParser.GetControl(MpeControlType.Screen);

            if (window.TextureBack != null)
            {
                thumbPanel.BackgroundImage = new Bitmap(window.TextureBack.FullName);
            }
            imageList.MouseWheel += new MouseEventHandler(imageList_MouseWheel);
        }
Example #18
0
        public void LoadSkin(DirectoryInfo skinDir)
        {
            try
            {
                // Cleanup used resources
                CloseSkin();
                // Initialize a parser to get the skin info
                Parser = new MpeParser(skinDir, new DirectoryInfo(MediaPortalEditor.Global.Preferences.MediaPortalDir));
                Parser.Load();

                // Create rootNode
                rootNode                    = skinTree.Nodes.Add("Skin (" + Parser.SkinName + ")");
                rootNode.ImageIndex         = 0;
                rootNode.SelectedImageIndex = 0;
                // Load skin resources
                LoadControls();
                LoadFonts();
                LoadImages();
                LoadLanguages();
                LoadScreens();
                // Setup tree
                skinTree.Scrollable = true;
                skinTree.Nodes[0].Expand();
                skinTree.Enabled = true;
                skinTree.Focus();
            }
            catch (MpeParserException spe)
            {
                MpeLog.Debug(spe);
                MpeLog.Error(spe);
            }
            catch (Exception e)
            {
                MpeLog.Debug(e);
                MpeLog.Error(e);
            }
        }
        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 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;
        }
Example #21
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeSelectButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   // Regular Button Properties
   label.Load(iterator, parser);
   label.AutoSize = false;
   label.Size = new Size(parser.GetInt(iterator, "width", Width), parser.GetInt(iterator, "height", Height));
   offset = new Point(parser.GetInt(iterator, "textXOff2", offset.X), parser.GetInt(iterator, "textYOff2", offset.Y));
   TextureButton = parser.GetImageFile(iterator, "textureNoFocus", TextureButton);
   TextureButtonFocus = parser.GetImageFile(iterator, "textureFocus", TextureButton);
   tags.Remove("align");
   tags.Remove("font");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("label");
   tags.Remove("textXOff");
   tags.Remove("textYOff");
   tags.Remove("textureFocus");
   tags.Remove("textureNoFocus");
   // Select Button Properties
   int x = parser.GetInt(iterator, "textXOff", TexturePadding.Width);
   TextureSize =
     new Size(parser.GetInt(iterator, "textureWidth", textureSize.Width),
              parser.GetInt(iterator, "textureHeight", textureSize.Height));
   TexturePadding = new MpeControlPadding(x/2, (Height - textureSize.Height)/2);
   TextureBackground = parser.GetImageFile(iterator, "texturebg", TextureBack);
   TextureLeft = parser.GetImageFile(iterator, "textureLeft", TextureLeft);
   TextureLeftFocus = parser.GetImageFile(iterator, "textureLeftFocus", TextureLeftFocus);
   TextureRight = parser.GetImageFile(iterator, "textureRight", TextureRight);
   TextureRightFocus = parser.GetImageFile(iterator, "textureRightFocus", TextureRightFocus);
   tags.Remove("texturebg");
   tags.Remove("textureLeft");
   tags.Remove("textureLeftFocus");
   tags.Remove("textureRight");
   tags.Remove("textureRightFocus");
   tags.Remove("textureWidth");
   tags.Remove("textureHeight");
   tags.Remove("textXOff2");
   tags.Remove("textYOff2");
   // Get SubItems
   items.Values.Clear();
   XPathNodeIterator i = iterator.Current.Select("subitems/subitem");
   while (i.MoveNext())
   {
     MpeItem item = new MpeItem();
     item.Value = i.Current.Value;
     items.Values.Add(item);
   }
   Prepare();
   Modified = false;
 }
Example #22
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeSpinButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   label.Load(iterator, parser);
   TextureUp = parser.GetImageFile(iterator, "textureUp", TextureUp);
   TextureUpFocus = parser.GetImageFile(iterator, "textureUpFocus", TextureUpFocus);
   TextureDown = parser.GetImageFile(iterator, "textureDown", TextureDown);
   TextureDownFocus = parser.GetImageFile(iterator, "textureDownFocus", TextureDownFocus);
   int w = parser.GetInt(iterator, "width", TextureSize.Width);
   int h = parser.GetInt(iterator, "height", TextureSize.Height);
   TextureSize = new Size(w, h);
   string s = parser.GetString(iterator, "orientation", "");
   if (s.Equals("vertical"))
   {
     Orientation = MpeControlOrientation.Vertical;
   }
   else
   {
     Orientation = MpeControlOrientation.Horizontal;
   }
   Reverse = parser.GetBoolean(iterator, "reverse", Reverse);
   ShowRange = parser.GetBoolean(iterator, "showrange", ShowRange);
   // Load SubItems
   s = parser.GetString(iterator, "subtype", "");
   if (s.Equals("integer"))
   {
     items.Type = MpeItemType.Integer;
     items.First = parser.GetString(iterator, "subitems/first", items.First);
     items.Last = parser.GetString(iterator, "subitems/last", items.Last);
     items.Digits = parser.GetString(iterator, "subitems/digits", items.Digits);
     items.Interval = parser.GetString(iterator, "subitems/interval", items.Interval);
   }
   else if (s.Equals("float"))
   {
     items.Type = MpeItemType.Float;
     items.First = parser.GetString(iterator, "subitems/first", items.First);
     items.Last = parser.GetString(iterator, "subitems/last", items.Last);
     items.Digits = parser.GetString(iterator, "subitems/digits", items.Digits);
     items.Interval = parser.GetString(iterator, "subitems/interval", items.Interval);
   }
   // Remove known tags
   tags.Remove("align");
   tags.Remove("font");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("label");
   tags.Remove("orientation");
   tags.Remove("reverse");
   tags.Remove("showrange");
   tags.Remove("subtype");
   tags.Remove("textureDown");
   tags.Remove("textureDownFocus");
   tags.Remove("textureUp");
   tags.Remove("textureUpFocus");
   SetLabel();
   Prepare();
   Modified = false;
 }
Example #23
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
     //
 }
Example #24
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeTextArea.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   Controls.Clear();
   Padding = parser.GetPadding(iterator, "mpe/padding", Padding);
   Spacing = parser.GetInt(iterator, "mpe/spacing", Spacing);
   Left -= Padding.Left;
   Top -= Padding.Top;
   label = (MpeLabel) parser.CreateControl(MpeControlType.Label);
   if (label != null)
   {
     label.Lookup = false;
     label.Embedded = true;
     label.AutoSize = false;
     label.Font = parser.GetFont(iterator, "font", label.Font);
     label.DisabledColor = parser.GetColor(iterator, "disabledcolor", label.DisabledColor);
     label.TextColor = parser.GetColor(iterator, "textcolor", label.TextColor);
     label.Text = parser.GetString(iterator, "text", label.Text);
     Controls.Add(label);
   }
   spinButton = (MpeSpinButton) parser.CreateControl(MpeControlType.SpinButton);
   if (spinButton != null)
   {
     spinButton.Embedded = true;
     spinButton.Color = parser.GetColor(iterator, "SpinColor", spinButton.Color);
     int w = parser.GetInt(iterator, "SpinWidth", spinButton.TextureSize.Width);
     int h = parser.GetInt(iterator, "SpinHeight", spinButton.TextureSize.Height);
     spinButton.TextureSize = new Size(w, h);
     spinButton.TextureUp = parser.GetImageFile(iterator, "textureUp", spinButton.TextureUp);
     spinButton.TextureUpFocus = parser.GetImageFile(iterator, "textureUpFocus", spinButton.TextureUpFocus);
     spinButton.TextureDown = parser.GetImageFile(iterator, "textureDown", spinButton.TextureDown);
     spinButton.TextureDownFocus = parser.GetImageFile(iterator, "textureDownFocus", spinButton.TextureDownFocus);
     SpinAlign = parser.GetAlignment(iterator, "SpinAlign", SpinAlign);
     Controls.Add(spinButton);
   }
   Width += Padding.Width;
   Height += Padding.Height + Spacing + spinButton.Height;
   // Remove known tags
   tags.Remove("align");
   tags.Remove("font");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("text");
   tags.Remove("textureDown");
   tags.Remove("textureDownFocus");
   tags.Remove("textureUp");
   tags.Remove("textureUpFocus");
   tags.Remove("spinAlign");
   tags.Remove("spinColor");
   tags.Remove("spinWidth");
   tags.Remove("spinHeight");
   tags.Remove("spinPosX");
   tags.Remove("spinPosY");
   tags.Remove("SpinAlign");
   tags.Remove("SpinColor");
   tags.Remove("SpinWidth");
   tags.Remove("SpinHeight");
   tags.Remove("SpinPosX");
   tags.Remove("SpinPosY");
   Modified = false;
 }
Example #25
0
 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);
     }
   }
 }
Example #26
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeToggleButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   AlternateTextureFocus = parser.GetImageFile(iterator, "AltTextureFocus", AlternateTextureFocus);
   AlternateTextureNoFocus = parser.GetImageFile(iterator, "AltTextureNoFocus", AlternateTextureNoFocus);
   tags.Remove("AltTextureFocus");
   tags.Remove("AltTextureNoFocus");
   Modified = false;
 }
Example #27
0
 public virtual void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeControl.Load()");
   this.parser = parser;
   if (iterator != null)
   {
     // First load tags
     XPathNodeIterator i = iterator.Current.SelectChildren("", "");
     while (i.MoveNext())
     {
       if (i.Current.Name != null && i.Current.Value != null)
       {
         XPathNodeIterator ci = i.Current.SelectChildren("", "");
         if (ci.Count == 0)
         {
           if (i.Current.Name == "animation")
           {
             int pos = -1;
             switch (i.Current.Value)
             {
               case "WindowOpen":
                 pos = 0;
                 break;
               case "WindowClose":
                 pos = 1;
                 break;
               case "Hidden":
                 pos = 2;
                 break;
               case "Focus":
                 pos = 3;
                 break;
               case "Unfocus":
                 pos = 4;
                 break;
               case "VisibleChange":
                 pos = 5;
                 break;
             }
             if (pos >= 0)
             {
               Animation.Animation[pos].Enabled = true;
               string efect = i.Current.GetAttribute("effect", String.Empty);
               switch (efect)
               {
                 case "fade":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.fade;
                   break;
                 case "slide":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.slide;
                   break;
                 case "rotate":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.rotate;
                   break;
                 case "rotatex":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.rotatex;
                   break;
                 case "rotatey":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.rotatey;
                   break;
                 case "zoom":
                   Animation.Animation[pos].Efect = MpeAnimationEfect.zoom;
                   break;
               }
               int parami = 0;
               bool paramb = false;
               int.TryParse(i.Current.GetAttribute("time",String.Empty ),out parami);
               Animation.Animation[pos].Time = parami;
               parami = 0;
               int.TryParse(i.Current.GetAttribute("delay", String.Empty), out parami);
               Animation.Animation[pos].Delay = parami;
               Animation.Animation[pos].Start = i.Current.GetAttribute("start", String.Empty);
               Animation.Animation[pos].End = i.Current.GetAttribute("end", String.Empty);
               parami = 0;
               int.TryParse(i.Current.GetAttribute("acceleration", String.Empty), out parami);
               Animation.Animation[pos].Acceleration = parami;
               string center = i.Current.GetAttribute("center", String.Empty);
               if (center.Contains(","))
               {
                 int.TryParse(center.Substring(0, center.IndexOf(',')), out parami);
                 int paramy = 0;
                 int.TryParse(center.Substring(center.IndexOf(',')+1), out paramy);
                 Animation.Animation[pos].Center = new Point(parami, paramy);
               }
               Animation.Animation[pos].Condition = i.Current.GetAttribute("condition", String.Empty);
               bool.TryParse(i.Current.GetAttribute("reversible", String.Empty), out paramb);
               Animation.Animation[pos].Reversible = paramb;
               paramb = false;
               bool.TryParse(i.Current.GetAttribute("pulse", String.Empty), out paramb);
               Animation.Animation[pos].Pulse = paramb;
               switch (i.Current.GetAttribute("tween", String.Empty))
               {
                 case "elastic":
                   Animation.Animation[pos].Tween = MpeAnimationTween.elastic;
                   break;
                 case "bounce":
                   Animation.Animation[pos].Tween = MpeAnimationTween.bounce;
                   break;
                 case "circle":
                   Animation.Animation[pos].Tween = MpeAnimationTween.circle;
                   break;
                 case "back":
                   Animation.Animation[pos].Tween = MpeAnimationTween.back;
                   break;
                 case "sine":
                   Animation.Animation[pos].Tween = MpeAnimationTween.sine;
                   break;
                 case "cubic":
                   Animation.Animation[pos].Tween = MpeAnimationTween.cubic;
                   break;
                 case "quadratic":
                   Animation.Animation[pos].Tween = MpeAnimationTween.quadratic;
                   break;
                 case "linear":
                   Animation.Animation[pos].Tween = MpeAnimationTween.linear;
                   break;
               }
               switch (i.Current.GetAttribute("easing", String.Empty))
               {
                 case "out":
                   Animation.Animation[pos].Easing = MpeAnimationEasing.Out;
                   break;
                 case "in":
                   Animation.Animation[pos].Easing = MpeAnimationEasing.In;
                   break;
                 case "inout":
                   Animation.Animation[pos].Easing = MpeAnimationEasing.inout;
                   break;
               }
             }
           }
           else
           {
             tags.Add(i.Current.Name, i.Current.Value, false);
           }
         }
       }
     }
     tags.Remove("type");
     Id = parser.GetInt(iterator, "id", Id);
     tags.Remove("id");
     Description = parser.GetString(iterator, "description", Description);
     tags.Remove("description");
     // The position must be converted from absolute to relative
     int x = parser.GetInt(iterator, "posX", Left);
     int y = parser.GetInt(iterator, "posY", Top);
     MpeContainer c = MpeParent;
     while (c != null && c.Type != MpeControlType.Screen)
     {
       x -= c.Left;
       y -= c.Top;
       c = c.MpeParent;
     }
     Left = x;
     Top = y;
     tags.Remove("posX");
     tags.Remove("posY");
     // Load the rest of the properties
     Width = parser.GetInt(iterator, "width", Width);
     tags.Remove("width");
     Height = parser.GetInt(iterator, "height", Height);
     tags.Remove("height");
     Padding = parser.GetPadding(iterator, "padding", Padding);
     Visible = parser.GetString(iterator, "visible", Visible);
     tags.Remove("visible");
     DiffuseColor = parser.GetColor(iterator, "colordiffuse", DiffuseColor);
     tags.Remove("colordiffuse");
     DimColor = parser.GetColor(iterator, "dimColor", DimColor);
     tags.Remove("dimColor");
     OnLeft = parser.GetInt(iterator, "onleft", OnLeft);
     tags.Remove("onleft");
     OnRight = parser.GetInt(iterator, "onright", OnRight);
     tags.Remove("onright");
     OnUp = parser.GetInt(iterator, "onup", OnUp);
     tags.Remove("onup");
     OnDown = parser.GetInt(iterator, "ondown", OnDown);
     tags.Remove("ondown");
   }
   if (reference)
   {
     Id = 1;
   }
 }
Example #28
0
    public override void Load(XPathNodeIterator iterator, MpeParser parser)
    {
      MpeLog.Debug("MpeScreen.Load()");
      this.parser = parser;
      XPathNodeIterator i = null;
      if (iterator == null)
      {
        throw new MpeParserException("The given iterator is invalid.");
      }
      if (iterator.Current.Name == "controls")
      {
        Width = parser.GetInt(iterator, "skin/width", Width);
        Height = parser.GetInt(iterator, "skin/height", Height);
        ScreenSize = MpeScreenSize.FromResolution(Width, Height);
        i = iterator.Current.Select("control[type='image']");
        if (i.MoveNext())
        {
          backImage.Load(i, parser);
        }
        Id = 0;
      }
      else if (iterator.Current.Name == "window")
      {
        string stype = parser.GetString(iterator, "type", "");
        if (stype == MpeScreenType.Dialog.ToString().ToLower())
        {
          screenType = MpeScreenType.Dialog;
        }
        else if (stype == MpeScreenType.OnScreenDisplay.ToString().ToLower())
        {
          screenType = MpeScreenType.OnScreenDisplay;
        }
        else
        {
          screenType = MpeScreenType.Window;
        }

        Id = parser.GetInt(iterator, "id", Id);
        AllowOverlay = parser.GetBoolean(iterator, "allowoverlay", AllowOverlay);
        AutohideTopbar = parser.GetBoolean(iterator, "autohidetopbar", AutohideTopbar);
        DefaultControl = parser.GetInt(iterator, "defaultcontrol", DefaultControl);

        if (screenType == MpeScreenType.Dialog)
        {
          // Initialize the default screen
          MpeScreen defaultScreen = (MpeScreen) parser.GetControl(MpeControlType.Screen);
          if (defaultScreen == null)
          {
            throw new MpeParserException("Reference screen was never initialized and loaded");
          }
          TextureBack = defaultScreen.TextureBack;
          Size = defaultScreen.Size;
          AllowDrop = false;
          // First create the dialog group

          MpeGroup dialog = (MpeGroup) parser.CreateControl(MpeControlType.Group);
          dialog.Id = DialogGroupId;
          dialog.LayoutStyle = MpeLayoutStyle.Grid;
          dialog.Parser = Parser;
          Controls.Add(dialog);

          // Add all the controls
          i = iterator.Current.Select("controls/control");
          bool first = true;
          while (i.MoveNext())
          {
            string s = parser.GetString(i, "type", "");
            if (first && s == MpeControlType.Image.ToString())
            {
              first = false;
              dialog.TextureBackImage.Load(i, parser);
              dialog.Size = dialog.TextureBackImage.Size;
              dialog.Location = dialog.TextureBackImage.Location;
            }
            else
            {
              XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
              if (typeIterator.MoveNext())
              {
                MpeControlType type = MpeControlType.Create(typeIterator.Current.Value);
                MpeControl c = parser.CreateControl(type);
                dialog.Controls.Add(c);
                c.Load(i, parser);
                c.BringToFront();
              }
            }
          }
        }
        else
        {
          AllowDrop = true;
          i = iterator.Current.Select("controls/control");
          bool first = true;
          while (i.MoveNext())
          {
            string s = parser.GetString(i, "type", "");
            if (first && s == MpeControlType.Image.ToString())
            {
              backImage.Load(i, parser);
            }
            else
            {
              XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
              if (typeIterator.MoveNext())
              {
                MpeControlType type = MpeControlType.Create(typeIterator.Current.Value);
                MpeControl c = parser.CreateControl(type);
                Controls.Add(c);
                c.Load(i, parser);
                c.BringToFront();
              }
            }
            first = false;
          }
        }
      }
      Modified = false;
    }
Example #29
0
    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 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 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();
                }
            }
        }
Example #32
0
 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);
     }
   }
 }
Example #33
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   base.Load(iterator, parser);
   MpeLog.Debug("MpeCheckBox.Load()");
   this.parser = parser;
   label.Load(iterator, parser);
   label.Enabled = false;
   tags.Remove("label");
   tags.Remove("align");
   tags.Remove("textcolor");
   tags.Remove("disabledcolor");
   tags.Remove("font");
   // Textures
   Texture = parser.GetImageFile(iterator, "textureCheckmarkNoFocus", Texture);
   tags.Remove("textureCheckmarkNoFocus");
   TextureChecked = parser.GetImageFile(iterator, "textureCheckmark", TextureChecked);
   tags.Remove("textureCheckmark");
   int w = parser.GetInt(iterator, "MarkWidth", TextureSize.Width);
   tags.Remove("MarkWidth");
   int h = parser.GetInt(iterator, "MarkHeight", TextureSize.Height);
   tags.Remove("MarkHeight");
   TextureSize = new Size(w, h);
   Modified = false;
 }
Example #34
0
 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);
     }
   }
 }
Example #35
0
 public MpeControl()
 {
   MpeLog.Debug("MpeControl()");
   preparing = true;
   SetStyle(ControlStyles.SupportsTransparentBackColor, true);
   SetStyle(ControlStyles.DoubleBuffer, true);
   SetStyle(ControlStyles.AllPaintingInWmPaint, true);
   SetStyle(ControlStyles.UserPaint, true);
   SetStyle(ControlStyles.ResizeRedraw, true);
   Animation = new MpeAnimationType();
   BackColor = Color.Transparent;
   Size = new Size(64, 64);
   Location = new Point(8, 8);
   alignment = MpeControlAlignment.Left;
   autoSize = false;
   borderPen = new Pen(Color.FromArgb(128, 255, 255, 255), 1.0f);
   borderPen.DashStyle = DashStyle.Dash;
   controlLock = new MpeControlLock();
   controlLock.LockChanged += new MpeControlLock.LockChangedHandler(OnLockChanged);
   description = "";
   diffuseColor = Color.FromArgb(255, 255, 255, 255);
   dimColor = Color.FromArgb(0x60ffffff);
   embedded = false;
   enabled = true;
   focused = false;
   id = 0;
   masked = false;
   modified = false;
   onLeft = 0;
   onRight = 0;
   onUp = 0;
   onDown = 0;
   padding = new MpeControlPadding(0);
   padding.PaddingChanged += new MpeControlPadding.PaddingChangedHandler(OnPaddingChanged);
   parser = null;
   textBrush = new SolidBrush(Color.Black);
   type = MpeControlType.Empty;
   visible = "true";
   screen = null;
   tags = new MpeTagCollection();
   tags.TagAdded += new MpeTagCollection.TagAddedHandler(OnTagCollectionChanged);
   tags.TagChanged += new MpeTagCollection.TagChangedHandler(OnTagCollectionChanged);
   tags.TagRemoved += new MpeTagCollection.TagRemovedHandler(OnTagCollectionChanged);
   preparing = false;
   reference = false;
 }
Example #36
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   //
 }
Example #37
0
    public override void Load(XPathNodeIterator iterator, MpeParser parser)
    {
      MpeLog.Debug("MpeGroup.Load()");
      base.Load(iterator, parser);
      this.parser = parser;
      //Animation = parser.GetAnimation(iterator, "animation", Animation);
      //tags.Remove("animation");

      // Mpe Specific Tags
      bool firstLoad = false;
      if (parser.GetString(iterator, "mpe/layout", null) == null)
      {
        MpeLog.Debug("This is a group that has never been opened with MPE!");
        firstLoad = true;
        Left = 0;
        Top = 0;
      }
      LayoutStyle = parser.GetLayout(iterator, "mpe/layout", LayoutStyle);
      Spring = parser.GetBoolean(iterator, "mpe/spring", Spring);
      Spacing = parser.GetInt(iterator, "mpe/spacing", Spacing);
      Padding = parser.GetPadding(iterator, "mpe/padding", Padding);
      // Child Controls
      XPathNodeIterator i = iterator.Current.Select("control");
      bool firstControl = true;
      int x = int.MaxValue;
      int y = int.MaxValue;
      int r = 0;
      int b = 0;
      while (i.MoveNext())
      {
        XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
        if (typeIterator.MoveNext())
        {
          MpeControlType ctype = MpeControlType.Create(typeIterator.Current.Value);
          if (firstControl && ctype == MpeControlType.Image)
          {
            firstControl = false;
            backImage.Load(i, parser);
          }
          else
          {
            MpeControl c = parser.CreateControl(ctype);
            Controls.Add(c);
            c.Load(i, parser);
            c.BringToFront();
            if (firstLoad)
            {
              if (c.Left < x)
              {
                x = c.Left;
              }
              if (c.Top < y)
              {
                y = c.Top;
              }
              if ((c.Left + c.Width) > r)
              {
                r = c.Left + c.Width;
              }
              if ((c.Top + c.Height) > b)
              {
                b = c.Top + c.Height;
              }
            }
          }
        }
      }
      if (firstLoad)
      {
        MpeLog.Info("x=" + x + " y=" + y);
        Left = x - 4;
        Top = y - 4;
        for (int a = 0; a < Controls.Count; a++)
        {
          if (Controls[a] is MpeControl)
          {
            Controls[a].Left -= x - 4;
            Controls[a].Top -= y - 4;
          }
        }
        Width = r - x + 8;
        Height = b - y + 8;
      }

      if (Spring)
      {
        Width = parser.GetInt(iterator, "width", Width);
        Height = parser.GetInt(iterator, "height", Height);
      }
      Modified = false;
    }
Example #38
0
 public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
 {
   //
 }
Example #39
0
 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);
 }
Example #40
0
    public override void Load(XPathNodeIterator iterator, MpeParser parser)
    {
      MpeLog.Debug("MpeImage.Load()");
      this.parser = parser;
      AutoSize = false;
      base.Load(iterator, parser);
      Texture = parser.GetImageFile(iterator, "texture", Texture);
      tags.Remove("texture");
      if (parser.GetInt(iterator, "width", -1) < 0 || parser.GetInt(iterator, "height", -1) < 0)
      {
        if (Texture == null)
        {
          AutoSize = false;
          Size = new Size(64, 64);
        }
        else
        {
          AutoSize = true;
        }
      }
      Centered = parser.GetBoolean(iterator, "centered", Centered);
      tags.Remove("centered");
      Filtered = parser.GetBoolean(iterator, "filtered", Filtered);
      tags.Remove("filtered");
      KeepAspectRatio = parser.GetBoolean(iterator, "keepaspectratio", KeepAspectRatio);
      tags.Remove("keepaspectratio");
      ColorKey = parser.GetInt(iterator, "colorkey", ColorKey);
      tags.Remove("colorkey");

      Modified = false;
    }
Example #41
0
 public override void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeButton.Load()");
   base.Load(iterator, parser);
   this.parser = parser;
   if (Text != null && Text.Equals("-"))
   {
     Text = "";
   }
   AutoSize = false;
   TextureFocus = parser.GetImageFile(iterator, "textureFocus", TextureFocus);
   tags.Remove("textureFocus");
   TextureNoFocus = parser.GetImageFile(iterator, "textureNoFocus", TextureNoFocus);
   tags.Remove("textureNoFocus");
   if (TextureNoFocusImage != null)
   {
     if (TextureNoFocusImage.Width == Width && TextureNoFocusImage.Height == Height)
     {
       MpeLog.Debug("TextureNoFocus = " + TextureNoFocusImage.Size + " AutoSize enabled");
       AutoSize = true;
     }
   }
   else if (TextureNoFocusImage == null && TextureFocusImage != null)
   {
     if (TextureFocusImage.Width == Width && TextureFocusImage.Height == Height)
     {
       MpeLog.Debug("TextureFocus = " + TextureFocusImage.Size + " AutoSize enabled");
       AutoSize = true;
     }
   }
   Padding.Left = Padding.Right = parser.GetInt(iterator, "textXOff", Padding.Left);
   Padding.Top = Padding.Bottom = parser.GetInt(iterator, "textYOff", Padding.Top);
   Hyperlink = parser.GetInt(iterator, "hyperlink", 0);
   tags.Remove("textXOff");
   tags.Remove("textYOff");
   tags.Remove("hyperlink");
   PrepareControl();
   Modified = false;
 }
Example #42
0
 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;
 }
Example #43
0
        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);
                            }
                        }
                    }
                }
            }
        }
Example #44
0
    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);
      }
    }
Example #45
0
        public MpeStringEditorForm(string currentValue, MpeParser parser, IWindowsFormsEditorService editorService)
        {
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            InitializeComponent();
            Height               = 184;
            propPanel.Location   = simplePanel.Location;
            propPanel.Size       = simplePanel.Size;
            stringPanel.Location = simplePanel.Location;
            stringPanel.Size     = simplePanel.Size;
            propPanel.Visible    = false;
            stringPanel.Visible  = false;
            simpleTextbox.Text   = currentValue;
            if (properties == null)
            {
                properties = new ArrayList();
                properties.Add("itemcount");
                properties.Add("selecteditem");
                properties.Add("selecteditem2");
                properties.Add("selectedthumb");
                properties.Add("title");
                properties.Add("artist");
                properties.Add("album");
                properties.Add("track");
                properties.Add("year");
                properties.Add("comment");
                properties.Add("director");
                properties.Add("genre");
                properties.Add("cast");
                properties.Add("dvdlabel");
                properties.Add("imdbnumber");
                properties.Add("file");
                properties.Add("plot");
                properties.Add("plotoutline");
                properties.Add("rating");
                properties.Add("tagline");
                properties.Add("votes");
                properties.Add("credits");
                properties.Add("thumb");
                properties.Add("currentplaytime");
                properties.Add("shortcurrentplaytime");
                properties.Add("duration");
                properties.Add("shortduration");
                properties.Add("playlogo");
                properties.Add("playspeed");
                properties.Add("percentage");
                properties.Add("currentmodule");
                properties.Add("channel");
                properties.Add("TV.start");
                properties.Add("TV.stop");
                properties.Add("TV.current");
                properties.Add("TV.Record.channel");
                properties.Add("TV.Record.start");
                properties.Add("TV.Record.stop");
                properties.Add("TV.Record.genre");
                properties.Add("TV.Record.title");
                properties.Add("TV.Record.description");
                properties.Add("TV.Record.thumb");
                properties.Add("TV.View.channel");
                properties.Add("TV.View.thumb");
                properties.Add("TV.View.start");
                properties.Add("TV.View.stop");
                properties.Add("TV.View.genre");
                properties.Add("TV.View.title");
                properties.Add("TV.View.description");
                properties.Add("TV.View.Percentage");
                properties.Add("TV.Guide.Day");
                properties.Add("TV.Guide.thumb");
                properties.Add("TV.Guide.Title");
                properties.Add("TV.Guide.Time");
                properties.Add("TV.Guide.Duration");
                properties.Add("TV.Guide.TimeFromNow");
                properties.Add("TV.Guide.Description");
                properties.Add("TV.Guide.Genre");
                properties.Add("TV.Guide.EpisodeName");
                properties.Add("TV.Guide.SeriesNumber");
                properties.Add("TV.Guide.EpisodeNumber");
                properties.Add("TV.Guide.EpisodePart");
                properties.Add("TV.Guide.EpisodeDetail");
                properties.Add("TV.Guide.Date");
                properties.Add("TV.Guide.StarRating");
                properties.Add("TV.Guide.Classification");
                properties.Add("TV.RecordedTV.Title");
                properties.Add("TV.RecordedTV.Time");
                properties.Add("TV.RecordedTV.Description");
                properties.Add("TV.RecordedTV.thumb");
                properties.Add("TV.RecordedTV.Genre");
                properties.Add("TV.Scheduled.Title");
                properties.Add("TV.Scheduled.Time");
                properties.Add("TV.Scheduled.Description");
                properties.Add("TV.Scheduled.thumb");
                properties.Add("TV.Scheduled.Genre");
                properties.Add("TV.Search.Title");
                properties.Add("TV.Search.Time");
                properties.Add("TV.Search.Description");
                properties.Add("TV.Search.thumb");
                properties.Add("TV.Search.Genre");
            }
            this.editorService = editorService;
            MpeStringTable table = parser.GetStringTable("English");

            int[]        keys = table.Keys;
            ListViewItem sel  = null;

            for (int i = 0; i < keys.Length; i++)
            {
                string s = table[keys[i]];
                //ListViewItem item = stringList.Items.Add(s);
                ListViewItem item = stringList.Items.Add(keys[i].ToString("D6"));
                item.Tag = keys[i];
                //item.SubItems.Add(keys[i].ToString("D6"));
                item.SubItems.Add(s);
                if (currentValue.Equals(keys[i].ToString()))
                {
                    item.Selected = true;
                    sel           = item;
                }
            }
            if (sel != null)
            {
                MpeLog.Debug("Is the selected string visible?");
                sel.EnsureVisible();
            }
            propertyList.DataSource = properties;
        }
        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);
            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);
        }
Example #48
0
 public void Load(XPathNodeIterator iterator, MpeParser parser)
 {
   MpeLog.Debug("MpeFont.Load()");
   textureWorkDir = parser.FontDir.FullName;
   name = parser.GetString(iterator, "name", name);
   string family = parser.GetString(iterator, "filename", Family);
   int height = parser.GetInt(iterator, "height", Size);
   string style = parser.GetString(iterator, "style", "");
   FontStyle fs = FontStyle.Regular;
   if (style.IndexOf("Bold") >= 0)
   {
     fs |= FontStyle.Bold;
   }
   if (style.IndexOf("Italic") >= 0)
   {
     fs |= FontStyle.Italic;
   }
   if (style.IndexOf("Underline") >= 0)
   {
     fs |= FontStyle.Underline;
   }
   if (style.IndexOf("Strikeout") >= 0)
   {
     fs |= FontStyle.Strikeout;
   }
   systemFont = new Font(family, (float) height, fs);
   startChar = parser.GetInt(iterator, "start", startChar);
   if (startChar < 32)
   {
     startChar = 32;
   }
   endChar = parser.GetInt(iterator, "end", endChar) + 1;
   if (endChar > 256)
   {
     endChar = 256;
   }
   // Setup Texture Files
   if (textureWorkDir != null)
   {
     textureFile = new FileInfo(textureWorkDir + "\\" + name + "_" + height + ".png");
     textureDataFile = new FileInfo(textureFile.FullName + ".xml");
     bool loaded = false;
     if (textureFile.Exists)
     {
       Bitmap b = null;
       try
       {
         b = new Bitmap(textureFile.FullName);
         texture = new Bitmap(b);
         loaded = true;
       }
       catch (Exception e)
       {
         MpeLog.Warn(e);
       }
       finally
       {
         if (b != null)
         {
           b.Dispose();
         }
       }
     }
     if (loaded && textureDataFile.Exists)
     {
       loaded = false;
       Stream r = null;
       try
       {
         r = File.Open(textureDataFile.FullName, FileMode.Open, FileAccess.Read);
         textureCoordinates = (float[,]) new SoapFormatter().Deserialize(r);
         spacingPerChar = (int) textureCoordinates[endChar - startChar, 0];
         ConvertTextureData();
         loaded = true;
       }
       catch (Exception e)
       {
         MpeLog.Warn(e);
       }
       finally
       {
         if (r != null)
         {
           r.Close();
         }
       }
     }
     if (loaded)
     {
       MpeLog.Info("Loaded font texture and data [" + name + "]");
     }
     else
     {
       GenerateTexture();
     }
   }
 }
Example #49
0
 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 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;
 }
Example #51
0
    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);
            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));
        }
Example #53
0
    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);
        }
      }
    }
Example #54
0
 public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
 {
     //
 }
Example #55
0
    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 MpeStringEditorForm(string currentValue, MpeParser parser, IWindowsFormsEditorService editorService)
 {
   SetStyle(ControlStyles.DoubleBuffer, true);
   SetStyle(ControlStyles.AllPaintingInWmPaint, true);
   InitializeComponent();
   Height = 184;
   propPanel.Location = simplePanel.Location;
   propPanel.Size = simplePanel.Size;
   stringPanel.Location = simplePanel.Location;
   stringPanel.Size = simplePanel.Size;
   propPanel.Visible = false;
   stringPanel.Visible = false;
   simpleTextbox.Text = currentValue;
   if (properties == null)
   {
     properties = new ArrayList();
     properties.Add("itemcount");
     properties.Add("selecteditem");
     properties.Add("selecteditem2");
     properties.Add("selectedthumb");
     properties.Add("title");
     properties.Add("artist");
     properties.Add("album");
     properties.Add("track");
     properties.Add("year");
     properties.Add("comment");
     properties.Add("director");
     properties.Add("genre");
     properties.Add("cast");
     properties.Add("dvdlabel");
     properties.Add("imdbnumber");
     properties.Add("file");
     properties.Add("plot");
     properties.Add("plotoutline");
     properties.Add("rating");
     properties.Add("tagline");
     properties.Add("votes");
     properties.Add("credits");
     properties.Add("thumb");
     properties.Add("currentplaytime");
     properties.Add("shortcurrentplaytime");
     properties.Add("duration");
     properties.Add("shortduration");
     properties.Add("playlogo");
     properties.Add("playspeed");
     properties.Add("percentage");
     properties.Add("currentmodule");
     properties.Add("channel");
     properties.Add("TV.start");
     properties.Add("TV.stop");
     properties.Add("TV.current");
     properties.Add("TV.Record.channel");
     properties.Add("TV.Record.start");
     properties.Add("TV.Record.stop");
     properties.Add("TV.Record.genre");
     properties.Add("TV.Record.title");
     properties.Add("TV.Record.description");
     properties.Add("TV.Record.thumb");
     properties.Add("TV.View.channel");
     properties.Add("TV.View.thumb");
     properties.Add("TV.View.start");
     properties.Add("TV.View.stop");
     properties.Add("TV.View.genre");
     properties.Add("TV.View.title");
     properties.Add("TV.View.description");
     properties.Add("TV.View.Percentage");
     properties.Add("TV.Guide.Day");
     properties.Add("TV.Guide.thumb");
     properties.Add("TV.Guide.Title");
     properties.Add("TV.Guide.Time");
     properties.Add("TV.Guide.Duration");
     properties.Add("TV.Guide.TimeFromNow");
     properties.Add("TV.Guide.Description");
     properties.Add("TV.Guide.Genre");
     properties.Add("TV.Guide.EpisodeName");
     properties.Add("TV.Guide.SeriesNumber");
     properties.Add("TV.Guide.EpisodeNumber");
     properties.Add("TV.Guide.EpisodePart");
     properties.Add("TV.Guide.EpisodeDetail");
     properties.Add("TV.Guide.Date");
     properties.Add("TV.Guide.StarRating");
     properties.Add("TV.Guide.Classification");
     properties.Add("TV.RecordedTV.Title");
     properties.Add("TV.RecordedTV.Time");
     properties.Add("TV.RecordedTV.Description");
     properties.Add("TV.RecordedTV.thumb");
     properties.Add("TV.RecordedTV.Genre");
     properties.Add("TV.Scheduled.Title");
     properties.Add("TV.Scheduled.Time");
     properties.Add("TV.Scheduled.Description");
     properties.Add("TV.Scheduled.thumb");
     properties.Add("TV.Scheduled.Genre");
     properties.Add("TV.Search.Title");
     properties.Add("TV.Search.Time");
     properties.Add("TV.Search.Description");
     properties.Add("TV.Search.thumb");
     properties.Add("TV.Search.Genre");
   }
   this.editorService = editorService;
   MpeStringTable table = parser.GetStringTable("English");
   int[] keys = table.Keys;
   ListViewItem sel = null;
   for (int i = 0; i < keys.Length; i++)
   {
     string s = table[keys[i]];
     //ListViewItem item = stringList.Items.Add(s);
     ListViewItem item = stringList.Items.Add(keys[i].ToString("D6"));
     item.Tag = keys[i];
     //item.SubItems.Add(keys[i].ToString("D6"));
     item.SubItems.Add(s);
     if (currentValue.Equals(keys[i].ToString()))
     {
       item.Selected = true;
       sel = item;
     }
   }
   if (sel != null)
   {
     MpeLog.Debug("Is the selected string visible?");
     sel.EnsureVisible();
   }
   propertyList.DataSource = properties;
 }
        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;
        }
Example #58
0
 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();
     }
   }
 }
Example #59
0
        public virtual void Save(XmlDocument doc, XmlNode node, MpeParser parser)
        {
            XmlNodeList n;
            string      name = "animation";

            if ((n = node.SelectNodes(name)) != null)
            {
                foreach (XmlNode nd in n)
                {
                    nd.RemoveAll();
                }
            }
            for (int i = 0; i < EFECTNUMBER; i++)
            {
                if (Animation[i].Enabled)
                {
                    string value = "-";
                    switch (i)
                    {
                    case 0:
                        value = MpeAnimationTypeEnum.WindowOpen.ToString();
                        break;

                    case 1:
                        value = MpeAnimationTypeEnum.WindowClose.ToString();
                        break;

                    case 2:
                        value = MpeAnimationTypeEnum.Hidden.ToString();
                        break;

                    case 3:
                        value = MpeAnimationTypeEnum.Focus.ToString();
                        break;

                    case 4:
                        value = MpeAnimationTypeEnum.Unfocus.ToString();
                        break;

                    case 5:
                        value = MpeAnimationTypeEnum.VisibleChange.ToString();
                        break;
                    }
                    XmlNode    elem = doc.CreateTextNode(value);
                    XmlElement e    = doc.CreateElement(name);
                    e.AppendChild(elem);
                    if (Animation[i].Efect != MpeAnimationEfect.None)
                    {
                        e.SetAttribute("effect", Animation[i].Efect.ToString());
                    }
                    if (Animation[i].Time != 0)
                    {
                        e.SetAttribute("time", Animation[i].Time.ToString());
                    }
                    if (Animation[i].Time != 0)
                    {
                        e.SetAttribute("time", Animation[i].Time.ToString());
                    }
                    if (Animation[i].Delay != 0)
                    {
                        e.SetAttribute("delay", Animation[i].Delay.ToString());
                    }
                    if (Animation[i].Start != "")
                    {
                        e.SetAttribute("start", Animation[i].Start);
                    }
                    if (Animation[i].End.Trim() != "")
                    {
                        e.SetAttribute("end", Animation[i].End);
                    }
                    if (Animation[i].Acceleration != 0)
                    {
                        e.SetAttribute("acceleration", Animation[i].Acceleration.ToString());
                    }

                    if ((Animation[i].Center.X != 0) && (Animation[i].Center.Y != 0))
                    {
                        e.SetAttribute("center", Animation[i].Center.X.ToString() + "," + Animation[i].Center.Y.ToString());
                    }
                    if (Animation[i].Condition != "")
                    {
                        e.SetAttribute("condition", Animation[i].Condition);
                    }
                    if (!Animation[i].Reversible)
                    {
                        e.SetAttribute("reversible", "false");
                    }
                    else
                    {
                        e.SetAttribute("reversible", "true");
                    }

                    if (Animation[i].Pulse)
                    {
                        e.SetAttribute("pulse", "true");
                    }
                    else
                    {
                        e.SetAttribute("pulse", "false");
                    }
                    if (Animation[i].Tween != MpeAnimationTween.None)
                    {
                        e.SetAttribute("tween", Animation[i].Tween.ToString());
                    }
                    if (Animation[i].Easing != MpeAnimationEasing.None)
                    {
                        e.SetAttribute("easing", Animation[i].Easing.ToString().ToLower());
                    }
                    node.AppendChild(e);
                }
            }
        }
Example #60
0
 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);
     }
   }
 }