예제 #1
0
 public VmcStudioTheme(string file, MediaCenterTheme theme)
     : base(file, FileMode.CreateNew)
 {
     this.themeInfo = new VmcStudioTheme.ThemeInfo();
     foreach (IThemeItem themeItem in (Collection <IThemeItem>)theme.ThemeItems)
     {
         if (themeItem is FontsThemeItem)
         {
             this.themeInfo.Fonts = (FontsThemeItem)themeItem;
         }
         if (themeItem is ColorsThemeItem)
         {
             this.themeInfo.Colors = (ColorsThemeItem)themeItem;
         }
         this.ThemeItems.Add(themeItem);
     }
     this.Name           = theme.Name;
     this.Author         = theme.Author;
     this.Comments       = theme.Comments;
     this.Version        = theme.Version;
     this.ThemeType      = theme.ThemeType;
     this.MainScreenshot = theme.MainScreenshot;
     this.FontFiles      = theme.FontFiles;
     this.ID             = Guid.NewGuid().ToString();
     this.themeInfo.Fonts.ClearDirty();
 }
예제 #2
0
 public VmcStudioTheme(string file, string id)
     : base(file, FileMode.CreateNew)
 {
     this.ID = id;
     this.themeInfo = new VmcStudioTheme.ThemeInfo();
     this.FontsItem = new FontsThemeItem();
     this.ColorsItem = new ColorsThemeItem();
 }
예제 #3
0
 public VmcStudioTheme(string file, string id)
     : base(file, FileMode.CreateNew)
 {
     this.ID         = id;
     this.themeInfo  = new VmcStudioTheme.ThemeInfo();
     this.FontsItem  = new FontsThemeItem();
     this.ColorsItem = new ColorsThemeItem();
 }
예제 #4
0
 public VmcStudioTheme(string file, MediaCenterTheme theme)
     : base(file, FileMode.CreateNew)
 {
     this.themeInfo = new VmcStudioTheme.ThemeInfo();
     foreach (IThemeItem themeItem in (Collection<IThemeItem>)theme.ThemeItems)
     {
         if (themeItem is FontsThemeItem)
             this.themeInfo.Fonts = (FontsThemeItem)themeItem;
         if (themeItem is ColorsThemeItem)
             this.themeInfo.Colors = (ColorsThemeItem)themeItem;
         this.ThemeItems.Add(themeItem);
     }
     this.Name = theme.Name;
     this.Author = theme.Author;
     this.Comments = theme.Comments;
     this.Version = theme.Version;
     this.ThemeType = theme.ThemeType;
     this.MainScreenshot = theme.MainScreenshot;
     this.FontFiles = theme.FontFiles;
     this.ID = Guid.NewGuid().ToString();
     this.themeInfo.Fonts.ClearDirty();
 }
예제 #5
0
 public VmcStudioTheme(string file)
     : base(file, FileMode.Open)
 {
     ZipEntry entry1 = this.ZipFile.GetEntry("Theme.xml");
     if (entry1 == null)
     {
         Trace.TraceError("Could not find Theme.xml in theme " + file);
         throw new Exception("Could not find theme entry in theme file.");
     }
     else
     {
         this.themeInfo = (VmcStudioTheme.ThemeInfo)new XmlSerializer(typeof(VmcStudioTheme.ThemeInfo)).Deserialize(this.ZipFile.GetInputStream(entry1));
         this.themeInfo.BeginInit();
         if (this.themeInfo.Fonts == null)
             this.themeInfo.Fonts = new FontsThemeItem();
         this.themeInfo.Fonts.ClearDirty();
         this.FontsItem = this.themeInfo.Fonts;
         if (this.themeInfo.Colors == null)
             this.themeInfo.Colors = new ColorsThemeItem();
         this.themeInfo.Colors.ClearDirty();
         this.ColorsItem = this.themeInfo.Colors;
         this.Name = this.themeInfo.Name;
         this.Author = this.themeInfo.Author;
         this.Version = new Version(this.themeInfo.Version);
         this.Comments = this.themeInfo.Comments;
         this.ThemeType = this.themeInfo.ThemeType;
         this.ID = this.themeInfo.ID;
         foreach (ZipEntry entry2 in this.ZipFile)
         {
             IThemeItem index = (IThemeItem)null;
             string[] strArray = entry2.Name.Split(new char[2]
       {
     '\\',
     '/'
       });
             if (strArray[0] == "Resources")
             {
                 string dllName = strArray[1] + ".dll";
                 string str = strArray[2];
                 string resourceName = strArray[3];
                 switch (str)
                 {
                     case "Images":
                         index = (IThemeItem)new ImageResourceThemeItem(dllName, resourceName, (Func<ResourceThemeItem, byte[]>)(themeItem => ZippedTheme.ReadZipEntry(this.ZipFile, this.themeItemEntries[(IThemeItem)themeItem])));
                         break;
                     case "Sounds":
                         index = (IThemeItem)new SoundResourceThemeItem(dllName, resourceName, (Func<ResourceThemeItem, byte[]>)(themeItem => ZippedTheme.ReadZipEntry(this.ZipFile, this.themeItemEntries[(IThemeItem)themeItem])));
                         break;
                 }
             }
             else if (strArray[0] == "Fonts")
                 this.fontEntries.Add(entry2);
             else if (entry2.Name == "Screenshot.png")
                 this.MainScreenshot = (BitmapSource)BitmapDecoder.Create(this.ZipFile.GetInputStream(entry2), BitmapCreateOptions.None, BitmapCacheOption.None).Frames[0];
             else if (strArray[0] == "Screenshots")
                 this.Screenshots.Add((BitmapSource)BitmapDecoder.Create(this.ZipFile.GetInputStream(entry2), BitmapCreateOptions.None, BitmapCacheOption.None).Frames[0]);
             if (index != null)
             {
                 this.themeItemEntries[index] = entry2;
                 this.ThemeItems.Add(index);
             }
         }
         this.themeInfo.EndInit();
     }
 }
예제 #6
0
        public VmcStudioTheme(string file)
            : base(file, FileMode.Open)
        {
            ZipEntry entry1 = this.ZipFile.GetEntry("Theme.xml");

            if (entry1 == null)
            {
                Trace.TraceError("Could not find Theme.xml in theme " + file);
                throw new Exception("Could not find theme entry in theme file.");
            }
            else
            {
                this.themeInfo = (VmcStudioTheme.ThemeInfo) new XmlSerializer(typeof(VmcStudioTheme.ThemeInfo)).Deserialize(this.ZipFile.GetInputStream(entry1));
                this.themeInfo.BeginInit();
                if (this.themeInfo.Fonts == null)
                {
                    this.themeInfo.Fonts = new FontsThemeItem();
                }
                this.themeInfo.Fonts.ClearDirty();
                this.FontsItem = this.themeInfo.Fonts;
                if (this.themeInfo.Colors == null)
                {
                    this.themeInfo.Colors = new ColorsThemeItem();
                }
                this.themeInfo.Colors.ClearDirty();
                this.ColorsItem = this.themeInfo.Colors;
                this.Name       = this.themeInfo.Name;
                this.Author     = this.themeInfo.Author;
                this.Version    = new Version(this.themeInfo.Version);
                this.Comments   = this.themeInfo.Comments;
                this.ThemeType  = this.themeInfo.ThemeType;
                this.ID         = this.themeInfo.ID;
                foreach (ZipEntry entry2 in this.ZipFile)
                {
                    IThemeItem index    = (IThemeItem)null;
                    string[]   strArray = entry2.Name.Split(new char[2]
                    {
                        '\\',
                        '/'
                    });
                    if (strArray[0] == "Resources")
                    {
                        string dllName      = strArray[1] + ".dll";
                        string str          = strArray[2];
                        string resourceName = strArray[3];
                        switch (str)
                        {
                        case "Images":
                            index = (IThemeItem) new ImageResourceThemeItem(dllName, resourceName, (Func <ResourceThemeItem, byte[]>)(themeItem => ZippedTheme.ReadZipEntry(this.ZipFile, this.themeItemEntries[(IThemeItem)themeItem])));
                            break;

                        case "Sounds":
                            index = (IThemeItem) new SoundResourceThemeItem(dllName, resourceName, (Func <ResourceThemeItem, byte[]>)(themeItem => ZippedTheme.ReadZipEntry(this.ZipFile, this.themeItemEntries[(IThemeItem)themeItem])));
                            break;
                        }
                    }
                    else if (strArray[0] == "Fonts")
                    {
                        this.fontEntries.Add(entry2);
                    }
                    else if (entry2.Name == "Screenshot.png")
                    {
                        this.MainScreenshot = (BitmapSource)BitmapDecoder.Create(this.ZipFile.GetInputStream(entry2), BitmapCreateOptions.None, BitmapCacheOption.None).Frames[0];
                    }
                    else if (strArray[0] == "Screenshots")
                    {
                        this.Screenshots.Add((BitmapSource)BitmapDecoder.Create(this.ZipFile.GetInputStream(entry2), BitmapCreateOptions.None, BitmapCacheOption.None).Frames[0]);
                    }
                    if (index != null)
                    {
                        this.themeItemEntries[index] = entry2;
                        this.ThemeItems.Add(index);
                    }
                }
                this.themeInfo.EndInit();
            }
        }