Exemple #1
0
        protected override void SaveInternal()
        {
            this.themeInfo.ID        = this.ID;
            this.themeInfo.Name      = this.Name;
            this.themeInfo.Author    = this.Author;
            this.themeInfo.Version   = ((object)(this.Version ?? new Version(0, 0))).ToString();
            this.themeInfo.Comments  = this.Comments;
            this.themeInfo.ThemeType = this.ThemeType;
            foreach (IThemeItem themeItem in (Collection <IThemeItem>) this.ThemeItems)
            {
                if (!themeItem.IsLoaded)
                {
                    themeItem.Load();
                }
            }
            this.ZipFile.BeginUpdate();
            foreach (ZipEntry entry in new List <ZipEntry>(Enumerable.OfType <ZipEntry>((IEnumerable)this.ZipFile)))
            {
                this.ZipFile.Delete(entry);
            }
            this.themeItemEntries.Clear();
            this.themeInfo.Fonts  = this.FontsItem;
            this.themeInfo.Colors = this.ColorsItem;
            MemoryStream memoryStream = new MemoryStream();

            new XmlSerializer(typeof(VmcStudioTheme.ThemeInfo)).Serialize((Stream)memoryStream, (object)this.themeInfo);
            this.ZipFile.Add((IStaticDataSource) new ZippedTheme.StreamDataSource((Stream)memoryStream), "Theme.xml");
            if (this.MainScreenshot != null)
            {
                VmcStudioTheme.AddImageResource(this.MainScreenshot, this.ZipFile, "Screenshot.png");
            }
            for (int index = 0; index < this.Screenshots.Count; ++index)
            {
                VmcStudioTheme.AddImageResource(this.Screenshots[index], this.ZipFile, string.Format("Screenshots\\{0}.png", (object)index));
            }
            foreach (ResourceThemeItem resourceThemeItem in Enumerable.OfType <ResourceThemeItem>((IEnumerable)this.ThemeItems))
            {
                string entryName = (string)null;
                if (resourceThemeItem is ImageResourceThemeItem)
                {
                    entryName = VmcStudioTheme.GetResourceZipPath(resourceThemeItem, "Images");
                }
                else if (resourceThemeItem is SoundResourceThemeItem)
                {
                    entryName = VmcStudioTheme.GetResourceZipPath(resourceThemeItem, "Sounds");
                }
                if (entryName == null)
                {
                    throw new Exception("Unknown theme item type - " + (object)resourceThemeItem.GetType());
                }
                this.ZipFile.Add(ZippedTheme.GetResourceThemeItemData(resourceThemeItem), entryName);
            }
            foreach (string fontName in Enumerable.Distinct <string>(Enumerable.Concat <string>(Enumerable.Select <FontClass, string>((IEnumerable <FontClass>) this.themeInfo.Fonts.FontClasses, (Func <FontClass, string>)(fontClass => fontClass.FontFace.FontFamily)), Enumerable.Select <FontOverride, string>(Enumerable.Where <FontOverride>((IEnumerable <FontOverride>) this.themeInfo.Fonts.FontOverrides, (Func <FontOverride, bool>)(fontOverride => fontOverride.FontFace != null)), (Func <FontOverride, string>)(fontOverride => fontOverride.FontFace.FontFamily)))))
            {
                FontFamily fontFamily = this.GetFontFamily(fontName);
                if (fontFamily != null)
                {
                    string file = FontUtil.GetFile(fontFamily);
                    if (file != null)
                    {
                        this.ZipFile.Add(file, "Fonts\\" + Path.GetFileName(file));
                    }
                }
            }
            this.ZipFile.CommitUpdate();
            this.ResetZipFile();
            foreach (IThemeItem themeItem in Enumerable.Where <IThemeItem>((IEnumerable <IThemeItem>) this.ThemeItems, (Func <IThemeItem, bool>)(t => t.IsDirty)))
            {
                themeItem.ClearDirty();
            }
            this.FontsItem.ClearDirty();
            this.ColorsItem.ClearDirty();
            this.IsDirty = false;
        }