corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using OpenMetaverse; |
2 | using OpenMetaverse.GUI; |
||
3 | using System; |
||
4 | using System.Collections.Generic; |
||
5 | using System.Drawing; |
||
6 | using System.Reflection; |
||
7 | using System.Windows.Forms; |
||
8 | |||
9 | namespace Dashboard |
||
10 | { |
||
11 | public partial class Dashboard : Form |
||
12 | { |
||
13 | |||
14 | GridClient Client; |
||
15 | LoginParams ClientLogin; |
||
16 | bool ShuttingDown = false; |
||
17 | |||
18 | /// <summary> |
||
19 | /// Provides a full representation of OpenMetaverse.GUI |
||
20 | /// </summary> |
||
21 | /// <param name="firstName"></param> |
||
22 | /// <param name="lastName"></param> |
||
23 | /// <param name="password"></param> |
||
24 | public Dashboard(string firstName, string lastName, string password) |
||
25 | { |
||
26 | InitializeComponent(); |
||
27 | |||
28 | //force logout and exit when form is closed |
||
29 | this.FormClosing += new FormClosingEventHandler(Dashboard_FormClosing); |
||
30 | |||
31 | //initialize the client object and related controls |
||
32 | InitializeClient(true); |
||
33 | |||
34 | //double-click events |
||
35 | avatarList1.OnAvatarDoubleClick += new AvatarList.AvatarCallback(avatarList1_OnAvatarDoubleClick); |
||
36 | friendsList1.OnFriendDoubleClick += new FriendList.FriendDoubleClickCallback(friendsList1_OnFriendDoubleClick); |
||
37 | groupList1.OnGroupDoubleClick += new GroupList.GroupDoubleClickCallback(groupList1_OnGroupDoubleClick); |
||
38 | |||
39 | //login |
||
40 | ClientLogin = Client.Network.DefaultLoginParams(firstName, lastName, password, "OpenMetaverse Dashboard", Assembly.GetExecutingAssembly().GetName().Version.ToString()); |
||
41 | loginPanel1.LoginParams = ClientLogin; |
||
42 | |||
43 | ClientLogin.Start = "last"; |
||
44 | |||
45 | if (firstName != String.Empty && lastName != String.Empty && password != String.Empty) |
||
46 | Client.Network.BeginLogin(ClientLogin); |
||
47 | } |
||
48 | |||
49 | private void InitializeClient(bool initialize) |
||
50 | { |
||
51 | if (Client != null) |
||
52 | { |
||
53 | if (Client.Network.Connected) |
||
54 | Client.Network.Logout(); |
||
55 | |||
56 | Client = null; |
||
57 | } |
||
58 | |||
59 | if (!initialize) return; |
||
60 | |||
61 | //initialize client object |
||
62 | Client = new GridClient(); |
||
63 | Client.Settings.USE_LLSD_LOGIN = true; |
||
64 | Client.Settings.USE_ASSET_CACHE = true; |
||
65 | |||
66 | Client.Network.Disconnected += Network_OnDisconnected; |
||
67 | Client.Self.IM += Self_IM; |
||
68 | |||
69 | //define the client object for each GUI element |
||
70 | avatarList1.Client = Client; |
||
71 | friendsList1.Client = Client; |
||
72 | groupList1.Client = Client; |
||
73 | inventoryTree1.Client = Client; |
||
74 | localChat1.Client = Client; |
||
75 | loginPanel1.Client = Client; |
||
76 | messageBar1.Client = Client; |
||
77 | miniMap1.Client = Client; |
||
78 | statusOutput1.Client = Client; |
||
79 | } |
||
80 | |||
81 | void Self_IM(object sender, InstantMessageEventArgs e) |
||
82 | { |
||
83 | if (e.IM.Dialog == InstantMessageDialog.RequestTeleport) |
||
84 | { |
||
85 | this.BeginInvoke((MethodInvoker)delegate |
||
86 | { |
||
87 | DialogResult result = MessageBox.Show(this, e.IM.FromAgentName + " has offered you a teleport request:" + Environment.NewLine + e.IM.Message, this.Text, MessageBoxButtons.YesNo); |
||
88 | if (result == DialogResult.Yes) |
||
89 | Client.Self.TeleportLureRespond(e.IM.FromAgentID, e.IM.IMSessionID, true); |
||
90 | }); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | void Dashboard_FormClosing(object sender, FormClosingEventArgs e) |
||
95 | { |
||
96 | ShuttingDown = true; |
||
97 | InitializeClient(false); |
||
98 | Environment.Exit(0); |
||
99 | } |
||
100 | |||
101 | void avatarList1_OnAvatarDoubleClick(TrackedAvatar trackedAvatar) |
||
102 | { |
||
103 | messageBar1.CreateSession(trackedAvatar.Name, trackedAvatar.ID, trackedAvatar.ID, true); |
||
104 | } |
||
105 | |||
106 | void friendsList1_OnFriendDoubleClick(FriendInfo friend) |
||
107 | { |
||
108 | messageBar1.CreateSession(friend.Name, friend.UUID, friend.UUID, true); |
||
109 | } |
||
110 | |||
111 | void groupList1_OnGroupDoubleClick(Group group) |
||
112 | { |
||
113 | MessageBox.Show(group.Name + " = " + group.ID); |
||
114 | } |
||
115 | |||
116 | void Network_OnDisconnected(object sender, DisconnectedEventArgs e) |
||
117 | { |
||
118 | InitializeClient(!ShuttingDown); |
||
119 | } |
||
120 | } |
||
121 | } |