2 // Radegast Metaverse Client
\r
3 // Copyright (c) 2009, Radegast Development Team
\r
4 // All rights reserved.
\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
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
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
32 using System.Collections.Generic;
\r
33 using System.Drawing;
\r
35 using System.Text.RegularExpressions;
\r
36 using System.Timers;
\r
37 using System.Threading;
\r
38 using System.Windows.Forms;
\r
39 using System.Resources;
\r
42 using Radegast.Netcom;
\r
43 using OpenMetaverse;
\r
44 using OpenMetaverse.StructuredData;
\r
48 public partial class frmMain : RadegastForm
\r
50 #region Public members
\r
51 public static ImageList ResourceImages = new ImageList();
\r
52 public static List<string> ImageNames = new List<string>();
\r
54 public TabsConsole TabConsole
\r
56 get { return tabsConsole; }
\r
59 public MapConsole WorldMap
\r
65 return (MapConsole)MapTab.Control;
\r
71 public RadegastTab MapTab
\r
75 if (tabsConsole.TabExists("map"))
\r
77 return tabsConsole.Tabs["map"];
\r
86 public MediaConsole MediaConsole { get { return mediaConsole; } }
\r
89 /// Drop down that contains the tools menu
\r
91 public ToolStripDropDownButton ToolsMenu
\r
93 get { return tbnTools; }
\r
97 /// Dropdown that contains the heelp menu
\r
99 public ToolStripDropDownButton HelpMenu
\r
101 get { return tbtnHelp; }
\r
105 /// Drop down that contants the plugins menu. Make sure to set it Visible if
\r
106 /// you add items to this menu, it's hidden by default
\r
108 public ToolStripDropDownButton PluginsMenu
\r
110 get { return tbnPlugins; }
\r
115 #region Private members
\r
116 private RadegastInstance instance;
\r
117 private GridClient client { get { return instance.Client; } }
\r
118 private RadegastNetcom netcom { get { return instance.Netcom; } }
\r
119 private TabsConsole tabsConsole;
\r
120 private System.Timers.Timer statusTimer;
\r
121 private AutoPilot ap;
\r
122 private bool AutoPilotActive = false;
\r
123 private TransparentButton btnDialogNextControl;
\r
124 private MediaConsole mediaConsole;
\r
127 #region Constructor and disposal
\r
128 public frmMain(RadegastInstance instance)
\r
132 InitializeComponent();
\r
133 Disposed += new EventHandler(frmMain_Disposed);
\r
135 this.instance = instance;
\r
136 this.instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(instance_ClientChanged);
\r
137 netcom.NetcomSync = this;
\r
139 pnlDialog.Visible = false;
\r
140 btnDialogNextControl = new TransparentButton();
\r
141 pnlDialog.Controls.Add(btnDialogNextControl);
\r
144 btnDialogNextControl.Size = new Size(35, 20);
\r
145 btnDialogNextControl.BackColor = Color.Transparent;
\r
146 btnDialogNextControl.ForeColor = Color.Gold;
\r
147 btnDialogNextControl.FlatAppearance.BorderSize = 0;
\r
148 btnDialogNextControl.FlatStyle = FlatStyle.Flat;
\r
149 btnDialogNextControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
\r
150 btnDialogNextControl.Text = ">>";
\r
151 btnDialogNextControl.Font = new Font(btnDialogNextControl.Font, FontStyle.Bold);
\r
152 btnDialogNextControl.Margin = new Padding(0);
\r
153 btnDialogNextControl.Padding = new Padding(0);
\r
154 btnDialogNextControl.UseVisualStyleBackColor = false;
\r
155 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
\r
156 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
\r
157 btnDialogNextControl.Click += new EventHandler(btnDialogNextControl_Click);
\r
159 if (instance.MonoRuntime)
\r
161 statusStrip1.LayoutStyle = ToolStripLayoutStyle.Table;
\r
165 if (instance.GlobalSettings["transaction_notification_chat"].Type == OSDType.Unknown)
\r
166 instance.GlobalSettings["transaction_notification_chat"] = OSD.FromBoolean(true);
\r
168 if (instance.GlobalSettings["transaction_notification_dialog"].Type == OSDType.Unknown)
\r
169 instance.GlobalSettings["transaction_notification_dialog"] = OSD.FromBoolean(true);
\r
172 netcom.ClientLoginStatus += new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
\r
173 netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
\r
174 netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
\r
175 RegisterClientEvents(client);
\r
177 InitializeStatusTimer();
\r
178 RefreshWindowTitle();
\r
181 private void RegisterClientEvents(GridClient client)
\r
183 client.Parcels.ParcelProperties += new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
\r
184 client.Self.MoneyBalanceReply += new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
\r
187 private void UnregisterClientEvents(GridClient client)
\r
189 client.Parcels.ParcelProperties -= new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
\r
190 client.Self.MoneyBalanceReply -= new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
\r
193 void instance_ClientChanged(object sender, ClientChangedEventArgs e)
\r
195 UnregisterClientEvents(e.OldClient);
\r
196 RegisterClientEvents(client);
\r
199 void frmMain_Disposed(object sender, EventArgs e)
\r
201 netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
\r
202 netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
\r
203 netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
\r
204 UnregisterClientEvents(client);
\r
205 this.instance.CleanUp();
\r
209 #region Event handlers
\r
210 void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e)
\r
212 if (!String.IsNullOrEmpty(e.Description))
\r
214 if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean())
\r
215 AddNotification(new ntfGeneric(instance, e.Description));
\r
216 if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean())
\r
217 TabConsole.DisplayNotificationInChat(e.Description);
\r
221 public void InitializeControls()
\r
223 InitializeTabsConsole();
\r
225 if (instance.MediaManager.SoundSystemAvailable)
\r
227 mediaConsole = new MediaConsole(instance);
\r
228 tbtnMedia.Visible = true;
\r
232 public bool InAutoReconnect { get; set; }
\r
234 private void DisplayAutoReconnectForm()
\r
236 if (InvokeRequired)
\r
238 BeginInvoke(new MethodInvoker(DisplayAutoReconnectForm));
\r
242 InAutoReconnect = true;
\r
243 frmReconnect dialog = new frmReconnect(instance, 120);
\r
244 dialog.ShowDialog(this);
\r
249 public void BeginAutoReconnect()
\r
251 // Sleep for 3 seconds on a separate thread while things unwind on
\r
252 // disconnect, since ShowDialog() blocks GUI thread
\r
253 (new Thread(new ThreadStart(() =>
\r
255 System.Threading.Thread.Sleep(3000);
\r
256 DisplayAutoReconnectForm();
\r
260 Name = "Reconnect Delay Thread",
\r
261 IsBackground = false
\r
266 private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e)
\r
268 if (e.Status == LoginStatus.Failed)
\r
270 if (InAutoReconnect)
\r
272 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
\r
273 BeginAutoReconnect();
\r
275 InAutoReconnect = false;
\r
278 else if (e.Status == LoginStatus.Success)
\r
280 InAutoReconnect = false;
\r
281 disconnectToolStripMenuItem.Enabled =
\r
282 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
\r
283 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = true;
\r
285 statusTimer.Start();
\r
286 RefreshWindowTitle();
\r
290 private void netcom_ClientLoggedOut(object sender, EventArgs e)
\r
292 disconnectToolStripMenuItem.Enabled =
\r
293 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
\r
294 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = false;
\r
296 reconnectToolStripMenuItem.Enabled = true;
\r
297 InAutoReconnect = false;
\r
299 if (statusTimer != null)
\r
300 statusTimer.Stop();
\r
302 RefreshStatusBar();
\r
303 RefreshWindowTitle();
\r
306 private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e)
\r
308 if (e.Reason == NetworkManager.DisconnectType.ClientInitiated) return;
\r
309 netcom_ClientLoggedOut(sender, EventArgs.Empty);
\r
311 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
\r
313 BeginAutoReconnect();
\r
317 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
\r
319 if (statusTimer != null)
\r
321 statusTimer.Stop();
\r
322 statusTimer.Dispose();
\r
323 statusTimer = null;
\r
326 if (mediaConsole != null)
\r
328 if (tabsConsole.TabExists("media"))
\r
330 tabsConsole.Tabs["media"].AllowClose = true;
\r
331 tabsConsole.Tabs["media"].Close();
\r
335 mediaConsole.Dispose();
\r
337 mediaConsole = null;
\r
340 if (netcom.IsLoggedIn)
\r
342 Thread saveInvToDisk = new Thread(new ThreadStart(
\r
345 client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
\r
347 saveInvToDisk.Name = "Save inventory to disk";
\r
348 saveInvToDisk.Start();
\r
355 # region Update status
\r
357 void Parcels_ParcelProperties(object sender, ParcelPropertiesEventArgs e)
\r
359 if (e.Result != ParcelResult.Single) return;
\r
360 if (InvokeRequired)
\r
362 BeginInvoke(new MethodInvoker(() => Parcels_ParcelProperties(sender, e)));
\r
366 Parcel parcel = e.Parcel;
\r
368 tlblParcel.Text = parcel.Name;
\r
369 tlblParcel.ToolTipText = parcel.Desc;
\r
371 if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)
\r
372 icoNoFly.Visible = true;
\r
374 icoNoFly.Visible = false;
\r
376 if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)
\r
377 icoNoBuild.Visible = true;
\r
379 icoNoBuild.Visible = false;
\r
381 if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)
\r
382 icoNoScript.Visible = true;
\r
384 icoNoScript.Visible = false;
\r
386 if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)
\r
387 icoNoPush.Visible = true;
\r
389 icoNoPush.Visible = false;
\r
391 if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)
\r
392 icoHealth.Visible = true;
\r
394 icoHealth.Visible = false;
\r
396 if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)
\r
397 icoNoVoice.Visible = true;
\r
399 icoNoVoice.Visible = false;
\r
402 private void RefreshStatusBar()
\r
404 if (netcom.IsLoggedIn)
\r
406 tlblLoginName.Text = netcom.LoginOptions.FullName;
\r
407 tlblMoneyBalance.Text = client.Self.Balance.ToString();
\r
408 icoHealth.Text = client.Self.Health.ToString() + "%";
\r
410 tlblRegionInfo.Text =
\r
411 client.Network.CurrentSim.Name +
\r
412 " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +
\r
413 Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +
\r
414 Math.Floor(client.Self.SimPosition.Z).ToString() + ")";
\r
418 tlblLoginName.Text = "Offline";
\r
419 tlblMoneyBalance.Text = "0";
\r
420 icoHealth.Text = "0%";
\r
421 tlblRegionInfo.Text = "No Region";
\r
422 tlblParcel.Text = "No Parcel";
\r
424 icoHealth.Visible = false;
\r
425 icoNoBuild.Visible = false;
\r
426 icoNoFly.Visible = false;
\r
427 icoNoPush.Visible = false;
\r
428 icoNoScript.Visible = false;
\r
429 icoNoVoice.Visible = false;
\r
433 private void RefreshWindowTitle()
\r
435 StringBuilder sb = new StringBuilder();
\r
436 sb.Append("Radegast - ");
\r
438 if (netcom.IsLoggedIn)
\r
440 sb.Append("[" + netcom.LoginOptions.FullName + "]");
\r
442 if (instance.State.IsAway)
\r
444 sb.Append(" - Away");
\r
445 if (instance.State.IsBusy) sb.Append(", Busy");
\r
447 else if (instance.State.IsBusy)
\r
449 sb.Append(" - Busy");
\r
452 if (instance.State.IsFollowing)
\r
454 sb.Append(" - Following ");
\r
455 sb.Append(instance.State.FollowName);
\r
460 sb.Append("Logged Out");
\r
463 this.Text = sb.ToString();
\r
467 private void InitializeStatusTimer()
\r
469 statusTimer = new System.Timers.Timer(250);
\r
470 statusTimer.SynchronizingObject = this;
\r
471 statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed);
\r
474 private void statusTimer_Elapsed(object sender, ElapsedEventArgs e)
\r
476 // Mono sometimes fires timer after is's disposed
\r
479 RefreshWindowTitle();
\r
480 RefreshStatusBar();
\r
486 #region Initialization, configuration, and key shortcuts
\r
487 private void InitializeTabsConsole()
\r
489 tabsConsole = new TabsConsole(instance);
\r
490 tabsConsole.Dock = DockStyle.Fill;
\r
491 toolStripContainer1.ContentPanel.Controls.Add(tabsConsole);
\r
494 private void frmMain_KeyDown(object sender, KeyEventArgs e)
\r
496 // Ctl-Shift-H: Teleport Home
\r
497 if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.H)
\r
499 e.Handled = e.SuppressKeyPress = true;
\r
500 tmnuTeleportHome.PerformClick();
\r
504 // Alt 1-8: Toggle various tabs
\r
505 if (e.Modifiers == Keys.Alt)
\r
510 e.Handled = e.SuppressKeyPress = true;
\r
511 tabsConsole.Tabs["chat"].Select();
\r
515 e.Handled = e.SuppressKeyPress = true;
\r
516 tbtnFriends.PerformClick();
\r
520 e.Handled = e.SuppressKeyPress = true;
\r
521 tbtnGroups.PerformClick();
\r
525 e.Handled = e.SuppressKeyPress = true;
\r
526 tbtnInventory.PerformClick();
\r
530 e.Handled = e.SuppressKeyPress = true;
\r
531 tbtnSearch.PerformClick();
\r
535 e.Handled = e.SuppressKeyPress = true;
\r
536 tbtnMap.PerformClick();
\r
540 e.Handled = e.SuppressKeyPress = true;
\r
541 tbnObjects.PerformClick();
\r
545 e.Handled = e.SuppressKeyPress = true;
\r
546 tbtnMedia.PerformClick();
\r
551 // ctrl-g, goto slurl
\r
552 if (e.Control && e.KeyCode == Keys.G)
\r
554 if (!ProcessLink(Clipboard.GetText(), true))
\r
555 MapToCurrentLocation();
\r
557 e.Handled = e.SuppressKeyPress = true;
\r
561 // ctrl-(shift)-tab for next/previous tab
\r
562 if (e.Control && e.KeyCode == Keys.Tab)
\r
566 TabConsole.SelectPreviousTab();
\r
570 TabConsole.SelectNextTab();
\r
572 e.Handled = e.SuppressKeyPress = true;
\r
577 private void frmMain_KeyUp(object sender, KeyEventArgs e)
\r
581 private void frmMain_Load(object sender, EventArgs e)
\r
583 tabsConsole.SelectTab("login");
\r
584 ResourceManager rm = Properties.Resources.ResourceManager;
\r
585 ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
\r
586 System.Collections.IDictionaryEnumerator de = set.GetEnumerator();
\r
587 while (de.MoveNext() == true)
\r
589 if (de.Entry.Value is Image)
\r
591 Bitmap bitMap = de.Entry.Value as Bitmap;
\r
592 ResourceImages.Images.Add(bitMap);
\r
593 ImageNames.Add(de.Entry.Key.ToString());
\r
596 StartUpdateCheck(false);
\r
600 #region Public methods
\r
602 private Dictionary<UUID, frmProfile> shownProfiles = new Dictionary<UUID, frmProfile>();
\r
604 public void ShowAgentProfile(string name, UUID agentID)
\r
606 lock (shownProfiles)
\r
608 frmProfile profile = null;
\r
609 if (shownProfiles.TryGetValue(agentID, out profile))
\r
611 profile.WindowState = FormWindowState.Normal;
\r
616 profile = new frmProfile(instance, name, agentID);
\r
618 profile.Disposed += (object sender, EventArgs e) =>
\r
620 lock (shownProfiles)
\r
622 frmProfile agentProfile = (frmProfile)sender;
\r
623 if (shownProfiles.ContainsKey(agentProfile.AgentID))
\r
624 shownProfiles.Remove(agentProfile.AgentID);
\r
630 shownProfiles.Add(agentID, profile);
\r
635 private Dictionary<UUID, frmGroupInfo> shownGroupProfiles = new Dictionary<UUID, frmGroupInfo>();
\r
637 public void ShowGroupProfile(OpenMetaverse.Group group)
\r
639 lock (shownGroupProfiles)
\r
641 frmGroupInfo profile = null;
\r
642 if (shownGroupProfiles.TryGetValue(group.ID, out profile))
\r
644 profile.WindowState = FormWindowState.Normal;
\r
649 profile = new frmGroupInfo(instance, group);
\r
651 profile.Disposed += (object sender, EventArgs e) =>
\r
653 lock (shownGroupProfiles)
\r
655 frmGroupInfo groupProfile = (frmGroupInfo)sender;
\r
656 if (shownGroupProfiles.ContainsKey(groupProfile.Group.ID))
\r
657 shownGroupProfiles.Remove(groupProfile.Group.ID);
\r
663 shownGroupProfiles.Add(group.ID, profile);
\r
668 public void ProcessLink(string link)
\r
670 ProcessLink(link, false);
\r
673 public bool ProcessLink(string link, bool onlyMap)
\r
675 if (!link.Contains("://"))
\r
677 link = "http://" + link;
\r
680 Regex r = new Regex(@"^(http://slurl.com/secondlife/|secondlife://)([^/]+)/(\d+)/(\d+)(/(\d+))?");
\r
681 Match m = r.Match(link);
\r
685 string region = HttpUtility.UrlDecode(m.Groups[2].Value);
\r
686 int x = int.Parse(m.Groups[3].Value);
\r
687 int y = int.Parse(m.Groups[4].Value);
\r
690 if (m.Groups.Count > 5 && m.Groups[6].Value != String.Empty)
\r
692 z = int.Parse(m.Groups[6].Value);
\r
696 WorldMap.DisplayLocation(region, x, y, z);
\r
701 System.Diagnostics.Process.Start(link);
\r
707 #region Notifications
\r
708 CircularList<Control> notifications = new CircularList<Control>();
\r
710 public Color NotificationBackground
\r
712 get { return pnlDialog.BackColor; }
\r
715 void ResizeNotificationByControl(Control active)
\r
717 int Width = active.Size.Width + 6;
\r
718 int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3;
\r
719 pnlDialog.Size = new Size(Width, Height);
\r
721 pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width;
\r
723 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
\r
724 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
\r
726 btnDialogNextControl.BringToFront();
\r
729 public void AddNotification(Control control)
\r
731 if (InvokeRequired)
\r
733 BeginInvoke(new MethodInvoker(delegate()
\r
735 AddNotification(control);
\r
741 FormFlash.StartFlash(this);
\r
742 pnlDialog.Visible = true;
\r
743 pnlDialog.BringToFront();
\r
745 foreach (Control existing in notifications)
\r
747 existing.Visible = false;
\r
750 notifications.Add(control);
\r
751 control.Visible = true;
\r
752 control.Anchor = AnchorStyles.Top | AnchorStyles.Left;
\r
755 pnlDialog.Controls.Add(control);
\r
756 ResizeNotificationByControl(control);
\r
758 btnDialogNextControl.Visible = notifications.Count > 1;
\r
761 public void RemoveNotification(Control control)
\r
763 pnlDialog.Controls.Remove(control);
\r
764 notifications.Remove(control);
\r
767 if (notifications.HasNext)
\r
769 pnlDialog.Visible = true;
\r
770 Control active = notifications.Next;
\r
771 active.Visible = true;
\r
772 ResizeNotificationByControl(active);
\r
776 pnlDialog.Visible = false;
\r
779 btnDialogNextControl.Visible = notifications.Count > 1;
\r
782 private void btnDialogNextControl_Click(object sender, EventArgs e)
\r
784 foreach (Control existing in notifications)
\r
786 existing.Visible = false;
\r
789 if (notifications.HasNext)
\r
791 pnlDialog.Visible = true;
\r
792 Control active = notifications.Next;
\r
793 active.Visible = true;
\r
794 ResizeNotificationByControl(active);
\r
798 pnlDialog.Visible = false;
\r
802 #endregion Notifications
\r
804 #region Menu click handlers
\r
806 private void tbtnTeleport_Click(object sender, EventArgs e)
\r
808 (new frmTeleport(instance)).ShowDialog();
\r
811 private void tmnuStatusAway_Click(object sender, EventArgs e)
\r
813 instance.State.SetAway(tmnuStatusAway.Checked);
\r
816 private void tmnuHelpReadme_Click(object sender, EventArgs e)
\r
818 System.Diagnostics.Process.Start(Application.StartupPath + @"\Readme.txt");
\r
821 private void tmnuStatusBusy_Click(object sender, EventArgs e)
\r
823 instance.State.SetBusy(tmnuStatusBusy.Checked);
\r
826 private void tmnuControlFly_Click(object sender, EventArgs e)
\r
828 instance.State.SetFlying(tmnuControlFly.Checked);
\r
831 private void tmnuControlAlwaysRun_Click(object sender, EventArgs e)
\r
833 instance.State.SetAlwaysRun(tmnuControlAlwaysRun.Checked);
\r
836 private void tmnuPrefs_Click(object sender, EventArgs e)
\r
838 (new frmSettings(instance)).ShowDialog();
\r
841 private void tbtnAppearance_Click(object sender, EventArgs e)
\r
843 client.Appearance.RequestSetAppearance(false);
\r
846 private void importObjectToolStripMenuItem_Click(object sender, EventArgs e)
\r
848 PrimDeserializer.ImportFromFile(client);
\r
851 private void autopilotToolStripMenuItem_Click(object sender, EventArgs e)
\r
855 ap = new AutoPilot(client);
\r
857 ap.InsertWaypoint(new Vector3(66, 163, 21));
\r
858 ap.InsertWaypoint(new Vector3(66, 98, 21));
\r
860 ap.InsertWaypoint(new Vector3(101, 98, 21));
\r
861 ap.InsertWaypoint(new Vector3(101, 45, 21));
\r
862 ap.InsertWaypoint(new Vector3(93, 27, 21));
\r
863 ap.InsertWaypoint(new Vector3(106, 12, 21));
\r
864 ap.InsertWaypoint(new Vector3(123, 24, 21));
\r
865 ap.InsertWaypoint(new Vector3(114, 45, 21));
\r
866 ap.InsertWaypoint(new Vector3(114, 98, 21));
\r
868 ap.InsertWaypoint(new Vector3(130, 98, 21));
\r
869 ap.InsertWaypoint(new Vector3(130, 163, 21));
\r
871 ap.InsertWaypoint(new Vector3(64, 68, 21));
\r
872 ap.InsertWaypoint(new Vector3(65, 20, 21));
\r
873 ap.InsertWaypoint(new Vector3(33, 23, 21));
\r
874 ap.InsertWaypoint(new Vector3(17, 39, 21));
\r
875 ap.InsertWaypoint(new Vector3(17, 62, 21));
\r
879 if (AutoPilotActive)
\r
881 AutoPilotActive = false;
\r
886 AutoPilotActive = true;
\r
892 private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)
\r
894 client.Assets.Cache.Clear();
\r
895 DirectoryInfo di = new DirectoryInfo(instance.AnimCacheDir);
\r
896 FileInfo[] files = di.GetFiles();
\r
899 foreach (FileInfo file in files)
\r
905 Logger.Log("Wiped out " + num + " files from the anim cache directory.", Helpers.LogLevel.Debug);
\r
909 private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e)
\r
911 client.Appearance.RequestSetAppearance(true);
\r
914 public void MapToCurrentLocation()
\r
916 if (MapTab != null && client.Network.Connected)
\r
919 WorldMap.DisplayLocation(client.Network.CurrentSim.Name,
\r
920 (int)client.Self.SimPosition.X,
\r
921 (int)client.Self.SimPosition.Y,
\r
922 (int)client.Self.SimPosition.Z);
\r
926 private void standToolStripMenuItem_Click(object sender, EventArgs e)
\r
928 client.Self.Stand();
\r
931 private void groundSitToolStripMenuItem_Click(object sender, EventArgs e)
\r
933 client.Self.SitOnGround();
\r
936 private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
\r
938 try { System.Diagnostics.Process.Start(Application.ExecutablePath); }
\r
939 catch (Exception) { }
\r
942 private void tmnuExit_Click(object sender, EventArgs e)
\r
947 private void tlblRegionInfo_Click(object sender, EventArgs e)
\r
949 if (WorldMap != null && client.Network.Connected)
\r
955 private void scriptEditorToolStripMenuItem_Click(object sender, EventArgs e)
\r
957 ScriptEditor se = new ScriptEditor(instance);
\r
958 se.Dock = DockStyle.Fill;
\r
962 private void tmnuSetHome_Click(object sender, EventArgs e)
\r
964 client.Self.SetHome();
\r
967 private void tmnuCreateLandmark_Click(object sender, EventArgs e)
\r
969 string location = string.Format(", {0} ({1}, {2}, {3})",
\r
970 client.Network.CurrentSim.Name,
\r
971 (int)client.Self.SimPosition.X,
\r
972 (int)client.Self.SimPosition.Y,
\r
973 (int)client.Self.SimPosition.Z
\r
976 string name = tlblParcel.Text;
\r
977 int maxLen = 63 - location.Length;
\r
979 if (name.Length > maxLen)
\r
980 name = name.Substring(0, maxLen);
\r
984 client.Inventory.RequestCreateItem(
\r
985 client.Inventory.FindFolderForType(AssetType.Landmark),
\r
987 tlblParcel.ToolTipText,
\r
988 AssetType.Landmark,
\r
990 InventoryType.Landmark,
\r
991 PermissionMask.All,
\r
992 (bool success, InventoryItem item) =>
\r
996 BeginInvoke(new MethodInvoker(() =>
\r
998 Landmark ln = new Landmark(instance, (InventoryLandmark)item);
\r
999 ln.Dock = DockStyle.Fill;
\r
1000 ln.Detached = true;
\r
1007 private void tmnuTeleportHome_Click(object sender, EventArgs e)
\r
1009 if (WorldMap != null)
\r
1011 WorldMap.GoHome();
\r
1015 private TimeZoneInfo SLTime;
\r
1017 private void GetSLTimeZone()
\r
1021 foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones())
\r
1023 if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles")
\r
1030 catch (Exception) { }
\r
1033 private void timerWorldClock_Tick(object sender, EventArgs e)
\r
1038 if (SLTime != null)
\r
1039 now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, SLTime);
\r
1041 now = DateTime.UtcNow.AddHours(-7);
\r
1045 now = DateTime.UtcNow.AddHours(-7);
\r
1047 lblTime.Text = now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture);
\r
1050 private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e)
\r
1052 ProcessLink("http://jira.openmetaverse.org/browse/RAD");
\r
1055 private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e)
\r
1057 (new frmAbout(instance)).ShowDialog();
\r
1060 #region Update Checking
\r
1061 private UpdateChecker updateChecker = null;
\r
1062 private bool ManualUpdateCheck = false;
\r
1064 public void StartUpdateCheck(bool userInitiated)
\r
1066 ManualUpdateCheck = userInitiated;
\r
1068 if (updateChecker != null)
\r
1070 if (ManualUpdateCheck)
\r
1071 tabsConsole.DisplayNotificationInChat("Update check already in progress.");
\r
1075 if (ManualUpdateCheck)
\r
1076 tabsConsole.DisplayNotificationInChat("Checking for updates...", ChatBufferTextStyle.StatusBlue);
\r
1077 updateChecker = new UpdateChecker();
\r
1078 updateChecker.OnUpdateInfoReceived += new UpdateChecker.UpdateInfoCallback(OnUpdateInfoReceived);
\r
1079 updateChecker.StartCheck();
\r
1082 private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
\r
1084 tabsConsole.SelectTab("chat");
\r
1085 StartUpdateCheck(true);
\r
1088 void OnUpdateInfoReceived(object sender, UpdateCheckerArgs e)
\r
1090 if (InvokeRequired)
\r
1092 BeginInvoke(new MethodInvoker(() => OnUpdateInfoReceived(sender, e)));
\r
1098 if (ManualUpdateCheck)
\r
1099 tabsConsole.DisplayNotificationInChat("Error: Failed connecting to the update site.", ChatBufferTextStyle.StatusBlue);
\r
1103 if (!ManualUpdateCheck && e.Info.DisplayMOTD)
\r
1105 tabsConsole.DisplayNotificationInChat(e.Info.MOTD, ChatBufferTextStyle.StatusBlue);
\r
1108 if (e.Info.UpdateAvailable)
\r
1110 tabsConsole.DisplayNotificationInChat("New version available at " + e.Info.DownloadSite, ChatBufferTextStyle.Alert);
\r
1114 if (ManualUpdateCheck)
\r
1115 tabsConsole.DisplayNotificationInChat("Your version is up to date.", ChatBufferTextStyle.StatusBlue);
\r
1119 updateChecker.Dispose();
\r
1120 updateChecker = null;
\r
1124 private void ToggleHidden(string tabName)
\r
1126 if (!tabsConsole.TabExists(tabName)) return;
\r
1128 RadegastTab tab = tabsConsole.Tabs[tabName];
\r
1136 if (!tab.Selected)
\r
1147 private void tbtnFriends_Click(object sender, EventArgs e)
\r
1149 ToggleHidden("friends");
\r
1152 private void tbtnInventory_Click(object sender, EventArgs e)
\r
1154 ToggleHidden("inventory");
\r
1157 private void tbtnSearch_Click(object sender, EventArgs e)
\r
1159 ToggleHidden("search");
\r
1162 private void tbtnGroups_Click(object sender, EventArgs e)
\r
1164 ToggleHidden("groups");
\r
1167 private void tbtnMedia_Click(object sender, EventArgs e)
\r
1169 if (tabsConsole.TabExists("media"))
\r
1171 ToggleHidden("media");
\r
1175 RadegastTab tab = tabsConsole.AddTab("media", "Media", mediaConsole);
\r
1176 tab.AllowClose = false;
\r
1177 tab.AllowHide = true;
\r
1182 private void tbnObjects_Click(object sender, EventArgs e)
\r
1184 if (tabsConsole.TabExists("objects"))
\r
1186 RadegastTab tab = tabsConsole.Tabs["objects"];
\r
1187 if (!tab.Selected)
\r
1190 ((ObjectsConsole)tab.Control).RefreshObjectList();
\r
1199 RadegastTab tab = tabsConsole.AddTab("objects", "Objects", new ObjectsConsole(instance));
\r
1200 tab.AllowClose = true;
\r
1201 tab.AllowDetach = true;
\r
1202 tab.Visible = true;
\r
1203 tab.AllowHide = false;
\r
1205 ((ObjectsConsole)tab.Control).RefreshObjectList();
\r
1209 private void tbtnMap_Click(object sender, EventArgs e)
\r
1211 ToggleHidden("map");
\r
1212 if (!MapTab.Hidden)
\r
1213 MapToCurrentLocation();
\r
1216 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
\r
1218 if (client.Network.Connected)
\r
1219 client.Network.RequestLogout();
\r
1222 private void reconnectToolStripMenuItem_Click(object sender, EventArgs e)
\r
1224 instance.Reconnect();
\r
1227 private frmKeyboardShortcuts keyboardShortcutsForm = null;
\r
1228 private void keyboardShortcutsToolStripMenuItem_Click(object sender, EventArgs e)
\r
1230 if (keyboardShortcutsForm != null)
\r
1232 keyboardShortcutsForm.Focus();
\r
1236 keyboardShortcutsForm = new frmKeyboardShortcuts(instance);
\r
1238 keyboardShortcutsForm.Disposed += (object senderx, EventArgs ex) =>
\r
1240 if (components != null)
\r
1242 components.Remove(keyboardShortcutsForm);
\r
1244 keyboardShortcutsForm = null;
\r
1247 keyboardShortcutsForm.Show(this);
\r
1248 keyboardShortcutsForm.Top = Top + 100;
\r
1249 keyboardShortcutsForm.Left = Left + 100;
\r
1251 if (components != null)
\r
1253 components.Add(keyboardShortcutsForm);
\r