WPF RichTextBox 和特定文化问题

发布于 2024-07-14 06:55:02 字数 4974 浏览 6 评论 0原文

我尝试将 System.Windows.Control.RichTextBox 的语言设置为“es-PE”,但我发现
一些问题,例如在某些计算机中,可以完美运行,并且可以使用“es-PE”启用拼写检查器
语言,但在其他语言中它只适用于“en-US”,所以我不知道
该控件有什么问题,我在 XAML 和 C# 中使用以下代码:

这是用户从 GridView 中选择行并然后显示附加的屏幕截图

 private void dlstInformes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (!dlstInformes.SelectedItem.ToString().Equals(""))
            {
                var source_ = dlstInformes.SelectedItems;
                InformeMedico demo = new InformeMedico(); //New Window

                foreach (informeMedico item in source_)
                {
                    numeroinforme = item.numeroinforme.ToString();
                    nombreinforme = item.nombreinforme;
                    fechainforme = item.fechainforme.ToString();
                    nombreMedico = item.medicoCompleto.ToString();
                    turnoMedico = item.turno.ToString();
                    nombrePaciente = item.pacienteCompleto.ToString();
                    nombreExamen = item.nombreinforme.ToString();

                }
                demo.Language = XmlLanguage.GetLanguage("es-PE");
                demo.txtNombreExamen.Text = nombreinforme;
                demo.lblNroInforme.Content = numeroinforme;
                demo.lblMedicoNombre.Content = nombreMedico;
                demo.lblNombrePac.Content = nombrePaciente;
                demo.lblTurnoMedico.Content = turnoMedico;
            using (DB db = new DB())
            {
                var lstTM = (from ea in db.EXAMENXATENCIONs where ea.turnomedico.Trim() != " " select ea.turnomedico).Distinct().ToList();
                string tm = (from ea in db.EXAMENXATENCIONs where ea.codigo == Convert.ToInt32(numeroinforme) select ea.turnomedico).FirstOrDefault();
                demo.cboTurnoMed.ItemsSource = lstTM;
                demo.cboTurnoMed.SelectedItem = tm;
                demo.cboTurnoMed.SelectedValue = tm;
                demo.cboTurnoMed.Text = tm;
                if (tm.Equals("RE/ES") || tm.Equals("RE/HS") || tm.Equals("RE/HT") || tm.Equals("RE/KV") || tm.Equals("HH/CS") || tm.Equals("HH/ES") || tm.Equals("HH/HS") || tm.Equals("HH/HT") || tm.Equals("HH/KV"))
                {
                    demo.FirmaUnoDefault.Content = "DEN51";
                    demo.FirmaDosDefault.Content = tm;
                }
                else if (tm.Equals("HH/AO") || tm.Equals("IU/AO") || tm.Equals("RE/AO") || tm.Equals("HH/JA") || tm.Equals("RR/JA") || tm.Equals("IU/JA"))
                {
                    demo.FirmaUnoDefault.Content = "DEN51";
                    demo.FirmaDosDefault.Content = "AOY20";
                }
                else if (tm.Equals("IU/CS") || tm.Equals("IU/ES") || tm.Equals("IU/HT") || tm.Equals("IU/KV"))
                {
                    demo.FirmaUnoDefault.Content = "IUU17";
                    demo.FirmaDosDefault.Content = tm;
                }
                else if (tm.Equals("RD/DE"))
                {
                    demo.FirmaUnoDefault.Content = "REE";
                    demo.FirmaDosDefault.Content = "DEN51";
                }
                else if (tm.Equals("RE/JC"))
                {
                    demo.FirmaUnoDefault.Content = "REE";
                    demo.FirmaDosDefault.Content = "JCCH25";
                }
                else if (tm.Equals("RE/CS"))
                {
                    demo.FirmaUnoDefault.Content = "DEN51";
                    demo.FirmaDosDefault.Content = "REE";
                }
            }
            demo.lblCodigoClase.Visibility = Visibility.Hidden;
            demo.lblCodigoEstudio.Visibility = Visibility.Hidden;
            demo.lblCodigoPaciente.Visibility = Visibility.Hidden;
            demo.FirmaUnoDefault.Visibility = Visibility.Hidden;
            demo.FirmaDosDefault.Visibility = Visibility.Hidden;
            demo.rtbHallazgo.Language = XmlLanguage.GetLanguage("es-PE");
            demo.rtbConclusion.Language = XmlLanguage.GetLanguage("es-PE");
            demo.rtbTecnica.Language = XmlLanguage.GetLanguage("es-PE");

            demo.rtbHallazgo.SpellCheck.IsEnabled = true;
            demo.rtbTecnica.SpellCheck.IsEnabled = true;
            demo.rtbConclusion.SpellCheck.IsEnabled = true;
            demo.rtbConclusion.SpellCheck.SpellingReform = SpellingReform.PreAndPostreform;

            demo.ResizeMode = ResizeMode.NoResize;

            demo.Closing += new System.ComponentModel.CancelEventHandler(notClosing_CancelEventArgs);

            demo.ShowDialog();
        }
        else
        {
            MessageBox.Show("Seleccione un item", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
        }
    }

替代文字

我还尝试从 SO 中配置和删除“en-US”语言,当拼写检查程序完全停止时,当我为键盘重新添加该语言时,拼写检查程序会重新出现。

仍然无法使用“es-PE”或仅使用西班牙语作为家长

提前致谢!

Im trying to set Language for System.Windows.Control.RichTextBox as "es-PE", but I found
some issues, for example in some computers, works perfectly and SpellChecker is enabled
with "es-PE" language, but in others it just works with "en-US", so I Dont know whats the matter with
that control, I was using the following code in XAML and C# :

this is code when users select row from GridView and then shows the screenshot attached

 private void dlstInformes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (!dlstInformes.SelectedItem.ToString().Equals(""))
            {
                var source_ = dlstInformes.SelectedItems;
                InformeMedico demo = new InformeMedico(); //New Window

                foreach (informeMedico item in source_)
                {
                    numeroinforme = item.numeroinforme.ToString();
                    nombreinforme = item.nombreinforme;
                    fechainforme = item.fechainforme.ToString();
                    nombreMedico = item.medicoCompleto.ToString();
                    turnoMedico = item.turno.ToString();
                    nombrePaciente = item.pacienteCompleto.ToString();
                    nombreExamen = item.nombreinforme.ToString();

                }
                demo.Language = XmlLanguage.GetLanguage("es-PE");
                demo.txtNombreExamen.Text = nombreinforme;
                demo.lblNroInforme.Content = numeroinforme;
                demo.lblMedicoNombre.Content = nombreMedico;
                demo.lblNombrePac.Content = nombrePaciente;
                demo.lblTurnoMedico.Content = turnoMedico;
            using (DB db = new DB())
            {
                var lstTM = (from ea in db.EXAMENXATENCIONs where ea.turnomedico.Trim() != " " select ea.turnomedico).Distinct().ToList();
                string tm = (from ea in db.EXAMENXATENCIONs where ea.codigo == Convert.ToInt32(numeroinforme) select ea.turnomedico).FirstOrDefault();
                demo.cboTurnoMed.ItemsSource = lstTM;
                demo.cboTurnoMed.SelectedItem = tm;
                demo.cboTurnoMed.SelectedValue = tm;
                demo.cboTurnoMed.Text = tm;
                if (tm.Equals("RE/ES") || tm.Equals("RE/HS") || tm.Equals("RE/HT") || tm.Equals("RE/KV") || tm.Equals("HH/CS") || tm.Equals("HH/ES") || tm.Equals("HH/HS") || tm.Equals("HH/HT") || tm.Equals("HH/KV"))
                {
                    demo.FirmaUnoDefault.Content = "DEN51";
                    demo.FirmaDosDefault.Content = tm;
                }
                else if (tm.Equals("HH/AO") || tm.Equals("IU/AO") || tm.Equals("RE/AO") || tm.Equals("HH/JA") || tm.Equals("RR/JA") || tm.Equals("IU/JA"))
                {
                    demo.FirmaUnoDefault.Content = "DEN51";
                    demo.FirmaDosDefault.Content = "AOY20";
                }
                else if (tm.Equals("IU/CS") || tm.Equals("IU/ES") || tm.Equals("IU/HT") || tm.Equals("IU/KV"))
                {
                    demo.FirmaUnoDefault.Content = "IUU17";
                    demo.FirmaDosDefault.Content = tm;
                }
                else if (tm.Equals("RD/DE"))
                {
                    demo.FirmaUnoDefault.Content = "REE";
                    demo.FirmaDosDefault.Content = "DEN51";
                }
                else if (tm.Equals("RE/JC"))
                {
                    demo.FirmaUnoDefault.Content = "REE";
                    demo.FirmaDosDefault.Content = "JCCH25";
                }
                else if (tm.Equals("RE/CS"))
                {
                    demo.FirmaUnoDefault.Content = "DEN51";
                    demo.FirmaDosDefault.Content = "REE";
                }
            }
            demo.lblCodigoClase.Visibility = Visibility.Hidden;
            demo.lblCodigoEstudio.Visibility = Visibility.Hidden;
            demo.lblCodigoPaciente.Visibility = Visibility.Hidden;
            demo.FirmaUnoDefault.Visibility = Visibility.Hidden;
            demo.FirmaDosDefault.Visibility = Visibility.Hidden;
            demo.rtbHallazgo.Language = XmlLanguage.GetLanguage("es-PE");
            demo.rtbConclusion.Language = XmlLanguage.GetLanguage("es-PE");
            demo.rtbTecnica.Language = XmlLanguage.GetLanguage("es-PE");

            demo.rtbHallazgo.SpellCheck.IsEnabled = true;
            demo.rtbTecnica.SpellCheck.IsEnabled = true;
            demo.rtbConclusion.SpellCheck.IsEnabled = true;
            demo.rtbConclusion.SpellCheck.SpellingReform = SpellingReform.PreAndPostreform;

            demo.ResizeMode = ResizeMode.NoResize;

            demo.Closing += new System.ComponentModel.CancelEventHandler(notClosing_CancelEventArgs);

            demo.ShowDialog();
        }
        else
        {
            MessageBox.Show("Seleccione un item", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
        }
    }

alt text

I also trying configurate and removing "en-US" language from SO, when it happens spellchecker stop completly and when I Re-Add that language for keyboard, it SpellChecker reappears.

Stills not working with "es-PE" or just Spanish as Parent

Thanks in Advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紧拥背影 2024-07-21 06:55:02

我不确定这是否有帮助,但可能值得一试。

在Application.StartUp事件中添加以下代码

FrameworkElement.LanguageProperty.OverrideMetadata(
            typeof(FrameworkElement),
            new FrameworkPropertyMetadata(
                XmlLanguage.GetLanguage(
                CultureInfo.CurrentCulture.IetfLanguageTag)));

或者您可以修改它以指定es-PE而不是当前区域性。

这篇文章可能提供更深入的详细信息:让 WPF 应用程序选择正确的区域设置

I'm not sure if this will help, but it might be worth a shot.

In the Application.StartUp event add the following code

FrameworkElement.LanguageProperty.OverrideMetadata(
            typeof(FrameworkElement),
            new FrameworkPropertyMetadata(
                XmlLanguage.GetLanguage(
                CultureInfo.CurrentCulture.IetfLanguageTag)));

Or you can modify it to specify es-PE instead of the current culture.

This post might provide more in-depth details: Getting a WPF application to pick up the correct regional settings

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文