corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using OpenMetaverse;
9 using OpenMetaverse.Packets;
10  
11 namespace groupmanager
12 {
13 public partial class frmGroupManager : Form
14 {
15 GridClient Client;
16 Dictionary<UUID, Group> Groups;
17  
18 public frmGroupManager()
19 {
20 Client = new GridClient();
21  
22 Client.Settings.MULTIPLE_SIMS = false;
23  
24 // Throttle unnecessary things down
25 Client.Throttle.Land = 0;
26 Client.Throttle.Wind = 0;
27 Client.Throttle.Cloud = 0;
28  
29 Client.Network.LoginProgress += Network_OnLogin;
30 Client.Network.EventQueueRunning += Network_OnEventQueueRunning;
31 Client.Groups.CurrentGroups += Groups_CurrentGroups;
32  
33 InitializeComponent();
34 }
35  
36 void Groups_CurrentGroups(object sender, CurrentGroupsEventArgs e)
37 {
38 Groups = e.Groups;
39  
40 Invoke(new MethodInvoker(UpdateGroups));
41 }
42  
43 private void UpdateGroups()
44 {
45 lock (lstGroups)
46 {
47 Invoke((MethodInvoker)delegate() { lstGroups.Items.Clear(); });
48  
49 foreach (Group group in Groups.Values)
50 {
51 Logger.Log(String.Format("Adding group {0} ({1})", group.Name, group.ID), Helpers.LogLevel.Info, Client);
52  
53 Invoke((MethodInvoker)delegate() { lstGroups.Items.Add(group); });
54 }
55 }
56 }
57  
58 /// <summary>
59 /// The main entry point for the application.
60 /// </summary>
61 [STAThread]
62 static void Main()
63 {
64 frmGroupManager frm = new frmGroupManager();
65 frm.ShowDialog();
66 }
67  
68 #region GUI Callbacks
69  
70 private void cmdConnect_Click(object sender, EventArgs e)
71 {
72 if (cmdConnect.Text == "Connect")
73 {
74 cmdConnect.Text = "Disconnect";
75 txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false;
76  
77 LoginParams loginParams = Client.Network.DefaultLoginParams(txtFirstName.Text, txtLastName.Text,
78 txtPassword.Text, "GroupManager", "1.0.0");
79 Client.Network.BeginLogin(loginParams);
80 }
81 else
82 {
83 Client.Network.Logout();
84 cmdConnect.Text = "Connect";
85 txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
86 groupBox.Enabled = false;
87 lstGroups.Items.Clear();
88 }
89 }
90  
91 private void lstGroups_SelectedIndexChanged(object sender, EventArgs e)
92 {
93 if (lstGroups.SelectedIndex >= 0)
94 {
95 cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = true;
96 }
97 else
98 {
99 cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = false;
100 }
101 }
102  
103 private void cmdInfo_Click(object sender, EventArgs e)
104 {
105 if (lstGroups.SelectedIndex >= 0 && lstGroups.Items[lstGroups.SelectedIndex].ToString() != "none")
106 {
107 Group group = (Group)lstGroups.Items[lstGroups.SelectedIndex];
108  
109 frmGroupInfo frm = new frmGroupInfo(group, Client);
110 frm.ShowDialog();
111 }
112 }
113  
114 #endregion GUI Callbacks
115  
116 #region Network Callbacks
117  
118 private void Network_OnLogin(object sender, LoginProgressEventArgs e)
119 {
120 if (e.Status == LoginStatus.Success)
121 {
122 BeginInvoke(
123 (MethodInvoker)delegate()
124 {
125 groupBox.Enabled = true;
126 });
127 }
128 else if (e.Status == LoginStatus.Failed)
129 {
130 BeginInvoke(
131 (MethodInvoker)delegate()
132 {
133 MessageBox.Show(this, "Error logging in: " + Client.Network.LoginMessage);
134 cmdConnect.Text = "Connect";
135 txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
136 groupBox.Enabled = false;
137 lstGroups.Items.Clear();
138 });
139 }
140 }
141  
142 private void Network_OnEventQueueRunning(object sender, EventQueueRunningEventArgs e)
143 {
144 if (e.Simulator == Client.Network.CurrentSim)
145 {
146 Console.WriteLine("Event queue connected for the primary simulator, requesting group info");
147  
148 Client.Groups.RequestCurrentGroups();
149 }
150 }
151  
152 #endregion
153 }
154 }