using FWindSoft.WindowsApi;
using FWindSoft.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
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;
namespace Test.MD5Test
{
///
/// WinMd5Test.xaml 的交互逻辑
///
public partial class WinMd5Test : HWindow
{
KeyboardHook m_Hook;
public WinMd5Test()
{
InitializeComponent();
this.RecordLocation = true;
MD5Results = new ObservableCollection();
this.DataContext = this;
//几千倍的数据访问速度提高
string path = @"E:\立项\SAGA.MBI.exe";
// var ff=Assembly.ReflectionOnlyLoadFrom(path).GetName().Version;
LoadData();
//this.AddHandler(ComboBox.DropDownOpened, cmb_DropDownOpened)
m_Hook = new KeyboardHook(true, Process.GetCurrentProcess().MainWindowHandle);
m_Hook.KeyUp += Hook_KeyUp;
m_Hook.Install();
}
private void Hook_KeyUp(object sender, FWindSoft.WindowsApi.KeyEventArgs e)
{
// MessageBox.Show(e.KeyData.ToString());
Debug.WriteLine(e.KeyData.ToString());
}
void cmb_DropDownOpened(object sender, EventArgs e)
{
}
private string m_Path;
public string Path
{
get { return m_Path; }
set { SetPropertyValue(ref m_Path, value); }
}
private ObservableCollection m_MD5Results;
public ObservableCollection MD5Results
{
get { return m_MD5Results; }
set { SetPropertyValue(ref m_MD5Results, value); }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//MessageBox.Show("路径为空");
//return;
if (string.IsNullOrWhiteSpace(Path))
{
MessageBox.Show("路径为空");
return;
}
var attach = MD5Utils.GetVersionRevitFile(Path);
var md5 = MD5Utils.GetMD5HashFromFile(Path);
string useMd5 = md5 ?? "无";
string item = string.Format("{0}-----{1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), useMd5);
MD5Results.Add(item);
}
}
public partial class WinMd5Test : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
///
/// 提交变更
///
/// 变更属性名称
protected void RaiseChanged(String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
protected void SetPropertyValue(ref T old, T value, [CallerMemberName] string propertyName = "")
{
old = value;
RaiseChanged(propertyName);
}
}
}