示例#1
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)];
 }
示例#2
0
        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";
        }
示例#3
0
        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);
        }
        //初始化系统字体列表
        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);
            }
        }
        public static string GetDisplayName(LanguageSpecificStringDictionary nameDictionary)
        {
            // Look up the display name based on the UI culture, which is the same culture
            // used for resource loading.
            XmlLanguage userLanguage = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag);

            // Look for an exact match.
            string name;

            if (nameDictionary.TryGetValue(userLanguage, out name))
            {
                return(name);
            }

            // No exact match; return the name for the most closely related language.
            int    bestRelatedness = -1;
            string bestName        = string.Empty;

            foreach (KeyValuePair <XmlLanguage, string> pair in nameDictionary)
            {
                int relatedness = GetRelatedness(pair.Key, userLanguage);
                if (relatedness > bestRelatedness)
                {
                    bestRelatedness = relatedness;
                    bestName        = pair.Value;
                }
            }

            return(bestName);
        }
示例#6
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;
        }
示例#7
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));
         }
     }
 }
示例#8
0
        /// <summary>
        /// Gets the display name for the current UI language.
        /// </summary>
        /// <param name="nameDictionary">The name dictionary.</param>
        /// <returns>The best name for the current language.</returns>
        public static string GetDisplayName(LanguageSpecificStringDictionary nameDictionary)
        {
            // Get the language tag for the current UI culture.
            XmlLanguage userLanguage = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag);

            // Search dictionary entry for this language.
            string name;

            if (nameDictionary.TryGetValue(userLanguage, out name))
            {
                return(name);
            }

            // No exact match. Make a fuzzy search.
            int    bestRelatedness = int.MinValue;
            string bestName        = string.Empty;

            foreach (KeyValuePair <XmlLanguage, string> pair in nameDictionary)
            {
                int relatedness = GetRelatedness(pair.Key, userLanguage);
                if (relatedness > bestRelatedness)
                {
                    bestRelatedness = relatedness;
                    bestName        = pair.Value;
                }
            }

            return(bestName);
        }
        public static string GetDisplayName(LanguageSpecificStringDictionary nameDictionary)
        {
            // Look up the display name based on the UI culture, which is the same culture
            // used for resource loading.
            var userLanguage = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag);

            // Look for an exact match.
            string name;
            if (nameDictionary.TryGetValue(userLanguage, out name))
            {
                return name;
            }

            // No exact match; return the name for the most closely related language.
            int bestRelatedness = -1;
            string bestName = string.Empty;

            foreach (KeyValuePair<XmlLanguage, string> pair in nameDictionary)
            {
                int relatedness = GetRelatedness(pair.Key, userLanguage);
                if (relatedness > bestRelatedness)
                {
                    bestRelatedness = relatedness;
                    bestName = pair.Value;
                }
            }

            return bestName;
        }
示例#10
0
        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 = "";
        }
示例#11
0
 static string GetLocalizedName(LanguageSpecificStringDictionary names)
 {
     if (names.TryGetValue(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name), out string name))
     {
         return(name);
     }
     return(names.First().Value);
 }
示例#12
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();
        }
示例#13
0
        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
        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;
        }
示例#15
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);
             }
         }
     }
 }
示例#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);
             }
         }
     }
 }
        /// <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");
        }
示例#18
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());
        }
示例#19
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);
        }
示例#20
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;
            }
        }
示例#21
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);
            }
        }
示例#22
0
        /// <summary>
        /// Gets the display name for the current UI language.
        /// </summary>
        /// <param name="nameDictionary">The name dictionary.</param>
        /// <returns>The best name for the current language.</returns>
        public static string GetDisplayName(LanguageSpecificStringDictionary nameDictionary)
        {
            // Get the language tag for the current UI culture.
            XmlLanguage userLanguage = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag);

            // Search dictionary entry for this language.
            string name;
            if (nameDictionary.TryGetValue(userLanguage, out name))
                return name;

            // No exact match. Make a fuzzy search.
            int bestRelatedness = int.MinValue;
            string bestName = string.Empty;
            foreach (KeyValuePair<XmlLanguage, string> pair in nameDictionary)
            {
                int relatedness = GetRelatedness(pair.Key, userLanguage);
                if (relatedness > bestRelatedness)
                {
                    bestRelatedness = relatedness;
                    bestName = pair.Value;
                }
            }

            return bestName;
        }
示例#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();
        }