2 // Radegast Metaverse Client
3 // Copyright (c) 2009, Radegast Development Team
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 // * Neither the name of the application "Radegast", nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 using System.Collections.Generic;
35 using System.Text.RegularExpressions;
37 using System.Threading;
38 using System.Windows.Forms;
39 using System.Resources;
42 using Radegast.Netcom;
44 using OpenMetaverse.StructuredData;
45 using OpenMetaverse.Assets;
49 public partial class frmMain : RadegastForm
51 #region Public members
52 public static ImageList ResourceImages = new ImageList();
53 public static List<string> ImageNames = new List<string>();
55 public TabsConsole TabConsole
57 get { return tabsConsole; }
60 public MapConsole WorldMap
66 return (MapConsole)MapTab.Control;
72 public RadegastTab MapTab
76 if (tabsConsole.TabExists("map"))
78 return tabsConsole.Tabs["map"];
87 public MediaConsole MediaConsole { get { return mediaConsole; } }
90 /// Drop down that contains the tools menu
92 public ToolStripDropDownButton ToolsMenu
94 get { return tbnTools; }
98 /// Dropdown that contains the heelp menu
100 public ToolStripDropDownButton HelpMenu
102 get { return tbtnHelp; }
106 /// Drop down that contants the plugins menu. Make sure to set it Visible if
107 /// you add items to this menu, it's hidden by default
109 public ToolStripDropDownButton PluginsMenu
111 get { return tbnPlugins; }
116 #region Private members
117 private RadegastInstance instance;
118 private GridClient client { get { return instance.Client; } }
119 private RadegastNetcom netcom { get { return instance.Netcom; } }
120 private TabsConsole tabsConsole;
121 private System.Timers.Timer statusTimer;
122 private AutoPilot ap;
123 private bool AutoPilotActive = false;
124 private TransparentButton btnDialogNextControl;
125 private MediaConsole mediaConsole;
128 #region Constructor and disposal
129 public frmMain(RadegastInstance instance)
133 InitializeComponent();
134 Disposed += new EventHandler(frmMain_Disposed);
136 this.instance = instance;
137 this.instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(instance_ClientChanged);
138 netcom.NetcomSync = this;
140 pnlDialog.Visible = false;
141 btnDialogNextControl = new TransparentButton();
142 pnlDialog.Controls.Add(btnDialogNextControl);
145 btnDialogNextControl.Size = new Size(35, 20);
146 btnDialogNextControl.BackColor = Color.Transparent;
147 btnDialogNextControl.ForeColor = Color.Gold;
148 btnDialogNextControl.FlatAppearance.BorderSize = 0;
149 btnDialogNextControl.FlatStyle = FlatStyle.Flat;
150 btnDialogNextControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
151 btnDialogNextControl.Text = ">>";
152 btnDialogNextControl.Font = new Font(btnDialogNextControl.Font, FontStyle.Bold);
153 btnDialogNextControl.Margin = new Padding(0);
154 btnDialogNextControl.Padding = new Padding(0);
155 btnDialogNextControl.UseVisualStyleBackColor = false;
156 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
157 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
158 btnDialogNextControl.Click += new EventHandler(btnDialogNextControl_Click);
160 if (instance.MonoRuntime)
162 statusStrip1.LayoutStyle = ToolStripLayoutStyle.Table;
166 if (instance.GlobalSettings["transaction_notification_chat"].Type == OSDType.Unknown)
167 instance.GlobalSettings["transaction_notification_chat"] = OSD.FromBoolean(true);
169 if (instance.GlobalSettings["transaction_notification_dialog"].Type == OSDType.Unknown)
170 instance.GlobalSettings["transaction_notification_dialog"] = OSD.FromBoolean(true);
173 netcom.ClientLoginStatus += new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
174 netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
175 netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
176 RegisterClientEvents(client);
178 InitializeStatusTimer();
179 RefreshWindowTitle();
182 private void RegisterClientEvents(GridClient client)
184 client.Parcels.ParcelProperties += new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
185 client.Self.MoneyBalanceReply += new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
188 private void UnregisterClientEvents(GridClient client)
190 client.Parcels.ParcelProperties -= new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
191 client.Self.MoneyBalanceReply -= new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
194 void instance_ClientChanged(object sender, ClientChangedEventArgs e)
196 UnregisterClientEvents(e.OldClient);
197 RegisterClientEvents(client);
200 void frmMain_Disposed(object sender, EventArgs e)
202 netcom.NetcomSync = null;
203 netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
204 netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
205 netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
206 UnregisterClientEvents(client);
207 this.instance.CleanUp();
211 #region Event handlers
212 void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e)
214 if (!String.IsNullOrEmpty(e.Description))
216 if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean())
217 AddNotification(new ntfGeneric(instance, e.Description));
218 if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean())
219 TabConsole.DisplayNotificationInChat(e.Description);
223 public void InitializeControls()
225 InitializeTabsConsole();
227 if (instance.MediaManager.SoundSystemAvailable)
229 mediaConsole = new MediaConsole(instance);
230 tbtnMedia.Visible = true;
234 public bool InAutoReconnect { get; set; }
236 private void DisplayAutoReconnectForm()
238 if (IsDisposed) return;
242 BeginInvoke(new MethodInvoker(DisplayAutoReconnectForm));
246 InAutoReconnect = true;
247 frmReconnect dialog = new frmReconnect(instance, 120);
248 dialog.ShowDialog(this);
253 public void BeginAutoReconnect()
255 // Sleep for 3 seconds on a separate thread while things unwind on
256 // disconnect, since ShowDialog() blocks GUI thread
257 (new Thread(new ThreadStart(() =>
259 System.Threading.Thread.Sleep(3000);
260 DisplayAutoReconnectForm();
264 Name = "Reconnect Delay Thread",
270 private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e)
272 if (e.Status == LoginStatus.Failed)
276 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
277 BeginAutoReconnect();
279 InAutoReconnect = false;
282 else if (e.Status == LoginStatus.Success)
284 InAutoReconnect = false;
285 tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
286 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
287 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = true;
290 RefreshWindowTitle();
294 private void netcom_ClientLoggedOut(object sender, EventArgs e)
296 tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
297 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
298 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = false;
300 reconnectToolStripMenuItem.Enabled = true;
301 InAutoReconnect = false;
303 if (statusTimer != null)
307 RefreshWindowTitle();
310 private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e)
312 if (e.Reason == NetworkManager.DisconnectType.ClientInitiated) return;
313 netcom_ClientLoggedOut(sender, EventArgs.Empty);
315 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
317 BeginAutoReconnect();
321 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
323 if (statusTimer != null)
326 statusTimer.Dispose();
330 if (mediaConsole != null)
332 if (tabsConsole.TabExists("media"))
334 tabsConsole.Tabs["media"].AllowClose = true;
335 tabsConsole.Tabs["media"].Close();
339 mediaConsole.Dispose();
344 if (netcom.IsLoggedIn)
346 Thread saveInvToDisk = new Thread(new ThreadStart(
349 client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
351 saveInvToDisk.Name = "Save inventory to disk";
352 saveInvToDisk.Start();
359 # region Update status
361 void Parcels_ParcelProperties(object sender, ParcelPropertiesEventArgs e)
363 if (e.Result != ParcelResult.Single) return;
366 BeginInvoke(new MethodInvoker(() => Parcels_ParcelProperties(sender, e)));
370 Parcel parcel = e.Parcel;
372 tlblParcel.Text = parcel.Name;
373 tlblParcel.ToolTipText = parcel.Desc;
375 if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)
376 icoNoFly.Visible = true;
378 icoNoFly.Visible = false;
380 if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)
381 icoNoBuild.Visible = true;
383 icoNoBuild.Visible = false;
385 if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)
386 icoNoScript.Visible = true;
388 icoNoScript.Visible = false;
390 if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)
391 icoNoPush.Visible = true;
393 icoNoPush.Visible = false;
395 if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)
396 icoHealth.Visible = true;
398 icoHealth.Visible = false;
400 if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)
401 icoNoVoice.Visible = true;
403 icoNoVoice.Visible = false;
406 private void RefreshStatusBar()
408 if (netcom.IsLoggedIn)
410 tlblLoginName.Text = netcom.LoginOptions.FullName;
411 tlblMoneyBalance.Text = client.Self.Balance.ToString();
412 icoHealth.Text = client.Self.Health.ToString() + "%";
414 tlblRegionInfo.Text =
415 client.Network.CurrentSim.Name +
416 " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +
417 Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +
418 Math.Floor(client.Self.SimPosition.Z).ToString() + ")";
422 tlblLoginName.Text = "Offline";
423 tlblMoneyBalance.Text = "0";
424 icoHealth.Text = "0%";
425 tlblRegionInfo.Text = "No Region";
426 tlblParcel.Text = "No Parcel";
428 icoHealth.Visible = false;
429 icoNoBuild.Visible = false;
430 icoNoFly.Visible = false;
431 icoNoPush.Visible = false;
432 icoNoScript.Visible = false;
433 icoNoVoice.Visible = false;
437 private void RefreshWindowTitle()
439 StringBuilder sb = new StringBuilder();
440 sb.Append("Radegast - ");
442 if (netcom.IsLoggedIn)
444 sb.Append("[" + netcom.LoginOptions.FullName + "]");
446 if (instance.State.IsAway)
448 sb.Append(" - Away");
449 if (instance.State.IsBusy) sb.Append(", Busy");
451 else if (instance.State.IsBusy)
453 sb.Append(" - Busy");
456 if (instance.State.IsFollowing)
458 sb.Append(" - Following ");
459 sb.Append(instance.State.FollowName);
464 sb.Append("Logged Out");
467 this.Text = sb.ToString();
471 private void InitializeStatusTimer()
473 statusTimer = new System.Timers.Timer(250);
474 statusTimer.SynchronizingObject = this;
475 statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed);
478 private void statusTimer_Elapsed(object sender, ElapsedEventArgs e)
480 // Mono sometimes fires timer after is's disposed
483 RefreshWindowTitle();
490 #region Initialization, configuration, and key shortcuts
491 private void InitializeTabsConsole()
493 tabsConsole = new TabsConsole(instance);
494 tabsConsole.Dock = DockStyle.Fill;
495 toolStripContainer1.ContentPanel.Controls.Add(tabsConsole);
498 private void frmMain_KeyDown(object sender, KeyEventArgs e)
501 if (e.Modifiers == Keys.Control && e.KeyCode == Keys.W)
503 e.Handled = e.SuppressKeyPress = true;
504 RadegastTab tab = tabsConsole.SelectedTab;
510 else if (tab.AllowHide)
518 // Ctl-Shift-H: Teleport Home
519 if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.H)
521 e.Handled = e.SuppressKeyPress = true;
522 tmnuTeleportHome.PerformClick();
526 // Alt 1-8: Toggle various tabs
527 if (e.Modifiers == Keys.Alt)
532 e.Handled = e.SuppressKeyPress = true;
533 tabsConsole.Tabs["chat"].Select();
537 e.Handled = e.SuppressKeyPress = true;
538 tbtnFriends.PerformClick();
542 e.Handled = e.SuppressKeyPress = true;
543 tbtnGroups.PerformClick();
547 e.Handled = e.SuppressKeyPress = true;
548 tbtnInventory.PerformClick();
552 e.Handled = e.SuppressKeyPress = true;
553 tbtnSearch.PerformClick();
557 e.Handled = e.SuppressKeyPress = true;
558 tbtnMap.PerformClick();
562 e.Handled = e.SuppressKeyPress = true;
563 tbnObjects.PerformClick();
567 e.Handled = e.SuppressKeyPress = true;
568 tbtnMedia.PerformClick();
572 e.Handled = e.SuppressKeyPress = true;
573 tbtnVoice.PerformClick();
578 // ctrl-g, goto slurl
579 if (e.Control && e.KeyCode == Keys.G)
581 if (!ProcessLink(Clipboard.GetText(), true))
582 MapToCurrentLocation();
584 e.Handled = e.SuppressKeyPress = true;
588 // ctrl-(shift)-tab for next/previous tab
589 if (e.Control && e.KeyCode == Keys.Tab)
593 TabConsole.SelectPreviousTab();
597 TabConsole.SelectNextTab();
599 e.Handled = e.SuppressKeyPress = true;
604 private void frmMain_KeyUp(object sender, KeyEventArgs e)
608 private void frmMain_Load(object sender, EventArgs e)
610 tabsConsole.SelectTab("login");
611 ResourceManager rm = Properties.Resources.ResourceManager;
612 ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
613 System.Collections.IDictionaryEnumerator de = set.GetEnumerator();
614 while (de.MoveNext() == true)
616 if (de.Entry.Value is Image)
618 Bitmap bitMap = de.Entry.Value as Bitmap;
619 ResourceImages.Images.Add(bitMap);
620 ImageNames.Add(de.Entry.Key.ToString());
623 StartUpdateCheck(false);
627 #region Public methods
629 private Dictionary<UUID, frmProfile> shownProfiles = new Dictionary<UUID, frmProfile>();
631 public void ShowAgentProfile(string name, UUID agentID)
635 frmProfile profile = null;
636 if (shownProfiles.TryGetValue(agentID, out profile))
638 profile.WindowState = FormWindowState.Normal;
643 profile = new frmProfile(instance, name, agentID);
645 profile.Disposed += (object sender, EventArgs e) =>
649 frmProfile agentProfile = (frmProfile)sender;
650 if (shownProfiles.ContainsKey(agentProfile.AgentID))
651 shownProfiles.Remove(agentProfile.AgentID);
657 shownProfiles.Add(agentID, profile);
662 private Dictionary<UUID, frmGroupInfo> shownGroupProfiles = new Dictionary<UUID, frmGroupInfo>();
664 public void ShowGroupProfile(AvatarGroup group)
666 ShowGroupProfile(new OpenMetaverse.Group()
669 InsigniaID = group.GroupInsigniaID,
670 Name = group.GroupName
675 public void ShowGroupProfile(OpenMetaverse.Group group)
677 lock (shownGroupProfiles)
679 frmGroupInfo profile = null;
680 if (shownGroupProfiles.TryGetValue(group.ID, out profile))
682 profile.WindowState = FormWindowState.Normal;
687 profile = new frmGroupInfo(instance, group);
689 profile.Disposed += (object sender, EventArgs e) =>
691 lock (shownGroupProfiles)
693 frmGroupInfo groupProfile = (frmGroupInfo)sender;
694 if (shownGroupProfiles.ContainsKey(groupProfile.Group.ID))
695 shownGroupProfiles.Remove(groupProfile.Group.ID);
701 shownGroupProfiles.Add(group.ID, profile);
706 public void ProcessLink(string link)
708 ProcessLink(link, false);
711 public bool ProcessLink(string link, bool onlyMap)
713 if (!link.Contains("://"))
715 link = "http://" + link;
718 Regex r = new Regex(@"^(http://slurl.com/secondlife/|secondlife://)([^/]+)/(\d+)/(\d+)(/(\d+))?");
719 Match m = r.Match(link);
723 string region = HttpUtility.UrlDecode(m.Groups[2].Value);
724 int x = int.Parse(m.Groups[3].Value);
725 int y = int.Parse(m.Groups[4].Value);
728 if (m.Groups.Count > 5 && m.Groups[6].Value != String.Empty)
730 z = int.Parse(m.Groups[6].Value);
734 WorldMap.DisplayLocation(region, x, y, z);
739 System.Diagnostics.Process.Start(link);
745 #region Notifications
746 CircularList<Control> notifications = new CircularList<Control>();
748 public Color NotificationBackground
750 get { return pnlDialog.BackColor; }
753 void ResizeNotificationByControl(Control active)
755 int Width = active.Size.Width + 6;
756 int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3;
757 pnlDialog.Size = new Size(Width, Height);
759 pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width;
761 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
762 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
764 btnDialogNextControl.BringToFront();
767 public void AddNotification(Control control)
771 BeginInvoke(new MethodInvoker(delegate()
773 AddNotification(control);
779 FormFlash.StartFlash(this);
780 pnlDialog.Visible = true;
781 pnlDialog.BringToFront();
783 foreach (Control existing in notifications)
785 existing.Visible = false;
788 notifications.Add(control);
789 control.Visible = true;
790 control.Anchor = AnchorStyles.Top | AnchorStyles.Left;
793 pnlDialog.Controls.Add(control);
794 ResizeNotificationByControl(control);
796 btnDialogNextControl.Visible = notifications.Count > 1;
799 public void RemoveNotification(Control control)
801 pnlDialog.Controls.Remove(control);
802 notifications.Remove(control);
805 if (notifications.HasNext)
807 pnlDialog.Visible = true;
808 Control active = notifications.Next;
809 active.Visible = true;
810 ResizeNotificationByControl(active);
814 pnlDialog.Visible = false;
817 btnDialogNextControl.Visible = notifications.Count > 1;
820 private void btnDialogNextControl_Click(object sender, EventArgs e)
822 foreach (Control existing in notifications)
824 existing.Visible = false;
827 if (notifications.HasNext)
829 pnlDialog.Visible = true;
830 Control active = notifications.Next;
831 active.Visible = true;
832 ResizeNotificationByControl(active);
836 pnlDialog.Visible = false;
840 #endregion Notifications
842 #region Menu click handlers
844 private void tbtnTeleport_Click(object sender, EventArgs e)
846 (new frmTeleport(instance)).ShowDialog();
849 private void tmnuStatusAway_Click(object sender, EventArgs e)
851 instance.State.SetAway(tmnuStatusAway.Checked);
854 private void tmnuHelpReadme_Click(object sender, EventArgs e)
856 System.Diagnostics.Process.Start(Application.StartupPath + @"\Readme.txt");
859 private void tmnuStatusBusy_Click(object sender, EventArgs e)
861 instance.State.SetBusy(tmnuStatusBusy.Checked);
864 private void tmnuControlFly_Click(object sender, EventArgs e)
866 instance.State.SetFlying(tmnuControlFly.Checked);
869 private void tmnuControlAlwaysRun_Click(object sender, EventArgs e)
871 instance.State.SetAlwaysRun(tmnuControlAlwaysRun.Checked);
874 private void tmnuPrefs_Click(object sender, EventArgs e)
876 (new frmSettings(instance)).ShowDialog();
879 private void tbtnAppearance_Click(object sender, EventArgs e)
881 client.Appearance.RequestSetAppearance(false);
884 private void importObjectToolStripMenuItem_Click(object sender, EventArgs e)
886 PrimDeserializer.ImportFromFile(client);
889 private void autopilotToolStripMenuItem_Click(object sender, EventArgs e)
893 ap = new AutoPilot(client);
895 ap.InsertWaypoint(new Vector3(66, 163, 21));
896 ap.InsertWaypoint(new Vector3(66, 98, 21));
898 ap.InsertWaypoint(new Vector3(101, 98, 21));
899 ap.InsertWaypoint(new Vector3(101, 45, 21));
900 ap.InsertWaypoint(new Vector3(93, 27, 21));
901 ap.InsertWaypoint(new Vector3(106, 12, 21));
902 ap.InsertWaypoint(new Vector3(123, 24, 21));
903 ap.InsertWaypoint(new Vector3(114, 45, 21));
904 ap.InsertWaypoint(new Vector3(114, 98, 21));
906 ap.InsertWaypoint(new Vector3(130, 98, 21));
907 ap.InsertWaypoint(new Vector3(130, 163, 21));
909 ap.InsertWaypoint(new Vector3(64, 68, 21));
910 ap.InsertWaypoint(new Vector3(65, 20, 21));
911 ap.InsertWaypoint(new Vector3(33, 23, 21));
912 ap.InsertWaypoint(new Vector3(17, 39, 21));
913 ap.InsertWaypoint(new Vector3(17, 62, 21));
919 AutoPilotActive = false;
924 AutoPilotActive = true;
930 private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)
932 client.Assets.Cache.Clear();
935 private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e)
937 client.Appearance.RequestSetAppearance(true);
940 public void MapToCurrentLocation()
942 if (MapTab != null && client.Network.Connected)
945 WorldMap.DisplayLocation(client.Network.CurrentSim.Name,
946 (int)client.Self.SimPosition.X,
947 (int)client.Self.SimPosition.Y,
948 (int)client.Self.SimPosition.Z);
952 private void standToolStripMenuItem_Click(object sender, EventArgs e)
957 private void groundSitToolStripMenuItem_Click(object sender, EventArgs e)
959 client.Self.SitOnGround();
962 private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
964 try { System.Diagnostics.Process.Start(Application.ExecutablePath); }
965 catch (Exception) { }
968 private void tmnuExit_Click(object sender, EventArgs e)
973 private void tlblRegionInfo_Click(object sender, EventArgs e)
975 if (WorldMap != null && client.Network.Connected)
981 private void scriptEditorToolStripMenuItem_Click(object sender, EventArgs e)
983 ScriptEditor se = new ScriptEditor(instance);
984 se.Dock = DockStyle.Fill;
988 private void tmnuSetHome_Click(object sender, EventArgs e)
990 client.Self.SetHome();
993 private void tmnuCreateLandmark_Click(object sender, EventArgs e)
995 string location = string.Format(", {0} ({1}, {2}, {3})",
996 client.Network.CurrentSim.Name,
997 (int)client.Self.SimPosition.X,
998 (int)client.Self.SimPosition.Y,
999 (int)client.Self.SimPosition.Z
1002 string name = tlblParcel.Text;
1003 int maxLen = 63 - location.Length;
1005 if (name.Length > maxLen)
1006 name = name.Substring(0, maxLen);
1010 client.Inventory.RequestCreateItem(
1011 client.Inventory.FindFolderForType(AssetType.Landmark),
1013 tlblParcel.ToolTipText,
1016 InventoryType.Landmark,
1018 (bool success, InventoryItem item) =>
1022 BeginInvoke(new MethodInvoker(() =>
1024 Landmark ln = new Landmark(instance, (InventoryLandmark)item);
1025 ln.Dock = DockStyle.Fill;
1033 private void tmnuTeleportHome_Click(object sender, EventArgs e)
1035 if (WorldMap != null)
1041 private TimeZoneInfo SLTime;
1043 private void GetSLTimeZone()
1047 foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones())
1049 if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles")
1056 catch (Exception) { }
1059 private void timerWorldClock_Tick(object sender, EventArgs e)
1065 now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, SLTime);
1067 now = DateTime.UtcNow.AddHours(-7);
1071 now = DateTime.UtcNow.AddHours(-7);
1073 lblTime.Text = now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture);
1076 private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e)
1078 ProcessLink("http://jira.openmetaverse.org/browse/RAD");
1081 private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e)
1083 (new frmAbout(instance)).ShowDialog();
1086 #region Update Checking
1087 private UpdateChecker updateChecker = null;
1088 private bool ManualUpdateCheck = false;
1090 public void StartUpdateCheck(bool userInitiated)
1092 ManualUpdateCheck = userInitiated;
1094 if (updateChecker != null)
1096 if (ManualUpdateCheck)
1097 tabsConsole.DisplayNotificationInChat("Update check already in progress.");
1101 if (ManualUpdateCheck)
1102 tabsConsole.DisplayNotificationInChat("Checking for updates...", ChatBufferTextStyle.StatusBlue);
1103 updateChecker = new UpdateChecker();
1104 updateChecker.OnUpdateInfoReceived += new UpdateChecker.UpdateInfoCallback(OnUpdateInfoReceived);
1105 updateChecker.StartCheck();
1108 private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
1110 tabsConsole.SelectTab("chat");
1111 StartUpdateCheck(true);
1114 void OnUpdateInfoReceived(object sender, UpdateCheckerArgs e)
1118 BeginInvoke(new MethodInvoker(() => OnUpdateInfoReceived(sender, e)));
1124 if (ManualUpdateCheck)
1125 tabsConsole.DisplayNotificationInChat("Error: Failed connecting to the update site.", ChatBufferTextStyle.StatusBlue);
1129 if (!ManualUpdateCheck && e.Info.DisplayMOTD)
1131 tabsConsole.DisplayNotificationInChat(e.Info.MOTD, ChatBufferTextStyle.StatusBlue);
1134 if (e.Info.UpdateAvailable)
1136 tabsConsole.DisplayNotificationInChat("New version available at " + e.Info.DownloadSite, ChatBufferTextStyle.Alert);
1140 if (ManualUpdateCheck)
1141 tabsConsole.DisplayNotificationInChat("Your version is up to date.", ChatBufferTextStyle.StatusBlue);
1145 updateChecker.Dispose();
1146 updateChecker = null;
1150 private void ToggleHidden(string tabName)
1152 if (!tabsConsole.TabExists(tabName)) return;
1154 RadegastTab tab = tabsConsole.Tabs[tabName];
1173 private void tbtnFriends_Click(object sender, EventArgs e)
1175 ToggleHidden("friends");
1178 private void tbtnInventory_Click(object sender, EventArgs e)
1180 ToggleHidden("inventory");
1183 private void tbtnSearch_Click(object sender, EventArgs e)
1185 ToggleHidden("search");
1188 private void tbtnGroups_Click(object sender, EventArgs e)
1190 ToggleHidden("groups");
1193 private void tbtnVoice_Click(object sender, EventArgs e)
1195 ToggleHidden("voice");
1198 private void tbtnMedia_Click(object sender, EventArgs e)
1200 if (tabsConsole.TabExists("media"))
1202 ToggleHidden("media");
1206 RadegastTab tab = tabsConsole.AddTab("media", "Media", mediaConsole);
1207 tab.AllowClose = false;
1208 tab.AllowHide = true;
1213 private void tbnObjects_Click(object sender, EventArgs e)
1215 if (tabsConsole.TabExists("objects"))
1217 RadegastTab tab = tabsConsole.Tabs["objects"];
1221 ((ObjectsConsole)tab.Control).RefreshObjectList();
1230 RadegastTab tab = tabsConsole.AddTab("objects", "Objects", new ObjectsConsole(instance));
1231 tab.AllowClose = true;
1232 tab.AllowDetach = true;
1234 tab.AllowHide = false;
1236 ((ObjectsConsole)tab.Control).RefreshObjectList();
1240 private void tbtnMap_Click(object sender, EventArgs e)
1242 ToggleHidden("map");
1244 MapToCurrentLocation();
1247 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
1249 if (client.Network.Connected)
1250 client.Network.RequestLogout();
1253 private void reconnectToolStripMenuItem_Click(object sender, EventArgs e)
1255 instance.Reconnect();
1258 private frmKeyboardShortcuts keyboardShortcutsForm = null;
1259 private void keyboardShortcutsToolStripMenuItem_Click(object sender, EventArgs e)
1261 if (keyboardShortcutsForm != null)
1263 keyboardShortcutsForm.Focus();
1267 keyboardShortcutsForm = new frmKeyboardShortcuts(instance);
1269 keyboardShortcutsForm.Disposed += (object senderx, EventArgs ex) =>
1271 if (components != null)
1273 components.Remove(keyboardShortcutsForm);
1275 keyboardShortcutsForm = null;
1278 keyboardShortcutsForm.Show(this);
1279 keyboardShortcutsForm.Top = Top + 100;
1280 keyboardShortcutsForm.Left = Left + 100;
1282 if (components != null)
1284 components.Add(keyboardShortcutsForm);
1289 // Menu item for testing out stuff
1290 private void testToolStripMenuItem_Click(object sender, EventArgs e)
1292 foreach (KeyValuePair<UUID, string> kvp in Sounds.ToDictionary())
1294 client.Assets.RequestAsset(kvp.Key, AssetType.Sound, true, (AssetDownload transfer, Asset asset) =>
1296 System.Console.WriteLine("Sound '{0}' download success: {1}", transfer.AssetID, transfer.Success);
1302 private void reloadInventoryToolStripMenuItem_Click(object sender, EventArgs e)
1304 if (tabsConsole.TabExists("inventory"))
1306 ((InventoryConsole)tabsConsole.Tabs["inventory"].Control).ReloadInventory();
1307 tabsConsole.Tabs["inventory"].Select();