|
- using BPA.Helper;
- using Helper;
- using HKCardOUT.ViewModels;
- using HKLog;
- using System;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Forms;
- using System.Windows.Media;
-
- namespace HKCardOUT.Views
- {
- public partial class RootView : HandyControl.Controls.Window
- {
- public RootView()
- {
- InitializeComponent();
- MessageLog.GetInstance.NotifyShow = new Action<string>((s) =>
- {
- HKLog.HKLogImport.WriteInfo(s);
- });
- MessageLog.GetInstance.NotifyShowEx = new Action<string>((s) =>
- {
- HKLog.HKLogImport.WriteInfo(s);
- });
- /*//TurnOn();
- if (!StartEXE.IsExistKey("HKCardOUT"))
- {
- var Paths = "D:\\HKSK\\HKCardOUT.exe";
- StartEXE.SelfRunning(true, "HKCardOUT", Paths);
- }
- if (StartEXE.IsExistKey("HKCardOUT"))
- {
- var Paths = "D:\\HKSK\\HKCardOUT.exe";
- StartEXE.SelfRunning(false, "HKCardOUT", Paths);
- }*/
- this.Loaded += RootView_Loaded;
- }
-
- private void RootView_Loaded(object sender, RoutedEventArgs e)
- {
- (this.DataContext as RootViewModel).Main = this;
- HKControl.Main.GetInstance.Init();
- }
-
-
- public bool TurnOn()
- {
- return SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1) != 0;
- }
-
- public bool TurnOff()
- {
- return SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2) != 0;
- }
-
- [DllImport("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
-
- private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
- private const uint WM_SYSCOMMAND = 0x0112;
- private const int SC_MONITORPOWER = 0xf170;
- }
-
- }
|