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);
                }
            }
        }
Exemplo n.º 2
0
 public override void Initialize()
 {
   try
   {
     AllowDrop = false;
     screen = (MpeScreen) Parser.CreateControl(MpeControlType.Screen);
     screen.Location = new Point(Mask.NodeSize, Mask.NodeSize);
     Controls.Add(screen);
     if (control.Type != MpeControlType.Screen)
     {
       screen.Controls.Add(control);
     }
     else
     {
       control = screen;
     }
     control.IsReference = true;
     control.Modified = false;
     MpeLog.Info("Control designer intialized [" + control.Type.DisplayName + "]");
   }
   catch (MpeParserException mpe)
   {
     MpeLog.Debug(mpe);
     throw new DesignerException(mpe.Message);
   }
   catch (Exception e)
   {
     MpeLog.Debug(e);
     throw new DesignerException(e.Message);
   }
 }
        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());
        }
Exemplo n.º 4
0
 public override void Destroy()
 {
     base.Destroy();
     for (int i = 0; i < Controls.Count; i++)
     {
         if (Controls[i] is MpeControl)
         {
             MpeControl c = (MpeControl)Controls[i];
             c.Destroy();
         }
     }
 }
Exemplo n.º 5
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);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 protected override sealed void OnControlRemoved(ControlEventArgs e)
 {
     if (e.Control != null && e.Control is MpeControl)
     {
         MpeControl c = (MpeControl)e.Control;
         c.SizeChanged -= new EventHandler(OnControlSizeChanged);
         if (c.Embedded)
         {
             c.Click     -= new EventHandler(OnEmbeddedClick);
             c.MouseDown -= new MouseEventHandler(OnEmbeddedMouseDown);
         } //else {
         Prepare();
         //}
         Modified = true;
     }
     base.OnControlRemoved(e);
 }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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);
         }
     }
 }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
0
 public MpeContainer(MpeContainer container) : base(container)
 {
     MpeLog.Debug("MpeContainer(container)");
     backImage   = new MpeImage(container.backImage);
     layoutStyle = container.layoutStyle;
     gridSize    = container.gridSize;
     showGrid    = container.showGrid;
     showBorder  = container.showBorder;
     snapToGrid  = container.snapToGrid;
     spring      = container.spring;
     spacing     = container.spacing;
     for (int i = 0; i < container.Controls.Count; i++)
     {
         if (container.Controls[i] is MpeControl)
         {
             MpeControl c = (MpeControl)container.Controls[i];
             if (c.Embedded == false)
             {
                 Controls.Add(c.Copy());
             }
         }
     }
 }
        public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
        {
            base.Save(doc, node, parser, reference);
            MpeToggleButton toggle = null;

            if (reference != null && reference is MpeToggleButton)
            {
                toggle = (MpeToggleButton)reference;
            }
            // TextureFocus
            if (toggle == null || toggle.AlternateTextureFocus == null ||
                toggle.AlternateTextureFocus.Equals(AlternateTextureFocus) == false)
            {
                if (AlternateTextureFocus == null)
                {
                    parser.SetValue(doc, node, "AltTextureFocus", "-");
                }
                else
                {
                    parser.SetValue(doc, node, "AltTextureFocus", AlternateTextureFocus.Name);
                }
            }
            // AlternateTextureNoFocus
            if (toggle == null || toggle.AlternateTextureNoFocus == null ||
                toggle.AlternateTextureNoFocus.Equals(AlternateTextureNoFocus) == false)
            {
                if (AlternateTextureNoFocus == null)
                {
                    parser.SetValue(doc, node, "AltTextureNoFocus", "-");
                }
                else
                {
                    parser.SetValue(doc, node, "AltTextureNoFocus", AlternateTextureNoFocus.Name);
                }
            }
        }
        public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
        {
            base.Save(doc, node, parser, reference);
            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);
        }
Exemplo n.º 13
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());
    }
Exemplo n.º 14
0
 protected void AddControl(MpeControl c)
 {
   Controls.Add(c);
 }
Exemplo n.º 15
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);
     }
   }
 }
Exemplo n.º 16
0
 public virtual void OnControlPropertyValueChanged(MpeControl sender, string property)
 {
   switch (property)
   {
     case "Id":
       UpdatePropertyManager();
       break;
   }
 }
Exemplo n.º 17
0
 protected void RemoveControl(MpeControl c)
 {
   Controls.Remove(c);
 }
Exemplo n.º 18
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();
                }
            }
        }
Exemplo n.º 19
0
 public MpeControlDesigner(MediaPortalEditor mpe, MpeControl control) : base(mpe)
 {
   this.control = control;
 }
Exemplo n.º 20
0
 public MpeControl CreateControl(MpeControlType type)
 {
   MpeControl c = GetControl(type);
   if (c != null)
   {
     return c.Copy();
   }
   if (type.IsKnown)
   {
     string filter = "Mpe" + type.DisplayName;
     Type t = typeof(MpeControl);
     if (t != null)
     {
       Module mod = t.Module;
       Type[] types = mod.FindTypes(Module.FilterTypeName, filter);
       if (types.Length == 1)
       {
         object o = types[0].InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
         c = (MpeControl) o;
       }
     }
     if (c == null)
     {
       MpeLog.Warn("Could not find implementation of type = [" + type.DisplayName + "]");
       c = new MpeControl();
     }
   }
   else
   {
     c = new MpeControl();
   }
   c.Type = type;
   c.Parser = this;
   return c;
 }
Exemplo n.º 21
0
 private MpeControl CreateControl(MpeControlType type, XPathNodeIterator iterator)
 {
   try
   {
     MpeControl c = null;
     if (type.IsKnown)
     {
       string filter = "Mpe" + type.DisplayName;
       Type t = typeof(MpeControl);
       if (t != null)
       {
         Module mod = t.Module;
         Type[] types = mod.FindTypes(Module.FilterTypeName, filter);
         if (types.Length == 1)
         {
           object o = types[0].InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
           c = (MpeControl) o;
         }
       }
       if (c == null)
       {
         MpeLog.Warn("Could not find implementation of type = [" + type.DisplayName + "]");
         c = new MpeControl();
       }
     }
     else
     {
       c = new MpeControl();
     }
     c.Type = type;
     c.Parser = this;
     c.Load(iterator, this);
     return c;
   }
   catch (Exception ee)
   {
     MpeLog.Debug(ee);
     throw new MpeParserException(ee.Message);
   }
 }
Exemplo n.º 22
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);
        }
      }
    }
Exemplo n.º 23
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;
 }
Exemplo n.º 24
0
 public virtual void OnControlIdentityChanged(MpeControl sender, IdentityEventArgs e)
 {
   if (ResourceList != null && ResourceList.IsUniqueId(e.New) == false)
   {
     e.Cancel = true;
     e.Message = "The new Id is not unique and will therefore be reset.";
   }
   else
   {
     e.Cancel = false;
     MpeLog.Info("Control Id set to " + e.New);
   }
 }
Exemplo n.º 25
0
 private void ReleaseControl(MpeControl c)
 {
   MpeLog.Debug("Removing " + c.ToString());
   if (c is MpeContainer)
   {
     for (int i = 0; i < c.Controls.Count; i++)
     {
       if (c.Controls[i] is MpeControl)
       {
         ReleaseControl((MpeControl) c.Controls[i]);
       }
     }
     c.ControlAdded -= new ControlEventHandler(OnControlAdded);
     c.ControlRemoved -= new ControlEventHandler(OnControlRemoved);
     if (AllowAdditions)
     {
       c.DragDrop -= new DragEventHandler(OnDragDrop);
       c.DragEnter -= new DragEventHandler(OnDragEnter);
     }
   }
   c.Click -= new EventHandler(OnControlClick);
   c.MouseDown -= new MouseEventHandler(OnControlMouseDown);
   c.StatusChanged -= new MpeControl.StatusChangedHandler(OnControlStatusChanged);
   c.KeyUp -= new KeyEventHandler(OnKeyUp);
   c.PropertyValueChanged -= new MpeControl.PropertyValueChangedHandler(OnControlPropertyValueChanged);
   c.IdentityChanged -= new MpeControl.IdentityChangedHandler(OnControlIdentityChanged);
   ResourceList.Remove(c);
   MpeLog.Debug("Removed " + c.ToString());
 }
Exemplo n.º 26
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);
     }
   }
 }
Exemplo n.º 27
0
 public override void OnControlStatusChanged(MpeControl sender, bool modified)
 {
   if (sender == control)
   {
     base.OnControlStatusChanged(sender, modified);
   }
 }
Exemplo n.º 28
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);
      }
    }
Exemplo n.º 29
0
    public void SaveControl(MpeControl control)
    {
      MpeLog.Debug("MpeParser.SaveControl(" + control.Type.ToString() + ")");
      XmlTextWriter writer = null;
      try
      {
        XmlDocument d = new XmlDocument();
        d.Load(controlFile.FullName);
        XmlNode node = null;
        if (control.Type != MpeControlType.Screen)
        {
          node = d.SelectSingleNode("/controls/control[type='" + control.Type.ToString() + "']", null);
          if (node == null)
          {
            XmlNode n = d.SelectSingleNode("/controls");
            if (n == null)
            {
              throw new MpeParserException("Invalid reference.xml file. Incorrect root node.");
            }
            node = d.CreateElement("control");
            n.AppendChild(node);
          }
          else
          {
            node.RemoveAll();
          }
        }
        else
        {
          node = d.SelectSingleNode("/controls");
        }
        control.Save(d, node, this, null);
        controls.Remove(control.Type);
        controls.Add(control.Type, control);

        writer = new XmlTextWriter(controlFile.FullName, Encoding.UTF8);
        writer.Formatting = Formatting.Indented;
        writer.Indentation = 3;
        d.WriteTo(writer);
        writer.Close();
      }
      catch (Exception e)
      {
        MpeLog.Debug(e);
        throw new MpeParserException("Error saving control: " + e.Message, e);
      }
      finally
      {
        if (writer != null)
        {
          writer.Close();
        }
      }
    }
Exemplo n.º 30
0
 public virtual void OnControlStatusChanged(MpeControl sender, bool modified)
 {
   mpe.ToggleDesignerStatus(ResourceName, modified);
 }
Exemplo n.º 31
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);
              }
            }
          }
        }
      }
    }
Exemplo n.º 32
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;
        }
Exemplo n.º 33
0
 public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
 {
   //
 }
Exemplo n.º 34
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);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 35
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);
                }
            }
        }
Exemplo n.º 36
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);
 }
Exemplo n.º 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;
        }
        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);
                }
            }
        }
Exemplo n.º 39
0
 public void OnPropertyValueChanged(MpeControl sender, string property)
 {
   if (sender != null && sender == SelectedControl)
   {
     if (property != null &&
         (property.Equals("Location") || property.Equals("Size") || property.Equals("LocationLocked") ||
          property.Equals("SizeLocked")))
     {
       Update();
     }
   }
 }
Exemplo n.º 40
0
 private void ClearControlStatus(MpeControl c)
 {
   if (c != null)
   {
     c.Modified = false;
     if (c is MpeContainer)
     {
       for (int i = 0; i < c.Controls.Count; i++)
       {
         if (c.Controls[i] is MpeControl)
         {
           ClearControlStatus((MpeControl) c.Controls[i]);
         }
       }
     }
   }
 }
Exemplo n.º 41
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);
              }
            }
          }
        }
      }
    }
Exemplo n.º 42
0
 protected override void PrepareControl()
 {
     MpeLog.Debug("MpeContainer.Prepare(" + Type.ToString() + ")");
     if (LayoutStyle == MpeLayoutStyle.VerticalFlow)
     {
         if (Spring)
         {
             int w     = Width - Padding.Width;
             int count = MpeControlCount;
             int h     = 64;
             if (count != 0)
             {
                 h = Height - Padding.Height - (count) * Spacing;
                 h = h / count;
             }
             int y = Padding.Top;
             for (int i = 0; i < Controls.Count; i++)
             {
                 if (Controls[i] is MpeControl)
                 {
                     MpeControl c = (MpeControl)Controls[i];
                     c.Left   = Padding.Left;
                     c.Top    = y;
                     c.Width  = w;
                     c.Height = h;
                     y       += h + Spacing;
                     if (c.Locked.Location == false)
                     {
                         c.Locked.Location = true;
                     }
                     if (c.Locked.Size == false)
                     {
                         c.Locked.Size = true;
                     }
                 }
             }
         }
         else
         {
             int x  = Padding.Left;
             int y  = Padding.Top;
             int w  = x;
             int h  = y;
             int cc = 0;
             for (int i = 0; i < Controls.Count; i++)
             {
                 if (Controls[i] is MpeControl)
                 {
                     MpeControl c = (MpeControl)Controls[i];
                     c.Left = x;
                     c.Top  = y;
                     int cw = x + c.Width;
                     if (w < cw)
                     {
                         w = cw;
                     }
                     y += c.Height + Spacing;
                     h += c.Height + Spacing;
                     cc++;
                     if (c.Locked.Location == false)
                     {
                         c.Locked.Location = true;
                     }
                     if (c.Locked.Size && c.AutoSize == false)
                     {
                         c.Locked.Size = false;
                     }
                 }
             }
             if (cc > 0)
             {
                 h     -= Spacing;
                 w     += Padding.Right;
                 h     += Padding.Bottom;
                 Width  = w;
                 Height = h;
             }
             else
             {
                 Size = new Size(64, 64);
             }
         }
     }
     else if (LayoutStyle == MpeLayoutStyle.HorizontalFlow)
     {
         if (Spring)
         {
             int h     = Height - Padding.Top - Padding.Bottom;
             int count = MpeControlCount;
             int w     = 64;
             if (count != 0)
             {
                 w = Width - Padding.Left - Padding.Right - (count) * Spacing;
                 w = w / count;
             }
             int x = Padding.Left;
             for (int i = 0; i < Controls.Count; i++)
             {
                 if (Controls[i] is MpeControl)
                 {
                     MpeControl c = (MpeControl)Controls[i];
                     c.Left   = x;
                     c.Top    = Padding.Top;
                     c.Width  = w;
                     c.Height = h;
                     x       += w + Spacing;
                     if (c.Locked.Location == false)
                     {
                         c.Locked.Location = true;
                     }
                     if (c.Locked.Size == false)
                     {
                         c.Locked.Size = true;
                     }
                 }
             }
         }
         else
         {
             int x  = Padding.Left;
             int y  = Padding.Top;
             int w  = x;
             int h  = y;
             int cc = 0;
             for (int i = 0; i < Controls.Count; i++)
             {
                 if (Controls[i] is MpeControl)
                 {
                     MpeControl c = (MpeControl)Controls[i];
                     c.Left = x;
                     c.Top  = y;
                     int ch = y + c.Height;
                     if (h < ch)
                     {
                         h = ch;
                     }
                     x += c.Width + Spacing;
                     w += c.Width + Spacing;
                     cc++;
                     if (c.Locked.Location == false)
                     {
                         c.Locked.Location = true;
                     }
                     if (c.Locked.Size && c.AutoSize == false)
                     {
                         c.Locked.Size = false;
                     }
                 }
             }
             if (cc > 0)
             {
                 w     -= Spacing;
                 w     += Padding.Right;
                 h     += Padding.Bottom;
                 Width  = w;
                 Height = h;
             }
             else
             {
                 Size = new Size(64, 64);
             }
         }
     }
     else
     {
         for (int i = 0; i < Controls.Count; i++)
         {
             if (Controls[i] is MpeControl)
             {
                 MpeControl c = (MpeControl)Controls[i];
                 if (c.Locked.Location)
                 {
                     c.Locked.Location = false;
                 }
                 if (c.Locked.Size && c.AutoSize == false)
                 {
                     c.Locked.Size = false;
                 }
             }
         }
     }
     Invalidate(true);
 }
Exemplo n.º 43
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));
 }
Exemplo n.º 44
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);
     }
   }
 }
Exemplo n.º 45
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);
     }
   }
 }
Exemplo n.º 46
0
 private void PrepareControl(MpeControl c)
 {
   if (c != null && c.Embedded == false)
   {
     MpeLog.Debug("Preparing " + c.ToString());
     ResourceList.Add(c);
     c.MpeScreen = screen;
     c.Click += new EventHandler(OnControlClick);
     c.MouseDown += new MouseEventHandler(OnControlMouseDown);
     c.StatusChanged += new MpeControl.StatusChangedHandler(OnControlStatusChanged);
     c.KeyUp += new KeyEventHandler(OnKeyUp);
     c.IdentityChanged += new MpeControl.IdentityChangedHandler(OnControlIdentityChanged);
     c.PropertyValueChanged += new MpeControl.PropertyValueChangedHandler(OnControlPropertyValueChanged);
     if (c is MpeContainer)
     {
       c.ControlAdded += new ControlEventHandler(OnControlAdded);
       c.ControlRemoved += new ControlEventHandler(OnControlRemoved);
       if (AllowAdditions)
       {
         c.DragDrop += new DragEventHandler(OnDragDrop);
         c.DragEnter += new DragEventHandler(OnDragEnter);
         MpeLog.Debug("DragDrop enabled");
       }
       for (int i = 0; i < c.Controls.Count; i++)
       {
         if (c.Controls[i] is MpeControl)
         {
           PrepareControl((MpeControl) c.Controls[i]);
         }
       }
     }
   }
   else if (c != null && c.Embedded == true)
   {
     MpeLog.Debug("Preparing Embedded " + c.ToString());
     c.MpeScreen = screen;
   }
   MpeLog.Debug("Prepared " + c.ToString());
 }
Exemplo n.º 47
0
 public override void OnControlStatusChanged(MpeControl sender, bool modified)
 {
   if (sender == screen)
   {
     base.OnControlStatusChanged(sender, modified);
   }
   else
   {
     if (modified == true && screen.Modified == false)
     {
       screen.Modified = true;
     }
     else if (modified == false && screen.Modified == true)
     {
       screen.Modified = false;
     }
   }
 }
Exemplo n.º 48
0
 public override void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
 {
     //
 }
        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));
        }
Exemplo n.º 50
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();
     }
   }
 }