Beispiel #1
0
        private void SaveCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            MediaCenterTheme theme = this.Document.Theme.Theme;

            e.CanExecute = (theme.CanSave && theme.IsDirty);
            e.Handled    = true;
        }
Beispiel #2
0
 public void Save(MediaCenterTheme theme)
 {
     if (this.BasePath == null)
     {
         throw new InvalidOperationException("Theme path not set.");
     }
     this.UpdateFromTheme(theme);
     if (File.Exists(this.SummaryPath))
     {
         File.Delete(this.SummaryPath);
     }
     using (FileStream fileStream = File.Open(this.SummaryPath, FileMode.CreateNew))
         new XmlSerializer(typeof(ThemeSummary)).Serialize((Stream)fileStream, (object)this);
     if (this.Screenshot != null)
     {
         using (FileStream fileStream = File.Open(this.ScreenshotPath, FileMode.OpenOrCreate))
         {
             while (this.Screenshot.IsDownloading)
             {
                 Application.DoEvents();
             }
             PngBitmapEncoder pngBitmapEncoder = new PngBitmapEncoder();
             pngBitmapEncoder.Frames.Add(BitmapFrame.Create(this.Screenshot));
             pngBitmapEncoder.Save((Stream)fileStream);
         }
     }
     else
     {
         if (!File.Exists(this.ScreenshotPath))
         {
             return;
         }
         File.Delete(this.ScreenshotPath);
     }
 }
Beispiel #3
0
 private void UpdateFromTheme(MediaCenterTheme theme)
 {
     this.Name       = theme.Name;
     this.ThemeType  = theme.ThemeType;
     this.ID         = theme.ID;
     this.Screenshot = theme.MainScreenshot;
 }
Beispiel #4
0
 private void ThemesList_DragEnter(object sender, DragEventArgs e)
 {
     e.Effects = DragDropEffects.None;
     string[] array = e.Data.GetData(DataFormats.FileDrop) as string[];
     if (array != null)
     {
         bool     flag   = true;
         string[] array2 = array;
         for (int i = 0; i < array2.Length; i++)
         {
             string path = array2[i];
             if (!MediaCenterTheme.IsThemeFile(path) && !Path.GetExtension(path).Equals(".dll", StringComparison.OrdinalIgnoreCase))
             {
                 flag = false;
                 break;
             }
         }
         if (flag)
         {
             e.Effects = DragDropEffects.Copy;
             string insert = (array.Length == 1) ? Path.GetFileName(array[0]) : "themes";
             Advent.Common.UI.DragDrop.SetDropDescriptionInsert(this.themesList, insert);
         }
     }
 }
Beispiel #5
0
        private void NewExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            MediaCenterTheme theme       = this.Document.ThemeManager.CreateTheme().OpenTheme();
            VmcDocument      vmcDocument = new ThemeEditDocument(new ThemeModel(theme, this.Document.ThemeManager));

            VmcStudioUtil.Application.Documents.Add(vmcDocument);
            VmcStudioUtil.Application.SelectedDocument = vmcDocument;
            e.Handled = true;
        }
Beispiel #6
0
 public ThemeSummary ImportTheme(string file)
 {
     if (Path.GetExtension(file).Equals(".dll", StringComparison.OrdinalIgnoreCase))
     {
         ThemeSummary theme = this.CreateTheme();
         using (MediaCenterTheme mediaCenterTheme = theme.OpenTheme())
         {
             mediaCenterTheme.AddResourceFileDifferences(VmcStudioUtil.BackupFile(Path.Combine(MediaCenterUtil.MediaCenterPath, "ehres.dll")), file);
             mediaCenterTheme.Save();
         }
         return(theme);
     }
     else
     {
         string directory     = Path.Combine(this.themesPath, Guid.NewGuid().ToString());
         string themeFileName = Path.GetFileName(file);
         string str           = Path.Combine(directory, themeFileName);
         Directory.CreateDirectory(directory);
         try
         {
             File.Copy(file, str);
             try
             {
                 Dispatcher   dispatcher = System.Windows.Application.Current.Dispatcher;
                 ThemeSummary summary    = new ThemeSummary();
                 Action       action     = (Action)(() =>
                 {
                     summary.BasePath = directory;
                     summary.ThemeFile = themeFileName;
                     summary.Save();
                     this.themes.Add(summary);
                 });
                 dispatcher.Invoke((Delegate)action, new object[0]);
                 return(summary);
             }
             catch (Exception ex)
             {
                 Trace.TraceError("Error importing theme {0}: {1}", (object)themeFileName, (object)((object)ex).ToString());
                 File.Delete(str);
                 throw;
             }
         }
         catch (Exception)
         {
             try
             {
                 Directory.Delete(directory, true);
             }
             catch (Exception ex2)
             {
                 Trace.TraceError("Could not delete failed import ({1}): {0}", (object)((object)ex2).ToString(), (object)directory);
             }
             throw;
         }
     }
 }
Beispiel #7
0
        public MediaCenterTheme OpenTheme()
        {
            if (string.IsNullOrEmpty(this.BasePath) || string.IsNullOrEmpty(this.ThemeFile))
            {
                throw new InvalidOperationException("Theme path not set.");
            }
            MediaCenterTheme mediaCenterTheme = MediaCenterTheme.FromFile(this.ThemeFullPath);

            mediaCenterTheme.Saved += new EventHandler(this.ThemeSaved);
            return(mediaCenterTheme);
        }
Beispiel #8
0
 public ThemeModel(MediaCenterTheme theme, ThemeManager manager)
     : base((string)null, (ThemeTreeItem)null)
 {
     this.Theme          = theme;
     this.ThemeManager   = manager;
     this.BiographyItem  = new BiographyModel(this);
     this.FontsItem      = new FontsItemModel((IThemeItem)theme.FontsItem, this, false);
     this.ColorsItem     = new ColorsItemModel((IThemeItem)theme.ColorsItem, this, false);
     this.ImagesCategory = new ImagesCategoryModel("Images", (ThemeTreeItem)this);
     this.Children.Add((ThemeTreeItem)this.BiographyItem);
     this.Children.Add((ThemeTreeItem)this.FontsItem);
     this.Children.Add((ThemeTreeItem)this.ColorsItem);
     this.Children.Add((ThemeTreeItem)this.ImagesCategory);
     this.BiographyItem.IsSelected = true;
     foreach (IThemeItem themeItem in (Collection <IThemeItem>) this.Theme.ThemeItems)
     {
         this.AddThemeItem(themeItem, false);
     }
     foreach (IThemeItem themeItem in this.DefaultThemeItems)
     {
         this.AddThemeItem(themeItem, true);
     }
     this.Sort();
 }
Beispiel #9
0
        public IEnumerable <FontOverride> GetFontOverrides(MediaCenterLibraryCache cache, MediaCenterTheme theme)
        {
            XDocument           xdocument  = XDocument.Load(MediaCenterUtil.GetXml(cache["Microsoft.MediaCenter.Shell.dll"].GetResource("FONTS.MCML", (object)this.DocumentResourceType)));
            string              str1       = string.Format("global://{0}:", (object)"me");
            List <FontOverride> list       = new List <FontOverride>();
            XNamespace          xnamespace = (XNamespace)"http://schemas.microsoft.com/2006/mcml";

            foreach (XElement element in xdocument.Root.Elements(xnamespace + "Font"))
            {
                FontOverride fontOverride = new FontOverride();
                fontOverride.Name = MediaCenterUtil.AttributeValue(element, (XName)"Name");
                string font = MediaCenterUtil.AttributeValue(element, (XName)"FontName");
                if (font.StartsWith(str1))
                {
                    fontOverride.FontClass = font.Substring(str1.Length);
                }
                else
                {
                    fontOverride.FontFace = FontUtilities.GetFontFaceInfo(font, theme);
                }
                if (!string.IsNullOrEmpty(fontOverride.FontClass) || fontOverride.FontFace != null)
                {
                    int result;
                    if (int.TryParse(MediaCenterUtil.AttributeValue(element, (XName)"FontSize"), out result))
                    {
                        fontOverride.Size = result;
                    }
                    string str2 = MediaCenterUtil.AttributeValue(element, (XName)"FontStyle");
                    if (str2 != null)
                    {
                        fontOverride.IsBold   = str2.Contains("Bold");
                        fontOverride.IsItalic = str2.Contains("Italic");
                    }
                    list.Add(fontOverride);
                }
            }
            return((IEnumerable <FontOverride>)list);
        }
Beispiel #10
0
 public void Save()
 {
     using (MediaCenterTheme theme = this.OpenTheme())
         this.Save(theme);
 }
Beispiel #11
0
 public BiographyThemeItem(MediaCenterTheme theme)
 {
     this.Theme   = theme;
     theme.Saved += new EventHandler(this.ThemeSaved);
 }