RecipeHelpView.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Shapes;
  13. using System.Diagnostics;
  14. using System.IO;
  15. namespace Aitex.UI.RecipeEditor
  16. {
  17. /// <summary>
  18. /// Interaction logic for RecipeHelpView.xaml
  19. /// </summary>
  20. public partial class RecipeHelpView : Window
  21. {
  22. readonly static Lazy<RecipeHelpView> _instace =
  23. new Lazy<RecipeHelpView>(() => new RecipeHelpView(), true);
  24. public static RecipeHelpView Instance
  25. {
  26. get
  27. {
  28. return _instace.Value;
  29. }
  30. }
  31. private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  32. {
  33. Hide();
  34. e.Cancel = true;
  35. }
  36. RecipeHelpView()
  37. {
  38. InitializeComponent();
  39. Closing += new System.ComponentModel.CancelEventHandler(Window_Closing);
  40. IsVisibleChanged += new DependencyPropertyChangedEventHandler(RecipeHelpView_IsVisibleChanged);
  41. try
  42. {
  43. var dir = new FileInfo(Process.GetCurrentProcess().MainModule.FileName).Directory;
  44. string docFile = dir + "\\HelpDoc.rtf";
  45. using (var swr = new System.IO.StreamReader(docFile))
  46. {
  47. Notes = swr.ReadToEnd();
  48. }
  49. }
  50. catch (Exception ex)
  51. {
  52. System.Diagnostics.Debug.WriteLine(ex.Message);
  53. }
  54. }
  55. void RecipeHelpView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  56. {
  57. DataContext = null;
  58. DataContext = this;
  59. }
  60. public string Notes { get; set; }
  61. }
  62. }