AboutView.xaml.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System.IO;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Documents;
  5. using System.Windows.Input;
  6. using Muchinfo.MTPClient.Infrastructure.Utilities;
  7. using Muchinfo.MTPClient.Resources;
  8. using Muchinfo.WPF.Controls.Windows;
  9. namespace Muchinfo.MTPClient.UI.Views
  10. {
  11. /// <summary>
  12. /// 关于
  13. /// </summary>
  14. public partial class AboutView : Window
  15. {
  16. /// <summary>
  17. /// 显示免责声明和关于我们 1-显示免责声明 2-显示关于我们
  18. /// </summary>
  19. /// <param name="type">1-显示免责声明 2-显示关于我们</param>
  20. public AboutView(int type)
  21. {
  22. InitializeComponent();
  23. if (type == 1)
  24. {
  25. Title = Client_Resource.UI2014_DisclaimerClause;
  26. sp.Visibility = Visibility.Hidden;
  27. grid.Visibility = Visibility.Visible;
  28. string content = string.Empty;
  29. try
  30. {
  31. //加载rtf文档
  32. var read = new StreamReader(ApplicationParameter.EscapeClauseFilePath);
  33. content = read.ReadToEnd();
  34. read.Close();
  35. }
  36. catch
  37. {
  38. }
  39. LoadFromRTF(txt, content);
  40. this.Width = 500;
  41. this.Height = 600;
  42. }
  43. else
  44. {
  45. comTitle.Visibility = UserManager.IsAccountLogin ? Visibility.Visible : Visibility.Collapsed;
  46. Title = Client_Resource.UI2014_AboutUs;
  47. proName.Text = ApplicationParameter.TradeSystemName;
  48. proCompName.Text = ApplicationParameter.ExchangeName;
  49. proVersion.Text = ApplicationParameter.Version;
  50. sp.Visibility = Visibility.Visible;
  51. grid.Visibility = Visibility.Hidden;
  52. proCopyright.Text = ApplicationParameter.Copyright;
  53. }
  54. }
  55. public static void LoadFromRTF(RichTextBox richTextBox, string rtf)
  56. {
  57. if (string.IsNullOrEmpty(rtf))
  58. {
  59. rtf = Client_Resource.UI2014_FailedToLoad;
  60. }
  61. TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
  62. using (MemoryStream ms = new MemoryStream())
  63. {
  64. using (StreamWriter sw = new StreamWriter(ms))
  65. {
  66. sw.Write(rtf);
  67. sw.Flush();
  68. ms.Seek(0, SeekOrigin.Begin);
  69. textRange.Load(ms, DataFormats.Rtf);
  70. }
  71. }
  72. }
  73. private void view_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
  74. {
  75. if (e.Key == Key.Escape)
  76. this.DialogResult = false;
  77. }
  78. }
  79. }