2 // Radegast Metaverse Client
3 // Copyright (c) 2009-2010, 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);
172 if (!instance.GlobalSettings.ContainsKey("minimize_to_tray"))
173 instance.GlobalSettings["minimize_to_tray"] = OSD.FromBoolean(false);
176 netcom.ClientLoginStatus += new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
177 netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
178 netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
179 RegisterClientEvents(client);
181 InitializeStatusTimer();
182 RefreshWindowTitle();
185 private void RegisterClientEvents(GridClient client)
187 client.Parcels.ParcelProperties += new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
188 client.Self.MoneyBalanceReply += new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
191 private void UnregisterClientEvents(GridClient client)
193 client.Parcels.ParcelProperties -= new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
194 client.Self.MoneyBalanceReply -= new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
197 void instance_ClientChanged(object sender, ClientChangedEventArgs e)
199 UnregisterClientEvents(e.OldClient);
200 RegisterClientEvents(client);
203 void frmMain_Disposed(object sender, EventArgs e)
207 netcom.NetcomSync = null;
208 netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
209 netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
210 netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
214 UnregisterClientEvents(client);
216 this.instance.CleanUp();
220 #region Event handlers
221 void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e)
223 if (!String.IsNullOrEmpty(e.Description))
225 if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean())
226 AddNotification(new ntfGeneric(instance, e.Description));
227 if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean())
228 TabConsole.DisplayNotificationInChat(e.Description);
232 public void InitializeControls()
234 InitializeTabsConsole();
236 if (instance.MediaManager.SoundSystemAvailable)
238 mediaConsole = new MediaConsole(instance);
239 tbtnMedia.Visible = true;
243 public bool InAutoReconnect { get; set; }
245 private void DisplayAutoReconnectForm()
247 if (IsDisposed) return;
251 BeginInvoke(new MethodInvoker(DisplayAutoReconnectForm));
255 InAutoReconnect = true;
256 frmReconnect dialog = new frmReconnect(instance, 120);
257 dialog.ShowDialog(this);
262 public void BeginAutoReconnect()
264 // Sleep for 3 seconds on a separate thread while things unwind on
265 // disconnect, since ShowDialog() blocks GUI thread
266 (new Thread(new ThreadStart(() =>
268 System.Threading.Thread.Sleep(3000);
269 DisplayAutoReconnectForm();
273 Name = "Reconnect Delay Thread",
279 private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e)
281 if (e.Status == LoginStatus.Failed)
285 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
286 BeginAutoReconnect();
288 InAutoReconnect = false;
291 else if (e.Status == LoginStatus.Success)
293 InAutoReconnect = false;
294 tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
295 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
296 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = true;
299 RefreshWindowTitle();
303 private void netcom_ClientLoggedOut(object sender, EventArgs e)
305 tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
306 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
307 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = false;
309 reconnectToolStripMenuItem.Enabled = true;
310 InAutoReconnect = false;
312 if (statusTimer != null)
316 RefreshWindowTitle();
319 private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e)
321 if (e.Reason == NetworkManager.DisconnectType.ClientInitiated) return;
322 netcom_ClientLoggedOut(sender, EventArgs.Empty);
324 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
326 BeginAutoReconnect();
330 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
332 if (statusTimer != null)
335 statusTimer.Dispose();
339 if (mediaConsole != null)
341 if (tabsConsole.TabExists("media"))
343 tabsConsole.Tabs["media"].AllowClose = true;
344 tabsConsole.Tabs["media"].Close();
348 mediaConsole.Dispose();
353 if (netcom.IsLoggedIn)
355 Thread saveInvToDisk = new Thread(new ThreadStart(
358 client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
360 saveInvToDisk.Name = "Save inventory to disk";
361 saveInvToDisk.Start();
368 # region Update status
370 void Parcels_ParcelProperties(object sender, ParcelPropertiesEventArgs e)
372 if (e.Result != ParcelResult.Single) return;
375 BeginInvoke(new MethodInvoker(() => Parcels_ParcelProperties(sender, e)));
379 Parcel parcel = instance.State.Parcel = e.Parcel;
381 tlblParcel.Text = parcel.Name;
382 tlblParcel.ToolTipText = parcel.Desc;
384 if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)
385 icoNoFly.Visible = true;
387 icoNoFly.Visible = false;
389 if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)
390 icoNoBuild.Visible = true;
392 icoNoBuild.Visible = false;
394 if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)
395 icoNoScript.Visible = true;
397 icoNoScript.Visible = false;
399 if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)
400 icoNoPush.Visible = true;
402 icoNoPush.Visible = false;
404 if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)
405 icoHealth.Visible = true;
407 icoHealth.Visible = false;
409 if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)
410 icoNoVoice.Visible = true;
412 icoNoVoice.Visible = false;
415 private void RefreshStatusBar()
417 if (netcom.IsLoggedIn)
419 tlblLoginName.Text = netcom.LoginOptions.FullName;
420 tlblMoneyBalance.Text = client.Self.Balance.ToString();
421 icoHealth.Text = client.Self.Health.ToString() + "%";
423 tlblRegionInfo.Text =
424 client.Network.CurrentSim.Name +
425 " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +
426 Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +
427 Math.Floor(client.Self.SimPosition.Z).ToString() + ")";
431 tlblLoginName.Text = "Offline";
432 tlblMoneyBalance.Text = "0";
433 icoHealth.Text = "0%";
434 tlblRegionInfo.Text = "No Region";
435 tlblParcel.Text = "No Parcel";
437 icoHealth.Visible = false;
438 icoNoBuild.Visible = false;
439 icoNoFly.Visible = false;
440 icoNoPush.Visible = false;
441 icoNoScript.Visible = false;
442 icoNoVoice.Visible = false;
446 private void RefreshWindowTitle()
448 StringBuilder sb = new StringBuilder();
449 sb.Append("Radegast - ");
451 if (netcom.IsLoggedIn)
453 sb.Append("[" + netcom.LoginOptions.FullName + "]");
455 if (instance.State.IsAway)
457 sb.Append(" - Away");
458 if (instance.State.IsBusy) sb.Append(", Busy");
460 else if (instance.State.IsBusy)
462 sb.Append(" - Busy");
465 if (instance.State.IsFollowing)
467 sb.Append(" - Following ");
468 sb.Append(instance.State.FollowName);
473 sb.Append("Logged Out");
476 this.Text = sb.ToString();
480 private void InitializeStatusTimer()
482 statusTimer = new System.Timers.Timer(250);
483 statusTimer.SynchronizingObject = this;
484 statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed);
487 private void statusTimer_Elapsed(object sender, ElapsedEventArgs e)
489 // Mono sometimes fires timer after is's disposed
492 RefreshWindowTitle();
499 #region Initialization, configuration, and key shortcuts
500 private void InitializeTabsConsole()
502 tabsConsole = new TabsConsole(instance);
503 tabsConsole.Dock = DockStyle.Fill;
504 toolStripContainer1.ContentPanel.Controls.Add(tabsConsole);
507 private void frmMain_KeyDown(object sender, KeyEventArgs e)
510 if (e.Modifiers == Keys.Control && e.KeyCode == Keys.W)
512 e.Handled = e.SuppressKeyPress = true;
513 RadegastTab tab = tabsConsole.SelectedTab;
519 else if (tab.AllowHide)
527 // Ctl-Shift-H: Teleport Home
528 if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.H)
530 e.Handled = e.SuppressKeyPress = true;
531 tmnuTeleportHome.PerformClick();
535 // Alt-Ctrl-D Open debug console
536 if (e.Modifiers == (Keys.Control | Keys.Alt) && e.KeyCode == Keys.D)
538 e.Handled = e.SuppressKeyPress = true;
539 debugConsoleToolStripMenuItem.PerformClick();
543 // Alt 1-8: Toggle various tabs
544 if (e.Modifiers == Keys.Alt)
549 e.Handled = e.SuppressKeyPress = true;
550 tabsConsole.Tabs["chat"].Select();
554 e.Handled = e.SuppressKeyPress = true;
555 tbtnFriends.PerformClick();
559 e.Handled = e.SuppressKeyPress = true;
560 tbtnGroups.PerformClick();
564 e.Handled = e.SuppressKeyPress = true;
565 tbtnInventory.PerformClick();
569 e.Handled = e.SuppressKeyPress = true;
570 tbtnSearch.PerformClick();
574 e.Handled = e.SuppressKeyPress = true;
575 tbtnMap.PerformClick();
579 e.Handled = e.SuppressKeyPress = true;
580 tbnObjects.PerformClick();
584 e.Handled = e.SuppressKeyPress = true;
585 tbtnMedia.PerformClick();
589 e.Handled = e.SuppressKeyPress = true;
590 tbtnVoice.PerformClick();
595 // ctrl-g, goto slurl
596 if (e.Control && e.KeyCode == Keys.G)
598 if (!ProcessLink(Clipboard.GetText(), true))
599 MapToCurrentLocation();
601 e.Handled = e.SuppressKeyPress = true;
605 // ctrl-(shift)-tab for next/previous tab
606 if (e.Control && e.KeyCode == Keys.Tab)
610 TabConsole.SelectPreviousTab();
614 TabConsole.SelectNextTab();
616 e.Handled = e.SuppressKeyPress = true;
621 bool firstLoad = true;
623 private void frmMain_Load(object sender, EventArgs e)
628 tabsConsole.SelectTab("login");
629 ResourceManager rm = Properties.Resources.ResourceManager;
630 ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
631 System.Collections.IDictionaryEnumerator de = set.GetEnumerator();
632 while (de.MoveNext() == true)
634 if (de.Entry.Value is Image)
636 Bitmap bitMap = de.Entry.Value as Bitmap;
637 ResourceImages.Images.Add(bitMap);
638 ImageNames.Add(de.Entry.Key.ToString());
641 StartUpdateCheck(false);
646 #region Public methods
648 private Dictionary<UUID, frmProfile> shownProfiles = new Dictionary<UUID, frmProfile>();
650 public void ShowAgentProfile(string name, UUID agentID)
654 frmProfile profile = null;
655 if (shownProfiles.TryGetValue(agentID, out profile))
657 profile.WindowState = FormWindowState.Normal;
662 profile = new frmProfile(instance, name, agentID);
664 profile.Disposed += (object sender, EventArgs e) =>
668 frmProfile agentProfile = (frmProfile)sender;
669 if (shownProfiles.ContainsKey(agentProfile.AgentID))
670 shownProfiles.Remove(agentProfile.AgentID);
676 shownProfiles.Add(agentID, profile);
681 private Dictionary<UUID, frmGroupInfo> shownGroupProfiles = new Dictionary<UUID, frmGroupInfo>();
683 public void ShowGroupProfile(AvatarGroup group)
685 ShowGroupProfile(new OpenMetaverse.Group()
688 InsigniaID = group.GroupInsigniaID,
689 Name = group.GroupName
694 public void ShowGroupProfile(OpenMetaverse.Group group)
696 lock (shownGroupProfiles)
698 frmGroupInfo profile = null;
699 if (shownGroupProfiles.TryGetValue(group.ID, out profile))
701 profile.WindowState = FormWindowState.Normal;
706 profile = new frmGroupInfo(instance, group);
708 profile.Disposed += (object sender, EventArgs e) =>
710 lock (shownGroupProfiles)
712 frmGroupInfo groupProfile = (frmGroupInfo)sender;
713 if (shownGroupProfiles.ContainsKey(groupProfile.Group.ID))
714 shownGroupProfiles.Remove(groupProfile.Group.ID);
720 shownGroupProfiles.Add(group.ID, profile);
725 public void ProcessLink(string link)
727 ProcessLink(link, false);
730 public bool ProcessLink(string link, bool onlyMap)
732 if (!link.Contains("://"))
734 link = "http://" + link;
737 Regex r = new Regex(@"^(http://(slurl\.com|maps\.secondlife\.com)/secondlife/|secondlife://)(?<region>[^/]+)/(?<x>\d+)/(?<y>\d+)(/(?<z>\d+))?",
738 RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase
740 Match m = r.Match(link);
744 string region = HttpUtility.UrlDecode(m.Groups["region"].Value);
745 int x = int.Parse(m.Groups["x"].Value);
746 int y = int.Parse(m.Groups["y"].Value);
749 if (!string.IsNullOrEmpty(m.Groups["z"].Value))
751 z = int.Parse(m.Groups["z"].Value);
755 WorldMap.DisplayLocation(region, x, y, z);
760 System.Diagnostics.Process.Start(link);
766 #region Notifications
767 CircularList<Control> notifications = new CircularList<Control>();
769 public Color NotificationBackground
771 get { return pnlDialog.BackColor; }
774 void ResizeNotificationByControl(Control active)
776 int Width = active.Size.Width + 6;
777 int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3;
778 pnlDialog.Size = new Size(Width, Height);
780 pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width;
782 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
783 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
785 btnDialogNextControl.BringToFront();
788 public void AddNotification(Control control)
792 BeginInvoke(new MethodInvoker(delegate()
794 AddNotification(control);
800 FormFlash.StartFlash(this);
801 pnlDialog.Visible = true;
802 pnlDialog.BringToFront();
804 foreach (Control existing in notifications)
806 existing.Visible = false;
809 notifications.Add(control);
810 control.Visible = true;
811 control.Anchor = AnchorStyles.Top | AnchorStyles.Left;
814 pnlDialog.Controls.Add(control);
815 ResizeNotificationByControl(control);
817 btnDialogNextControl.Visible = notifications.Count > 1;
820 public void RemoveNotification(Control control)
822 pnlDialog.Controls.Remove(control);
823 notifications.Remove(control);
826 if (notifications.HasNext)
828 pnlDialog.Visible = true;
829 Control active = notifications.Next;
830 active.Visible = true;
831 ResizeNotificationByControl(active);
835 pnlDialog.Visible = false;
838 btnDialogNextControl.Visible = notifications.Count > 1;
841 private void btnDialogNextControl_Click(object sender, EventArgs e)
843 foreach (Control existing in notifications)
845 existing.Visible = false;
848 if (notifications.HasNext)
850 pnlDialog.Visible = true;
851 Control active = notifications.Next;
852 active.Visible = true;
853 ResizeNotificationByControl(active);
857 pnlDialog.Visible = false;
861 #endregion Notifications
863 #region Menu click handlers
865 private void tmnuStatusAway_Click(object sender, EventArgs e)
867 instance.State.SetAway(tmnuStatusAway.Checked);
870 private void tmnuHelpReadme_Click(object sender, EventArgs e)
872 System.Diagnostics.Process.Start(Application.StartupPath + @"\Readme.txt");
875 private void tmnuStatusBusy_Click(object sender, EventArgs e)
877 instance.State.SetBusy(tmnuStatusBusy.Checked);
880 private void tmnuControlFly_Click(object sender, EventArgs e)
882 instance.State.SetFlying(tmnuControlFly.Checked);
885 private void tmnuControlAlwaysRun_Click(object sender, EventArgs e)
887 instance.State.SetAlwaysRun(tmnuControlAlwaysRun.Checked);
890 private void tmnuPrefs_Click(object sender, EventArgs e)
892 (new frmSettings(instance)).ShowDialog();
895 private void tbtnAppearance_Click(object sender, EventArgs e)
897 client.Appearance.RequestSetAppearance(false);
900 private void importObjectToolStripMenuItem_Click(object sender, EventArgs e)
902 PrimDeserializer.ImportFromFile(client);
905 private void autopilotToolStripMenuItem_Click(object sender, EventArgs e)
909 ap = new AutoPilot(client);
911 ap.InsertWaypoint(new Vector3(66, 163, 21));
912 ap.InsertWaypoint(new Vector3(66, 98, 21));
914 ap.InsertWaypoint(new Vector3(101, 98, 21));
915 ap.InsertWaypoint(new Vector3(101, 45, 21));
916 ap.InsertWaypoint(new Vector3(93, 27, 21));
917 ap.InsertWaypoint(new Vector3(106, 12, 21));
918 ap.InsertWaypoint(new Vector3(123, 24, 21));
919 ap.InsertWaypoint(new Vector3(114, 45, 21));
920 ap.InsertWaypoint(new Vector3(114, 98, 21));
922 ap.InsertWaypoint(new Vector3(130, 98, 21));
923 ap.InsertWaypoint(new Vector3(130, 163, 21));
925 ap.InsertWaypoint(new Vector3(64, 68, 21));
926 ap.InsertWaypoint(new Vector3(65, 20, 21));
927 ap.InsertWaypoint(new Vector3(33, 23, 21));
928 ap.InsertWaypoint(new Vector3(17, 39, 21));
929 ap.InsertWaypoint(new Vector3(17, 62, 21));
935 AutoPilotActive = false;
940 AutoPilotActive = true;
946 private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)
948 client.Assets.Cache.Clear();
951 private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e)
953 client.Appearance.RequestSetAppearance(true);
956 public void MapToCurrentLocation()
958 if (MapTab != null && client.Network.Connected)
961 WorldMap.DisplayLocation(client.Network.CurrentSim.Name,
962 (int)client.Self.SimPosition.X,
963 (int)client.Self.SimPosition.Y,
964 (int)client.Self.SimPosition.Z);
968 private void standToolStripMenuItem_Click(object sender, EventArgs e)
970 instance.State.SetSitting(false, UUID.Zero);
973 private void groundSitToolStripMenuItem_Click(object sender, EventArgs e)
975 client.Self.SitOnGround();
978 private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
980 try { System.Diagnostics.Process.Start(Application.ExecutablePath); }
981 catch (Exception) { }
984 private void tmnuExit_Click(object sender, EventArgs e)
989 private void tlblRegionInfo_Click(object sender, EventArgs e)
991 if (WorldMap != null && client.Network.Connected)
997 private void scriptEditorToolStripMenuItem_Click(object sender, EventArgs e)
999 ScriptEditor se = new ScriptEditor(instance);
1000 se.Dock = DockStyle.Fill;
1004 private void tmnuSetHome_Click(object sender, EventArgs e)
1006 client.Self.SetHome();
1009 private void tmnuCreateLandmark_Click(object sender, EventArgs e)
1011 string location = string.Format(", {0} ({1}, {2}, {3})",
1012 client.Network.CurrentSim.Name,
1013 (int)client.Self.SimPosition.X,
1014 (int)client.Self.SimPosition.Y,
1015 (int)client.Self.SimPosition.Z
1018 string name = tlblParcel.Text;
1019 int maxLen = 63 - location.Length;
1021 if (name.Length > maxLen)
1022 name = name.Substring(0, maxLen);
1026 client.Inventory.RequestCreateItem(
1027 client.Inventory.FindFolderForType(AssetType.Landmark),
1029 tlblParcel.ToolTipText,
1032 InventoryType.Landmark,
1034 (bool success, InventoryItem item) =>
1038 BeginInvoke(new MethodInvoker(() =>
1040 Landmark ln = new Landmark(instance, (InventoryLandmark)item);
1041 ln.Dock = DockStyle.Fill;
1049 private TimeZoneInfo SLTime;
1051 private void GetSLTimeZone()
1055 foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones())
1057 if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles")
1064 catch (Exception) { }
1067 private void timerWorldClock_Tick(object sender, EventArgs e)
1073 now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, SLTime);
1075 now = DateTime.UtcNow.AddHours(-7);
1079 now = DateTime.UtcNow.AddHours(-7);
1081 lblTime.Text = now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture);
1084 private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e)
1086 ProcessLink("http://jira.openmetaverse.org/browse/RAD");
1089 private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e)
1091 (new frmAbout(instance)).ShowDialog();
1094 #region Update Checking
1095 private UpdateChecker updateChecker = null;
1096 private bool ManualUpdateCheck = false;
1098 public void StartUpdateCheck(bool userInitiated)
1100 ManualUpdateCheck = userInitiated;
1102 if (updateChecker != null)
1104 if (ManualUpdateCheck)
1105 tabsConsole.DisplayNotificationInChat("Update check already in progress.");
1109 if (ManualUpdateCheck)
1110 tabsConsole.DisplayNotificationInChat("Checking for updates...", ChatBufferTextStyle.StatusBlue);
1111 updateChecker = new UpdateChecker();
1112 updateChecker.OnUpdateInfoReceived += new UpdateChecker.UpdateInfoCallback(OnUpdateInfoReceived);
1113 updateChecker.StartCheck();
1116 private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
1118 tabsConsole.SelectTab("chat");
1119 StartUpdateCheck(true);
1122 void OnUpdateInfoReceived(object sender, UpdateCheckerArgs e)
1126 BeginInvoke(new MethodInvoker(() => OnUpdateInfoReceived(sender, e)));
1132 if (ManualUpdateCheck)
1133 tabsConsole.DisplayNotificationInChat("Error: Failed connecting to the update site.", ChatBufferTextStyle.StatusBlue);
1137 if (!ManualUpdateCheck && e.Info.DisplayMOTD)
1139 tabsConsole.DisplayNotificationInChat(e.Info.MOTD, ChatBufferTextStyle.StatusBlue);
1142 if (e.Info.UpdateAvailable)
1144 tabsConsole.DisplayNotificationInChat("New version available at " + e.Info.DownloadSite, ChatBufferTextStyle.Alert);
1148 if (ManualUpdateCheck)
1149 tabsConsole.DisplayNotificationInChat("Your version is up to date.", ChatBufferTextStyle.StatusBlue);
1153 updateChecker.Dispose();
1154 updateChecker = null;
1158 private void ToggleHidden(string tabName)
1160 if (!tabsConsole.TabExists(tabName)) return;
1162 RadegastTab tab = tabsConsole.Tabs[tabName];
1181 private void tbtnFriends_Click(object sender, EventArgs e)
1183 ToggleHidden("friends");
1186 private void tbtnInventory_Click(object sender, EventArgs e)
1188 ToggleHidden("inventory");
1191 private void tbtnSearch_Click(object sender, EventArgs e)
1193 ToggleHidden("search");
1196 private void tbtnGroups_Click(object sender, EventArgs e)
1198 ToggleHidden("groups");
1201 private void tbtnVoice_Click(object sender, EventArgs e)
1203 ToggleHidden("voice");
1206 private void tbtnMedia_Click(object sender, EventArgs e)
1208 if (tabsConsole.TabExists("media"))
1210 ToggleHidden("media");
1214 RadegastTab tab = tabsConsole.AddTab("media", "Media", mediaConsole);
1215 tab.AllowClose = false;
1216 tab.AllowHide = true;
1221 private void debugConsoleToolStripMenuItem_Click(object sender, EventArgs e)
1223 if (tabsConsole.TabExists("debug"))
1225 ToggleHidden("debug");
1229 RadegastTab tab = tabsConsole.AddTab("debug", "Debug", new DebugConsole(instance));
1230 tab.AllowClose = false;
1231 tab.AllowHide = true;
1236 private void tbnObjects_Click(object sender, EventArgs e)
1238 if (tabsConsole.TabExists("objects"))
1240 RadegastTab tab = tabsConsole.Tabs["objects"];
1244 ((ObjectsConsole)tab.Control).RefreshObjectList();
1253 RadegastTab tab = tabsConsole.AddTab("objects", "Objects", new ObjectsConsole(instance));
1254 tab.AllowClose = true;
1255 tab.AllowDetach = true;
1257 tab.AllowHide = false;
1259 ((ObjectsConsole)tab.Control).RefreshObjectList();
1263 private void tbtnMap_Click(object sender, EventArgs e)
1265 ToggleHidden("map");
1267 MapToCurrentLocation();
1270 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
1272 if (client.Network.Connected)
1273 client.Network.RequestLogout();
1276 private void reconnectToolStripMenuItem_Click(object sender, EventArgs e)
1278 instance.Reconnect();
1281 private frmKeyboardShortcuts keyboardShortcutsForm = null;
1282 private void keyboardShortcutsToolStripMenuItem_Click(object sender, EventArgs e)
1284 if (keyboardShortcutsForm != null)
1286 keyboardShortcutsForm.Focus();
1290 keyboardShortcutsForm = new frmKeyboardShortcuts(instance);
1292 keyboardShortcutsForm.Disposed += (object senderx, EventArgs ex) =>
1294 if (components != null)
1296 components.Remove(keyboardShortcutsForm);
1298 keyboardShortcutsForm = null;
1301 keyboardShortcutsForm.Show(this);
1302 keyboardShortcutsForm.Top = Top + 100;
1303 keyboardShortcutsForm.Left = Left + 100;
1305 if (components != null)
1307 components.Add(keyboardShortcutsForm);
1315 // Menu item for testing out stuff
1316 private void testToolStripMenuItem_Click(object sender, EventArgs e)
1320 Logger.Log("Number of regions: " + nr_reg.ToString() + " agents: " + nr_agent.ToString(), Helpers.LogLevel.Info);
1323 client.Grid.GridRegion -= new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
1327 client.Grid.GridRegion += new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
1328 client.Grid.RequestMainlandSims(GridLayerType.Objects);
1331 void Grid_GridRegion(object sender, GridRegionEventArgs e)
1334 if ((nr_reg % 100) == 0)
1336 nr_agent += e.Region.Agents;
1337 Logger.Log("Number of regions: " + nr_reg.ToString() + " agents: " + nr_agent.ToString(), Helpers.LogLevel.Info);
1341 private void reloadInventoryToolStripMenuItem_Click(object sender, EventArgs e)
1343 if (tabsConsole.TabExists("inventory"))
1345 ((InventoryConsole)tabsConsole.Tabs["inventory"].Control).ReloadInventory();
1346 tabsConsole.Tabs["inventory"].Select();
1350 private void btnLoadScript_Click(object sender, EventArgs e)
1352 if (!TabConsole.TabExists("plugin_manager"))
1354 TabConsole.AddTab("plugin_manager", "Plugins", new PluginsTab(instance));
1356 TabConsole.Tabs["plugin_manager"].Select();
1359 private void frmMain_Resize(object sender, EventArgs e)
1361 if (WindowState == FormWindowState.Minimized && instance.GlobalSettings["minimize_to_tray"].AsBoolean())
1363 ShowInTaskbar = false;
1364 trayIcon.Visible = true;
1368 private void treyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
1370 WindowState = FormWindowState.Normal;
1371 ShowInTaskbar = true;
1372 trayIcon.Visible = false;
1375 private void ctxTreyRestore_Click(object sender, EventArgs e)
1377 treyIcon_MouseDoubleClick(this, null);
1380 private void ctxTreyExit_Click(object sender, EventArgs e)
1382 tmnuExit_Click(this, EventArgs.Empty);
1385 private void tmnuTeleportHome_Click(object sender, EventArgs e)
1387 TabConsole.DisplayNotificationInChat("Teleporting home...");
1388 client.Self.RequestTeleport(UUID.Zero);
1391 private void stopAllAnimationsToolStripMenuItem_Click(object sender, EventArgs e)
1393 instance.State.StopAllAnimations();