コード例 #1
0
        /*public Bitmap GetImage(string name)
         * {
         *  Bitmap bmp = null;
         *  string fname = null;
         *  if (pluginRes != null)
         *  {
         *      foreach (string str in pluginRes.ImageFiles)
         *      {
         *          if (Path.GetFileNameWithoutExtension(str) == name)
         *              fname = @"Images/" + str;
         *      }
         *  }
         *  if (fname == null)
         *      fname = name + ".png"; // backward compatibility needed ??
         *  //try to load a bitmap from the zip file
         *  try
         *  {
         *      using (ZipFile m_zip = ZipFile.Read(m_filename))
         *      {
         *           ZipEntry ze = m_zip[fname];
         *          Stream stream = new MemoryStream();
         *          ze.Extract(stream);
         *          bmp = new Bitmap(stream);
         *          if (bmp != null)
         *              return bmp;
         *      }
         *  }
         *  catch (Exception)
         *  {
         *      DebugLogger.Instance().LogError("Image resource " + name + ".png error loading from plugin " + m_filename);
         *  }
         *  return bmp;
         * }*/

        public void LoadManifest()
        {
            pluginRes = new PluginResources();
            try
            {
                using (ZipFile m_zip = ZipFile.Read(m_filename))
                {
                    ZipEntry     ze     = m_zip["PluginManifest.xml"];
                    MemoryStream stream = new MemoryStream();
                    ze.Extract(stream);
                    pluginRes.ParseManifest(stream);
                }
            }
            catch (Exception)
            {
                DebugLogger.Instance().LogError("Error loading PluginManifest.xml from plugin " + m_filename);
            }
        }
コード例 #2
0
ファイル: PluginLite.cs プロジェクト: David-Estevez/Sunrise
 /*public Bitmap GetImage(string name)
 {
     Bitmap bmp = null;
     string fname = null;
     if (pluginRes != null)
     {
         foreach (string str in pluginRes.ImageFiles)
         {
             if (Path.GetFileNameWithoutExtension(str) == name)
                 fname = @"Images/" + str;
         }
     }
     if (fname == null)
         fname = name + ".png"; // backward compatibility needed ??
     //try to load a bitmap from the zip file
     try
     {
         using (ZipFile m_zip = ZipFile.Read(m_filename))
         {
              ZipEntry ze = m_zip[fname];
             Stream stream = new MemoryStream();
             ze.Extract(stream);
             bmp = new Bitmap(stream);
             if (bmp != null)
                 return bmp;
         }
     }
     catch (Exception)
     {
         DebugLogger.Instance().LogError("Image resource " + name + ".png error loading from plugin " + m_filename);
     }
     return bmp;
 }*/
 public void LoadManifest()
 {
     pluginRes = new PluginResources();
     try
     {
         using (ZipFile m_zip = ZipFile.Read(m_filename))
         {
             ZipEntry ze = m_zip["PluginManifest.xml"];
             MemoryStream stream = new MemoryStream();
             ze.Extract(stream);
             pluginRes.ParseManifest(stream);
         }
     }
     catch (Exception)
     {
         DebugLogger.Instance().LogError("Error loading PluginManifest.xml from plugin " + m_filename);
     }
 }