Exemplo n.º 1
0
        private void ShowNotificationMessage(string message, int duration)
        {
            var textSize = FontUtility.GetTextSize(StatusNotification.FontFamily, StatusNotification.FontSize, message);

            StatusNotification.Width  = textSize.Width + 100; // actual width + padding
            StatusNotification.Height = textSize.Height + 50; // actual height + padding
            StatusNotification.Show(message, duration);
        }
Exemplo n.º 2
0
        public ConsiderationEngineSettingDialog()
        {
            InitializeComponent();

            InitViewModel();

            FontUtility.ReplaceFont(this, TheApp.app.Config.FontManager.SettingDialog);
        }
Exemplo n.º 3
0
        public SoundSettingDialog()
        {
            InitializeComponent();

            BindControl();
            Disposed += OnDisposed;

            FontUtility.ReplaceFont(this, TheApp.app.Config.FontManager.SettingDialog);
        }
Exemplo n.º 4
0
        public override bool UpdateFont()
        {
            string?        family = _CurrentCell.DescriptionConfig.FontFamily;
            FontAttributes attr   = _CurrentCell.DescriptionConfig.FontAttributes;

            Typeface = FontUtility.CreateTypeface(family, attr);

            return(true);
        }
Exemplo n.º 5
0
        public EngineDefineEditDialogOld()
        {
            InitializeComponent();

            InitEngineDefine();

            // フォント変更。
            FontUtility.ReplaceFont(this, TheApp.app.Config.FontManager.SettingDialog);
        }
Exemplo n.º 6
0
        public EngineDefineEditDialog()
        {
            InitializeComponent();

            // フォント変更。
            FontUtility.ReplaceFont(this, TheApp.app.Config.FontManager.SettingDialog);

            // textBox5,6は、数値のみのテキストボックスにしたいのだが、
            // キーハンドラ書くの面倒なので、まあいいや…。
        }
Exemplo n.º 7
0
        /// <summary>
        /// 対局結果の保存設定ダイアログ
        ///
        ///   自動保存するか
        ///   保存先のフォルダ
        ///   保存件数上限
        ///
        /// を設定できるようにする。
        ///
        /// </summary>
        public GameResultWindowSettingDialog()
        {
            InitializeComponent();

            // TheApp.app.Config.GameResultSettingを、このFormのControlたちとデータバインドしておく。
            BindSetting();

            Disposed += OnDisposed;

            FontUtility.ReplaceFont(this, TheApp.app.Config.FontManager.SettingDialog);
        }
        private void FontWeightPicker_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedValue = FontUtility.PredefinedFontWeights[FontWeightPicker.SelectedIndex];

            EditorSettingsService.EditorFontWeight = FontUtility.TryGetFontWeight(selectedValue, out var fontWeight)
                ? new FontWeight()
            {
                Weight = fontWeight
            }
                : FontWeights.Normal;
        }
Exemplo n.º 9
0
        private void FontWeightPicker_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedValue = (string)e.AddedItems.First();

            EditorSettingsService.EditorFontWeight = FontUtility.TryGetFontWeight(selectedValue, out var fontWeight)
                ? new FontWeight()
            {
                Weight = fontWeight
            }
                : FontWeights.Normal;
        }
Exemplo n.º 10
0
        private void ShowNotificationMessage(string message, int duration)
        {
            if (StatusNotification == null)
            {
                this.FindName("StatusNotification"); // Lazy loading
            }
            var textSize = FontUtility.GetTextSize(StatusNotification.FontFamily, StatusNotification.FontSize, message);

            StatusNotification.Width  = textSize.Width + 100; // actual width + padding
            StatusNotification.Height = textSize.Height + 50; // actual height + padding
            StatusNotification.Show(message, duration);
        }
Exemplo n.º 11
0
        private void InitializeFonts()
        {
            this.FontList = new ItemsViewModel <FontVM>();

            List <FontFamily> fonts = FontUtility.GetFontFamily();

            foreach (FontFamily font in fonts)
            {
                FontVM vm = new FontVM(font);
                this.FontList.Items.Add(vm);
            }
        }
Exemplo n.º 12
0
        private void UpdateValueTextFont()
        {
            if (ValueLabel.Font is null)
            {
                return;                 // for HotReload
            }
            string         family = _LabelCell.ValueTextFontFamily ?? CellParent.CellValueTextFontFamily;
            FontAttributes attr   = _LabelCell.ValueTextFontAttributes ?? CellParent.CellValueTextFontAttributes;

            if (_LabelCell.ValueTextFontSize > 0)
            {
                ValueLabel.Font = FontUtility.CreateNativeFont(family, (float)_LabelCell.ValueTextFontSize, attr);
            }
            else if (CellParent != null)
            {
                ValueLabel.Font = FontUtility.CreateNativeFont(family, (float)CellParent.CellValueTextFontSize, attr);
            }
        }
Exemplo n.º 13
0
        private void UpdateDescriptionFont()
        {
            if (DescriptionLabel is null)
            {
                return;                 // for HotReload
            }
            string         family = CellBase.DescriptionFontFamily ?? CellParent.CellDescriptionFontFamily;
            FontAttributes attr   = CellBase.DescriptionFontAttributes ?? CellParent.CellDescriptionFontAttributes;

            if (CellBase.DescriptionFontSize > 0)
            {
                DescriptionLabel.Font = FontUtility.CreateNativeFont(family, (float)CellBase.DescriptionFontSize, attr);
            }
            else if (CellParent != null)
            {
                DescriptionLabel.Font = FontUtility.CreateNativeFont(family, (float)CellParent.CellDescriptionFontSize, attr);
            }
        }
Exemplo n.º 14
0
        private static void ApplyNewFont(SubtitleSection section)
        {
            var letters = section.Texts.SelectMany(x => x.TranslatedText).Where(x => x >= '가' && x <= '힣').Distinct().ToArray();

            var start = section.FontData.Length / 144;

            start = 0x9000 + start + 1 + start / 255;

            start = 0x9001;

            var rs = new List <string>();
            var rt = new List <string>();

            foreach (var item in letters)
            {
                if ((start & 0xFF) == 0)
                {
                    start++;
                }

                rs.Add(new string(item, 1));
                rt.Add($"\\x{start++:X4}");
            }

            for (int i = 0; i < section.Texts.Count; i++)
            {
                var buffer = new StringBuilder(section.Texts[i].TranslatedText);
                for (int j = 0; j < letters.Length; j++)
                {
                    buffer.Replace(rs[j], rt[j]);
                }
                section.Texts[i].Text = " " + buffer.Replace(" ", "  ").Replace("[NL]", "[NL] ").ToString();
            }

            using (var bitmap = FontUtility.GenerateFontBitmap(letters))
            {
                section.FontData = FontUtility.GetBytes(letters.Length, bitmap);
            }
        }
Exemplo n.º 15
0
        private void UpdateValueTextFont()
        {
            string         family = _EntryCell.ValueTextFontFamily ?? CellParent.CellValueTextFontFamily;
            FontAttributes attr   = _EntryCell.ValueTextFontAttributes ?? CellParent.CellValueTextFontAttributes;

            if (_EntryCell.ValueTextFontSize > 0)
            {
                ValueField.Font = FontUtility.CreateNativeFont(family, (float)_EntryCell.ValueTextFontSize, attr);
            }
            else if (CellParent != null)
            {
                ValueField.Font = FontUtility.CreateNativeFont(family, (float)CellParent.CellValueTextFontSize, attr);
            }

            //make the view height fit font size
            nfloat contentH = ValueField.IntrinsicContentSize.Height;
            CGRect bounds   = ValueField.Bounds;

            ValueField.Bounds = new CGRect(0, 0, bounds.Width, contentH);

            _FieldWrapper.Bounds = new CGRect(0, 0, _FieldWrapper.Bounds.Width, contentH);
        }
Exemplo n.º 16
0
 private void SetDefaultTabStop(FontFamily font, double fontSize)
 {
     Document.DefaultTabStop     = (float)FontUtility.GetTextSize(font, fontSize, "text").Width;
     TextDocument.DefaultTabStop = (float)FontUtility.GetTextSize(font, fontSize, "text").Width;
 }
Exemplo n.º 17
0
        internal void Initialize(SRL Engine)
        {
            if (Engine.Initialized)
            {
                return;
            }

            //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);//.net core

#if DEBUG
            if (Config.Default.Debug)
            {
                System.Diagnostics.Debugger.Launch();
            }
#else
            if (Config.Default.Debug)
            {
                Log.Error("You can't Debug a Release Build of the SRL.");
            }
#endif

            Log.Information($"SRL - StringReloads v{Engine.Settings.SRLVersion}");
            Log.Information($"Created by Marcussacana");

            Log.Debug($"Working Directory: {Engine.Settings.WorkingDirectory}");
            Log.Debug("Initializing SRL...");

            if (File.Exists(Engine.Settings.CachePath))
            {
                var Cache = new Cache(Engine.Settings.CachePath);
                Engine.Databases    = Cache.GetDatabases().ToList();
                Engine.CharRemap    = Cache.GetRemaps().ToDictionary();
                Engine.CharRemapAlt = Cache.GetRemapsAlt().ToDictionary();
            }
            else
            {
                BuildCache(Engine);
            }

            if (Engine.Settings.Hashset)
            {
                Log.Debug("Generating Hashset...");
                foreach (var Database in Engine.Databases)
                {
                    foreach (var Entry in Database)
                    {
                        Engine.Hashset.Add(Entry.OriginalLine);
                        Engine.Hashset.Add(Minify.Default.Apply(Entry.OriginalLine, null));
                    }
                }
            }

            Log.Debug($"{Engine.Databases.Count} Database(s) Loaded");
            Log.Debug($"{Engine.CharRemap.Count} Remap(s) Loaded");
            Log.Debug($"{Engine.CharRemapAlt.Count} Alternative Remap(s) Loaded");
            Log.Debug($"{Engine.Hashset.Count} Hashes Ready");

            PluginsInitializer(Engine);

            if (Engine.Settings.LoadLocalFont)
            {
                FontUtility.LoadLocalFonts();
            }

            ModifiersInitializer(Engine);
            HooksInitializer(Engine);
            ModsInitializer(Engine);

            AutoInstall(Engine);

            EnableExceptionHandler(Engine);

            if (Engine.Settings.FastMode)
            {
                Log.Debug("Fast Mode Enabled, Disabling Cool Features...");
                IMatch Basic = (from x in Engine.Matchs where x is BasicMatch select x).First();
                Engine._Matchs = new IMatch[] { Basic };
            }

            Engine.Initialized = true;
            Log.Information("SRL Initialized");
        }
Exemplo n.º 18
0
 private void SetDefaultTabStop(FontFamily font, double fontSize)
 {
     Document.DefaultTabStop     = FontUtility.GetTextWidth(font, fontSize, "text");
     TextDocument.DefaultTabStop = FontUtility.GetTextWidth(font, fontSize, "text");
 }
Exemplo n.º 19
0
        /// <summary>
        /// Detects font sets by analyzing all "text-face-name" properties.
        /// </summary>
        /// <param name="definitions"></param>
        /// <param name="env"></param>
        public static void SetFontSets(Map map, List <CartoDefinition> definitions, Env env, ICartoTranslator cartoTranslator)
        {
            List <FontSet> fontSets = new List <FontSet>();
            Dictionary <string, FontSet> dictFontSets = new Dictionary <string, FontSet>();

            using (FontFamilyCollection fontCollection = FontUtility.GetFontFamilyCollection())
            {
                List <FontFamilyTypeface> typeFaces         = new List <FontFamilyTypeface>();
                List <string>             notFoundFontNames = new List <string>();

                int fontSetCounter = 0;

                foreach (CartoDefinition def in definitions)
                {
                    foreach (CartoRule rule in def.Rules)
                    {
                        if (rule.Name == "text-face-name" || rule.Name == "shield-face-name")
                        {
                            try
                            {
                                Value  value        = rule.Value as Value;
                                string strFontNames = value.Evaluate(env).ToString().Replace("\"", "");

                                FontSet fontSet = null;
                                if (_dictFontSets.TryGetValue(strFontNames, out fontSet))
                                {
                                    if (!fontSets.Contains(fontSet))
                                    {
                                        fontSets.Add((FontSet)fontSet.Clone());
                                        dictFontSets.Add(strFontNames, fontSet);
                                    }

                                    continue;
                                }

                                string[] fontNames = strFontNames.Split(',');

                                for (int i = 0; i < fontNames.Length; i++)
                                {
                                    fontNames[i] = fontNames[i].Trim('\'').Trim();
                                }

                                typeFaces.Clear();

                                foreach (string fontName in fontNames)
                                {
                                    string             fName    = fontName.Replace(" ", "");
                                    FontFamilyTypeface typeFace = null;

                                    foreach (MapSurfer.Drawing.FontFamily fontFamily in fontCollection.FontFamilies)
                                    {
                                        if (typeFace != null)
                                        {
                                            break;
                                        }

                                        foreach (FontFamilyTypeface fft in fontFamily.GetTypefaces())
                                        {
                                            foreach (string faceName in fft.FaceNames)
                                            {
                                                string fullName = (fontFamily.Name + faceName).Replace(" ", "");

                                                if (string.Equals(fName, fullName, StringComparison.OrdinalIgnoreCase))
                                                {
                                                    typeFace = fft;
                                                    break;
                                                }
                                            }
                                        }
                                    }

                                    // We were not able to find appropriate type face
                                    if (typeFace == null)
                                    {
                                        if (!notFoundFontNames.Contains(fontName))
                                        {
                                            notFoundFontNames.Add(fontName);
                                            LogFactory.WriteLogEntry(Logger.Default, string.Format("Unable to find font face(s) for '{0}'", fontName), LogEntryType.Warning);
                                        }
                                    }
                                    else
                                    {
                                        typeFaces.Add(typeFace);
                                    }
                                }

                                string fontSetName = "fontset-" + fontSetCounter.ToString();

                                if (typeFaces.Count > 0)
                                {
                                    FontSet fs = new FontSet(fontSetName, typeFaces[0].Style, typeFaces[0].Weight);
                                    foreach (FontFamilyTypeface fft in typeFaces)
                                    {
                                        fs.FontNames.Add(fft.FontFamily.Name);
                                    }

                                    fontSets.Add((FontSet)fs.Clone());
                                    _dictFontSets.TryAdd(strFontNames, fs);
                                    dictFontSets.Add(strFontNames, fs);

                                    fontSetCounter++;
                                }
                            }
                            catch
                            { }
                        }
                    }
                }
            }

            if (fontSets.Count > 0)
            {
                map.FontSets.AddRange(fontSets);
            }

            cartoTranslator.FontSets = dictFontSets;
        }