using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
namespace DoorFan.Windows
{
///
/// Interaction logic for EULA.xaml
///
public partial class EULA : Window
{
public EULA()
{
InitializeComponent();
string titleText = App.AppTitleFull; //translated and with full version and admin if necessary
this.EULATitleText.Text = titleText;
FlowDocument flowDocument = new FlowDocument();
FileStream fileStream;
string ToStartMenuPath = "";
string EULAPath ="";
bool fileOpened = false;
bool textLoaded = false;
try
{
// load DoorFan5\ToStartMenu\Release_Notes.txt into the viewer
ToStartMenuPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ToStartMenu");
EULAPath = System.IO.Path.Combine(ToStartMenuPath, "EULA-" + LocalizationCode.LocalizationManager.CurrentCulture.TwoLetterISOLanguageName + ".rtf");
if (!File.Exists(EULAPath))
{
EULAPath = System.IO.Path.Combine(ToStartMenuPath, "EULA-en.rtf");
}
fileStream = File.Open(EULAPath, FileMode.Open, FileAccess.Read, FileShare.Read);
fileOpened = true;
TextRange textRange = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
textRange.Load(fileStream, DataFormats.Rtf);
textLoaded = true;
}
catch (Exception ex)
{
App.Log.ReportCaughtError("EULAWindowCreate", "problem getting EULA file: " + EULAPath + " from start menu path: " + ToStartMenuPath, ex);
}
if (!(fileOpened && textLoaded))
{
Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add("Unable to read text of End User License Agreement - Retrotec Inc. provides no warranty, explicit or implied, and assumes no liability for the use of this software");
flowDocument = new FlowDocument(paragraph);
}
EULAViewer.Document = flowDocument;
if (!(App.Settings.EULAAgreedTo == null || App.Settings.EULAAgreedTo < App.Settings.EULACurrent))
{
this.hideAcceptButtons();
}
}
private void hideAcceptButtons()
{
this.AgreeButton.Visibility = System.Windows.Visibility.Hidden;
this.CancelButton.Visibility = System.Windows.Visibility.Hidden;
DateTime EULADate = App.Settings.EULAAgreedTo;
string EULAstring = EULADate.Year.ToString() + "-" + EULADate.Month.ToString() + "-"+ EULADate.Day.ToString();
AcceptedDateTextBlock.Text = App.Translate("AcceptedDate") + " " + EULAstring;
}
private void AgreeButton_Click(object sender, RoutedEventArgs e)
{
if (App.Settings.EULAAgreedTo == null || App.Settings.EULAAgreedTo < App.Settings.EULACurrent)
{
App.Settings.EULAAgreedTo = DateTime.Now;
App.Settings.Save();
}
this.DialogResult = true;
this.Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//xaml code follows:
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// accessing code follows:
private void HelpMenu_EULA_Click(object sender, RoutedEventArgs e)
{
try
{
Windows.EULA EULAWindow = new Windows.EULA();
EULAWindow.ShowDialog();
}
catch (Exception ex)
{
App.Log.ReportCaughtError("MainWindow.HelpMenu_EULA_Click()", "unable to show EULA window", ex);
}
}