コード例 #1
0
 private void button_send_Click(object sender, EventArgs e)
 {
     if (text_input.Text != "")
     {
         bot.CurrentTrade.SendMessage(text_input.Text);
         text_log.AppendText(Bot.displayName + ": " + text_input.Text + " [" + DateTime.Now.ToLongTimeString() + "]\r\n");
         text_log.ScrollToCaret();
         ChatTab.AppendLog(sid, "[Trade Chat] " + Bot.displayName + ": " + text_input.Text + " [" + DateTime.Now.ToLongTimeString() + "]\r\n");
         clear();
     }
 }
コード例 #2
0
        public ShowTrade(Bot bot, string name)
        {
            InitializeComponent();
            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)
                {
                    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;
                    }
                }
            });

            checkExpired.Start();
        }
コード例 #3
0
 public void AddChat(string name, SteamKit2.SteamID steamId)
 {
     page           = new TabPage();
     page.Tag       = steamId;
     page.Text      = name;
     page.BackColor = System.Drawing.Color.White;
     chatTab        = new ChatTab(this, bot, steamId);
     chatTab.Dock   = DockStyle.Fill;
     page.Controls.Add(chatTab);
     this.ChatTabControl.TabPages.Add(page);
     this.ChatTabControl.SelectTab(page);
     this.Text = this.ChatTabControl.SelectedTab.Text + " - Chat";
 }
コード例 #4
0
 public void AddChat(string name, ulong sid)
 {
     page            = new TabPage();
     page.Text       = name;
     page.BackColor  = System.Drawing.Color.White;
     chatTab         = new ChatTab(this, bot, sid);
     chatTab.Dock    = DockStyle.Fill;
     chatTab.Padding = new Padding(3, 3, 3, 3);
     page.Controls.Add(chatTab);
     chatTab.tab = page;
     this.ChatTabControl.TabPages.Add(page);
     this.ChatTabControl.SelectTab(page);
     this.Text = this.ChatTabControl.SelectedTab.Text + " - Chat";
 }
コード例 #5
0
ファイル: Chat.cs プロジェクト: notafraid90/Mist
 public void AddChat(string name, ulong sid)
 {
     page = new TabPage();
     page.Text = name;
     page.BackColor = System.Drawing.Color.White;
     chatTab = new ChatTab(this, bot, sid);
     chatTab.Dock = DockStyle.Fill;
     chatTab.Padding = new Padding(3, 3, 3, 3);
     page.Controls.Add(chatTab);
     chatTab.tab = page;
     this.ChatTabControl.TabPages.Add(page);
     this.ChatTabControl.SelectTab(page);
     this.Text = this.ChatTabControl.SelectedTab.Text + " - Chat";
 }
コード例 #6
0
 private void text_input_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 1)
     {
         text_input.SelectAll();
     }
     if (e.KeyChar == (char)Keys.Enter)
     {
         if (text_input.Text != "")
         {
             e.Handled = true;
             bot.CurrentTrade.SendMessage(text_input.Text);
             text_log.AppendText(Bot.displayName + ": " + text_input.Text + " [" + DateTime.Now.ToLongTimeString() + "]\r\n");
             text_log.ScrollToCaret();
             ChatTab.AppendLog(sid, "[Trade Chat] " + Bot.displayName + ": " + text_input.Text + " [" + DateTime.Now.ToLongTimeString() + "]\r\n");
             clear();
         }
         else
         {
             e.Handled = true;
         }
     }
 }
コード例 #7
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();
        }