Exemplo n.º 1
0
        private static List <SourcedFontFamilyItem> GetFontFamilies(IEnumerable <SystemFontFamily> systemFonts, ICollection <IProjectFont> projectFonts, SceneNodeObjectSet sceneNodeObjectSet)
        {
            Dictionary <string, ProjectFontFamilyItem> dictionary = new Dictionary <string, ProjectFontFamilyItem>();
            List <SourcedFontFamilyItem> list1 = new List <SourcedFontFamilyItem>();

            foreach (ProjectFont projectFont in (IEnumerable <IProjectFont>)projectFonts)
            {
                ProjectFontFamilyItem projectFontFamilyItem = new ProjectFontFamilyItem(projectFont, sceneNodeObjectSet);
                projectFontFamilyItem.IsInEmbeddedFontSection = true;
                list1.Add((SourcedFontFamilyItem)projectFontFamilyItem);
                dictionary[projectFontFamilyItem.FamilyName] = projectFontFamilyItem;
            }
            List <SourcedFontFamilyItem> list2 = new List <SourcedFontFamilyItem>();

            foreach (SystemFontFamily systemFontFamily in systemFonts)
            {
                SystemFontFamilyItem  systemFontFamilyItem = new SystemFontFamilyItem(systemFontFamily, sceneNodeObjectSet);
                ProjectFontFamilyItem projectFontFamilyItem;
                if (dictionary.TryGetValue(systemFontFamily.FontFamilyName, out projectFontFamilyItem))
                {
                    projectFontFamilyItem = new ProjectFontFamilyItem(projectFontFamilyItem.ProjectFont, sceneNodeObjectSet);
                    projectFontFamilyItem.SystemFontFamilyItem = systemFontFamilyItem;
                    list2.Add((SourcedFontFamilyItem)projectFontFamilyItem);
                }
                else
                {
                    list2.Add((SourcedFontFamilyItem)systemFontFamilyItem);
                }
            }
            list1.AddRange((IEnumerable <SourcedFontFamilyItem>)list2);
            list1.Sort((IComparer <SourcedFontFamilyItem>) new FontFamilyValueEditor.FontFamilyComparer());
            return(list1);
        }
Exemplo n.º 2
0
            public int Compare(SourcedFontFamilyItem x, SourcedFontFamilyItem y)
            {
                ProjectFontFamilyItem projectFontFamilyItem1 = x as ProjectFontFamilyItem;
                ProjectFontFamilyItem projectFontFamilyItem2 = y as ProjectFontFamilyItem;

                if (projectFontFamilyItem1 != null && projectFontFamilyItem2 != null)
                {
                    if (projectFontFamilyItem1.IsInEmbeddedFontSection != projectFontFamilyItem2.IsInEmbeddedFontSection)
                    {
                        return(!projectFontFamilyItem1.IsInEmbeddedFontSection ? 1 : -1);
                    }
                }
                else
                {
                    if (projectFontFamilyItem1 != null && projectFontFamilyItem1.IsInEmbeddedFontSection)
                    {
                        return(-1);
                    }
                    if (projectFontFamilyItem2 != null && projectFontFamilyItem2.IsInEmbeddedFontSection)
                    {
                        return(1);
                    }
                }
                SystemFontFamilyItem systemFontFamilyItem1 = x as SystemFontFamilyItem;
                SystemFontFamilyItem systemFontFamilyItem2 = y as SystemFontFamilyItem;

                if (systemFontFamilyItem1 != null && systemFontFamilyItem2 != null)
                {
                    if (systemFontFamilyItem1.DisplayAsNativeSilverlightFont != systemFontFamilyItem2.DisplayAsNativeSilverlightFont)
                    {
                        return(!systemFontFamilyItem1.DisplayAsNativeSilverlightFont ? 1 : -1);
                    }
                }
                else
                {
                    if (systemFontFamilyItem1 != null && systemFontFamilyItem1.DisplayAsNativeSilverlightFont)
                    {
                        return(-1);
                    }
                    if (systemFontFamilyItem2 != null && systemFontFamilyItem2.DisplayAsNativeSilverlightFont)
                    {
                        return(1);
                    }
                }
                return(string.Compare(x.FamilyName, y.FamilyName, StringComparison.CurrentCulture));
            }
Exemplo n.º 3
0
 private void projectFontFamilies_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (this.sceneNodeObjectSet == null)
     {
         return;
     }
     if (e.OldItems != null)
     {
         foreach (ProjectFont projectFont in (IEnumerable)e.OldItems)
         {
             SystemFontFamilyItem systemFontFamilyItem = (SystemFontFamilyItem)null;
             bool flag = false;
             for (int index = this.fontFamilyEditor.FontFamilies.Count - 1; index >= 0; --index)
             {
                 ProjectFontFamilyItem projectFontFamilyItem = this.fontFamilyEditor.FontFamilies[index] as ProjectFontFamilyItem;
                 if (projectFontFamilyItem != null && projectFontFamilyItem.ProjectFont == projectFont)
                 {
                     if (projectFontFamilyItem.SystemFontFamilyItem != null)
                     {
                         systemFontFamilyItem = projectFontFamilyItem.SystemFontFamilyItem;
                     }
                     flag = this.fontFamilyEditor.CurrentFontItem == projectFontFamilyItem;
                     this.fontFamilyEditor.FontFamilies.RemoveAt(index);
                 }
             }
             if (systemFontFamilyItem != null)
             {
                 this.InsertFontItem((SourcedFontFamilyItem)systemFontFamilyItem);
                 if (flag)
                 {
                     this.fontFamilyEditor.InvalidateProperty(FontFamilyEditor.CurrentFontItemProperty);
                 }
             }
         }
     }
     if (e.NewItems == null)
     {
         return;
     }
     foreach (ProjectFont projectFont in (IEnumerable)e.NewItems)
     {
         bool flag = false;
         ProjectFontFamilyItem projectFontFamilyItem = new ProjectFontFamilyItem(projectFont, this.sceneNodeObjectSet);
         SystemFontFamilyItem  systemFontFamilyItem1 = (SystemFontFamilyItem)null;
         for (int index = 0; index < this.fontFamilyEditor.FontFamilies.Count; ++index)
         {
             SystemFontFamilyItem systemFontFamilyItem2 = this.fontFamilyEditor.FontFamilies[index] as SystemFontFamilyItem;
             if (systemFontFamilyItem2 != null && systemFontFamilyItem2.FamilyName == projectFontFamilyItem.FamilyName)
             {
                 systemFontFamilyItem1 = systemFontFamilyItem2;
                 this.fontFamilyEditor.FontFamilies.RemoveAt(index);
                 flag = this.fontFamilyEditor.CurrentFontItem == systemFontFamilyItem2;
                 break;
             }
         }
         projectFontFamilyItem.IsInEmbeddedFontSection = true;
         projectFontFamilyItem.SystemFontFamilyItem    = systemFontFamilyItem1;
         this.InsertFontItem((SourcedFontFamilyItem)projectFontFamilyItem);
         if (flag)
         {
             this.fontFamilyEditor.InvalidateProperty(FontFamilyEditor.CurrentFontItemProperty);
         }
         this.InsertFontItem((SourcedFontFamilyItem) new ProjectFontFamilyItem(projectFont, this.sceneNodeObjectSet)
         {
             SystemFontFamilyItem = systemFontFamilyItem1
         });
     }
 }