コード例 #1
0
ファイル: TextControl.cs プロジェクト: zou-z/PicEditor
        public TextControl()
        {
            List <FontFamilyClass> ZhFontFamily = new List <FontFamilyClass>();

            foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontdics = fontfamily.FamilyNames;
                string fontfamilyname;
                //添加英文字体
                if (fontdics.ContainsKey(XmlLanguage.GetLanguage("en-us")))
                {
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("en-us"), out fontfamilyname))
                    {
                        AllFontFamily.Add(new FontFamilyClass(fontfamilyname));
                    }
                }
                //添加中文字体
                if (fontdics.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                {
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out fontfamilyname))
                    {
                        ZhFontFamily.Add(new FontFamilyClass(fontfamilyname));
                    }
                }
            }
            AllFontFamily.AddRange(ZhFontFamily);
        }
コード例 #2
0
ファイル: TextEditor.xaml.cs プロジェクト: zhoushh/NGESys
        private void TextEditorPage_Loaded(object sender, RoutedEventArgs e)
        {
            //设置编辑器的可选字体
            foreach (FontFamily f in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontDic = f.FamilyNames;
                if (fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                {
                    string fontName = "";
                    if (fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out fontName))
                    {
                        editorFontToolBarCb.Items.Add(fontName);
                    }
                }
            }

            //设置编辑器可选的字号范围
            for (int i = 8; i <= 100; i += 2)
            {
                editorSizeToolBarCb.Items.Add(i);
            }

            //设置编辑器初始的字号与字体
            editorFontToolBarCb.SelectedItem = "宋体";
            editorSizeToolBarCb.SelectedItem = 16;

            //重置状态栏
            RichTextBoxStatus.Content = "";
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: ZKHDEV/DanMuClient
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //字体样式列表
            foreach (FontFamily _f in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary _fontDic = _f.FamilyNames;
                if (_fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                {
                    string _fontName = null;
                    if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out _fontName))
                    {
                        FontStyleBox.Items.Add(_fontName);
                    }
                }
                else
                {
                    string _fontName = null;
                    if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("en-us"), out _fontName))
                    {
                        FontStyleBox.Items.Add(_fontName);
                    }
                }
            }

            //字体大小列表
            for (int i = 5; i <= 72; i += 5)
            {
                FontSizeBox.Items.Add(i.ToString());
            }

            FontStyleBox.SelectedValue = "宋体";
            FontSizeBox.SelectedValue  = "45";
        }
コード例 #4
0
 private void InitUI()
 {
     //FontTypeCB.ItemsSource = SystemFonts.Fa;
     foreach (FontFamily _f in Fonts.SystemFontFamilies)
     {
         LanguageSpecificStringDictionary _fontDic = _f.FamilyNames;
         if (_fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
         {
             string _fontName = null;
             if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out _fontName))
             {
                 FontTypeCB.Items.Add(_fontName);
             }
         }
         else
         {
             string _fontName = null;
             if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("en-us"), out _fontName))
             {
                 FontTypeCB.Items.Add(_fontName);
             }
         }
     }
     FontTypeCB.SelectionChanged += FontType_SelectionChanged;
     FontTypeCB.SelectedIndex     = 0;
     //FontTypeCB.SelectedItem = FontTypeCB.Items[FontTypeCB.Items.IndexOf(TypeEB.FontFamily)];
 }
コード例 #5
0
        private void addtoolfontname()
        {
            ICollection <FontFamily> familyCollection = Fonts.SystemFontFamilies;

            if (familyCollection != null)
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary _fontDic = family.FamilyNames;
                    if (_fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                    {
                        string _fontName = null;
                        if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out _fontName))
                        {
                            toolfontname.Items.Add(_fontName);
                        }
                    }
                }
                toolfontname.SelectedIndex = 0;
            }
            for (int i = 10; i <= 36; i++)
            {
                toolfontsize.Items.Add(i.ToString());
            }
            toolfontsize.SelectedIndex = 0;
        }
コード例 #6
0
 public FontPicker()
 {
     foreach (var item in Fonts.SystemFontFamilies)
     {
         LanguageSpecificStringDictionary fontDic = item.FamilyNames;
         if (fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
         {
             if (fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out string fontName))
             {
                 Items.Add(GetNewItem(fontName, item));
             }
         }
     }
     foreach (var item in Fonts.SystemFontFamilies)
     {
         LanguageSpecificStringDictionary fontDic = item.FamilyNames;
         if (fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
         {
             if (!fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out string fontName))
             {
                 Items.Add(GetNewItem(item.ToString(), item));
             }
         }
         else
         {
             Items.Add(GetNewItem(item.ToString(), item));
         }
     }
 }
コード例 #7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //选择字体
            foreach (FontFamily _f in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary _font = _f.FamilyNames;
                if (_font.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")))
                {
                    string _fontName = null;
                    if (_font.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out _fontName))
                    {
                        TextBlock fontItem = new TextBlock();
                        fontItem.Text       = _fontName;
                        fontItem.FontFamily = new FontFamily(_fontName);
                        fontItem.FontSize   = 12;
                        comboBoxFontFamily.Items.Add(fontItem);
                    }
                }
            }
            foreach (TextBlock fontItem in comboBoxFontFamily.Items)
            {
                if (fontItem.Text == setting.getFontFamily().ToString())
                {
                    comboBoxFontFamily.SelectedItem = fontItem;
                    break;
                }
            }
            comboBoxFontColor.SelectedIndex = 7;

            for (int i = 10; i <= 120; i += 2)
            {
                comboBoxFontSize.Items.Add(i);
            }
            comboBoxFontSize.SelectedItem = (int)setting.getFontSize();

            if (setting.getFontStyle() == FontStyles.Italic)
            {
                checkBoxFontStyle.IsChecked = true;
            }
            if (setting.getFontWeight() == FontWeights.Bold)
            {
                checkBoxFontWeight.IsChecked = true;
            }
            if (setting.getRandomColor())
            {
                comboBoxFontColor.IsEnabled = false;
            }
            checkBoxRandomColor.IsChecked = setting.getRandomColor();
            if (setting.getRandomFontFamily())
            {
                comboBoxFontFamily.IsEnabled = false;
            }
            checkBoxRandomFontFamily.IsChecked = setting.getRandomFontFamily();

            textBoxNum.Text      = setting.getNUM().ToString();
            textBoxDuration.Text = setting.getDURATION().ToString();
            textBoxSpeed.Text    = setting.getSPEED().ToString();
        }
コード例 #8
0
        public Settings()
        {
            InitializeComponent();

            vieModel_Settings = new VieModel_Settings();
            vieModel_Settings.Reset();

            this.DataContext = vieModel_Settings;


            //绑定中文字体
            foreach (FontFamily _f in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary _font = _f.FamilyNames;
                if (_font.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")))
                {
                    string _fontName = null;
                    if (_font.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out _fontName))
                    {
                        ComboBox_Ttile.Items.Add(_fontName);
                    }
                }
            }

            bool IsMatch = false;

            foreach (var item  in ComboBox_Ttile.Items)
            {
                if (Properties.Settings.Default.Font_Title_Family == item.ToString())
                {
                    ComboBox_Ttile.SelectedItem = item;
                    IsMatch = true;
                    break;
                }
            }

            if (!IsMatch)
            {
                ComboBox_Ttile.SelectedIndex = 0;
            }

            var childsps = MainGrid.Children.OfType <StackPanel>().ToList();

            foreach (var item in childsps)
            {
                item.Visibility = Visibility.Hidden;
            }
            childsps[Properties.Settings.Default.SettingsIndex].Visibility = Visibility.Visible;

            var RadioButtons = RadioButtonStackPanel.Children.OfType <RadioButton>().ToList();

            RadioButtons[Properties.Settings.Default.SettingsIndex].IsChecked = true;
        }
コード例 #9
0
 public void win_LoadedEvent(object sender, RoutedEventArgs e)
 {
     foreach (FontFamily _f in Fonts.SystemFontFamilies)
     {
         LanguageSpecificStringDictionary _fontDic = _f.FamilyNames;
         string _fontName = null;
         if (_fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
         {
             if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out _fontName))
             {
                 cbo_Demo.Items.Add(_fontName);
             }
         }
         else if (_fontDic.ContainsKey(XmlLanguage.GetLanguage("en-us")))
         {
             if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("en-us"), out _fontName))
             {
                 cbo_Demo.Items.Add(_fontName);
             }
         }
     }
 }
        //初始化系统字体列表
        private void initFontFamily()
        {
            List <String> listCn = new List <String>();
            List <String> listEn = new List <String>();

            foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontdics = fontfamily.FamilyNames;
                //判断该字体是不是中文字体
                if (fontdics.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                {
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out string fontfamilyname))
                    {
                        listCn.Add(fontfamilyname);
                    }
                }
                //英文字体
                else
                {
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("en-us"), out string fontfamilyname))
                    {
                        listEn.Add(fontfamilyname);
                    }
                }
            }

            foreach (string s in listCn)
            {
                ComboBoxItem child = new ComboBoxItem();
                child.Content = s;
                child.Tag     = s;
                //if (dc.id == currDControl.showInWhichCFrame)
                //{
                //    child.IsSelected = true;
                //}
                fontFamily.Items.Add(child);
            }
            foreach (string s in listEn)
            {
                ComboBoxItem child = new ComboBoxItem();
                child.Content = s;
                child.Tag     = s;
                //if (dc.id == currDControl.showInWhichCFrame)
                //{
                //    child.IsSelected = true;
                //}
                fontFamily.Items.Add(child);
            }
        }
コード例 #11
0
        /// <summary>
        /// 获取根据当地文化(比如汉语)显示的字体名称
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static string GetLocaliteFontName(FontFamily font)
        {
            if (font == null)
            {
                return("");
            }
            LanguageSpecificStringDictionary dic = font.FamilyNames;
            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            if (dic.ContainsKey(XmlLanguage.GetLanguage(cultureInfo.Name)))
            {
                return(font.FamilyNames[XmlLanguage.GetLanguage(cultureInfo.Name)]);
            }
            else
            {
                return(font.FamilyNames[XmlLanguage.GetLanguage("en-us")]);
            }
        }
コード例 #12
0
        public static string GetPreferChineseFontName(FontFamily font)
        {
            if (font == null)
            {
                return(null);
            }
            LanguageSpecificStringDictionary fontDic = font.FamilyNames;

            if (fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
            {
                if (!fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out string fontName))
                {
                    {
                        return(fontName);
                    }
                }
            }
            return(font.ToString());
        }
コード例 #13
0
ファイル: WayWord.xaml.cs プロジェクト: wwwK/EntityDB
        private void InitializeFontFamilyList()
        {
            List <string> names = new List <string>();

            foreach (FontFamily family in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontDics = family.FamilyNames;
                if (fontDics.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")))
                {
                    string fontName = null;
                    if (fontDics.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out fontName))
                    {
                        names.Add(fontName);
                    }
                }
                else
                {
                    string fontName = null;
                    if (fontDics.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("en-us"), out fontName))
                    {
                        names.Add(fontName);
                    }
                }
            }
            names.Sort();
            foreach (String fontname in names)
            {
                ComboBoxItem item = new ComboBoxItem();

                TextBlock textitem = new TextBlock();
                textitem.Text       = fontname;
                textitem.FontSize   = 16;
                textitem.FontFamily = new FontFamily(fontname);
                item.Content        = textitem;
                cmb_fontfamily.Items.Add(item);

                if (fontname == "宋体")
                {
                    cmb_fontfamily.SelectedIndex = cmb_fontfamily.Items.Count - 1;
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// 获取系统中文字体
        /// </summary>
        /// <returns>返回字体列表</returns>
        public static List <string> GetTypeface()
        {
            List <string> Typeface = new List <string>();

            foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontdics = fontfamily.FamilyNames;

                //判断该字体是不是中文字体   英文字体为en-us
                if (fontdics.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                {
                    string fontfamilyname = null;
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out fontfamilyname))
                    {
                        Typeface.Add(fontfamilyname);
                    }
                }
            }
            return(Typeface);
        }
コード例 #15
0
        public FontItemsUserControl(FontFamily font)
        {
            InitializeComponent();
            Font = font;
            LanguageSpecificStringDictionary fontFamilyNames = font.FamilyNames;

            if (fontFamilyNames.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")))
            {
                string fontName = null;
                if (fontFamilyNames.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out fontName))
                {
                    text.FontFamily = font;
                    text.Text       = fontName;
                }
            }
            else
            {
                text.FontFamily = font;
                text.Text       = font.Source;
            }
        }
コード例 #16
0
 /// <summary>
 /// 读取字体
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FontComboBox_Loaded(object sender, RoutedEventArgs e)
 {
     foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
     {
         LanguageSpecificStringDictionary fontdics = fontfamily.FamilyNames;
         //判断该字体是不是中文字体
         if (fontdics.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
         {
             if (fontdics.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out string fontfamilyname))
             {
                 FontComboBox.Items.Add(fontfamilyname);
             }
         }
         else
         {
             if (fontdics.TryGetValue(XmlLanguage.GetLanguage("en-us"), out string fontfamilyname))
             {
                 FontComboBox.Items.Add(fontfamilyname);
             }
         }
     }
 }
コード例 #17
0
        /// <summary>
        /// load font list
        /// </summary>
        public void LoadFontList()
        {
            FontItems.Clear();

            var currentLanguages = Cultures.ToDictionary((e) => e.CultureInfo.Name);

            foreach (FontFamily fontFamily in Fonts.SystemFontFamilies)
            {
                foreach (var culture in Cultures)
                {
                    XmlLanguage userLanguage = XmlLanguage.GetLanguage(culture.CultureInfo.Name);

                    LanguageSpecificStringDictionary dictionary = fontFamily.FamilyNames;

                    if (dictionary.ContainsKey(userLanguage) == false)
                    {
                        continue;
                    }

                    var fontName = dictionary[userLanguage];

                    if (_searchWord.Length > 0)
                    {
                        if (!fontName.Contains(_searchWord))
                        {
                            continue;
                        }
                    }

                    var fontModel = new MogeraFontModel()
                    {
                        FontFamily = fontFamily,
                        FontName   = fontName,
                    };

                    FontItems.Add(new FontItemViewModel(fontModel));
                }
            }
        }
コード例 #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FontFamily fontfamily = (FontFamily)value;
            LanguageSpecificStringDictionary lsd = fontfamily.FamilyNames;

            if (lsd.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")))
            {
                string fontname = null;
                if (lsd.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out fontname))
                {
                    return(fontname);
                }
            }
            else
            {
                string fontname = null;
                if (lsd.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("en-us"), out fontname))
                {
                    return(fontname);
                }
            }
            return("Arial");
        }
コード例 #19
0
        private void FontTypeButton_Loaded(object sender, RoutedEventArgs e)
        {
            LinkedList <string> fontnames = new LinkedList <string>();

            foreach (FontFamily font in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontname = font.FamilyNames;
                string _fontname = null;
                if (fontname.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")) &&
                    fontname.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out _fontname))
                {
                    fontnames.AddLast(_fontname);
                }
                else
                {
                    FontTypeButton.Items.Add(font.Source);
                }
            }
            foreach (string fontname in fontnames)
            {
                FontTypeButton.Items.Add(fontname);
            }
        }
コード例 #20
0
        public SetEpgView()
        {
            InitializeComponent();

            try
            {
                foreach (string name in ColorDef.ColorNames)
                {
                    colorList.Add(name, new ColorSelectionItem(name, ColorDef.Instance.ColorTable[name]));
                }
                comboBox0.DataContext               = colorList.Values;
                comboBox1.DataContext               = colorList.Values;
                comboBox2.DataContext               = colorList.Values;
                comboBox3.DataContext               = colorList.Values;
                comboBox4.DataContext               = colorList.Values;
                comboBox5.DataContext               = colorList.Values;
                comboBox6.DataContext               = colorList.Values;
                comboBox7.DataContext               = colorList.Values;
                comboBox8.DataContext               = colorList.Values;
                comboBox9.DataContext               = colorList.Values;
                comboBox10.DataContext              = colorList.Values;
                comboBox11.DataContext              = colorList.Values;
                comboBox12.DataContext              = colorList.Values;
                comboBox13.DataContext              = colorList.Values;
                comboBox_reserveNormal.DataContext  = colorList.Values;
                comboBox_reserveNo.DataContext      = colorList.Values;
                comboBox_reserveNoTuner.DataContext = colorList.Values;
                comboBox_reserveWarning.DataContext = colorList.Values;
                comboBox_colorTitle1.DataContext    = colorList.Values;
                comboBox_colorTitle2.DataContext    = colorList.Values;

                if (Settings.Instance.ContentColorList.Count == 0)
                {
                    Settings.LoadFromXmlFile();
                }

                comboBox0.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x00]];
                comboBox1.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x01]];
                comboBox2.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x02]];
                comboBox3.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x03]];
                comboBox4.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x04]];
                comboBox5.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x05]];
                comboBox6.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x06]];
                comboBox7.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x07]];
                comboBox8.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x08]];
                comboBox9.SelectedItem  = colorList[Settings.Instance.ContentColorList[0x09]];
                comboBox10.SelectedItem = colorList[Settings.Instance.ContentColorList[0x0A]];
                comboBox11.SelectedItem = colorList[Settings.Instance.ContentColorList[0x0B]];
                comboBox12.SelectedItem = colorList[Settings.Instance.ContentColorList[0x0F]];
                comboBox13.SelectedItem = colorList[Settings.Instance.ContentColorList[0x10]];

                comboBox_reserveNormal.SelectedItem  = colorList[Settings.Instance.ReserveRectColorNormal];
                comboBox_reserveNo.SelectedItem      = colorList[Settings.Instance.ReserveRectColorNo];
                comboBox_reserveNoTuner.SelectedItem = colorList[Settings.Instance.ReserveRectColorNoTuner];
                comboBox_reserveWarning.SelectedItem = colorList[Settings.Instance.ReserveRectColorWarning];
                checkBox_reserveBackground.IsChecked = Settings.Instance.ReserveRectBackground;

                comboBox_colorTitle1.SelectedItem = colorList[Settings.Instance.TitleColor1];
                comboBox_colorTitle2.SelectedItem = colorList[Settings.Instance.TitleColor2];

                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dictionary = family.FamilyNames;

                    XmlLanguage FLanguage = XmlLanguage.GetLanguage("ja-JP");
                    if (dictionary.ContainsKey(FLanguage) == true)
                    {
                        string s = dictionary[FLanguage] as string;
                        comboBox_font.Items.Add(s);
                        if (String.Compare(s, Settings.Instance.FontName) == 0)
                        {
                            comboBox_font.SelectedItem = s;
                        }
                        comboBox_fontTitle.Items.Add(s);
                        if (String.Compare(s, Settings.Instance.FontNameTitle) == 0)
                        {
                            comboBox_fontTitle.SelectedItem = s;
                        }
                    }
                }
                if (comboBox_font.SelectedItem == null)
                {
                    comboBox_font.SelectedIndex = 0;
                }
                if (comboBox_fontTitle.SelectedItem == null)
                {
                    comboBox_fontTitle.SelectedIndex = 0;
                }
                textBox_fontSize.Text            = Settings.Instance.FontSize.ToString();
                textBox_fontSizeTitle.Text       = Settings.Instance.FontSizeTitle.ToString();
                checkBox_fontBoldTitle.IsChecked = Settings.Instance.FontBoldTitle;

                textBox_mouse_scroll.Text              = Settings.Instance.ScrollSize.ToString();
                textBox_minHeight.Text                 = Settings.Instance.MinHeight.ToString();
                textBox_service_width.Text             = Settings.Instance.ServiceWidth.ToString();
                textBox_dragScroll.Text                = Settings.Instance.DragScroll.ToString();
                textBox_minimumHeight.Text             = Settings.Instance.MinimumHeight.ToString();
                checkBox_descToolTip.IsChecked         = Settings.Instance.EpgToolTip;
                checkBox_title_indent.IsChecked        = Settings.Instance.EpgTitleIndent;
                checkBox_toolTip_noView_only.IsChecked = Settings.Instance.EpgToolTipNoViewOnly;
                textBox_toolTipWait.Text               = Settings.Instance.EpgToolTipViewWait.ToString();

                if (Settings.Instance.UseCustomEpgView == false)
                {
                    radioButton_1_def.IsChecked  = true;
                    radioButton_1_cust.IsChecked = false;
                }
                else
                {
                    radioButton_1_def.IsChecked  = false;
                    radioButton_1_cust.IsChecked = true;
                }
                foreach (CustomEpgTabInfo info in Settings.Instance.CustomEpgTabList)
                {
                    listBox_tab.Items.Add(info);
                }
                if (listBox_tab.Items.Count > 0)
                {
                    listBox_tab.SelectedIndex = 0;
                }

                byte r = 0;
                byte g = 0;
                byte b = 0;
                foreach (UInt32 argb in Settings.Instance.ContentCustColorList)
                {
                    r = (byte)((argb & 0x00FF0000) >> 16);
                    g = (byte)((argb & 0x0000FF00) >> 8);
                    b = (byte)(argb & 0x000000FF);

                    Color item = Color.FromArgb(0xFF, r, g, b);
                    custColorList.Add(item);
                }
                r = (byte)((Settings.Instance.TitleCustColor1 & 0x00FF0000) >> 16);
                g = (byte)((Settings.Instance.TitleCustColor1 & 0x0000FF00) >> 8);
                b = (byte)(Settings.Instance.TitleCustColor1 & 0x000000FF);
                custTitleColor1 = Color.FromArgb(0xFF, r, g, b);
                r = (byte)((Settings.Instance.TitleCustColor2 & 0x00FF0000) >> 16);
                g = (byte)((Settings.Instance.TitleCustColor2 & 0x0000FF00) >> 8);
                b = (byte)(Settings.Instance.TitleCustColor2 & 0x000000FF);
                custTitleColor2 = Color.FromArgb(0xFF, r, g, b);

                titleColor1.Color = custTitleColor1;
                titleColor2.Color = custTitleColor2;

                backColor0.Color    = custColorList[0x00];
                backColor1.Color    = custColorList[0x01];
                backColor2.Color    = custColorList[0x02];
                backColor3.Color    = custColorList[0x03];
                backColor4.Color    = custColorList[0x04];
                backColor5.Color    = custColorList[0x05];
                backColor6.Color    = custColorList[0x06];
                backColor7.Color    = custColorList[0x07];
                backColor8.Color    = custColorList[0x08];
                backColor9.Color    = custColorList[0x09];
                backColor10.Color   = custColorList[0x0a];
                backColor11.Color   = custColorList[0x0b];
                backColor12.Color   = custColorList[0x0f];
                backColor13.Color   = custColorList[0x10];
                backColor14.Color   = custColorList[0x11];
                backColor15.Color   = custColorList[0x12];
                backColor16.Color   = custColorList[0x13];
                backColor17.Color   = custColorList[0x14];
                button0.Background  = backColor0;
                button1.Background  = backColor1;
                button2.Background  = backColor2;
                button3.Background  = backColor3;
                button4.Background  = backColor4;
                button5.Background  = backColor5;
                button6.Background  = backColor6;
                button7.Background  = backColor7;
                button8.Background  = backColor8;
                button9.Background  = backColor9;
                button10.Background = backColor10;
                button11.Background = backColor11;
                button12.Background = backColor12;
                button13.Background = backColor13;
                button14.Background = backColor14;
                button15.Background = backColor15;
                button16.Background = backColor16;
                button17.Background = backColor17;

                button_colorTitle1.Background = titleColor1;
                button_colorTitle2.Background = titleColor2;

                checkBox_singleOpen.IsChecked = Settings.Instance.EpgInfoSingleClick;
                if (Settings.Instance.EpgInfoOpenMode == 0)
                {
                    checkBox_openInfo.IsChecked = false;
                }
                else
                {
                    checkBox_openInfo.IsChecked = true;
                }

                checkBox_scrollAuto.IsChecked = Settings.Instance.MouseScrollAuto;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
コード例 #21
0
        //---------------------------------------------------------------------------------------------
        // cmbLanguage の選択に伴って、lstFamilyName を更新する
        private void UpdateFamilyName()
        {
            var list = new List <ListedFontViewModel>();

            int fontIndex = 0;

            // すべての言語のとき
            if (DlgLanguage == null)
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dic1 = family.FamilyNames;

                    foreach (XmlLanguage lang in dic1.Keys)
                    {
                        ListedFontViewModel item1 = new ListedFontViewModel();

                        string s = dic1[lang] as string;

                        if ((s != null) && (s.Length > 0))
                        {
                            item1.FontName     = s;
                            item1.FontFamily   = family;
                            item1.SampleString = "Getting Comfortable with Aow";

                            list.Add(item1);
                        }
                    }
                }
            }
            else // 特定の言語のとき
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dic2 = family.FamilyNames;
                    ListedFontViewModel item2             = new ListedFontViewModel();

                    string s = "";

                    if (dic2.ContainsKey(FXmlLanguage))
                    {
                        s = dic2[FXmlLanguage] as string;

                        if ((s != null) && (s.Length > 0))
                        {
                            item2.FontName     = s;
                            item2.FontFamily   = family;
                            item2.SampleString = "Kappaと発音してください。";

                            list.Add(item2);
                        }
                    }
                }
            }

            list.Sort(SortComparison);

            fontIndex = Math.Max(list.FindIndex(t => (t.FontFamily as FontFamily).Equals(FFontFamily)), 0);

            lstFamilyName.ItemsSource = list;

            lstFamilyName.SelectedIndex = fontIndex;
            txtFamilyName.Text          = ((string)list[fontIndex].FontName).ToString();

            lstFamilyName.ScrollIntoView(lstFamilyName.SelectedItem);
        }
コード例 #22
0
        //---------------------------------------------------------------------------------------------
        // cmbLanguage の選択に伴って、FirstFamilyName を更新する
        private void UpdateFamilyName()
        {
            var list = new List <FontFamily>();

            // すべての言語のとき
            if (FFont.FontLanguage == null)
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dic1 = family.FamilyNames;

                    foreach (XmlLanguage lang in dic1.Keys)
                    {
                        var item1 = new FontFamily();

                        string s = dic1[lang] as string;

                        if ((s != null) && (s.Length > 0))
                        {
                            item1 = family;
                            list.Add(item1);
                        }
                    }
                }
            }
            else // 特定の言語のとき
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dic2 = family.FamilyNames;
                    var item2 = new FontFamily();

                    string s = "";

                    if (dic2.ContainsKey(FXmlLanguage))
                    {
                        s = dic2[FXmlLanguage] as string;

                        if ((s != null) && (s.Length > 0))
                        {
                            item2 = family;

                            list.Add(item2);
                        }
                    }
                }
            }

            list.Sort(SortComparison);
            FirstFamilyName.ItemsSource = list;

            // 指定のフォントを選択状態にする
            int index = 0;

            for (int i = 0; i < list.Count; ++i)
            {
                if (list[i].Equals(FFont.FontFamily))
                {
                    index = i;
                    break;
                }
            }

            FirstFamilyName.SelectedIndex = index;
            txtFamilyName.Text            = list[index].ToString();
            FirstFamilyName.ScrollIntoView(FirstFamilyName.SelectedItem);
        }
コード例 #23
0
        public MainWindow()
        {
            // 初始化isExist
            for (int i = 0; i < NUM; i++)
            {
                isExist[i] = false;
            }

            // 初始化窗口元素并显示
            InitializeComponent();

            // 初始化系统托盘图标
            InitialTray();

            notifyIcon.BalloonTipText = "登录成功,弹幕派正在运行。";
            notifyIcon.ShowBalloonTip(500);

            // 尝试从 setting.ini 中恢复设置
            setting.RestoreSetting();

            FormattedText formattedText = new FormattedText(
                "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor",
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface(setting.getFontFamily().ToString()),
                setting.getFontSize(),
                setting.getForeground());

            textHeight      = (int)formattedText.Height;
            trackNum        = (int)(screenHeight / textHeight);
            danmuNumInTrack = new int[trackNum + 1];
            for (int i = 0; i <= trackNum; i++)
            {
                danmuNumInTrack[i] = -1;
            }

            foreach (FontFamily _f in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary _font = _f.FamilyNames;
                if (_font.ContainsKey(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn")))
                {
                    string _fontName = null;
                    if (_font.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("zh-cn"), out _fontName))
                    {
                        fontFamilyList.Add(_fontName);
                    }
                }
            }

            Type type = typeof(System.Windows.Media.Brushes);

            System.Reflection.PropertyInfo[] info = type.GetProperties();
            foreach (System.Reflection.PropertyInfo pi in info)
            {
                colorList.Add(pi.Name);
            }

            // 设置后台进程的属性
            fetchBW.WorkerReportsProgress      = true;
            fetchBW.WorkerSupportsCancellation = true;
            fetchBW.DoWork             += new DoWorkEventHandler(FetchBW_DoWork);
            fetchBW.ProgressChanged    += new ProgressChangedEventHandler(FetchBW_ProgressChanged);
            fetchBW.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FetchBW_RunWorkerCompleted);

            // 初始化弹幕Textblock的各属性
            for (int i = 0; i < NUM; i++)
            {
                TextBlock text = new TextBlock();
                text.Text = "";
                text.VerticalAlignment   = VerticalAlignment.Top;
                text.HorizontalAlignment = HorizontalAlignment.Right;
                text.FontSize            = setting.getFontSize();
                text.Foreground          = setting.getForeground();
                text.Background          = setting.getBackground();
                text.FontFamily          = setting.getFontFamily();
                text.FontStyle           = setting.getFontStyle();
                text.FontWeight          = setting.getFontWeight();
                grid.Children.Add(text);
                grid.RegisterName("textBlockDanmu" + i.ToString(), text);
                textBlockDanmu.Add(text);
            }

            // 初始化房间号textBlockRoomNum
            textBlockRoomNum.Margin = new Thickness(screenWidth / 2 - 200, screenHeight / 2 - 20,
                                                    screenWidth / 2 - 200, screenHeight / 2 - 20);

            // 设置各计时器的属性
            mainTimer          = new System.Timers.Timer();
            mainTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            mainTimer.Interval = 10; // 计时间隔 = 10

            getWebContentTimer           = new Timer();
            getWebContentTimer.Elapsed  += new ElapsedEventHandler(getWebContentTimeOut);
            getWebContentTimer.Interval  = 2000;
            getWebContentTimer.AutoReset = false; // 不会自动重置计时器,即只计时一次

            displayRoomNumTimer           = new Timer();
            displayRoomNumTimer.Elapsed  += new ElapsedEventHandler(displayRoomNumTimeOut);
            displayRoomNumTimer.Interval  = 10000;
            displayRoomNumTimer.AutoReset = false;

            displayRoomNumViaDanmuTimer           = new Timer();
            displayRoomNumViaDanmuTimer.Elapsed  += new ElapsedEventHandler(displayTimeOut);
            displayRoomNumViaDanmuTimer.Interval  = 10000;
            displayRoomNumViaDanmuTimer.AutoReset = true;
            // 主计时器开始计时
            mainTimer.Start();
        }