You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

  1. using BPA.Helper;
  2. using Helper;
  3. using HKCardOUT.ViewModels;
  4. using HKLog;
  5. using System;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Runtime.InteropServices;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Forms;
  12. using System.Windows.Media;
  13. namespace HKCardOUT.Views
  14. {
  15. public partial class RootView : HandyControl.Controls.Window
  16. {
  17. public RootView()
  18. {
  19. InitializeComponent();
  20. MessageLog.GetInstance.NotifyShow = new Action<string>((s) =>
  21. {
  22. HKLog.HKLogImport.WriteInfo(s);
  23. });
  24. MessageLog.GetInstance.NotifyShowEx = new Action<string>((s) =>
  25. {
  26. HKLog.HKLogImport.WriteInfo(s);
  27. });
  28. /*//TurnOn();
  29. if (!StartEXE.IsExistKey("HKCardOUT"))
  30. {
  31. var Paths = "D:\\HKSK\\HKCardOUT.exe";
  32. StartEXE.SelfRunning(true, "HKCardOUT", Paths);
  33. }
  34. if (StartEXE.IsExistKey("HKCardOUT"))
  35. {
  36. var Paths = "D:\\HKSK\\HKCardOUT.exe";
  37. StartEXE.SelfRunning(false, "HKCardOUT", Paths);
  38. }*/
  39. this.Loaded += RootView_Loaded;
  40. }
  41. private void RootView_Loaded(object sender, RoutedEventArgs e)
  42. {
  43. (this.DataContext as RootViewModel).Main = this;
  44. HKControl.Main.GetInstance.Init();
  45. }
  46. public bool TurnOn()
  47. {
  48. return SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1) != 0;
  49. }
  50. public bool TurnOff()
  51. {
  52. return SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2) != 0;
  53. }
  54. [DllImport("user32.dll")]
  55. public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
  56. private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
  57. private const uint WM_SYSCOMMAND = 0x0112;
  58. private const int SC_MONITORPOWER = 0xf170;
  59. }
  60. }