示例#1
0
文件: ChatTab.cs 项目: Jamyn/Mist
        public ChatTab(Chat chat, Bot bot, ulong sid)
        {
            InitializeComponent();
            this.Chat = chat;
            this.sid = sid;
            this.bot = bot;
            this.steam_name.Text = bot.SteamFriends.GetFriendPersonaName(sid);
            this.steam_status.Text = bot.SteamFriends.GetFriendPersonaState(sid).ToString();
            this.chat_status.Text = "";
            SteamKit2.SteamID SteamID = sid;
            byte[] avatarHash = bot.SteamFriends.GetFriendAvatar(SteamID);
            bool validHash = avatarHash != null && !IsZeros(avatarHash);

            if ((AvatarHash == null && !validHash && avatarBox.Image != null) || (AvatarHash != null && AvatarHash.SequenceEqual(avatarHash)))
            {
                // avatar is already up to date, no operations necessary
            }
            else if (validHash)
            {
                AvatarHash = avatarHash;
                CDNCache.DownloadAvatar(SteamID, avatarHash, AvatarDownloaded);
            }
            else
            {
                AvatarHash = null;
                avatarBox.Image = ComposeAvatar(null);
            }
        }
示例#2
0
        public ChatTab(Chat chat, Bot bot, ulong sid)
        {
            InitializeComponent();
            this.Chat = chat;
            this.userSteamId = sid;
            this.bot = bot;
            this.StyleManager.OnThemeChanged += metroStyleManager1_OnThemeChanged;
            this.StyleManager.Theme = Friends.GlobalStyleManager.Theme;
            this.StyleManager.Style = Friends.GlobalStyleManager.Style;
            Util.LoadTheme(null, this.Controls, this);
            this.Theme = Friends.GlobalStyleManager.Theme;
            this.StyleManager.Style = Friends.GlobalStyleManager.Style;
            metroStyleManager1_OnThemeChanged(null, EventArgs.Empty);
            try
            {
                this.steam_name.Text = prevName = bot.SteamFriends.GetFriendPersonaName(sid);
                this.steam_status.Text = prevStatus = bot.SteamFriends.GetFriendPersonaState(sid).ToString();
            }
            catch
            {

            }
            this.chat_status.Text = "";
            SteamKit2.SteamID SteamID = sid;
            try
            {
                byte[] avatarHash = bot.SteamFriends.GetFriendAvatar(SteamID);
                bool validHash = avatarHash != null && !IsZeros(avatarHash);

                if ((AvatarHash == null && !validHash && avatarBox.Image != null) || (AvatarHash != null && AvatarHash.SequenceEqual(avatarHash)))
                {
                    // avatar is already up to date, no operations necessary
                }
                else if (validHash)
                {
                    AvatarHash = avatarHash;
                    CDNCache.DownloadAvatar(SteamID, avatarHash, AvatarDownloaded);
                }
                else
                {
                    AvatarHash = null;
                    avatarBox.Image = ComposeAvatar(null);
                }
            }
            catch
            {

            }
            new System.Threading.Thread(GetChatLog).Start();
            status_update.RunWorkerAsync();
            text_input.Focus();
        }
示例#3
0
 private void openChatToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bot.main.Invoke((Action)(() =>
     {
         SteamID steamId = new SteamID(contextMenuSteamId);
         string selected = bot.SteamFriends.GetFriendPersonaName(contextMenuSteamId);
         if (!chat_opened)
         {
             chat = new Chat(bot);
             chat.AddChat(selected, contextMenuSteamId);
             chat.Show();
             chat.Focus();
             chat_opened = true;
         }
         else
         {
             bool found = false;
             foreach (TabPage tab in chat.ChatTabControl.TabPages)
             {
                 if ((SteamID)tab.Tag == steamId)
                 {
                     chat.ChatTabControl.SelectedTab = tab;
                     chat.Focus();
                     found = true;
                 }
             }
             if (!found)
             {
                 chat.AddChat(selected, contextMenuSteamId);
                 chat.Focus();
             }
         }
     }));
 }
示例#4
0
        void OpenChatHandler(object sender, JavascriptMethodEventArgs e)
        {
            try
            {
                bot.main.Invoke((Action)(() =>
                {
                    ulong steamId = Convert.ToUInt64(e.Arguments[0].ToString());
                    string selected = bot.SteamFriends.GetFriendPersonaName(steamId);
                    if (!chat_opened)
                    {
                        chat = new Chat(bot);
                        chat.AddChat(selected, steamId);
                        chat.Show();
                        chat.Activate();
                        chat_opened = true;
                    }
                    else
                    {
                        bool found = false;
                        foreach (TabPage tab in chat.ChatTabControl.TabPages)
                        {
                            if ((SteamID)tab.Tag == new SteamID(steamId))
                            {
                                chat.ChatTabControl.SelectedTab = tab;
                                chat.Activate();
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            chat.AddChat(selected, steamId);
                            chat.Activate();
                        }
                    }
                }));
            }
            catch
            {

            }
        }
示例#5
0
 private void inviteToTradeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bot.main.Invoke((Action)(() =>
     {
         string selected = bot.SteamFriends.GetFriendPersonaName(contextMenuSteamId);
         if (!chat_opened)
         {
             chat = new Chat(bot);
             chat.AddChat(selected, contextMenuSteamId);
             chat.Show();
             chat.Focus();
             chat_opened = true;
             chat.chatTab.tradeClicked();
         }
         else
         {
             bool found = false;
             foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
             {
                 if ((SteamID)tab.Tag == new SteamID(contextMenuSteamId))
                 {
                     found = true;
                     tab.Invoke((Action)(() =>
                     {
                         foreach (var item in tab.Controls)
                         {
                             chat.chatTab = (ChatTab)item;
                             chat.chatTab.tradeClicked();
                         }
                     }));
                     return;
                 }
             }
             if (!found)
             {
                 chat.AddChat(selected, contextMenuSteamId);
                 chat.Focus();
                 chat.chatTab.tradeClicked();
             }
         }
     }));
 }
示例#6
0
 private void openChatToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bot.main.Invoke((Action)(() =>
     {
         if (friends_list.SelectedItem != null)
         {
             ulong sid = Convert.ToUInt64(column_sid.GetValue(friends_list.SelectedItem.RowObject));
             string selected = bot.SteamFriends.GetFriendPersonaName(sid);
             if (!chat_opened)
             {
                 chat = new Chat(bot);
                 chat.AddChat(selected, sid);
                 chat.Show();
                 chat.Focus();
                 chat_opened = true;
             }
             else
             {
                 bool found = false;
                 foreach (TabPage tab in chat.ChatTabControl.TabPages)
                 {
                     if (tab.Text == selected)
                     {
                         chat.ChatTabControl.SelectedTab = tab;
                         chat.Focus();
                         found = true;
                     }
                 }
                 if (!found)
                 {
                     chat.AddChat(selected, sid);
                     chat.Focus();
                 }
             }
         }
     }));
 }
示例#7
0
文件: Friends.cs 项目: Jamyn/Mist
 private void inviteToTradeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bot.main.Invoke((Action)(() =>
     {
         ulong sid = Convert.ToUInt64(column_sid.GetValue(friends_list.SelectedItem.RowObject));
         string selected = bot.SteamFriends.GetFriendPersonaName(sid);
         if (!chat_opened)
         {
             chat = new Chat(bot);
             chat.AddChat(selected, sid);
             chat.Show();
             chat.Focus();
             chat_opened = true;
             chat.chatTab.tradeClicked();
         }
         else
         {
             bool found = false;
             foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
             {
                 if (tab.Text == selected)
                 {
                     found = true;
                     tab.Invoke((Action)(() =>
                     {
                         foreach (var item in tab.Controls)
                         {
                             chat.chatTab = (ChatTab) item;
                             chat.chatTab.tradeClicked();
                         }
                     }));
                     return;
                 }
             }
             if (!found)
             {
                 chat.AddChat(selected, sid);
                 chat.Focus();
                 chat.chatTab.tradeClicked();
             }
         }
     }));
 }
示例#8
0
文件: Friends.cs 项目: Jamyn/Mist
 private void friends_list_ItemActivate(object sender, EventArgs e)
 {
     bot.main.Invoke((Action)(() =>
     {
         string selected = "";
         try
         {
             selected = friends_list.SelectedItem.Text;
         }
         catch
         {
             selected = null;
         }
         if (selected != null)
         {
             ulong sid = ListFriends.GetSID(selected);
             if (!chat_opened)
             {
                 chat = new Chat(bot);
                 chat.AddChat(selected, sid);
                 chat.Show();
                 chat.Activate();
                 chat_opened = true;
             }
             else
             {
                 bool found = false;
                 foreach (TabPage tab in chat.ChatTabControl.TabPages)
                 {
                     if (tab.Text == selected)
                     {
                         chat.ChatTabControl.SelectedTab = tab;
                         chat.Activate();
                         found = true;
                     }
                 }
                 if (!found)
                 {
                     chat.AddChat(selected, sid);
                     chat.Activate();
                 }
             }
         }
     }));
 }