OSDN Git Service

loggign chat
[radegast/radegast.git] / Radegast / GUI / Dialogs / MainForm.cs
1 // \r
2 // Radegast Metaverse Client\r
3 // Copyright (c) 2009, Radegast Development Team\r
4 // All rights reserved.\r
5 // \r
6 // Redistribution and use in source and binary forms, with or without\r
7 // modification, are permitted provided that the following conditions are met:\r
8 // \r
9 //     * Redistributions of source code must retain the above copyright notice,\r
10 //       this list of conditions and the following disclaimer.\r
11 //     * Redistributions in binary form must reproduce the above copyright\r
12 //       notice, this list of conditions and the following disclaimer in the\r
13 //       documentation and/or other materials provided with the distribution.\r
14 //     * Neither the name of the application "Radegast", nor the names of its\r
15 //       contributors may be used to endorse or promote products derived from\r
16 //       this software without specific prior written permission.\r
17 // \r
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 //\r
29 // $Id$\r
30 //\r
31 using System;\r
32 using System.Collections.Generic;\r
33 using System.ComponentModel;\r
34 using System.Configuration;\r
35 using System.Data;\r
36 using System.Drawing;\r
37 using System.Text;\r
38 using System.Text.RegularExpressions;\r
39 using System.Timers;\r
40 using System.Windows.Forms;\r
41 using System.Resources;\r
42 using System.IO;\r
43 using RadegastNc;\r
44 using OpenMetaverse;\r
45 using OpenMetaverse.Imaging;\r
46 \r
47 namespace Radegast\r
48 {\r
49     public partial class frmMain : Form\r
50     {\r
51         #region Public members\r
52         public static ImageList ResourceImages = new ImageList();\r
53         public static List<string> ImageNames = new List<string>();\r
54         public frmMap worldMap;\r
55         public TabsConsole TabConsole\r
56         {\r
57             get { return tabsConsole; }\r
58         }\r
59         #endregion\r
60 \r
61         #region Private members\r
62         private RadegastInstance instance;\r
63         private RadegastNetcom netcom;\r
64         private GridClient client;\r
65         private TabsConsole tabsConsole;\r
66         private frmDebugLog debugLogForm;\r
67         private System.Timers.Timer statusTimer;\r
68         private AutoPilot ap;\r
69         private bool AutoPilotActive = false;\r
70         private TransparentButton btnDialogNextControl;\r
71         #endregion\r
72 \r
73         #region Constructor and disposal\r
74         public frmMain(RadegastInstance instance)\r
75         {\r
76             InitializeComponent();\r
77             Disposed += new EventHandler(frmMain_Disposed);\r
78 \r
79             this.instance = instance;\r
80             client = this.instance.Client;\r
81             netcom = this.instance.Netcom;\r
82             netcom.NetcomSync = this;\r
83 \r
84             pnlDialog.Visible = false;\r
85             btnDialogNextControl = new TransparentButton();\r
86             pnlDialog.Controls.Add(btnDialogNextControl);\r
87 \r
88             btnDialogNextControl.Size = new Size(35, 20);\r
89             btnDialogNextControl.BackColor = Color.Transparent;\r
90             btnDialogNextControl.ForeColor = Color.Gold;\r
91             btnDialogNextControl.FlatAppearance.BorderSize = 0;\r
92             btnDialogNextControl.FlatStyle = FlatStyle.Flat;\r
93             btnDialogNextControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;\r
94             btnDialogNextControl.Text = ">>";\r
95             btnDialogNextControl.Font = new Font(btnDialogNextControl.Font, FontStyle.Bold);\r
96             btnDialogNextControl.Margin = new Padding(0);\r
97             btnDialogNextControl.Padding = new Padding(0);\r
98             btnDialogNextControl.UseVisualStyleBackColor = false;\r
99             btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;\r
100             btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;\r
101             btnDialogNextControl.Click += new EventHandler(btnDialogNextControl_Click);\r
102 \r
103             if (instance.MonoRuntime)\r
104             {\r
105                 statusStrip1.LayoutStyle = ToolStripLayoutStyle.Table;\r
106             }\r
107 \r
108             // Callbacks\r
109             netcom.ClientLoginStatus += new EventHandler<ClientLoginEventArgs>(netcom_ClientLoginStatus);\r
110             netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);\r
111             netcom.ClientDisconnected += new EventHandler<ClientDisconnectEventArgs>(netcom_ClientDisconnected);\r
112             client.Parcels.OnParcelProperties += new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties);\r
113             client.Self.OnMoneyBalanceReplyReceived += new AgentManager.MoneyBalanceReplyCallback(Self_OnMoneyBalanceReplyReceived);\r
114             \r
115             InitializeStatusTimer();\r
116             RefreshWindowTitle();\r
117 \r
118             ApplyConfig(this.instance.Config.CurrentConfig, true);\r
119             this.instance.Config.ConfigApplied += new EventHandler<ConfigAppliedEventArgs>(Config_ConfigApplied);\r
120         }\r
121 \r
122         void frmMain_Disposed(object sender, EventArgs e)\r
123         {\r
124             netcom.ClientLoginStatus -= new EventHandler<ClientLoginEventArgs>(netcom_ClientLoginStatus);\r
125             netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);\r
126             netcom.ClientDisconnected -= new EventHandler<ClientDisconnectEventArgs>(netcom_ClientDisconnected);\r
127             client.Parcels.OnParcelProperties -= new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties);\r
128             client.Self.OnMoneyBalanceReplyReceived -= new AgentManager.MoneyBalanceReplyCallback(Self_OnMoneyBalanceReplyReceived);\r
129 \r
130             this.instance.Config.ConfigApplied -= new EventHandler<ConfigAppliedEventArgs>(Config_ConfigApplied);\r
131             this.instance.CleanUp();\r
132         }\r
133         #endregion\r
134 \r
135         #region Event handlers\r
136         void Self_OnMoneyBalanceReplyReceived(UUID transactionID, bool transactionSuccess, int balance, int metersCredit, int metersCommitted, string description)\r
137         {\r
138             if (!String.IsNullOrEmpty(description))\r
139             {\r
140                 AddNotification(new ntfGeneric(instance, description));\r
141             }\r
142         }\r
143 \r
144         private void Config_ConfigApplied(object sender, ConfigAppliedEventArgs e)\r
145         {\r
146             ApplyConfig(e.AppliedConfig, false);\r
147         }\r
148 \r
149         private void ApplyConfig(Config config, bool doingInit)\r
150         {\r
151             if (doingInit)\r
152                 this.WindowState = (FormWindowState)config.MainWindowState;\r
153 \r
154             if (config.InterfaceStyle == 0) //System\r
155                 toolStrip1.RenderMode = ToolStripRenderMode.System;\r
156             else if (config.InterfaceStyle == 1) //Office 2003\r
157                 toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode;\r
158             aLICEToolStripMenuItem.Checked = config.UseAlice;\r
159         }\r
160 \r
161         public void InitializeControls()\r
162         {\r
163             InitializeTabsConsole();\r
164             InitializeDebugLogForm();\r
165         }\r
166 \r
167         private void netcom_ClientLoginStatus(object sender, ClientLoginEventArgs e)\r
168         {\r
169             if (e.Status != LoginStatus.Success) return;\r
170 \r
171             tbnObjects.Enabled = tbtnStatus.Enabled = tbtnControl.Enabled = tbnTeleprotMulti.Enabled = tmnuImport.Enabled = true;\r
172             statusTimer.Start();\r
173             RefreshWindowTitle();\r
174         }\r
175 \r
176         private void netcom_ClientLoggedOut(object sender, EventArgs e)\r
177         {\r
178             tbnObjects.Enabled = tbtnStatus.Enabled = tbtnControl.Enabled = tbnTeleprotMulti.Enabled = tmnuImport.Enabled = false;\r
179 \r
180             statusTimer.Stop();\r
181 \r
182             RefreshStatusBar();\r
183             RefreshWindowTitle();\r
184         }\r
185 \r
186         private void netcom_ClientDisconnected(object sender, ClientDisconnectEventArgs e)\r
187         {\r
188             if (e.Type == NetworkManager.DisconnectType.ClientInitiated) return;\r
189 \r
190             tbnObjects.Enabled = tbtnStatus.Enabled = tbtnControl.Enabled = tbnTeleprotMulti.Enabled = false;\r
191 \r
192             statusTimer.Stop();\r
193 \r
194             RefreshStatusBar();\r
195             RefreshWindowTitle();\r
196         }\r
197 \r
198         private void frmMain_FormClosing(object sender, FormClosingEventArgs e)\r
199         {\r
200             if (debugLogForm != null) {\r
201                 debugLogForm.Close();\r
202                 debugLogForm = null;\r
203             };\r
204 \r
205             if (worldMap != null)\r
206             {\r
207                 worldMap.Close();\r
208                 worldMap = null;\r
209             }\r
210 \r
211             if (netcom.IsLoggedIn) netcom.Logout();\r
212 \r
213             instance.Config.CurrentConfig.MainWindowState = (int)this.WindowState;\r
214         }\r
215         #endregion\r
216 \r
217         # region Update status\r
218 \r
219         private void Parcels_OnParcelProperties(Simulator simulator, Parcel parcel, ParcelResult result, int selectedPrims,\r
220     int sequenceID, bool snapSelection)\r
221         {\r
222             if (result != ParcelResult.Single) return;\r
223             if (InvokeRequired)\r
224             {\r
225                 BeginInvoke(new MethodInvoker(delegate()\r
226                 {\r
227                     Parcels_OnParcelProperties(simulator, parcel, result, selectedPrims, sequenceID, snapSelection);\r
228                 }\r
229                 ));\r
230                 return;\r
231             }\r
232 \r
233             tlblParcel.Text = parcel.Name;\r
234             tlblParcel.ToolTipText = parcel.Desc;\r
235 \r
236             if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)\r
237                 icoNoFly.Visible = true;\r
238             else\r
239                 icoNoFly.Visible = false;\r
240 \r
241             if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)\r
242                 icoNoBuild.Visible = true;\r
243             else\r
244                 icoNoBuild.Visible = false;\r
245 \r
246             if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)\r
247                 icoNoScript.Visible = true;\r
248             else\r
249                 icoNoScript.Visible = false;\r
250 \r
251             if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)\r
252                 icoNoPush.Visible = true;\r
253             else\r
254                 icoNoPush.Visible = false;\r
255 \r
256             if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)\r
257                 icoHealth.Visible = true;\r
258             else\r
259                 icoHealth.Visible = false;\r
260 \r
261             if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)\r
262                 icoNoVoice.Visible = true;\r
263             else\r
264                 icoNoVoice.Visible = false;\r
265         }\r
266 \r
267         private void RefreshStatusBar()\r
268         {\r
269             if (netcom.IsLoggedIn)\r
270             {\r
271                 tlblLoginName.Text = netcom.LoginOptions.FullName;\r
272                 tlblMoneyBalance.Text = client.Self.Balance.ToString();\r
273                 icoHealth.Text = client.Self.Health.ToString() + "%";\r
274 \r
275                 tlblRegionInfo.Text =\r
276                     client.Network.CurrentSim.Name +\r
277                     " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +\r
278                     Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +\r
279                     Math.Floor(client.Self.SimPosition.Z).ToString() + ")";\r
280             }\r
281             else\r
282             {\r
283                 tlblLoginName.Text = "Offline";\r
284                 tlblMoneyBalance.Text = "0";\r
285                 icoHealth.Text = "0%";\r
286                 tlblRegionInfo.Text = "No Region";\r
287                 tlblParcel.Text = "No Parcel";\r
288 \r
289                 icoHealth.Visible = false;\r
290                 icoNoBuild.Visible = false;\r
291                 icoNoFly.Visible = false;\r
292                 icoNoPush.Visible = false;\r
293                 icoNoScript.Visible = false;\r
294                 icoNoVoice.Visible = false;\r
295             }\r
296         }\r
297 \r
298         private void RefreshWindowTitle()\r
299         {\r
300             StringBuilder sb = new StringBuilder();\r
301             sb.Append("Radegast - ");\r
302 \r
303             if (netcom.IsLoggedIn)\r
304             {\r
305                 sb.Append("[" + netcom.LoginOptions.FullName + "]");\r
306 \r
307                 if (instance.State.IsAway)\r
308                 {\r
309                     sb.Append(" - Away");\r
310                     if (instance.State.IsBusy) sb.Append(", Busy");\r
311                 }\r
312                 else if (instance.State.IsBusy)\r
313                 {\r
314                     sb.Append(" - Busy");\r
315                 }\r
316 \r
317                 if (instance.State.IsFollowing)\r
318                 {\r
319                     sb.Append(" - Following ");\r
320                     sb.Append(instance.State.FollowName);\r
321                 }\r
322             }\r
323             else\r
324             {\r
325                 sb.Append("Logged Out");\r
326             }\r
327 \r
328             this.Text = sb.ToString();\r
329             sb = null;\r
330         }\r
331 \r
332         private void InitializeStatusTimer()\r
333         {\r
334             statusTimer = new System.Timers.Timer(250);\r
335             statusTimer.SynchronizingObject = this;\r
336             statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed);\r
337         }\r
338 \r
339         private void statusTimer_Elapsed(object sender, ElapsedEventArgs e)\r
340         {\r
341             RefreshWindowTitle();\r
342             RefreshStatusBar();\r
343         }\r
344         #endregion\r
345 \r
346         #region Initialization, configuration, and key shortcuts\r
347         private void InitializeTabsConsole()\r
348         {\r
349             tabsConsole = new TabsConsole(instance);\r
350             tabsConsole.Dock = DockStyle.Fill;\r
351             toolStripContainer1.ContentPanel.Controls.Add(tabsConsole);\r
352         }\r
353 \r
354         private void InitializeDebugLogForm()\r
355         {\r
356             debugLogForm = new frmDebugLog(instance);\r
357         }\r
358 \r
359         private void frmMain_KeyUp(object sender, KeyEventArgs e)\r
360         {\r
361             if (e.Control && e.Alt && e.KeyCode == Keys.D)\r
362                 tbtnDebug.Visible = !tbtnDebug.Visible;\r
363 \r
364             if (e.Control && e.KeyCode == Keys.O && client.Network.Connected)\r
365             {\r
366                 (new frmObjects(instance)).Show();\r
367             }\r
368         }\r
369 \r
370 \r
371         private void frmMain_Load(object sender, EventArgs e)\r
372         {\r
373             worldMap = new frmMap(instance);\r
374             tabsConsole.SelectTab("Main");\r
375             ResourceManager rm = Properties.Resources.ResourceManager;\r
376             ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);\r
377             System.Collections.IDictionaryEnumerator de = set.GetEnumerator();\r
378             while (de.MoveNext() == true)\r
379             {\r
380                 if (de.Entry.Value is Image)\r
381                 {\r
382                     Bitmap bitMap = de.Entry.Value as Bitmap;\r
383                     ResourceImages.Images.Add(bitMap);\r
384                     ImageNames.Add(de.Entry.Key.ToString());\r
385                 }\r
386             }\r
387         }\r
388         #endregion\r
389 \r
390         #region Public methods\r
391         public void processLink(string link)\r
392         {\r
393             if (!(link.StartsWith("http://") || link.StartsWith("ftp://")))\r
394             {\r
395                 link = "http://" + link;\r
396             }\r
397 \r
398             Regex r = new Regex(@"^(http://slurl.com/secondlife/|secondlife://)([^/]+)/(\d+)/(\d+)(/(\d+))?");\r
399             Match m = r.Match(link);\r
400 \r
401             if (m.Success)\r
402             {\r
403                 string region = Uri.UnescapeDataString(m.Groups[2].Value);\r
404                 int x = int.Parse(m.Groups[3].Value);\r
405                 int y = int.Parse(m.Groups[4].Value);\r
406                 int z = 0;\r
407 \r
408                 if (m.Groups.Count > 5 && m.Groups[6].Value != String.Empty)\r
409                 {\r
410                     z = int.Parse(m.Groups[6].Value);\r
411                 }\r
412             \r
413                 worldMap.Show();\r
414                 worldMap.Focus();\r
415                 worldMap.displayLocation(region, x, y, z);\r
416             }\r
417             else\r
418             {\r
419                 System.Diagnostics.Process.Start(link);\r
420             }\r
421 \r
422         }\r
423         #endregion\r
424 \r
425         #region Notifications\r
426         CircularList<Control> notifications = new CircularList<Control>();\r
427 \r
428         public Color NotificationBackground\r
429         {\r
430             get { return pnlDialog.BackColor; }\r
431         }\r
432 \r
433         void ResizeNotificationByControl(Control active)\r
434         {\r
435             int Width = active.Size.Width + 6;\r
436             int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3;\r
437             pnlDialog.Size = new Size(Width, Height);\r
438             pnlDialog.Top = 0;\r
439             pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width;\r
440 \r
441             btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;\r
442             btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;\r
443 \r
444             btnDialogNextControl.BringToFront();\r
445         }\r
446 \r
447         public void AddNotification(Control control)\r
448         {\r
449             if (InvokeRequired)\r
450             {\r
451                 BeginInvoke(new MethodInvoker(delegate()\r
452                 {\r
453                     AddNotification(control);\r
454                 }\r
455                 ));\r
456                 return;\r
457             }\r
458 \r
459             FormFlash.StartFlash(this);\r
460             pnlDialog.Visible = true;\r
461             pnlDialog.BringToFront();\r
462 \r
463             foreach (Control existing in notifications)\r
464             {\r
465                 existing.Visible = false;\r
466             }\r
467 \r
468             notifications.Add(control);\r
469             control.Visible = true;\r
470             control.Anchor = AnchorStyles.Top | AnchorStyles.Left;\r
471             control.Top = 3;\r
472             control.Left = 3;\r
473             pnlDialog.Controls.Add(control);\r
474             ResizeNotificationByControl(control);\r
475 \r
476             btnDialogNextControl.Visible = notifications.Count > 1;\r
477         }\r
478 \r
479         public void RemoveNotification(Control control)\r
480         {\r
481             pnlDialog.Controls.Remove(control);\r
482             notifications.Remove(control);\r
483             control.Dispose();\r
484 \r
485             if (notifications.HasNext)\r
486             {\r
487                 pnlDialog.Visible = true;\r
488                 Control active = notifications.Next;\r
489                 active.Visible = true;\r
490                 ResizeNotificationByControl(active);\r
491             }\r
492             else\r
493             {\r
494                 pnlDialog.Visible = false;\r
495             }\r
496 \r
497             btnDialogNextControl.Visible = notifications.Count > 1;\r
498         }\r
499 \r
500         private void btnDialogNextControl_Click(object sender, EventArgs e)\r
501         {\r
502             foreach (Control existing in notifications)\r
503             {\r
504                 existing.Visible = false;\r
505             }\r
506 \r
507             if (notifications.HasNext)\r
508             {\r
509                 pnlDialog.Visible = true;\r
510                 Control active = notifications.Next;\r
511                 active.Visible = true;\r
512                 ResizeNotificationByControl(active);\r
513             }\r
514             else\r
515             {\r
516                 pnlDialog.Visible = false;\r
517             }\r
518 \r
519         }\r
520         #endregion Notifications\r
521 \r
522         #region Menu click handlers\r
523 \r
524         private void tbtnTeleport_Click(object sender, EventArgs e)\r
525         {\r
526             (new frmTeleport(instance)).ShowDialog();\r
527         }\r
528 \r
529         private void tmnuStatusAway_Click(object sender, EventArgs e)\r
530         {\r
531             instance.State.SetAway(tmnuStatusAway.Checked);\r
532         }\r
533 \r
534         private void tmnuHelpReadme_Click(object sender, EventArgs e)\r
535         {\r
536             System.Diagnostics.Process.Start(Application.StartupPath + @"\Readme.txt");\r
537         }\r
538 \r
539         private void tmnuStatusBusy_Click(object sender, EventArgs e)\r
540         {\r
541             instance.State.SetBusy(tmnuStatusBusy.Checked);\r
542         }\r
543 \r
544         private void tmnuControlFly_Click(object sender, EventArgs e)\r
545         {\r
546             instance.State.SetFlying(tmnuControlFly.Checked);\r
547         }\r
548 \r
549         private void tmnuControlAlwaysRun_Click(object sender, EventArgs e)\r
550         {\r
551             instance.State.SetAlwaysRun(tmnuControlAlwaysRun.Checked);\r
552         }\r
553 \r
554         private void tmnuDebugLog_Click(object sender, EventArgs e)\r
555         {\r
556             debugLogForm.Show();\r
557         }\r
558 \r
559         private void tmnuPrefs_Click(object sender, EventArgs e)\r
560         {\r
561             (new frmPreferences(instance)).ShowDialog();\r
562         }\r
563 \r
564         private void tbtnObjects_Click(object sender, EventArgs e)\r
565         {\r
566             (new frmObjects(instance)).Show();\r
567         }\r
568 \r
569         private void tbtnAppearance_Click(object sender, EventArgs e)\r
570         {\r
571             client.Appearance.SetPreviousAppearance(true);\r
572         }\r
573 \r
574         private void groupsToolStripMenuItem_Click(object sender, EventArgs e)\r
575         {\r
576             (new GroupsDialog(instance)).Show();\r
577         }\r
578 \r
579         private void homeToolStripMenuItem_Click(object sender, EventArgs e)\r
580         {\r
581             worldMap.GoHome();\r
582         }\r
583 \r
584         private void importObjectToolStripMenuItem_Click(object sender, EventArgs e)\r
585         {\r
586             PrimDeserializer.ImportFromFile(client);\r
587         }\r
588 \r
589         private void autopilotToolStripMenuItem_Click(object sender, EventArgs e)\r
590         {\r
591             if (ap == null) {\r
592                 ap = new AutoPilot(client);\r
593                 /*\r
594                 ap.InsertWaypoint(new Vector3(66, 163, 21));\r
595                 ap.InsertWaypoint(new Vector3(66, 98, 21));\r
596 \r
597                 ap.InsertWaypoint(new Vector3(101, 98, 21));\r
598                 ap.InsertWaypoint(new Vector3(101, 45, 21));\r
599                 ap.InsertWaypoint(new Vector3(93, 27, 21));\r
600                 ap.InsertWaypoint(new Vector3(106, 12, 21));\r
601                 ap.InsertWaypoint(new Vector3(123, 24, 21));\r
602                 ap.InsertWaypoint(new Vector3(114, 45, 21));\r
603                 ap.InsertWaypoint(new Vector3(114, 98, 21));\r
604 \r
605                 ap.InsertWaypoint(new Vector3(130, 98, 21));\r
606                 ap.InsertWaypoint(new Vector3(130, 163, 21));\r
607                  **/\r
608                 ap.InsertWaypoint(new Vector3(64, 68, 21));\r
609                 ap.InsertWaypoint(new Vector3(65, 20, 21));\r
610                 ap.InsertWaypoint(new Vector3(33, 23, 21));\r
611                 ap.InsertWaypoint(new Vector3(17, 39, 21));\r
612                 ap.InsertWaypoint(new Vector3(17, 62, 21));\r
613 \r
614 \r
615             }\r
616             if (AutoPilotActive) {\r
617                 AutoPilotActive = false;\r
618                 ap.Stop();\r
619             } else {\r
620                 AutoPilotActive = true;\r
621                 ap.Start();\r
622             }\r
623 \r
624         }\r
625 \r
626         private void aLICEToolStripMenuItem_Click(object sender, EventArgs e)\r
627         {\r
628             if (instance.Config.CurrentConfig.UseAlice == false) {\r
629                 instance.Config.CurrentConfig.UseAlice = true;\r
630                 aLICEToolStripMenuItem.Checked = true;\r
631             } else {\r
632                 instance.Config.CurrentConfig.UseAlice = false;\r
633                 aLICEToolStripMenuItem.Checked = false;\r
634             }\r
635             instance.Config.SaveCurrentConfig();\r
636         }\r
637 \r
638         private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)\r
639         {\r
640             client.Assets.Cache.Clear();\r
641             DirectoryInfo di = new DirectoryInfo(instance.AnimCacheDir);\r
642             FileInfo[] files = di.GetFiles();\r
643 \r
644             int num = 0;\r
645             foreach (FileInfo file in files)\r
646             {\r
647                 file.Delete();\r
648                 ++num;\r
649             }\r
650 \r
651             Logger.Log("Wiped out " + num + " files from the anim cache directory.", Helpers.LogLevel.Debug);\r
652 \r
653         }\r
654 \r
655         private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e)\r
656         {\r
657             client.Appearance.ForceRebakeAvatarTextures();\r
658         }\r
659 \r
660         private void mapToolStripMenuItem_Click(object sender, EventArgs e)\r
661         {\r
662             if (!worldMap.Visible)\r
663             {\r
664                 worldMap.Show();\r
665             }\r
666             else\r
667             {\r
668                 worldMap.Focus();\r
669             }\r
670         }\r
671 \r
672         private void standToolStripMenuItem_Click(object sender, EventArgs e)\r
673         {\r
674             client.Self.Stand();\r
675         }\r
676 \r
677         private void groundSitToolStripMenuItem_Click(object sender, EventArgs e)\r
678         {\r
679             client.Self.SitOnGround();\r
680         }\r
681 \r
682         private void tbnObjects_Click(object sender, EventArgs e)\r
683         {\r
684             (new frmObjects(instance)).Show();\r
685         }\r
686 \r
687         private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)\r
688         {\r
689             try { System.Diagnostics.Process.Start(Application.ExecutablePath); }\r
690             catch (Exception) { }\r
691         }\r
692 \r
693         private void tmnuExit_Click(object sender, EventArgs e)\r
694         {\r
695             Close();\r
696         }\r
697 \r
698         private void tlblRegionInfo_Click(object sender, EventArgs e)\r
699         {\r
700             if (worldMap != null && client.Network.Connected)\r
701             {\r
702                 worldMap.Show();\r
703             }\r
704         }\r
705         #endregion\r
706     }\r
707 }