Beispiel #1
0
 public static void ClearAll()
 {
     ListInventory.Clear();
     ListUserOfferings.Clear();
     ListOtherOfferings.Clear();
 }
Beispiel #2
0
        public ShowTrade(Bot bot, string name)
        {
            InitializeComponent();
            list_inventory.CellToolTip.InitialDelay      = list_inventory.CellToolTip.ReshowDelay = 0;
            list_otherofferings.CellToolTip.InitialDelay = list_otherofferings.CellToolTip.ReshowDelay = 0;
            list_userofferings.CellToolTip.InitialDelay  = list_userofferings.CellToolTip.ReshowDelay = 0;
            list_inventory.CellToolTipGetter             = (column, modelObject) =>
            {
                if (list_inventory.SelectedItem == null)
                {
                    return(null);
                }
                var itemId = (ulong)column_id.GetValue(modelObject);
                if ((ulong)column_id.GetValue(list_inventory.SelectedItem.RowObject) != itemId)
                {
                    return(null);
                }
                if (itemId == 0)
                {
                    return(null);
                }
                bot.GetInventory();
                foreach (var item in bot.MyInventory.Items)
                {
                    if (item.Id == itemId)
                    {
                        return(GetTooltipText(item));
                    }
                }
                return(null);
            };
            list_userofferings.CellToolTipGetter = (column, modelObject) =>
            {
                if (list_userofferings.SelectedItem == null)
                {
                    return(null);
                }
                var itemId = (ulong)column_id.GetValue(modelObject);
                if ((ulong)column_id.GetValue(list_userofferings.SelectedItem.RowObject) != itemId)
                {
                    return(null);
                }
                if (itemId == 0)
                {
                    return(null);
                }
                bot.GetInventory();
                foreach (var item in bot.MyInventory.Items)
                {
                    if (item.Id == itemId)
                    {
                        return(GetTooltipText(item));
                    }
                }
                return(null);
            };
            list_otherofferings.CellToolTipGetter = (column, modelObject) =>
            {
                var itemId = (ulong)column_id.GetValue(modelObject);
                if (itemId == 0)
                {
                    return(null);
                }
                foreach (var item in ListOtherOfferings.Get())
                {
                    if (item.ItemID == itemId)
                    {
                        return(GetTooltipText(item.Item));
                    }
                }
                return(null);
            };
            list_inventory.CellToolTip.SetMaxWidth(450);
            list_otherofferings.CellToolTip.SetMaxWidth(450);
            list_userofferings.CellToolTip.SetMaxWidth(450);
            Util.LoadTheme(metroStyleManager1);
            this.Text     = "Trading with " + name;
            this.bot      = bot;
            this.sid      = bot.CurrentTrade.OtherSID;
            this.username = name;
            this.label_yourvalue.RightToLeft  = System.Windows.Forms.RightToLeft.Yes;
            this.label_othervalue.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            column_otherofferings.Text        = name + "'s Offerings:";
            ListInventory.ShowTrade           = this;
            Thread checkExpired = new Thread(() =>
            {
                while (true)
                {
                    try
                    {
                        if (loading)
                        {
                            if (!list_inventory.IsDisposed && controlLoaded)
                            {
                                Invoke((Action)(() => list_inventory.EmptyListMsg = "Loading..."));
                            }
                        }
                        else
                        {
                            if (!list_inventory.IsDisposed && controlLoaded && !this.IsDisposed)
                            {
                                Invoke((Action)(() => list_inventory.EmptyListMsg = "Empty inventory."));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    if (bot.CurrentTrade == null)
                    {
                        bot.main.Invoke((Action)(this.Close));
                        bot.log.Warn("Trade expired.");
                        if (Friends.chat_opened)
                        {
                            bot.main.Invoke((Action)(() =>
                            {
                                foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
                                {
                                    if (tab.Text == bot.SteamFriends.GetFriendPersonaName(sid))
                                    {
                                        tab.Invoke((Action)(() =>
                                        {
                                            foreach (var item in tab.Controls)
                                            {
                                                Friends.chat.chatTab = (ChatTab)item;
                                            }
                                            string result = "The trade session has closed.";
                                            bot.log.Warn(result);
                                            string date = "[" + DateTime.Now + "] ";
                                            Friends.chat.chatTab.UpdateChat("[" + DateTime.Now + "] " + result + "\r\n", false);
                                            ChatTab.AppendLog(sid, "===========[TRADE ENDED]===========\r\n");
                                        }));
                                        break;;
                                    }
                                }
                            }));
                        }
                        break;
                    }
                    Thread.Sleep(100);
                }
            });

            checkExpired.Start();
        }
Beispiel #3
0
        public static void Remove(string itemName, ulong itemID)
        {
            ListOtherOfferings item = list.Find(x => x.itemName == itemName && x.itemID == itemID);

            list.Remove(item);
        }
Beispiel #4
0
        public static void Add(string itemName, ulong itemID, string price, Inventory.Item item)
        {
            ListOtherOfferings ite = new ListOtherOfferings(itemName, itemID, price, item);

            list.Add(ite);
        }
Beispiel #5
0
        public static void Add(string itemName, ulong itemID, string price)
        {
            ListOtherOfferings item = new ListOtherOfferings(itemName, itemID, price);

            list.Add(item);
        }
 public static void Add(string itemName, ulong itemID, string price)
 {
     ListOtherOfferings item = new ListOtherOfferings(itemName, itemID, price);
     list.Add(item);
 }