Example #1
0
        public static string GetFullName(string fontName)
        {
            string foundName = null;

            // First try fullname
            foundName = FontList.FirstOrDefault(item => item == fontName);

            // Then the ful name with flf extension
            if (foundName == null)
            {
                foundName = FontList.FirstOrDefault(item => item.Contains("/" + fontName + ".flf"));
            }

            // Then with flf extension
            if (foundName == null)
            {
                foundName = FontList.FirstOrDefault(item => item.Contains(fontName + ".flf"));
            }

            // Then any match
            if (foundName == null)
            {
                foundName = FontList.FirstOrDefault(item => item.Contains(fontName));
            }

            return(foundName);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FontList.DataSource = FontsData.Fonts;
                FontList.DataBind();
                string sampleText = string.Empty;
                switch (LoremType)
                {
                case "Sagan":
                    sampleText = FontsData.SaganText;
                    break;

                case "Hipster":
                    sampleText = FontsData.HipsterText;
                    break;

                case "Pirate":
                    sampleText = FontsData.PirateText;
                    break;

                default:
                    sampleText = FontsData.LoremText;
                    break;
                }
                FillerText.Text = sampleText;
            }
        }
Example #3
0
        /// <summary>
        /// byte배열 형태의 폰트 데이터를 저장한다. (MKV 내의 폰트 등)
        /// </summary>
        /// <param name="fontsData"></param>
        /// <returns></returns>
        public static async void InstallFont(IEnumerable <KeyValuePair <string, byte[]> > fontsData, bool fireListChangedEvent)
        {
            var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Fonts", CreationCollisionOption.OpenIfExists);

            await Task.Factory.StartNew(() =>
            {
                var compare = new FontPathCompare();
                Parallel.ForEach(fontsData, async(fontData) =>
                {
                    StorageFile fontFile = null;

                    fontFile = await folder.CreateFileAsync(fontData.Key, Windows.Storage.CreationCollisionOption.OpenIfExists);
                    var prop = await fontFile.GetBasicPropertiesAsync();

                    if (prop.Size == 0)
                    {
                        //시뉵 폰트 파일 저장
                        await Windows.Storage.FileIO.WriteBytesAsync(fontFile, fontData.Value);
                        //System.Diagnostics.Debug.WriteLine($"폰트 저장 : {fontData.Key}");
                    }
                    else
                    {
                        //이미 폰트가 존재하는 경우, 새롭게 설치 요청이 들어오면 기존 삭제 대상폰트 리스트에서 제거 한다. (초기화)
                        FontDAO.DeleteTempFont(new string[] { fontFile.Path });
                        //System.Diagnostics.Debug.WriteLine($"폰트 이미 존재 : {fontData.Key}");
                    }


                    List <KeyName> addedList = new List <KeyName>();
                    foreach (var font in await GetFontItems(fontFile))
                    {
                        lock (lockobj)
                        {
                            if (!FontList.Contains(font, compare))
                            {
                                if (!addedList.Contains(font))
                                {
                                    addedList.Add(font);
                                }
                                FontList.Add(font);
                            }
                        }
                    }

                    if (fireListChangedEvent)
                    {
                        //이벤트 처리
                        if (FontFamilyListChanged != null && addedList.Count > 0)
                        {
                            FontFamilyListChanged(FontList, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, addedList));
                            //System.Diagnostics.Debug.WriteLine($"추가 이벤트 발생 : {fontData.Key}");
                        }
                    }
                });
            });
        }
Example #4
0
 public void AcceptMetafileDescriptorFontList(FontList fontList, PrintContext parameter)
 {
     parameter.WriteLine("Font List: {0} entries", fontList.Fonts.Count());
     parameter.BeginLevel();
     foreach (string font in fontList.Fonts)
     {
         parameter.WriteLine(font);
     }
     parameter.EndLevel();
 }
Example #5
0
 public static ReportFont Create(FontList fontList, float fontSize, ReportColor color, FontStyle style)
 {
     return(new ReportFont
     {
         FontList = fontList,
         Color = color,
         FontSize = fontSize,
         Style = style
     });
 }
Example #6
0
 private void populateFontFamilyCombobox()
 {
     using (InstalledFontCollection fontsCollection = new InstalledFontCollection())
     {
         System.Drawing.FontFamily[] fontFamilies = fontsCollection.Families;
         foreach (System.Drawing.FontFamily font in fontFamilies)
         {
             FontList.Add(font.Name);
         }
     }
 }
Example #7
0
        protected override void ApplyFontToWindow()
        {
            if (DefaultFontFamily == null)
            {
                DefaultFontFamily  = this.FontFamily;
                SelectedFontFamily = DefaultFontFamily;
                FontList.Clear();
                FontList.AddRange(Fonts.GetFontFamilies(Environment.GetFolderPath(Environment.SpecialFolder.Fonts)).ToList());
            }

            base.ApplyFontToWindow();
        }
Example #8
0
        /// <summary>
        /// 사용자가 입력한 폰트 파일을 저장한다.
        /// </summary>
        /// <param name="fontFile"></param>
        /// <returns></returns>
        public static async Task InstallFont(StorageFile fontFile, ObservableCollection <KeyName> fontListSource, TappedEventHandler tapped)
        {
            var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Fonts", CreationCollisionOption.OpenIfExists);

            try
            {
                //폰트 복사(설치)
                var copy = await fontFile.CopyAsync(folder, Path.GetFileName(fontFile.Name), NameCollisionOption.FailIfExists);

                List <KeyName> addedFontList = new List <KeyName>();

                foreach (var fontItem in await GetFontItems(copy))
                {
                    fontItem.ItemTapped = tapped;
                    if (fontListSource != null)
                    {
                        if (!fontListSource.Any(x => x.Key == fontItem.Key))
                        {
                            var index = fontListSource.IndexOf(fontListSource.LastOrDefault(x => x.Name.CompareTo(fontItem.Name) < 0));
                            fontListSource.Insert(index + 1, fontItem);
                        }
                    }

                    if (FontList != null)
                    {
                        if (!FontList.Any(x => x.Key == fontItem.Key))
                        {
                            var index = FontList.IndexOf(FontList.Where(x => x.Type == FontTypes.App.ToString()).LastOrDefault(x => x.Name.CompareTo(fontItem.Name) < 0));
                            FontList.Insert(index + 1, fontItem);
                        }
                    }

                    if (!addedFontList.Contains(fontItem))
                    {
                        addedFontList.Add(fontItem);
                    }

                    if (fontItem.Payload is StorageFile)
                    {
                        var path = (fontItem.Payload as StorageFile).Path;
                        FontDAO.DeleteTempFont(new string[] { path });
                    }
                }

                //이벤트 처리
                if (FontFamilyListChanged != null)
                {
                    FontFamilyListChanged(FontList, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, addedFontList));
                }
            }
            catch (Exception) { }
        }
Example #9
0
 public static Font2Font GetFont2Font(string name)
 {
     if (FontList.ContainsKey(name) == true)
     {
         //Debug.LogWarning("xFont:命中" + FontList.Count.ToString());
         return(FontList[name]);
     }
     else
     {
         //Debug.LogWarning("xFont:脱吧" + FontList.Count.ToString());
         return(FontList.First().Value);
     }
 }
Example #10
0
            public void Write(FileWriter writer)
            {
                RecalculateMaterialReferences();

                writer.SetByteOrder(IsBigEndian);
                writer.WriteSignature(Magic);
                if (Magic == "TYLR")
                {
                    writer.ReverseMagic = true;
                }
                writer.Write(ByteOrderMark);
                writer.Write((ushort)Version);
                writer.Write(uint.MaxValue);   //Reserve space for file size later
                writer.Write(HeaderSize);
                writer.Write(ushort.MaxValue); //Reserve space for section count later

                int sectionCount = 1;

                WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));
                if (TextureList != null && TextureList.Textures.Count > 0)
                {
                    WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
                    sectionCount++;
                }
                if (FontList != null && FontList.Fonts.Count > 0)
                {
                    WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
                    sectionCount++;
                }
                if (MaterialList != null && MaterialList.Materials.Count > 0)
                {
                    WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
                    sectionCount++;
                }

                WritePanes(writer, RootPane, this, ref sectionCount);
                WriteGroupPanes(writer, RootGroup, this, ref sectionCount);

                //Write the total section count
                using (writer.TemporarySeek(14, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((ushort)sectionCount);
                }

                //Write the total file size
                using (writer.TemporarySeek(8, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((uint)writer.BaseStream.Length);
                }
            }
 private void SettingsChanged()
 {
     if (CurrentSettings != null)
     {
         SelectedFontFamily     = FontList.Single(font => font.FontName.Equals(CurrentSettings.FontFamily.Source));
         IsAutosave             = CurrentSettings.IsAutosave;
         FontSize               = CurrentSettings.FontSize;
         SelectedTargetLanguage = LanguageList.Single(lang => lang.TargetLanguageName == CurrentSettings.TargetLanguage);
     }
     else
     {
         SelectedFontFamily = FontList.Single(font => font.FontName.Equals("Default"));
     }
 }
Example #12
0
        static FontFactory()
        {
            Stream fontzip = Assembly.GetExecutingAssembly().GetManifestResourceStream("CLIForms_FIGFonts.fonts.zip");

            using (ZipFile zip = ZipFile.Read(fontzip))
            {
                foreach (string entry in zip.EntryFileNames)
                {
                    if (entry.EndsWith(".flf"))
                    {
                        FontList.Add(entry);
                    }
                }
            }
        }
Example #13
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count == 0 && SpriteList.All.Count == 0)
            {
                FontList.Load(EFont.timelineNormal, "Times New Roman", 2.0, Color.FromArgb(193, 180, 255), FontStyle.Bold);
                FontList.Load(EFont.timelineError, "Times New Roman", 2.0, Color.Red, FontStyle.Bold);

                FontList.Load(EFont.main, "Times New Roman", 3.0, Color.FromArgb(193, 209, 255), FontStyle.Bold);

                FontList.Load(EFont.player0, "Times New Roman", 3.0, Color.FromArgb(230, 70, 70), FontStyle.Bold);
                FontList.Load(EFont.player1, "Times New Roman", 3.0, Color.FromArgb(70, 230, 70), FontStyle.Bold);

                SpriteList.Load(ESprite.man0, -90);
                SpriteList.Load(ESprite.man1, -90);
            }
        }
        private void Init(string file)
        {
            XmlDocument xmlDocument = new XmlDocument();

            if (File.Exists(file))
            {
                xmlDocument.Load(file);

                XmlNodeList languageList = xmlDocument.SelectNodes("/Configuration/Languages/Language");
                if (languageList.Count > 0)
                {
                    foreach (XmlNode item in languageList)
                    {
                        LanguageList.Add(item.Attributes["Name"].Value);
                        FilenameExtensionDic.Add(item.Attributes["Name"].Value, item.Attributes["Extension"].Value);
                    }
                }

                XmlNodeList themeList = xmlDocument.SelectNodes("/Configuration/Themes/Theme");
                if (themeList.Count > 0)
                {
                    foreach (XmlNode item in themeList)
                    {
                        ThemeList.Add(item.InnerText);
                    }
                }

                XmlNodeList fontSizeList = xmlDocument.SelectNodes("/Configuration/FontSizes/FontSize");
                if (fontSizeList.Count > 0)
                {
                    foreach (XmlNode item in fontSizeList)
                    {
                        FontSizeList.Add(int.Parse(item.InnerText));
                    }
                }

                XmlNodeList fontList = xmlDocument.SelectNodes("/Configuration/Fonts/Font");
                if (fontList.Count > 0)
                {
                    foreach (XmlNode item in fontList)
                    {
                        FontList.Add(item.InnerText);
                    }
                }
            }
        }
Example #15
0
        public static async void LoadAllFont(Action complete)
        {
            if (FontList == null)
            {
                IsLoaded = false;
                FontList = new List <KeyName>();
            }

            //사용자 폰트
            var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Fonts", CreationCollisionOption.OpenIfExists);

            var files = await folder.GetFilesAsync();

            //삭제 대상 폰트
            var reservedDeletionFontList = FontDAO.GetTempFontList();

            //사용자폰트 로드
            foreach (var file in files.OrderBy(x => x.Name))
            {
                foreach (var fontItem in await GetFontItems(file))
                {
                    if (!FontList.Any(x => x.Key.ToString() == fontItem.Key.ToString()) && !reservedDeletionFontList.Any(x => x == (fontItem.Payload as StorageFile).Path))
                    {
                        FontList.Add(fontItem);
                        //System.Diagnostics.Debug.WriteLine($"모든 폰트 로드 : {fontItem.Key}");
                    }
                }
            }
            //기본값
            FontList.Add(new KeyName(FONT_FAMILY_DEFAUT, FONT_FAMILY_DEFAUT)
            {
                Type = FontTypes.OS.ToString()
            });
            //시스템 폰트
            IList <NativeHelper.Font> systemFontList = NativeHelper.FontList.GetSystemFontList("en-us");

            FontList.AddRange(systemFontList.Where(x => !IgnoreFonts.Contains(x.FamilyName) && !string.IsNullOrWhiteSpace(x.FamilyName))
                              .Select(x => new KeyName(x.FamilyName, x.FamilyName)
            {
                Type = FontTypes.OS.ToString()
            }));
            IsLoaded = true;

            complete?.Invoke();
        }
Example #16
0
        public static void RemoveFont(ObservableCollection <KeyName> fontListSource, KeyName pickerItem)
        {
            List <KeyName> removedFontList = new List <KeyName>();

            if (pickerItem.Payload is StorageFile)
            {
                var file = pickerItem.Payload as StorageFile;
                FontDAO.InsertTempFont(file.Path);
            }

            if (fontListSource != null)
            {
                //공유되는 폰트를 모두 삭제
                foreach (var font in fontListSource.Where(x => x.Payload == pickerItem.Payload).ToList())
                {
                    fontListSource.Remove(font);

                    if (!removedFontList.Contains(font))
                    {
                        removedFontList.Add(font);
                    }
                }
            }

            if (FontList != null)
            {
                foreach (var font in FontList.Where(x => x.Payload == pickerItem.Payload).ToList())
                {
                    FontList.Remove(font);

                    if (!removedFontList.Contains(font))
                    {
                        removedFontList.Add(font);
                    }
                }
            }

            //이벤트 처리
            if (FontFamilyListChanged != null)
            {
                FontFamilyListChanged(FontList, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedFontList));
            }
        }
Example #17
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count == 0 && SpriteList.All.Count == 0)
            {
                FontList.Load(EFont.timelineNormal, "Times New Roman", 1.6, Color.FromArgb(200, 200, 200));
                FontList.Load(EFont.timelineError, "Times New Roman", 1.9, Color.Red, FontStyle.Bold);
                FontList.Load(EFont.playerNumbers, "Times New Roman", 1.5, Color.White);
                FontList.Load(EFont.Time, "Times New Roman", 2.0, Color.FromArgb(200, 200, 200), FontStyle.Bold);
                FontList.Load(EFont.TeamOne, "Times New Roman", 2.0, Color.FromArgb(200, 0, 180, 230), FontStyle.Bold);
                FontList.Load(EFont.TeamTwo, "Times New Roman", 2.0, Color.FromArgb(200, 180, 140, 0), FontStyle.Bold);
                FontList.Load(EFont.ScoreOne, "Times New Roman", 4.0, Color.FromArgb(255, 0, 180, 230), FontStyle.Bold);
                FontList.Load(EFont.ScoreTwo, "Times New Roman", 4.0, Color.FromArgb(255, 180, 140, 0), FontStyle.Bold);
                //  SpriteList.Load(ESprite.green);
                FontList.Load(EFont.CoordsOnField, "Times New Roman", 1.5, Color.FromArgb(200, 200, 200), FontStyle.Bold);
                FontList.Load(EFont.Possession, "Times New Roman", 1.5, Color.FromArgb(150, 150, 150), FontStyle.Bold);
                FontList.Load(EFont.Goal, "Lucida Console", 20, Color.FromArgb(150, 220, 0, 0), FontStyle.Bold);

                SpriteList.Load(ESprite.explosion, defaultSizeExact: new Vector2d(50), defaultDepth: 10000, frameCountHorizontal: 6, frameCountVertical: 5);
            }
        }
Example #18
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count == 0 && SpriteList.All.Count == 0)
            {
                FontList.Load(EFont.ScoreOne, "Times New Roman", 20.0, Color.FromArgb(150, 0, 180, 230), FontStyle.Bold);



                FontList.Load(EFont.timelineNormal, "Times New Roman", 12, Color.FromArgb(40, 40, 40));
                FontList.Load(EFont.timelineError, "Times New Roman", 14, Color.Red, FontStyle.Bold);
                FontList.Load(EFont.black, "Times New Roman", 15, Color.Black);
                //FontList.Load(EFont.Time, "Times New Roman", 2.0, Color.FromArgb(200, 200, 200), FontStyle.Bold);
                //FontList.Load(EFont.TeamOne, "Times New Roman", 2.0, Color.FromArgb(200, 0, 180, 230), FontStyle.Bold);
                //FontList.Load(EFont.TeamTwo, "Times New Roman", 2.0, Color.FromArgb(200, 180, 140, 0), FontStyle.Bold);
                //FontList.Load(EFont.ScoreTwo, "Times New Roman", 4.0, Color.FromArgb(255, 180, 140, 0), FontStyle.Bold);
                ////  SpriteList.Load(ESprite.green);
                //FontList.Load(EFont.CoordsOnField, "Times New Roman", 1.5, Color.FromArgb(200, 200, 200), FontStyle.Bold);
                //FontList.Load(EFont.Possession, "Times New Roman", 1.5, Color.FromArgb(150, 150, 150), FontStyle.Bold);
                //FontList.Load(EFont.Goal, "Lucida Console", 20, Color.FromArgb(150, 220, 0, 0), FontStyle.Bold);
            }
        }
Example #19
0
        public static string GetFontPath(FontList font, FontStyle style)
        {
            if (font == FontList.TimesNewRoman)
            {
                if (style == FontStyle.Bold)
                {
                    return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "timesbd.ttf"));
                }
                else if (style == FontStyle.Italic)
                {
                    return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "timesi.ttf"));
                }
                else if (style == FontStyle.BoldItalic)
                {
                    return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "timesbi.ttf"));
                }

                return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "times.ttf"));
            }

            return(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "times.ttf"));
        }
        /// <summary>フォント名称からFontInfoを取得します</summary>
        /// <param name="fontName">対象のフォント名</param>
        /// <returns></returns>
        /// <remarks>フォント名設定コンボボックスに表示されているフォント名称と合致するかを判定するので、引数の日本語/英語は考慮しなくて良い</remarks>
        private FontInfo GetFontInfoFromFontName(string fontName)
        {
            if (string.IsNullOrEmpty(fontName))
            {
                //todo:log
                return(null);
            }

            if (FontList == null || FontList.Any() == false)
            {
                //todo:log
                return(null);
            }

            FontInfo target = null;

            foreach (FontInfo fontInfo in FontList) //todo:高速化, 重複することないのでParallel等を検討
            {
                if (fontInfo == null)
                {
                    // ログを出せる情報がない
                    continue;
                }

                if (fontInfo.FontName.Equals(fontName))
                {
                    target = fontInfo;
                    break;
                }
            }

            if (target == null)
            {
                //todo:log
            }

            return(target);
        }
Example #21
0
        public void LoadSpritesAndFonts()
        {
            if (FontList.All.Count > 0)
            {
                return;
            }
            FontList.Load(EFont.regular, "Arial", 20, Color.Black,
                          FontStyle.Regular);
            FontList.Load(EFont.teamSmall1, "Times New Roman", 15, Color.FromArgb(64, 178, 119), FontStyle.Bold);
            FontList.Load(EFont.teamSmall2, "Times New Roman", 15, Color.FromArgb(188, 64, 66), FontStyle.Bold);
            FontList.Load(EFont.teamSmall3, "Times New Roman", 15, Color.FromArgb(114, 91, 200), FontStyle.Bold);
            FontList.Load(EFont.teamSmall4, "Times New Roman", 15, Color.FromArgb(150, 147, 61), FontStyle.Bold);
            FontList.Load(EFont.teamBig1, "Times New Roman", 27, Color.FromArgb(64, 178, 119), FontStyle.Bold);
            FontList.Load(EFont.teamBig2, "Times New Roman", 27, Color.FromArgb(188, 64, 66), FontStyle.Bold);
            FontList.Load(EFont.teamBig3, "Times New Roman", 27, Color.FromArgb(114, 91, 200), FontStyle.Bold);
            FontList.Load(EFont.teamBig4, "Times New Roman", 27, Color.FromArgb(150, 147, 61), FontStyle.Bold);

            FontList.Load(EFont.timelineNormal, "Times New Roman", 10, Color.Black, FontStyle.Regular);
            FontList.Load(EFont.timelineError, "Times New Roman", 12, Color.Red, FontStyle.Bold);

            SpriteList.Load(ESprite.board10, defaultSizeExact: new Vector2d(431, 452));
            //   SpriteList.Load(ESprite.background);
            SpriteList.Load(ESprite.Design);

            SpriteList.Load(ESprite.red, defaultSizeExact: new Vector2d(40, 40));
            SpriteList.Load(ESprite.green, defaultSizeExact: new Vector2d(40, 40));
            SpriteList.Load(ESprite.violet, defaultSizeExact: new Vector2d(40, 40));
            SpriteList.Load(ESprite.yellow, defaultSizeExact: new Vector2d(40, 40));

            SpriteList.Load(ESprite.redRect);
            SpriteList.Load(ESprite.greenRect);
            SpriteList.Load(ESprite.violetRect);
            SpriteList.Load(ESprite.yellowRect);

            SpriteList.Load(ESprite.humanDestination, defaultSizeExact: new Vector2d(43, 43));
            SpriteList.Load(ESprite.humanSource, defaultSizeExact: new Vector2d(43, 43));
            SpriteList.Load(ESprite.humanPointer, defaultSizeExact: new Vector2d(43, 43));
        }
Example #22
0
 public static SpriteFont GetFont(FontList f) => loadedFonts[(int)f];
Example #23
0
        public void Write(FileWriter writer)
        {
            RecalculateMaterialReferences();

            Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;

            foreach (var pane in PaneLookup.Values)
            {
                if (pane is PIC1)
                {
                    ((PIC1)pane).MaterialIndex = (ushort)MaterialList.Materials.IndexOf(((PIC1)pane).Material);
                }
            }

            writer.SetByteOrder(true);
            writer.WriteSignature(Magic);
            if (!IsBigEndian)
            {
                writer.Write((ushort)0xFFFE);
            }
            else
            {
                writer.Write((ushort)0xFEFF);
            }
            writer.SetByteOrder(IsBigEndian);
            writer.Write(HeaderSize);
            writer.Write(Version);
            writer.Write(uint.MaxValue);   //Reserve space for file size later
            writer.Write(ushort.MaxValue); //Reserve space for section count later
            writer.Seek(2);                //padding

            int sectionCount = 1;

            WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));

            if (UserData != null && UserData.Entries?.Count > 0)
            {
                WriteSection(writer, "usd1", UserData, () => UserData.Write(writer, this));
                sectionCount++;
            }

            if (TextureList != null && TextureList.Textures.Count > 0)
            {
                WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
                sectionCount++;
            }
            if (FontList != null && FontList.Fonts.Count > 0)
            {
                WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
                sectionCount++;
            }
            if (MaterialList != null && MaterialList.Materials.Count > 0)
            {
                WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
                sectionCount++;
            }

            WritePanes(writer, RootPane, this, ref sectionCount);
            WriteGroupPanes(writer, RootGroup, this, ref sectionCount);

            foreach (var section in UnknownSections)
            {
                WriteSection(writer, section.Signature, section, () => section.Write(writer, this));
                sectionCount++;
            }

            //Write the total section count
            using (writer.TemporarySeek(0x10, System.IO.SeekOrigin.Begin))
            {
                writer.Write((ushort)sectionCount);
            }

            //Write the total file size
            using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
            {
                writer.Write((uint)writer.BaseStream.Length);
            }
        }
Example #24
0
        public SettingWindow()
        {
            InitializeComponent();

            IsSetting             = true;
            Language              = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
            FontList.DataContext  = Fonts.SystemFontFamilies.ToList();
            FontList.SelectedItem = Fonts.SystemFontFamilies.FirstOrDefault(x => x.Source == Properties.Settings.Default.Font);
            FontList.ScrollIntoView(Fonts.SystemFontFamilies.FirstOrDefault(x => x.Source == Properties.Settings.Default.Font));

            IsSetting = false;
            OverlayFont.DataContext  = Fonts.SystemFontFamilies.ToList();
            OverlayFont.SelectedItem = Fonts.SystemFontFamilies.FirstOrDefault(x => x.Source == Properties.Settings.Default.OverlayFont);
            IsSetting = true;

            IP.Text             = Properties.Settings.Default.BouyomiIP;
            FontSizeBox.Content = Properties.Settings.Default.FontSize.ToString("N1");

            // - - - - LoadUI
            if (Properties.Settings.Default.Language == "ja-JP")
            {
                JA.IsChecked = true;
            }
            else if (Properties.Settings.Default.Language == "zh-TW")
            {
                TWHK.IsChecked = true;
            }
            else if (Properties.Settings.Default.Language == "en-US")
            {
                EN.IsChecked = true;
            }

            // - - - -

            if (Properties.Settings.Default.BackContent == "Color")
            {
                RadioColor.IsChecked = true;
            }
            else if (Properties.Settings.Default.BackContent == "Image")
            {
                RadioImage.IsChecked = true;
            }
            BackColorInput.Content  = Properties.Settings.Default.BackColor;
            BackPreview.Fill        = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Properties.Settings.Default.BackColor));
            TextColorBox.Content    = Properties.Settings.Default.FontColor;
            TextColorBox.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Properties.Settings.Default.FontColor));

            ForegroundUIColor.Content    = Properties.Settings.Default.Foreground;
            ForegroundUIColor.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Properties.Settings.Default.Foreground));
            PathLabel.Content            = "Path : " + Properties.Settings.Default.ImagePath;
            if (File.Exists(Properties.Settings.Default.ImagePath))
            {
                try
                {
                    BitmapImage bitmap = new BitmapImage(new Uri(Properties.Settings.Default.ImagePath));
                    PreviewImage.Source = bitmap;
                }
                catch { }
            }
            else
            {
                PathLabel.Content = "Image directory path Error";
            }


            //UpdateInv Slider Loading
            if (Properties.Settings.Default.Updateinv < 1000)
            {
                ChangeInv.Value = Properties.Settings.Default.Updateinv / 50;
            }
            else if (1000 <= Properties.Settings.Default.Updateinv)
            {
                ChangeInv.Value = (Properties.Settings.Default.Updateinv - 1000) / 500 + 11;
            }
            ChangeInvResult.Content = Properties.Settings.Default.Updateinv + "ms";
        }
 public FontListViewModel(FontList fontList)
 {
     Nodes.AddRange(fontList.Fonts.Select(font => new SimpleNode(font)));
 }
Example #26
0
 public SpriteFont GetFont(FontList fontName)
 {
     return(_fonts[(int)fontName].Font);
 }
Example #27
0
        public void ReadSections(ref BinaryStream s)
        {
            SectionHeader section = new SectionHeader(ref s);

            currentSection = section;

            s.BaseStream.Position -= 8;

            switch (section.signature)
            {
            case "lyt1":
                layoutSettings = new LayoutSettings(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Layout Settings [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "txl1":
                textureList = new TextureList(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Texture List [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "fnl1":
                fontList = new FontList(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Font List [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "mat1":
                materialList = new MaterialList(ref s);

                System.Windows.Forms.MessageBox.Show($"Read Material List [{section.signature}]");

                layoutSettings.sectionHeader = section;
                break;

            case "pan1":
                Pane pane = new Pane(ref s);

                if (rootPane == null)
                {
                    rootPane = pane;
                }

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(pane);

                    pane.parent = parentPane;
                }

                lastPane = pane;

                System.Windows.Forms.MessageBox.Show($"Read Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "pic1":
                Picture pic = new Picture(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(pic);

                    pic.parent = parentPane;
                }

                lastPane = pic;

                System.Windows.Forms.MessageBox.Show($"Read Picture Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "txt1":
                TextBox txt = new TextBox(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(txt);

                    txt.parent = parentPane;
                }

                lastPane = txt;

                System.Windows.Forms.MessageBox.Show($"Read TextBox Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "wnd1":
                Window wnd = new Window(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(wnd);

                    wnd.parent = parentPane;
                }

                lastPane = wnd;

                System.Windows.Forms.MessageBox.Show($"Read Window Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "bnd1":
                Bounding bnd = new Bounding(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(bnd);

                    bnd.parent = parentPane;
                }

                lastPane = bnd;

                System.Windows.Forms.MessageBox.Show($"Read Bounding Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "cpt1":
                Capture cpt = new Capture(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(cpt);

                    cpt.parent = parentPane;
                }

                lastPane = cpt;

                System.Windows.Forms.MessageBox.Show($"Read Capture Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "prt1":
                s.ReadBytes(section.size);
                break;

            case "ali1":
                Alignment ali = new Alignment(ref s);     // Read Alignment Pane later

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(ali);

                    ali.parent = parentPane;
                }

                lastPane = ali;

                System.Windows.Forms.MessageBox.Show($"Read Alignment Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "scr1":
                Scissor scr = new Scissor(ref s);

                if (parentPane != null)
                {
                    if (parentPane.children == null)
                    {
                        parentPane.children = new List <dynamic>();
                    }

                    parentPane.children.Add(scr);

                    scr.parent = parentPane;
                }

                lastPane = scr;

                System.Windows.Forms.MessageBox.Show($"Read Scissor Pane [{section.signature}]");

                lastPane.sectionHeader = section;
                break;

            case "pas1":
                if (lastPane != null)
                {
                    parentPane = lastPane;
                }

                s.ReadBytes(8);
                break;

            case "pae1":
                lastPane   = parentPane;
                parentPane = lastPane != null ? lastPane.parent : null;

                s.ReadBytes(8);
                break;

            case "grp1":
                Group group = new Group(ref s);

                if (rootGroup == null)
                {
                    rootGroup = group;
                }

                if (parentGroup != null)
                {
                    if (parentGroup.children == null)
                    {
                        parentGroup.children = new List <Group>();
                    }

                    parentGroup.children.Add(group);

                    group.parent = parentGroup;
                }

                lastGroup = group;

                System.Windows.Forms.MessageBox.Show($"Read Group [{section.signature}]");

                lastGroup.sectionHeader = section;
                break;

            case "grs1":
                if (lastGroup != null)
                {
                    parentGroup = lastGroup;
                }

                s.ReadBytes(8);
                break;

            case "gre1":
                lastGroup   = parentGroup;
                parentGroup = lastGroup != null ? lastGroup.parent : null;

                s.ReadBytes(8);
                break;

            case "usd1":     // Temporary
                s.ReadBytes(section.size);
                break;

            case "cnt1":     // Temporary
                s.ReadBytes(section.size);
                break;
            }
        }
Example #28
0
        private void LoadProgramState()
        {
            try
            {
                var isoStore = IsolatedStorageFile.GetUserStoreForAssembly();

                if (isoStore.FileExists(SavedStateFileName))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ProgramState));

                    using var isoStream = new IsolatedStorageFileStream(SavedStateFileName, FileMode.Open, isoStore);
                    using var reader    = new StreamReader(isoStream);

                    var state           = (ProgramState)serializer.Deserialize(reader);
                    var savedFontFamily = new FontFamily(state.FontFamilySource);

                    // Check if the saved font exists in the collection
                    // in case the user has deleted the font that was saved
                    if (FontList.Contains(savedFontFamily))
                    {
                        SelectedFont = savedFontFamily;
                    }
                    else
                    {
                        SelectedFont = DefaultFontFamily;
                    }

                    SelectedFontWeight    = LocalizedFontWeight.FromEnglishName(state.FontWeight);
                    SelectedFontSize      = state.FontSize;
                    SelectedKanjiFontSize = state.KanjiFontSize;
                    SpacingAdjustment     = state.SpacingAdjustment;
                    GlyphHorizontalMargin = state.HorizontalMargin;

                    DropShadowSettings.BlurRadius = state.BlurRadius;
                    DropShadowSettings.Direction  = state.Direction;
                    DropShadowSettings.Depth      = state.ShadowDepth;
                    DropShadowSettings.Opacity    = state.Opacity;

                    AdvancedExpanded = state.AdvancedExpanded;
                    DisplayBoundingRectanglesChecked = state.DisplayBoundingRectangles;
                    UseDarkTheme = state.UseDarkTheme;

                    if (!string.IsNullOrEmpty(state.SelectedLanguage))
                    {
                        CultureResources.ChangeCulture(new CultureInfo(state.SelectedLanguage));
                        var lang = Languages.Find(l => l.Culture.Name == state.SelectedLanguage);
                        if (lang != null)
                        {
                            SelectedLanguage = lang;
                        }
                    }
                }
                else
                {
                    SelectedFont = DefaultFontFamily;
                }
            }
            catch (IsolatedStorageException ex)
            {
                Console.WriteLine("Loading state failed: " + ex.Message);
            }
            catch (FileNotFoundException)
            {
                // Default settings will be used
            }
        }
Example #29
0
            public void Write(FileWriter writer)
            {
                Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;

                writer.SetByteOrder(true);
                writer.WriteSignature(Magic);
                if (!IsBigEndian)
                {
                    writer.Write((ushort)0xFFFE);
                }
                else
                {
                    writer.Write((ushort)0xFEFF);
                }
                writer.SetByteOrder(IsBigEndian);
                writer.Write(HeaderSize);
                writer.Write(Version);
                writer.Write(uint.MaxValue);   //Reserve space for file size later
                writer.Write(ushort.MaxValue); //Reserve space for section count later
                writer.Seek(2);                //padding

                int sectionCount = 1;

                WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));

                /*if (UserData != null && UserData.Entries?.Count > 0)
                 * {
                 *  WriteSection(writer, "usd1", UserData, () => UserData.Write(writer, this));
                 *  sectionCount++;
                 * }*/

                if (TextureList != null && TextureList.Textures.Count > 0)
                {
                    WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
                    sectionCount++;
                }
                if (FontList != null && FontList.Fonts.Count > 0)
                {
                    WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
                    sectionCount++;
                }
                if (MaterialList != null && MaterialList.Materials.Count > 0)
                {
                    WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
                    sectionCount++;
                }

                WritePanes(writer, RootPane, this, ref sectionCount);
                WriteGroupPanes(writer, RootGroup, this, ref sectionCount);

                //Write the total section count
                using (writer.TemporarySeek(0x10, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((ushort)sectionCount);
                }

                //Write the total file size
                using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
                {
                    writer.Write((uint)writer.BaseStream.Length);
                }
            }
Example #30
0
 public virtual void AcceptMetafileDescriptorFontList(FontList fontList, T parameter)
 {
     // intentionally left blank
 }