コード例 #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
ファイル: ChatTab.cs プロジェクト: The-Mad-Pirate/Mist
        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
ファイル: Friends.cs プロジェクト: The-Mad-Pirate/Mist
 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
ファイル: Friends.cs プロジェクト: The-Mad-Pirate/Mist
        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
ファイル: Friends.cs プロジェクト: The-Mad-Pirate/Mist
 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
ファイル: Friends.cs プロジェクト: notafraid90/Mist
 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();
                 }
             }
         }
     }));
 }