using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using Muchinfo.MTPClient.Infrastructure.Utilities;
using Muchinfo.MTPClient.Resources;
using Muchinfo.WPF.Controls.Windows;
namespace Muchinfo.MTPClient.UI.Views
{
///
/// 关于
///
public partial class AboutView : Window
{
///
/// 显示免责声明和关于我们 1-显示免责声明 2-显示关于我们
///
/// 1-显示免责声明 2-显示关于我们
public AboutView(int type)
{
InitializeComponent();
if (type == 1)
{
Title = Client_Resource.UI2014_DisclaimerClause;
sp.Visibility = Visibility.Hidden;
grid.Visibility = Visibility.Visible;
string content = string.Empty;
try
{
//加载rtf文档
var read = new StreamReader(ApplicationParameter.EscapeClauseFilePath);
content = read.ReadToEnd();
read.Close();
}
catch
{
}
LoadFromRTF(txt, content);
this.Width = 500;
this.Height = 600;
}
else
{
comTitle.Visibility = UserManager.IsAccountLogin ? Visibility.Visible : Visibility.Collapsed;
Title = Client_Resource.UI2014_AboutUs;
proName.Text = ApplicationParameter.TradeSystemName;
proCompName.Text = ApplicationParameter.ExchangeName;
proVersion.Text = ApplicationParameter.Version;
sp.Visibility = Visibility.Visible;
grid.Visibility = Visibility.Hidden;
proCopyright.Text = ApplicationParameter.Copyright;
}
}
public static void LoadFromRTF(RichTextBox richTextBox, string rtf)
{
if (string.IsNullOrEmpty(rtf))
{
rtf = Client_Resource.UI2014_FailedToLoad;
}
TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
using (MemoryStream ms = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(ms))
{
sw.Write(rtf);
sw.Flush();
ms.Seek(0, SeekOrigin.Begin);
textRange.Load(ms, DataFormats.Rtf);
}
}
}
private void view_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Escape)
this.DialogResult = false;
}
}
}