private void Window_Closed(object sender, EventArgs e) { if (mAdministrator && mConfig != null) { if (mInstalledHotKey) { RemoveRegisterHotKey(); } if (mConfig.Options.UseCtrlWheel) { MouseHook.Stop(); } } }
private void Window_Closed(object sender, EventArgs e) { if (mAdministrator && mConfigData != null) { if (mIsHotKey) { RemoveRegisterHotKey(); } if (mConfigData.Options.CtrlWheel) { MouseHook.Stop(); } } TrayIcon.Visible = false; TrayIcon.Dispose(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (!Setting()) { Application.Current.Shutdown(); return; } ResStr.ServerType = ResStr.ServerType == "" ? mConfigData.Options.League : ResStr.ServerType; ResStr.ServerType = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ResStr.ServerType.ToLower()).Replace(" ", "%20"); ResStr.ServerLang = (byte)(mConfigData.Options.Server == "en" ? 1 : 0); ComboBox[] cbs = { cbOrbs, cbSplinters, cbCorrupt, cbPriceListCount, cbInfluence }; foreach (ComboBox cb in cbs) { ControlTemplate ct = cb.Template; Popup popup = ct.FindName("PART_Popup", cb) as Popup; if (popup != null) { popup.Placement = PlacementMode.Top; } } int cnt = 0; cbOrbs.Items.Add("교환을 원하는 오브 선택"); cbSplinters.Items.Add("원하는 화석, 파편 선택"); foreach (KeyValuePair <string, string> item in ResStr.lExchangeCurrency) { if (item.Key == "대장장이의 숫돌") { break; } if (cnt++ > 33) { cbSplinters.Items.Add(item.Key); } else { cbOrbs.Items.Add(item.Key); } } mMainHwnd = new WindowInteropHelper(this).Handle; if (mAdministrator) { foreach (var item in mConfigData.Shortcuts) { if (item.Keycode > 0 && (item.Value ?? "") != "") { if (!mDisableClip && item.Value.ToLower() == "{run}") { mDisableClip = true; } else if (item.Value.ToLower() == "{close}") { closeKeyCode = item.Keycode; } } } } HwndSource source = HwndSource.FromHwnd(mMainHwnd); source.AddHook(new HwndSourceHook(WndProc)); string tmp = "프로그램 버전 " + GetFileVersion() + " 을(를) 시작합니다." + '\n' + '\n' + "* 사용법: 인게임 아이템 위에서 Ctrl + C 하면 창이 뜹니다." + '\n' + "* 종료는: 트레이 아이콘을 우클릭 하시면 됩니다." + '\n' + '\n' + (mAdministrator ? "관리자로 실행했기에 추가 단축키 기능이" : "추가 단축키 기능은 관리자 권한으로 실행해야") + " 작동합니다."; if (mConfigData.Options.CheckUpdates && CheckUpdates()) { MessageBoxResult result = MessageBox.Show(Application.Current.MainWindow, tmp + '\n' + '\n' + "이 프로그램의 최신 버전이 발견 되었습니다." + '\n' + "지금 새 버전을 받으러 가시겠습니까?", "POE 거래소 검색", MessageBoxButton.YesNo, MessageBoxImage.Question ); if (result == MessageBoxResult.Yes) { Process.Start("https://github.com/phiDelPark/PoeTradeSearch/releases"); mTerminate = true; Close(); } } else { MessageBox.Show(Application.Current.MainWindow, tmp + '\n' + "더 자세한 정보를 보시려면 프로그램 상단 (?) 를 눌러 확인하세요.", "POE 거래소 검색"); } if (!mDisableClip) { IntPtr mNextClipBoardViewerHWnd = NativeMethods.SetClipboardViewer(new WindowInteropHelper(this).Handle); } if (mAdministrator) { //InstallRegisterHotKey(); // 창 활성화 후킹 사용시 가끔 꼬여서 타이머로 교체 (타이머를 쓰면 다른 목적으로 사용도 가능하고...) //EventHook.EventAction += new EventHandler(WinEvent); //EventHook.Start(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += new EventHandler(Timer_Tick); timer.Start(); if (mConfigData.Options.CtrlWheel) { MouseHookCallbackTime = Convert.ToDateTime(DateTime.Now); MouseHook.MouseAction += new EventHandler(MouseEvent); MouseHook.Start(); } } this.Title += " - " + ResStr.ServerType; this.Visibility = Visibility.Hidden; }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (!Setting()) { Application.Current.Shutdown(0xD); //ERROR_INVALID_DATA return; } string outString = ""; int update_type = mConfigData.Options.CheckUpdates ? CheckUpdates(mParserData == null ? "0.0.0.0" : mParserData.Version[1]) : 0; string start_msg = "프로그램 버전 " + GetFileVersion() + " 을(를) 시작합니다." + '\n' + '\n' + "* 사용법: 인게임 아이템 위에서 Ctrl + C 하면 창이 뜹니다." + '\n' + "* 종료는: 트레이 아이콘을 우클릭 하시면 됩니다." + '\n' + '\n' + (mAdministrator ? "관리자로 실행했기에 추가 단축키 기능이" : "추가 단축키 기능은 관리자 권한으로 실행해야") + " 작동합니다."; if (update_type == 1) { MessageBoxResult result = MessageBox.Show( Application.Current.MainWindow, start_msg + '\n' + '\n' + "이 프로그램의 최신 버전이 발견 되었습니다." + '\n' + "자동으로 업데이트를 하시겠습니까?", "POE 거래소 검색", MessageBoxButton.YesNo, MessageBoxImage.Question ); if (result == MessageBoxResult.Yes) { // Process.Start("https://github.com/phiDelPark/PoeTradeSearch/releases"); PoeExeUpdates(); Application.Current.Shutdown(); return; } } else { if (update_type == 2) { WinPopup winPopup = new WinPopup(null); Task.Factory.StartNew(() => { if (PoeDataUpdates()) { if (!Setting()) { Application.Current.Shutdown(0xD); //ERROR_INVALID_DATA return; } } else { start_msg = start_msg + '\n' + '\n' + "최신 POE 데이터 업데이트를 실패하였습니다." + '\n' + "접속이 원할하지 않을 수 있으므로 다음 실행시 다시 시도합니다." + '\n'; } this.Dispatcher.Invoke(() => { winPopup.Close(); }); }); winPopup.ShowDialog(); } MessageBox.Show( Application.Current.MainWindow, start_msg + '\n' + "더 자세한 정보를 보시려면 프로그램 상단 (?) 를 눌러 확인하세요.", "POE 거래소 검색" ); } if (!LoadData(out outString)) { this.Visibility = Visibility.Hidden; Application.Current.Shutdown(0xD); //ERROR_INVALID_DATA return; } ///////////// RS.ServerType = RS.ServerType == "" ? mConfigData.Options.League : RS.ServerType; RS.ServerType = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(RS.ServerType.ToLower()).Replace(" ", "%20"); RS.ServerLang = (byte)(mConfigData.Options.Server == "en" ? 1 : 0); ComboBox[] cbs = { cbOrbs, cbSplinters, cbCorrupt, cbInfluence1, cbInfluence2 }; foreach (ComboBox cb in cbs) { ControlTemplate ct = cb.Template; Popup popup = ct.FindName("PART_Popup", cb) as Popup; if (popup != null) { popup.Placement = PlacementMode.Top; } } Grid input = cbName.Template.FindName("templateRoot", cbName) as Grid; if (input != null) { ToggleButton toggleButton = input.FindName("toggleButton") as ToggleButton; if (toggleButton != null) { Border border = toggleButton.Template.FindName("templateRoot", toggleButton) as Border; if (border != null) { border.BorderThickness = new Thickness(0, 0, 0, 1); border.Background = System.Windows.Media.Brushes.Transparent; } } } cbName.FontSize = cbOrbs.FontSize + 2; cbOrbs.Items.Add("교환을 원하는 오브 선택"); foreach (ParserDictionary item in mParserData.Currency) { if (item.Hidden == false) { cbOrbs.Items.Add(item.Text[0]); } } cbSplinters.Items.Add("기폭제, 화석, 조각등등"); foreach (ParserDictionary item in mParserData.Exchange) { if (item.Hidden == false) { cbSplinters.Items.Add(item.Text[0]); } } this.Title += " - " + RS.ServerType; this.Visibility = Visibility.Hidden; ///////////////// mMainHwnd = new WindowInteropHelper(this).Handle; HwndSource source = HwndSource.FromHwnd(mMainHwnd); source.AddHook(new HwndSourceHook(WndProc)); if (mAdministrator) { foreach (var item in mConfigData.Shortcuts) { if (item.Keycode > 0 && (item.Value ?? "") != "") { if (!mDisableClip && item.Value.ToLower() == "{run}") { mDisableClip = true; } else if (item.Value.ToLower() == "{close}") { closeKeyCode = item.Keycode; } } } // 창 활성화 후킹 사용시 가끔 꼬여서 타이머로 교체 //InstallRegisterHotKey(); //EventHook.EventAction += new EventHandler(WinEvent); //EventHook.Start(); if (mConfigData.Options.CtrlWheel) { mMouseHookCallbackTime = Convert.ToDateTime(DateTime.Now); MouseHook.MouseAction += new EventHandler(MouseEvent); MouseHook.Start(); } DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += new EventHandler(Timer_Tick); timer.Start(); } if (!mDisableClip) { IntPtr mNextClipBoardViewerHWnd = Native.SetClipboardViewer(mMainHwnd); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (!Setting()) { Application.Current.Shutdown(0xD); //ERROR_INVALID_DATA return; } string outString = ""; int update_type = mConfig.Options.AutoCheckUpdates ? CheckUpdates() : 0; mTrayIcon.BalloonTipTitle = "버전 " + Application.Current.Properties["FileVersion"]; if (!LoadData(out outString)) { this.Visibility = Visibility.Hidden; Application.Current.Shutdown(0xD); //ERROR_INVALID_DATA return; } if (update_type == 1) { mTrayIcon.BalloonTipText = "최신 버전이 발견 되었습니다." + "\n" + "트레이 아이콘을 우클릭해 업데이트 하세요."; mTrayIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.None; //mTrayIcon.BalloonTipClicked += (sd,ea) => {}; } else { mTrayIcon.ContextMenu.MenuItems.Find("this_update", false)[0].Enabled = false; mTrayIcon.BalloonTipText = "프로그램을 시작합니다." + "\n" + "사용법: 아이템 위에서 Ctrl + C" + "\n" + "종료는: 트레이 아이콘을 우클릭"; mTrayIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; } Native.SetForegroundWindow(Native.FindWindow("Shell_TrayWnd", null)); mTrayIcon.ShowBalloonTip(5000); InitializeControls(); mAutoSearchTimer = new DispatcherTimer(); mAutoSearchTimer.Interval = TimeSpan.FromSeconds(1); mAutoSearchTimer.Tick += new EventHandler(AutoSearchTimer_Tick); tkPriceInfo.Tag = tkPriceInfo.Text = "시세를 검색하려면 클릭해주세요"; mMainHwnd = new WindowInteropHelper(this).Handle; if (mAdministrator) { // 창 활성화 후킹 사용시 가끔 꼬여서 타이머로 교체 //InstallRegisterHotKey(); //EventHook.EventAction += new EventHandler(WinEvent); //EventHook.Start(); if (mConfig.Options.UseCtrlWheel) { mMouseHookCallbackTime = Convert.ToDateTime(DateTime.Now); MouseHook.MouseAction += new EventHandler(MouseEvent); MouseHook.Start(); } DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += new EventHandler(Timer_Tick); timer.Start(); } uint styles = (uint)Native.GetWindowLong(mMainHwnd, Native.GWL_EXSTYLE); Native.SetWindowLong(mMainHwnd, Native.GWL_EXSTYLE, (int)(styles |= Native.WS_EX_CONTEXTHELP)); IntPtr mNextClipBoardViewerHWnd = Native.SetClipboardViewer(mMainHwnd); HwndSource.FromHwnd(mMainHwnd).AddHook(new HwndSourceHook(WndProc)); this.Title += " - " + mConfig.Options.League; }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == Native.WM_DRAWCLIPBOARD) { if (!mPausedHotKey) { #if DEBUG if (true) #else if (Native.GetForegroundWindow().Equals(Native.FindWindow(RS.PoeClass, RS.PoeCaption))) #endif { try { if (Clipboard.ContainsText(TextDataFormat.UnicodeText) || Clipboard.ContainsText(TextDataFormat.Text)) { ItemTextParser(GetClipText(Clipboard.ContainsText(TextDataFormat.UnicodeText)), !mShowWiki); if (mShowWiki) { Button_Click_4(null, new RoutedEventArgs()); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { mShowWiki = false; } } } } else if (msg == (int)0x0112 /*WM_SYSCOMMAND*/ && ((int)wParam & 0xFFF0) == (int)0xf180 /*SC_CONTEXTHELP*/) { WinSetting winSetting = new WinSetting(); winSetting.Show(); handled = true; } else if (!mHotkeyProcBlock && msg == (int)0x312) //WM_HOTKEY { mHotkeyProcBlock = true; IntPtr findHwnd = Native.FindWindow(RS.PoeClass, RS.PoeCaption); if (Native.GetForegroundWindow().Equals(findHwnd)) { int key_idx = wParam.ToInt32() - 10001; const string POPUP_WINDOW_TITLE = "이곳을 잡고 이동, 닫기는 클릭 또는 ESC"; try { if (key_idx == -1) { IntPtr pHwnd = Native.FindWindow(null, POPUP_WINDOW_TITLE); IntPtr pHwnd2 = Native.FindWindow(null, Title + " - " + "{grid:stash}"); if (pHwnd.ToInt32() != 0 || pHwnd2.ToInt32() != 0) { if (pHwnd.ToInt32() != 0) { Native.SendMessage(pHwnd, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } if (pHwnd2.ToInt32() != 0) { Native.SendMessage(pHwnd2, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } } else if (this.Visibility == Visibility.Hidden) { Native.SendMessage(findHwnd, 0x0101, new IntPtr(/* ESC = */ 27), IntPtr.Zero); } else if (this.Visibility == Visibility.Visible) { Close(); } } else { ConfigShortcut shortcut = mConfig.Shortcuts[key_idx]; if (shortcut != null && shortcut.Value != null) { string valueLower = shortcut.Value.ToLower(); if (valueLower.IndexOf("{pause}") == 0) { mPausedHotKey = !mPausedHotKey; if (mPausedHotKey) { if (mConfig.Options.UseCtrlWheel) { MouseHook.Stop(); } MessageBox.Show(Application.Current.MainWindow, "프로그램 동작을 일시 중지합니다." + '\n' + "다시 시작하려면 일시 중지 단축키를 한번더 누르세요.", "POE 거래소 검색"); } else { if (mConfig.Options.UseCtrlWheel) { MouseHook.Start(); } MessageBox.Show(Application.Current.MainWindow, "프로그램 동작을 다시 시작합니다.", "POE 거래소 검색"); } Native.SetForegroundWindow(findHwnd); } else if (valueLower.IndexOf("{restart}") == 0) { Process.Start(new ProcessStartInfo(Assembly.GetExecutingAssembly().Location) { Arguments = "/wait_shutdown" }); Application.Current.Shutdown(); } else if (!mPausedHotKey) { if (valueLower.IndexOf("{run}") == 0 || valueLower.IndexOf("{wiki}") == 0) { mShowWiki = valueLower.IndexOf("{wiki}") == 0; System.Windows.Forms.SendKeys.SendWait("^{c}"); } else if (valueLower.IndexOf("{enter}") == 0) { Regex regex = new Regex(@"{enter}", RegexOptions.IgnoreCase); string tmp = regex.Replace(shortcut.Value, "" + '\n'); string[] strs = tmp.Trim().Split('\n'); for (int i = 0; i < strs.Length; i++) { SetClipText(strs[i], TextDataFormat.UnicodeText); Thread.Sleep(300); System.Windows.Forms.SendKeys.SendWait("{enter}"); System.Windows.Forms.SendKeys.SendWait("^{a}"); System.Windows.Forms.SendKeys.SendWait("^{v}"); System.Windows.Forms.SendKeys.SendWait("{enter}"); } } else if (valueLower.IndexOf("{link}") == 0) { Regex regex = new Regex(@"{link}", RegexOptions.IgnoreCase); string tmp = regex.Replace(shortcut.Value, "" + '\n'); string[] strs = tmp.Trim().Split('\n'); if (strs.Length > 0) { Process.Start(strs[0]); } } else if (valueLower.IndexOf("{grid:stash}") == 0) { IntPtr pHwnd = Native.FindWindow(null, Title + " - " + "{grid:stash}"); if (pHwnd.ToInt32() != 0) { Native.SendMessage(pHwnd, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } else { WinGrid winGrid = new WinGrid(findHwnd); winGrid.Title = Title + " - " + "{grid:stash}"; winGrid.Show(); } } else if (valueLower.IndexOf(".jpg") > 0) { IntPtr pHwnd = Native.FindWindow(null, POPUP_WINDOW_TITLE); if (pHwnd.ToInt32() != 0) { Native.SendMessage(pHwnd, /* WM_CLOSE = */ 0x10, IntPtr.Zero, IntPtr.Zero); } WinPopup winPopup = new WinPopup(shortcut.Value); winPopup.WindowStartupLocation = WindowStartupLocation.Manual; winPopup.Title = POPUP_WINDOW_TITLE; winPopup.Left = 10; winPopup.Top = 10; winPopup.Show(); } } } } } catch (Exception) { ForegroundMessage("잘못된 단축키 명령입니다.", "단축키 에러", MessageBoxButton.OK, MessageBoxImage.Error); } handled = true; } mHotkeyProcBlock = false; } return(IntPtr.Zero); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (!Setting()) { Application.Current.Shutdown(); return; } Restr.ServerType = Restr.ServerType == "" ? mConfigData.Options.League : Restr.ServerType; Restr.ServerType = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Restr.ServerType.ToLower()).Replace(" ", "%20"); Restr.ServerLang = (byte)(mConfigData.Options.Server == "en" ? 1 : 0); ComboBox[] cbs = { cbOrbs, cbSplinters, cbCorrupt, cbPriceListCount, cbInfluence1, cbInfluence2 }; foreach (ComboBox cb in cbs) { ControlTemplate ct = cb.Template; Popup popup = ct.FindName("PART_Popup", cb) as Popup; if (popup != null) { popup.Placement = PlacementMode.Top; } } int cnt = 0; cbOrbs.Items.Add("Select the orbs you want to exchange"); cbSplinters.Items.Add("Select the fossils, splinters you want"); foreach (KeyValuePair <string, string> item in Restr.lExchangeCurrency) { if (item.Key == "Blacksmith Whetstone") { break; } if (cnt++ > 33) { cbSplinters.Items.Add(item.Key); } else { cbOrbs.Items.Add(item.Key); } } mMainHwnd = new WindowInteropHelper(this).Handle; if (mAdministrator) { foreach (var item in mConfigData.Shortcuts) { if (item.Keycode > 0 && (item.Value ?? "") != "") { if (!mDisableClip && item.Value.ToLower() == "{run}") { mDisableClip = true; } else if (item.Value.ToLower() == "{close}") { closeKeyCode = item.Keycode; } } } } HwndSource source = HwndSource.FromHwnd(mMainHwnd); source.AddHook(new HwndSourceHook(WndProc)); string tmp = "Program version " + GetFileVersion() + " 을(를) 시작합니다." + '\n' + '\n' + "* Usage: In game press Ctrl + C on an in-game item." + '\n' + "* To close the program, right click on the tray icon." + '\n' + '\n' + (mAdministrator ? "Additional shortcuts have been enabled" : "To use the additional shortcuts, the program must be ran as administrator") + ""; if (mConfigData.Options.CheckUpdates && CheckUpdates()) { MessageBoxResult result = MessageBox.Show(Application.Current.MainWindow, tmp + '\n' + '\n' + "The latest version of this program has been found." + '\n' + "Would you like to get that verison now?", "POE 거래소 검색", MessageBoxButton.YesNo, MessageBoxImage.Question ); if (result == MessageBoxResult.Yes) { Process.Start("https://github.com/redSol/PoeTradeSearchEN/releases"); mTerminate = true; Close(); } } else { if (!mConfigData.Options.DisableStartupMessage) { MessageBox.Show(Application.Current.MainWindow, tmp + '\n' + "Press the top of the program (?) for more information.", "POETradeSearch - created by phiDelPark"); } } if (!mDisableClip) { IntPtr mNextClipBoardViewerHWnd = Native.SetClipboardViewer(new WindowInteropHelper(this).Handle); } if (mAdministrator) { //InstallRegisterHotKey(); // 창 활성화 후킹 사용시 가끔 꼬여서 타이머로 교체 (타이머를 쓰면 다른 목적으로 사용도 가능하고...) //EventHook.EventAction += new EventHandler(WinEvent); //EventHook.Start(); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += new EventHandler(Timer_Tick); timer.Start(); if (mConfigData.Options.CtrlWheel) { MouseHookCallbackTime = Convert.ToDateTime(DateTime.Now); MouseHook.MouseAction += new EventHandler(MouseEvent); MouseHook.Start(); } } this.Title += " - " + Restr.ServerType; this.Visibility = Visibility.Hidden; }