forked from BearWare/TeamTalk5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsersView.cs
More file actions
119 lines (107 loc) · 3.79 KB
/
UsersView.cs
File metadata and controls
119 lines (107 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright (c) 2005-2018, BearWare.dk
*
* Contact Information:
*
* Bjoern D. Rasmussen
* Kirketoften 5
* DK-8260 Viby J
* Denmark
* Email: contact@bearware.dk
* Phone: +45 20 20 54 59
* Web: http://www.bearware.dk
*
* This source code is part of the TeamTalk SDK owned by
* BearWare.dk. Use of this file, or its compiled unit, requires a
* TeamTalk SDK License Key issued by BearWare.dk.
*
* The TeamTalk SDK License Agreement along with its Terms and
* Conditions are outlined in the file License.txt included with the
* TeamTalk SDK distribution.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using BearWare;
namespace TeamTalkApp.NET
{
class UsersView
{
TeamTalkBase ttclient;
ListView listview;
public UsersView(TeamTalkBase tt, ListView list)
{
ttclient = tt;
listview = list;
listview.Columns.Add("ID");
listview.Columns.Add("Nickname");
listview.Columns.Add("Username");
listview.Columns.Add("Channel");
listview.Columns.Add("IP-Address");
listview.Columns.Add("StatusMsg");
listview.Columns.Add("User Type");
listview.Columns.Add("UserData");
ttclient.OnCmdUserLoggedIn += new TeamTalkBase.UserUpdate(ttclient_OnCmdUserLoggedIn);
ttclient.OnCmdUserLoggedOut += new TeamTalkBase.UserUpdate(ttclient_OnCmdUserLoggedOut);
ttclient.OnCmdUserUpdate += new TeamTalkBase.UserUpdate(ttclient_OnCmdUserUpdate);
}
int GetSelectedUser()
{
if (listview.SelectedItems.Count > 0)
return (int)listview.SelectedItems[0].Tag;
return 0;
}
ListViewItem GetUser(int userid)
{
foreach (ListViewItem item in listview.Items)
if ((int)item.Tag == userid)
return item;
return null;
}
public List<int> GetUsers()
{
List<int> users = new List<int>();
foreach (ListViewItem item in listview.Items)
users.Add((int)item.Tag);
return users;
}
void ttclient_OnCmdUserLoggedIn(User user)
{
ListViewItem item = new ListViewItem();
item.Text = user.nUserID.ToString();
item.SubItems.Add(user.szNickname);
item.SubItems.Add(user.szUsername);
string chanpath = "";
if (user.nChannelID > 0)
ttclient.GetChannelPath(user.nChannelID, ref chanpath);
item.SubItems.Add(chanpath);
item.SubItems.Add(user.szIPAddress);
item.SubItems.Add(user.szStatusMsg);
item.SubItems.Add((user.uUserType & UserType.USERTYPE_ADMIN) == UserType.USERTYPE_ADMIN ? "Admin" : "Default");
item.SubItems.Add(user.nUserData.ToString());
item.Tag = user.nUserID;
listview.Items.Add(item);
}
void ttclient_OnCmdUserLoggedOut(User user)
{
listview.Items.Remove(GetUser(user.nUserID));
}
void ttclient_OnCmdUserUpdate(User user)
{
ListViewItem item = GetUser(user.nUserID);
if (item == null)
return;
item.SubItems[1].Text = user.szNickname;
string chanpath = "";
if (user.nChannelID > 0)
ttclient.GetChannelPath(user.nChannelID, ref chanpath);
item.SubItems[3].Text = chanpath;
item.SubItems[4].Text = user.szIPAddress;
item.SubItems[5].Text = user.szStatusMsg;
}
}
}