Files
libremetaverse/libsecondlife/examples/groupmanager/frmGroupManager.cs
John Hurliman 3013742668 * Increased SIMULATOR_TIMEOUT to 30 seconds
* Converted all timers to System.Threading timers to fix problems running in services and the CF
* UDPBase now uses our own ReaderWriterLock that is more efficient, and CF compatible
* Login uses a hand-created LoginProxy object instead of dynamically building the class with reflection .Emit()
* Replaced ParameterizedThreadStart calls with class-wide variables for CF compat.
* Removed transfer timeout code (irrelevant now that uploads go through CAPS)
* Added several new Helpers methods to wrap desktop and CF conditional code
* Replaced Monitor calls with AutoResetEvent in BlockingQueue
* InventoryNodeDictionary uses generics now
* Removed final lingering piece of XML serialization
* Added CookComputing.XmlRpc.CF.dll for the CF

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1479 52acb1d6-8a22-11de-b505-999d5b087335
2007-11-06 09:26:10 +00:00

131 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using libsecondlife;
using libsecondlife.Packets;
namespace groupmanager
{
public partial class frmGroupManager : Form
{
SecondLife Client;
Dictionary<LLUUID, Group> Groups;
public frmGroupManager()
{
Client = new SecondLife();
Client.Settings.MULTIPLE_SIMS = false;
// Throttle unnecessary things down
Client.Throttle.Land = 0;
Client.Throttle.Wind = 0;
Client.Throttle.Cloud = 0;
Client.Network.OnEventQueueRunning += new NetworkManager.EventQueueRunningCallback(Network_OnEventQueueRunning);
Client.Groups.OnCurrentGroups += new GroupManager.CurrentGroupsCallback(GroupsUpdatedHandler);
InitializeComponent();
}
void Network_OnEventQueueRunning(Simulator simulator)
{
if (simulator == Client.Network.CurrentSim)
{
Console.WriteLine("Event queue connected for the primary simulator, requesting group info");
Client.Groups.RequestCurrentGroups();
}
}
void GroupsUpdatedHandler(Dictionary<LLUUID, Group> groups)
{
Groups = groups;
Invoke(new MethodInvoker(UpdateGroups));
}
void UpdateGroups()
{
lock (lstGroups)
{
lstGroups.Items.Clear();
foreach (Group group in Groups.Values)
{
Console.WriteLine(String.Format("Adding group {0} ({1})", group.Name, group.ID.ToStringHyphenated()));
lstGroups.Items.Add(group);
}
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
frmGroupManager frm = new frmGroupManager();
frm.ShowDialog();
}
private void cmdConnect_Click(object sender, EventArgs e)
{
if (cmdConnect.Text == "Connect")
{
cmdConnect.Text = "Disconnect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false;
if (Client.Network.Login(txtFirstName.Text, txtLastName.Text, txtPassword.Text, "GroupManager",
"jhurliman@metaverseindustries.com"))
{
groupBox.Enabled = true;
}
else
{
MessageBox.Show(this, "Error logging in: " + Client.Network.LoginMessage);
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
groupBox.Enabled = false;
lstGroups.Items.Clear();
}
}
else
{
Client.Network.Logout();
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
groupBox.Enabled = false;
lstGroups.Items.Clear();
}
}
private void lstGroups_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstGroups.SelectedIndex >= 0)
{
cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = true;
}
else
{
cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = false;
}
}
private void cmdInfo_Click(object sender, EventArgs e)
{
if (lstGroups.SelectedIndex >= 0 && lstGroups.Items[lstGroups.SelectedIndex].ToString() != "none")
{
Group group = (Group)lstGroups.Items[lstGroups.SelectedIndex];
frmGroupInfo frm = new frmGroupInfo(group, Client);
frm.ShowDialog();
}
}
}
}