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.Diagnostics;
using System.IO;
namespace Aitex.UI.RecipeEditor
{
    /// 
    /// Interaction logic for RecipeHelpView.xaml
    /// 
    public partial class RecipeHelpView : Window
    {
        readonly static Lazy _instace =
        new Lazy(() => new RecipeHelpView(), true);
        public static RecipeHelpView Instance
        {
            get
            {
                return _instace.Value;
            }
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Hide();
            e.Cancel = true;
        }
        RecipeHelpView()
        {
            InitializeComponent();
            Closing += new System.ComponentModel.CancelEventHandler(Window_Closing);
            IsVisibleChanged += new DependencyPropertyChangedEventHandler(RecipeHelpView_IsVisibleChanged);
            try
            {
                var dir = new FileInfo(Process.GetCurrentProcess().MainModule.FileName).Directory;
                string docFile = dir + "\\HelpDoc.rtf";
                using (var swr = new System.IO.StreamReader(docFile))
                {
                    Notes = swr.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
        void RecipeHelpView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            DataContext = null;
            DataContext = this;            
        }
        public string Notes { get; set; }
    }
}