Пример #1
0
        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);
        }
Пример #2
0
 private void RemoveItem()
 {
     ((StackPanel)Parent).Children.Remove(this);
     stashGridHighlight.RemoveStashControl(tItem);
     TradeItemControl.RemoveTICfromList(this);
     TradeItem.RemoveItemFromList(tItem);
     stashGridHighlight.ClearCanvas();
 }
Пример #3
0
        public static void RemoveTICfromList(TradeItemControl tradeItemControl)
        {
            intNumberItems--;

            if (intNumberItems == 3)
            {
                OnEqualThreeItems();
            }
        }
Пример #4
0
        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
            {
            }
        }
Пример #5
0
        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);
            }
        }