this.btnIM = new System.Windows.Forms.Button();\r
this.btnProfile = new System.Windows.Forms.Button();\r
this.groupBox1 = new System.Windows.Forms.GroupBox();\r
+ this.btnPay = new System.Windows.Forms.Button();\r
this.btnOfferTeleport = new System.Windows.Forms.Button();\r
this.label1 = new System.Windows.Forms.Label();\r
this.chkSeeMeOnline = new System.Windows.Forms.CheckBox();\r
this.chkSeeMeOnMap = new System.Windows.Forms.CheckBox();\r
this.chkModifyMyObjects = new System.Windows.Forms.CheckBox();\r
this.timInitDelay = new System.Windows.Forms.Timer(this.components);\r
- this.btnPay = new System.Windows.Forms.Button();\r
+ this.btnRemove = new System.Windows.Forms.Button();\r
this.groupBox1.SuspendLayout();\r
this.SuspendLayout();\r
// \r
// \r
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
| System.Windows.Forms.AnchorStyles.Right)));\r
+ this.groupBox1.Controls.Add(this.btnRemove);\r
this.groupBox1.Controls.Add(this.btnPay);\r
this.groupBox1.Controls.Add(this.btnOfferTeleport);\r
this.groupBox1.Controls.Add(this.lblFriendName);\r
this.groupBox1.TabIndex = 4;\r
this.groupBox1.TabStop = false;\r
// \r
+ // btnPay\r
+ // \r
+ this.btnPay.Enabled = false;\r
+ this.btnPay.Location = new System.Drawing.Point(286, 46);\r
+ this.btnPay.Name = "btnPay";\r
+ this.btnPay.Size = new System.Drawing.Size(75, 23);\r
+ this.btnPay.TabIndex = 5;\r
+ this.btnPay.Text = "Pay...";\r
+ this.btnPay.UseVisualStyleBackColor = true;\r
+ this.btnPay.Click += new System.EventHandler(this.btnPay_Click);\r
+ // \r
// btnOfferTeleport\r
// \r
this.btnOfferTeleport.Enabled = false;\r
this.timInitDelay.Interval = 3000;\r
this.timInitDelay.Tick += new System.EventHandler(this.timInitDelay_Tick);\r
// \r
- // btnPay\r
+ // btnRemove\r
// \r
- this.btnPay.Enabled = false;\r
- this.btnPay.Location = new System.Drawing.Point(286, 46);\r
- this.btnPay.Name = "btnPay";\r
- this.btnPay.Size = new System.Drawing.Size(75, 23);\r
- this.btnPay.TabIndex = 5;\r
- this.btnPay.Text = "Pay...";\r
- this.btnPay.UseVisualStyleBackColor = true;\r
- this.btnPay.Click += new System.EventHandler(this.btnPay_Click);\r
+ this.btnRemove.Enabled = false;\r
+ this.btnRemove.Location = new System.Drawing.Point(367, 46);\r
+ this.btnRemove.Name = "btnRemove";\r
+ this.btnRemove.Size = new System.Drawing.Size(75, 23);\r
+ this.btnRemove.TabIndex = 6;\r
+ this.btnRemove.Text = "Remove";\r
+ this.btnRemove.UseVisualStyleBackColor = true;\r
+ this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);\r
// \r
// FriendsConsole\r
// \r
private System.Windows.Forms.Button btnOfferTeleport;\r
private System.Windows.Forms.Timer timInitDelay;\r
private System.Windows.Forms.Button btnPay;\r
+ private System.Windows.Forms.Button btnRemove;\r
}\r
}\r
using System.Collections.Generic;\r
using System.Drawing;\r
using System.Windows.Forms;\r
+using System.Threading;\r
using OpenMetaverse;\r
\r
namespace Radegast\r
// Callbacks\r
client.Friends.OnFriendOffline += new FriendsManager.FriendOfflineEvent(Friends_OnFriendOffline);\r
client.Friends.OnFriendOnline += new FriendsManager.FriendOnlineEvent(Friends_OnFriendOnline);\r
+ client.Friends.OnFriendshipTerminated += new FriendsManager.FriendshipTerminatedEvent(Friends_OnFriendshipTerminated);\r
\r
}\r
\r
{\r
client.Friends.OnFriendOffline -= new FriendsManager.FriendOfflineEvent(Friends_OnFriendOffline);\r
client.Friends.OnFriendOnline -= new FriendsManager.FriendOnlineEvent(Friends_OnFriendOnline);\r
+ client.Friends.OnFriendshipTerminated -= new FriendsManager.FriendshipTerminatedEvent(Friends_OnFriendshipTerminated);\r
}\r
\r
private void InitializeFriendsList()\r
List<FriendInfo> friends = client.Friends.FriendList.FindAll(delegate(FriendInfo f) { return true; });\r
\r
lbxFriends.BeginUpdate();\r
-\r
+ lbxFriends.Items.Clear();\r
foreach (FriendInfo friend in friends)\r
lbxFriends.Items.Add(new FriendsListItem(friend));\r
\r
\r
private void RefreshFriendsList()\r
{\r
- lbxFriends.Refresh();\r
+ InitializeFriendsList();\r
SetFriend(selectedFriend);\r
}\r
\r
- //Separate thread\r
private void Friends_OnFriendOffline(FriendInfo friend)\r
{\r
- BeginInvoke(new MethodInvoker(RefreshFriendsList));\r
+ if (InvokeRequired)\r
+ {\r
+ BeginInvoke(new MethodInvoker(() => Friends_OnFriendOffline(friend)));\r
+ return;\r
+ }\r
+\r
+ instance.MainForm.TabConsole.DisplayNotificationInChat(friend.Name + " is offline");\r
+ RefreshFriendsList();\r
}\r
\r
- //Separate thread\r
private void Friends_OnFriendOnline(FriendInfo friend)\r
{\r
- BeginInvoke(new MethodInvoker(RefreshFriendsList));\r
+ if (InvokeRequired)\r
+ {\r
+ BeginInvoke(new MethodInvoker(() => Friends_OnFriendOnline(friend)));\r
+ return;\r
+ }\r
+\r
+ instance.MainForm.TabConsole.DisplayNotificationInChat(friend.Name + " is online");\r
+ RefreshFriendsList();\r
+ }\r
+\r
+ void Friends_OnFriendshipTerminated(UUID agentID, string agentName)\r
+ {\r
+ if (agentName == string.Empty)\r
+ {\r
+ using (ManualResetEvent done = new ManualResetEvent(false))\r
+ {\r
+\r
+ AvatarManager.AvatarNamesCallback callback = delegate(Dictionary<UUID, string> names)\r
+ {\r
+ if (names.ContainsKey(agentID))\r
+ {\r
+ agentName = names[agentID];\r
+ done.Set();\r
+ }\r
+ };\r
+\r
+ client.Avatars.OnAvatarNames += callback;\r
+ agentName = instance.getAvatarName(agentID);\r
+ if (agentName == RadegastInstance.INCOMPLETE_NAME)\r
+ {\r
+ done.WaitOne(3000, false);\r
+ }\r
+ client.Avatars.OnAvatarNames -= callback;\r
+ }\r
+ }\r
+\r
+ if (InvokeRequired)\r
+ {\r
+ BeginInvoke(new MethodInvoker(() => Friends_OnFriendshipTerminated(agentID, agentName)));\r
+ return;\r
+ }\r
+\r
+ instance.MainForm.TabConsole.DisplayNotificationInChat(agentName + " is no longer on your friend list");\r
+ RefreshFriendsList();\r
}\r
\r
private void SetFriend(FriendInfo friend)\r
\r
lblFriendName.Text = friend.Name + (friend.IsOnline ? " (online)" : " (offline)");\r
\r
- btnIM.Enabled = btnProfile.Enabled = btnOfferTeleport.Enabled = btnPay.Enabled = true;\r
+ btnIM.Enabled = btnProfile.Enabled = btnOfferTeleport.Enabled = btnPay.Enabled = btnRemove.Enabled = true;\r
chkSeeMeOnline.Enabled = chkSeeMeOnMap.Enabled = chkModifyMyObjects.Enabled = true;\r
chkSeeMeOnMap.Enabled = friend.CanSeeMeOnline;\r
\r
FriendsListItem itemToDraw = (FriendsListItem)lbxFriends.Items[e.Index];\r
Brush textBrush = null;\r
Font textFont = null;\r
- \r
+\r
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)\r
{\r
textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText));\r
e.Graphics.DrawImage(Properties.Resources.GreenOrb_16, e.Bounds.Left + 2, e.Bounds.Top + 2);\r
else\r
e.Graphics.DrawImage(Properties.Resources.GreenOrbFaded_16, e.Bounds.Left + 2, e.Bounds.Top + 2);\r
- \r
+\r
e.Graphics.DrawString(itemToDraw.Friend.Name, textFont, textBrush, stringX, stringY);\r
\r
e.DrawFocusRectangle();\r
if (settingFriend) return;\r
\r
selectedFriend.CanSeeMeOnline = chkSeeMeOnline.Checked;\r
- client.Friends.GrantRights(selectedFriend.UUID, FriendRights.CanSeeOnline);\r
-\r
- chkSeeMeOnMap.Enabled = chkSeeMeOnline.Checked;\r
+ client.Friends.GrantRights(selectedFriend.UUID, selectedFriend.TheirFriendRights);\r
}\r
\r
private void chkSeeMeOnMap_CheckedChanged(object sender, EventArgs e)\r
if (settingFriend) return;\r
\r
selectedFriend.CanSeeMeOnMap = chkSeeMeOnMap.Checked;\r
- // client.Friends.GrantRights(selectedFriend.UUID);\r
+ client.Friends.GrantRights(selectedFriend.UUID, selectedFriend.TheirFriendRights);\r
}\r
\r
private void chkModifyMyObjects_CheckedChanged(object sender, EventArgs e)\r
if (settingFriend) return;\r
\r
selectedFriend.CanModifyMyObjects = chkModifyMyObjects.Checked;\r
- // client.Friends.GrantRights(selectedFriend.UUID);\r
+ client.Friends.GrantRights(selectedFriend.UUID, selectedFriend.TheirFriendRights);\r
}\r
\r
private void btnOfferTeleport_Click(object sender, EventArgs e)\r
{\r
(new frmPay(instance, selectedFriend.UUID, selectedFriend.Name, false)).ShowDialog();\r
}\r
+\r
+ private void btnRemove_Click(object sender, EventArgs e)\r
+ {\r
+ client.Friends.TerminateFriendship(selectedFriend.UUID);\r
+ if (lbxFriends.Items.Count > 0)\r
+ {\r
+ lbxFriends.SelectedIndex = 0;\r
+ }\r
+ }\r
}\r
}\r