//----------------------------------------------------------------------------------------- public TradeItemControl(TradeItem tItemArg) { InitializeComponent(); if (Settings.Default.CollapsedItems == true) { CollapseExpandItem(); } tItem = tItemArg; FillControl(tItemArg); StartAnimatioin(); if (Settings.Default.PlayNotificationSound) { System.Media.SystemSounds.Hand.Play(); } if (stashGridHighlight == null) { stashGridHighlight = new StashGridHighlight(); stashGridHighlight.Show(); } }
private void Button_Click(object sender, RoutedEventArgs e) { String strWhisper = "@From Labooo: wtb Caer Blaidd, Wolfpack's Den Underground River Map listed for 100 alch in bestiary (stash \"~price 1 alt\"; left 2, top 8)"; TradeItem tItem = new TradeItem(strWhisper); TradeItemControl uc = new TradeItemControl(tItem); stk_MainPnl.Children.Add(uc); }
private void RemoveItem() { ((StackPanel)Parent).Children.Remove(this); stashGridHighlight.RemoveStashControl(tItem); TradeItemControl.RemoveTICfromList(this); TradeItem.RemoveItemFromList(tItem); stashGridHighlight.ClearCanvas(); }
private void DispatcherTimer_Tick(object sender, EventArgs e) { if (lastReadLength < 0) { lastReadLength = 0; } try { var fileSize = new FileInfo(filePath).Length; if (fileSize > lastReadLength) { using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { fs.Seek(lastReadLength, SeekOrigin.Begin); var buffer = new byte[1024]; while (true) { var bytesRead = fs.Read(buffer, 0, buffer.Length); lastReadLength += bytesRead; if (bytesRead == 0) { break; } var text = Encoding.UTF8.GetString(buffer, 0, bytesRead); using (var reader = new StringReader(text)) { for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) { if (line.Contains(" @")) { try { TradeItem tItem = new TradeItem(line); TradeItemControl uc = new TradeItemControl(tItem); stk_MainPnl.Children.Add(uc); } catch (Exception) { // Ignore Exception. Exception was thrown, because no RegEx pattern matched } } } } } } } } catch { } }
public static void RemoveItemFromList(TradeItem ti) { for (int i = 0; i < lstTradeItems.Count; i++) { if (lstTradeItems[i].Item == ti.Item && lstTradeItems[i].Customer == ti.Customer && lstTradeItems[i].Price == ti.Price && lstTradeItems[i].StashPosition == ti.StashPosition && lstTradeItems[i].TradeType == ti.TradeType) { lstTradeItems.RemoveAt(i); } } }
public static bool ItemExists(TradeItem ti) { foreach (var item in lstTradeItems) { if (item.Item == ti.Item && item.Customer == ti.Customer && item.Price == ti.Price && item.StashPosition == ti.StashPosition && item.TradeType == ti.TradeType) { return(true); } } return(false); }
//----------------------------------------------------------------------------------------- private void FillControl(TradeItem tItemArg) { if (tItem.TradeType == TradeItem.TradeTypes.BUY) { txt_Item.Foreground = System.Windows.Media.Brushes.GreenYellow; } else if (tItem.TradeType == TradeItem.TradeTypes.SELL) { txt_Item.Foreground = System.Windows.Media.Brushes.OrangeRed; } txt_Customer.Text = tItem.Customer; txt_Item.Text = tItem.Item; try { txt_Price.Text = TradeItem.ExtractFloatFromString(tItem.Price); } catch (Exception) { } if (tItem.Price == null) { txt_Price.Text = "--"; } txt_League.Text = tItem.League; txt_Stash.Text = tItem.Stash; btn_stash.ToolTip = tItem.StashPosition.ToString(); if (tItem.AdditionalText == "" || tItem.AdditionalText == null) { btn_AdditionalText.Visibility = Visibility.Collapsed; btn_AdditionalText.Visibility = Visibility.Hidden; } else { txt_AdditionalText.Text = tItem.AdditionalText; } img_Currency.Source = tItem.PriceCurrencyBitmap; }
//----------------------------------------------------------------------------------------- public TradeItemControl(TradeItem tItemArg) { tItem = tItemArg; intNumberItems++; if (intNumberItems >= intNumberItemsForControlBar) { OnMoreThanThreeItems(); } InitializeComponent(); LoadSettings(); SetupControls(tItem); StartAnimatioin(); OpenStashGridHighlightWindow(); StartTime(); }
private void SetupControls(TradeItem tItemArg) { if (!String.IsNullOrEmpty(tItem.Item.ToString())) { btn_Item.ToolTip = tItem.Item.ToString(); } if (!String.IsNullOrEmpty(tItem.Price)) { btn_Price.ToolTip = tItem.Price.ToString(); } if (tItem.TradeType == TradeItem.TradeTypes.BUY) { txt_Item.Foreground = System.Windows.Media.Brushes.GreenYellow; btn_InviteCustomer.Visibility = Visibility.Collapsed; btn_StartTrade.Visibility = Visibility.Collapsed; btn_SearchItem.Visibility = Visibility.Collapsed; btn_AskIfInterested.Visibility = Visibility.Collapsed; btn_SendBusyMessage.Visibility = Visibility.Collapsed; btn_stash.Click -= ClickStashIsQuad; } else if (tItem.TradeType == TradeItem.TradeTypes.SELL) { txt_Item.Foreground = System.Windows.Media.Brushes.OrangeRed; btn_VisitCustomerHideout.Visibility = Visibility.Collapsed; btn_VisitOwnHideout.Visibility = Visibility.Collapsed; btn_SendWhisperAgain.Visibility = Visibility.Collapsed; } if (tItem.ItemIsCurrency == true) { txt_Customer.Text = tItem.Customer; txt_Item.Text = tItem.ItemCurrencyQuant; img_ItemCurrency.Source = tItem.ItemCurrencyBitmap; txt_League.Text = tItem.League; try { txt_Price.Text = TradeItem.ExtractPointNumberFromString(tItem.Price); } catch (Exception) { } if (tItem.Stash == null) { btn_stash.Visibility = Visibility.Collapsed; btn_stash.Visibility = Visibility.Hidden; } else { txt_Stash.Text = tItem.Stash; btn_stash.ToolTip = tItem.StashPosition.ToString(); } double dblPrice = 0; double dblItemPrice = 0; try { dblPrice = Double.Parse(TradeItem.ExtractPointNumberFromString(tItem.Price)); dblItemPrice = Double.Parse(TradeItem.ExtractPointNumberFromString(tItem.ItemCurrencyQuant)); } catch (Exception) { } if ((dblItemPrice / dblPrice) >= 1) { txt_Ratio1.Text = "1"; img_Ratio1.Source = tItem.PriceCurrencyBitmap; txt_Ratio2.Text = (dblItemPrice / dblPrice).ToString(); img_Ratio2.Source = tItem.ItemCurrencyBitmap; } else { txt_Ratio1.Text = "1"; img_Ratio1.Source = tItem.ItemCurrencyBitmap; txt_Ratio2.Text = (dblPrice / dblItemPrice).ToString(); img_Ratio2.Source = tItem.PriceCurrencyBitmap; } btn_stash.Visibility = Visibility.Collapsed; btn_stash.Visibility = Visibility.Hidden; } else { txt_Customer.Text = tItem.Customer; txt_Item.Text = tItem.Item; spnl_CurrencyRatio.Visibility = Visibility.Collapsed; try { txt_Price.Text = TradeItem.ExtractPointNumberFromString(tItem.Price); } catch (Exception) { } if (String.IsNullOrEmpty(tItem.Price)) { txt_Price.Text = "--"; } txt_League.Text = tItem.League; if (tItem.Stash == null) { btn_stash.Visibility = Visibility.Collapsed; btn_stash.Visibility = Visibility.Hidden; } else { txt_Stash.Text = tItem.Stash; btn_stash.ToolTip = tItem.StashPosition.ToString(); } } if (String.IsNullOrEmpty(tItem.AdditionalText)) { btn_AdditionalText.Visibility = Visibility.Collapsed; btn_AdditionalText.Visibility = Visibility.Hidden; } else { txt_AdditionalText.Text = tItem.AdditionalText; } img_Currency.Source = tItem.PriceCurrencyBitmap; }
private void DispatcherTimer_Tick(object sender, EventArgs e) { string filePath = Settings.Default.PathToClientTxt; CheckIfPoeIsForegroundWindow(); if (lastReadLength < 0) { lastReadLength = 0; } try { var fileSize = new FileInfo(filePath).Length; if (fileSize > lastReadLength) { using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { fs.Seek(lastReadLength, SeekOrigin.Begin); var buffer = new byte[1024]; var bytesRead = fs.Read(buffer, 0, buffer.Length); lastReadLength += bytesRead; var text = Encoding.UTF8.GetString(buffer, 0, bytesRead); using (var reader = new StringReader(text)) { for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) { // Check for trade whispers if (line.Contains(" @")) { // Get a handle to POE. The window class and window name were obtained using the Spy++ tool. IntPtr poeHandle = FindWindow("POEWindowClass", "Path of Exile"); // Verify that POE is a running process. if (poeHandle != IntPtr.Zero) { try { TradeItem tItem = new TradeItem(line); TradeItemControl uc = new TradeItemControl(tItem); stk_MainPnl.Children.Add(uc); var customMenuItem = new CustMenuItem(uc); customMenuItem.Click += CustomMenuItem_Click; itmHistory.DropDownItems.Add(customMenuItem); } catch (NoCurrencyBitmapFoundException) { //System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } catch (NoCurrencyFoundException) { //System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } catch (NoRegExMatchException) { //System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } catch (TradeItemExistsException) { //System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } // Check if customer joined or left else if (customerJoinedRegEx.IsMatch(line)) { MatchCollection matches = Regex.Matches(line, customerJoinedRegEx.ToString()); foreach (Match match in matches) { foreach (TradeItemControl item in stk_MainPnl.Children) { if (item.tItem.Customer == match.Groups[1].Value) { item.CustomerJoined(); } } } } // Check if customer left else if (customerLeftRegEx.IsMatch(line)) { MatchCollection matches = Regex.Matches(line, customerLeftRegEx.ToString()); foreach (Match match in matches) { foreach (TradeItemControl item in stk_MainPnl.Children) { if (item.tItem.Customer == match.Groups[1].Value) { item.CustomerLeft(); } } } } } } } } } catch (FileNotFoundException) { dispatcherTimer.Tick -= DispatcherTimer_Tick; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
private void ClipMoni_OnClipboardContentChanged(object sender, EventArgs e) { string strClipboard = GetClipboardText(); if (strClipboard.StartsWith("@")) { bool sendCustomWhisper3 = Keyboard.IsKeyDown(Key.RightCtrl); bool sendCustomWhisper4 = Keyboard.IsKeyDown(Key.LeftCtrl); try { string message = Regex.Replace(strClipboard, @"^\@(.+?)\s+(.+)$", match => ("@To " + match.Groups[1].Value + ": " + match.Groups[2].Value)); TradeItem tItem = new TradeItem(message, false); } catch { SoundPlayer player = new SoundPlayer(Properties.Resources.error); player.Play(); return; } // Get a handle to POE. The window class and window name were obtained using the Spy++ tool. IntPtr poeHandle = FindWindow("POEWindowClass", "Path of Exile"); // Verify that POE is a running process. if (poeHandle == IntPtr.Zero) { // Show message box if POE is not running MessageBox.Show("Path of Exile is not running."); return; } InputSimulator iSim = new InputSimulator(); // Need to press ALT because the SetForegroundWindow sometimes does not work iSim.Keyboard.KeyPress(VirtualKeyCode.MENU); // Make POE the foreground application and send input SetForegroundWindow(poeHandle); Thread.Sleep(100); iSim.Keyboard.KeyPress(VirtualKeyCode.RETURN); iSim.Keyboard.TextEntry(strClipboard); iSim.Keyboard.KeyPress(VirtualKeyCode.RETURN); if (sendCustomWhisper3) { Thread.Sleep(100); iSim.Keyboard.KeyPress(VirtualKeyCode.RETURN); iSim.Keyboard.TextEntry(Settings.Default.CustomWhisper3); iSim.Keyboard.KeyPress(VirtualKeyCode.RETURN); } if (sendCustomWhisper4) { Thread.Sleep(100); iSim.Keyboard.KeyPress(VirtualKeyCode.RETURN); iSim.Keyboard.TextEntry(Settings.Default.CustomWhisper4); iSim.Keyboard.KeyPress(VirtualKeyCode.RETURN); } iSim = null; Clipboard.Clear(); } }