public IEnumerable <FontEmbedOption> GetLinkedProjectFonts(FontEmbedOption font)
 {
     if (font.ProjectFont != null)
     {
         return((IEnumerable <FontEmbedOption>) this.linkedProjectFonts[font.ProjectFont.FontDocumentReference]);
     }
     return(Enumerable.Empty <FontEmbedOption>());
 }
        public FontEmbeddingDialogModel(SceneViewModel viewModel)
        {
            this.viewModel = viewModel;
            Dictionary <string, FontEmbedOption> dictionary = new Dictionary <string, FontEmbedOption>();

            foreach (ProjectFont projectFont in (Collection <IProjectFont>)viewModel.ProjectContext.ProjectFonts)
            {
                IProjectItem projectItem = viewModel.DesignerContext.ActiveProject.FindItem(projectFont.FontDocumentReference);
                if (projectItem != null)
                {
                    FontEmbedOption fontEmbedOption = new FontEmbedOption(projectFont, projectItem, viewModel, this);
                    this.fonts.Add(fontEmbedOption);
                    dictionary[projectFont.FontFamilyName] = fontEmbedOption;
                    List <FontEmbedOption> list;
                    if (!this.linkedProjectFonts.TryGetValue(projectFont.FontDocumentReference, out list))
                    {
                        list = new List <FontEmbedOption>();
                        this.linkedProjectFonts[projectFont.FontDocumentReference] = list;
                    }
                    list.Add(fontEmbedOption);
                }
            }
            foreach (SystemFontFamily systemFont in FontEmbedder.GetSystemFonts((ITypeResolver)viewModel.ProjectContext))
            {
                FontEmbedOption fontEmbedOption = (FontEmbedOption)null;
                if (dictionary.TryGetValue(systemFont.FontFamilyName, out fontEmbedOption))
                {
                    if (fontEmbedOption.WasSystemFont)
                    {
                        fontEmbedOption.SystemFont = systemFont;
                    }
                }
                else if (!systemFont.IsNativeSilverlightFont || !this.viewModel.ProjectContext.IsCapabilitySet(PlatformCapability.DisallowEmbeddingSilverlightFonts))
                {
                    this.fonts.Add(new FontEmbedOption(systemFont, viewModel, this));
                }
            }
            this.fonts.Sort((Comparison <FontEmbedOption>)((lhs, rhs) =>
            {
                if (lhs.ProjectFont != null && rhs.ProjectFont == null)
                {
                    return(-1);
                }
                if (lhs.ProjectFont == null && rhs.ProjectFont != null)
                {
                    return(1);
                }
                return(lhs.FontFamilyName.CompareTo(rhs.FontFamilyName));
            }));
            this.fontsView = CollectionViewSource.GetDefaultView((object)this.fonts);
            this.fontsView.CurrentChanged += new EventHandler(this.fontsView_CurrentChanged);
        }