public MpeFont(MpeFont font)
 {
     textureWorkDir  = font.textureWorkDir;
     name            = font.name;
     systemFont      = new Font(font.systemFont.FontFamily, font.systemFont.Size, font.systemFont.Style);
     spacingPerChar  = font.spacingPerChar;
     startChar       = font.startChar;
     endChar         = font.endChar;
     textureFile     = font.textureFile;
     textureDataFile = font.TextureDataFile;
     if (font.texture != null)
     {
         try
         {
             texture = new Bitmap(font.texture, font.texture.Width, font.texture.Height);
         }
         catch (Exception e)
         {
             MpeLog.Warn(e);
         }
     }
     if (font.textureCoordinates != null)
     {
         textureCoordinates = new float[font.textureCoordinates.GetLength(0), font.textureCoordinates.GetLength(1)];
         for (int i = 0; i < textureCoordinates.GetLength(0); i++)
         {
             for (int j = 0; j < textureCoordinates.GetLength(1); j++)
             {
                 textureCoordinates[i, j] = font.textureCoordinates[i, j];
             }
         }
         ConvertTextureData();
     }
 }
Exemple #2
0
 public MpeFont(MpeFont font)
 {
   textureWorkDir = font.textureWorkDir;
   name = font.name;
   systemFont = new Font(font.systemFont.FontFamily, font.systemFont.Size, font.systemFont.Style);
   spacingPerChar = font.spacingPerChar;
   startChar = font.startChar;
   endChar = font.endChar;
   textureFile = font.textureFile;
   textureDataFile = font.TextureDataFile;
   if (font.texture != null)
   {
     try
     {
       texture = new Bitmap(font.texture, font.texture.Width, font.texture.Height);
     }
     catch (Exception e)
     {
       MpeLog.Warn(e);
     }
   }
   if (font.textureCoordinates != null)
   {
     textureCoordinates = new float[font.textureCoordinates.GetLength(0),font.textureCoordinates.GetLength(1)];
     for (int i = 0; i < textureCoordinates.GetLength(0); i++)
     {
       for (int j = 0; j < textureCoordinates.GetLength(1); j++)
       {
         textureCoordinates[i, j] = font.textureCoordinates[i, j];
       }
     }
     ConvertTextureData();
   }
 }
Exemple #3
0
 public MpeLabel(MpeLabel label) : base(label)
 {
     MpeLog.Debug("MpeLabel(label)");
     font          = label.font;
     text          = label.text;
     textValue     = label.textValue;
     disabledBrush = (SolidBrush)label.disabledBrush.Clone();
     textSize      = label.textSize;
     textOffset    = label.textOffset;
     lookup        = label.lookup;
     onLeft        = 0;
     onRight       = 0;
     onUp          = 0;
     onDown        = 0;
 }
Exemple #4
0
 public MpeLabel(MpeLabel label) : base(label)
 {
   MpeLog.Debug("MpeLabel(label)");
   font = label.font;
   text = label.text;
   textValue = label.textValue;
   disabledBrush = (SolidBrush) label.disabledBrush.Clone();
   textSize = label.textSize;
   textOffset = label.textOffset;
   lookup = label.lookup;
   onLeft = 0;
   onRight = 0;
   onUp = 0;
   onDown = 0;
 }
Exemple #5
0
 public MpeLabel() : base()
 {
     MpeLog.Debug("MpeLabel()");
     Type          = MpeControlType.Label;
     disabledBrush = new SolidBrush(Color.Gray);
     lookup        = true;
     font          = new MpeFont();
     text          = "";
     textValue     = "";
     textSize      = Size.Empty;
     textOffset    = Point.Empty;
     onLeft        = 0;
     onRight       = 0;
     onUp          = 0;
     onDown        = 0;
 }
Exemple #6
0
 public MpeLabel() : base()
 {
   MpeLog.Debug("MpeLabel()");
   Type = MpeControlType.Label;
   disabledBrush = new SolidBrush(Color.Gray);
   lookup = true;
   font = new MpeFont();
   text = "";
   textValue = "";
   textSize = Size.Empty;
   textOffset = Point.Empty;
   onLeft = 0;
   onRight = 0;
   onUp = 0;
   onDown = 0;
 }
 public MpeFontViewer(MpeFont font, FileInfo background) : base()
 {
   MpeLog.Debug("MpeFontViewer()");
   id = 1;
   controlLock.Location = true;
   controlLock.Size = true;
   mpeFont = font;
   showBackground = true;
   showBorders = false;
   selectedBrush = new SolidBrush(Color.DarkGray);
   hoverBrush = new SolidBrush(Color.Gray);
   borderPen = new Pen(Color.Lime, 1.0f);
   selectedIndex = -1;
   hoverIndex = -1;
   BackImageFile = background;
   Prepare();
   SelectedIndex = 0;
   Modified = false;
 }
Exemple #8
0
 public MpeFontViewer(MpeFont font, FileInfo background) : base()
 {
     MpeLog.Debug("MpeFontViewer()");
     id = 1;
     controlLock.Location = true;
     controlLock.Size     = true;
     mpeFont        = font;
     showBackground = true;
     showBorders    = false;
     selectedBrush  = new SolidBrush(Color.DarkGray);
     hoverBrush     = new SolidBrush(Color.Gray);
     borderPen      = new Pen(Color.Lime, 1.0f);
     selectedIndex  = -1;
     hoverIndex     = -1;
     BackImageFile  = background;
     Prepare();
     SelectedIndex = 0;
     Modified      = false;
 }
 public FontDesigner(MediaPortalEditor mpe, MpeFont font) : base(mpe)
 {
   this.font = font;
 }
Exemple #10
0
 public void SaveFont(MpeFont font)
 {
   if (font == null)
   {
     throw new MpeParserException("Invalid Font");
   }
   XmlTextWriter writer = null;
   try
   {
     XmlDocument doc = new XmlDocument();
     doc.Load(fontFile.FullName);
     XmlNode node = doc.SelectSingleNode("/fonts/font[name='" + font.Name + "']");
     if (node == null)
     {
       XmlNode parent = doc.SelectSingleNode("/fonts");
       if (parent == null)
       {
         throw new MpeParserException("Invalid fonts.xml file.");
       }
       node = doc.CreateElement("font");
       parent.AppendChild(node);
     }
     else
     {
       node.RemoveAll();
     }
     // First get the existing font and destroy it
     MpeFont oldFont = GetFont(font.Name);
     if (oldFont != null)
     {
       fonts.Remove(font.Name);
       oldFont.Destroy();
     }
     // Save the new font and store a copy of it
     font.Save(doc, node, this, null);
     fonts.Add(font.Name, new MpeFont(font));
     // Write the document
     writer = new XmlTextWriter(fontFile.FullName, Encoding.UTF8);
     writer.Formatting = Formatting.Indented;
     writer.Indentation = 3;
     doc.WriteTo(writer);
   }
   catch (Exception e)
   {
     throw new MpeParserException(e.Message);
   }
   finally
   {
     if (writer != null)
     {
       writer.Close();
     }
   }
 }
Exemple #11
0
 public MpeFont GetFont(XPathNodeIterator iterator, string tagName, MpeFont defaultValue)
 {
   XPathNodeIterator i = iterator.Current.Select(tagName);
   if (i.MoveNext())
   {
     try
     {
       MpeFont font = GetFont(i.Current.Value);
       if (font != null)
       {
         return font;
       }
     }
     catch
     {
       MpeLog.Warn("Could not load the specified font.");
     }
   }
   return defaultValue;
 }