123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- 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
- {
- /// <summary>
- /// WinMd5Test.xaml 的交互逻辑
- /// </summary>
- public partial class WinMd5Test : HWindow
- {
- KeyboardHook m_Hook;
- public WinMd5Test()
- {
- InitializeComponent();
- this.RecordLocation = true;
- MD5Results = new ObservableCollection<string>();
- 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<string> m_MD5Results;
- public ObservableCollection<string> 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;
- /// <summary>
- /// 提交变更
- /// </summary>
- /// <param name="propertyName">变更属性名称</param>
- protected void RaiseChanged(String propertyName = "")
- {
-
- if (PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- protected void SetPropertyValue<T>(ref T old, T value, [CallerMemberName] string propertyName = "")
- {
- old = value;
- RaiseChanged(propertyName);
- }
- }
- }
|