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 RadegastNetcom netcom;
\r
118 private GridClient client;
\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 client = this.instance.Client;
\r
137 netcom = this.instance.Netcom;
\r
138 netcom.NetcomSync = this;
\r
140 pnlDialog.Visible = false;
\r
141 btnDialogNextControl = new TransparentButton();
\r
142 pnlDialog.Controls.Add(btnDialogNextControl);
\r
145 btnDialogNextControl.Size = new Size(35, 20);
\r
146 btnDialogNextControl.BackColor = Color.Transparent;
\r
147 btnDialogNextControl.ForeColor = Color.Gold;
\r
148 btnDialogNextControl.FlatAppearance.BorderSize = 0;
\r
149 btnDialogNextControl.FlatStyle = FlatStyle.Flat;
\r
150 btnDialogNextControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
\r
151 btnDialogNextControl.Text = ">>";
\r
152 btnDialogNextControl.Font = new Font(btnDialogNextControl.Font, FontStyle.Bold);
\r
153 btnDialogNextControl.Margin = new Padding(0);
\r
154 btnDialogNextControl.Padding = new Padding(0);
\r
155 btnDialogNextControl.UseVisualStyleBackColor = false;
\r
156 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
\r
157 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
\r
158 btnDialogNextControl.Click += new EventHandler(btnDialogNextControl_Click);
\r
160 if (instance.MonoRuntime)
\r
162 statusStrip1.LayoutStyle = ToolStripLayoutStyle.Table;
\r
166 if (instance.GlobalSettings["transaction_notification_chat"].Type == OSDType.Unknown)
\r
167 instance.GlobalSettings["transaction_notification_chat"] = OSD.FromBoolean(true);
\r
169 if (instance.GlobalSettings["transaction_notification_dialog"].Type == OSDType.Unknown)
\r
170 instance.GlobalSettings["transaction_notification_dialog"] = OSD.FromBoolean(true);
\r
173 netcom.ClientLoginStatus += new EventHandler<ClientLoginEventArgs>(netcom_ClientLoginStatus);
\r
174 netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
\r
175 netcom.ClientDisconnected += new EventHandler<ClientDisconnectEventArgs>(netcom_ClientDisconnected);
\r
176 client.Parcels.OnParcelProperties += new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties);
\r
177 client.Self.OnMoneyBalanceReplyReceived += new AgentManager.MoneyBalanceReplyCallback(Self_OnMoneyBalanceReplyReceived);
\r
179 InitializeStatusTimer();
\r
180 RefreshWindowTitle();
\r
183 void frmMain_Disposed(object sender, EventArgs e)
\r
185 netcom.ClientLoginStatus -= new EventHandler<ClientLoginEventArgs>(netcom_ClientLoginStatus);
\r
186 netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
\r
187 netcom.ClientDisconnected -= new EventHandler<ClientDisconnectEventArgs>(netcom_ClientDisconnected);
\r
188 client.Parcels.OnParcelProperties -= new ParcelManager.ParcelPropertiesCallback(Parcels_OnParcelProperties);
\r
189 client.Self.OnMoneyBalanceReplyReceived -= new AgentManager.MoneyBalanceReplyCallback(Self_OnMoneyBalanceReplyReceived);
\r
190 this.instance.CleanUp();
\r
194 #region Event handlers
\r
195 void Self_OnMoneyBalanceReplyReceived(UUID transactionID, bool transactionSuccess, int balance, int metersCredit, int metersCommitted, string description)
\r
197 if (!String.IsNullOrEmpty(description))
\r
199 if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean())
\r
200 AddNotification(new ntfGeneric(instance, description));
\r
201 if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean())
\r
202 TabConsole.DisplayNotificationInChat(description);
\r
206 public void InitializeControls()
\r
208 InitializeTabsConsole();
\r
210 if (instance.MediaManager.SoundSystemAvailable)
\r
212 mediaConsole = new MediaConsole(instance);
\r
213 tbtnMedia.Visible = true;
\r
217 private void netcom_ClientLoginStatus(object sender, ClientLoginEventArgs e)
\r
219 if (e.Status != LoginStatus.Success) return;
\r
221 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
\r
222 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = true;
\r
224 statusTimer.Start();
\r
225 RefreshWindowTitle();
\r
228 private void netcom_ClientLoggedOut(object sender, EventArgs e)
\r
230 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
\r
231 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = false;
\r
233 statusTimer.Stop();
\r
235 RefreshStatusBar();
\r
236 RefreshWindowTitle();
\r
239 private void netcom_ClientDisconnected(object sender, ClientDisconnectEventArgs e)
\r
241 if (e.Type == NetworkManager.DisconnectType.ClientInitiated) return;
\r
242 netcom_ClientLoggedOut(sender, EventArgs.Empty);
\r
245 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
\r
247 if (mediaConsole != null)
\r
249 if (tabsConsole.TabExists("media"))
\r
251 tabsConsole.Tabs["media"].AllowClose = true;
\r
252 tabsConsole.Tabs["media"].Close();
\r
256 mediaConsole.Dispose();
\r
258 mediaConsole = null;
\r
261 if (netcom.IsLoggedIn)
\r
263 Thread saveInvToDisk = new Thread(new ThreadStart(
\r
266 client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
\r
268 saveInvToDisk.Name = "Save inventory to disk";
\r
269 saveInvToDisk.Start();
\r
276 # region Update status
\r
278 private void Parcels_OnParcelProperties(Simulator simulator, Parcel parcel, ParcelResult result, int selectedPrims,
\r
279 int sequenceID, bool snapSelection)
\r
281 if (result != ParcelResult.Single) return;
\r
282 if (InvokeRequired)
\r
284 BeginInvoke(new MethodInvoker(delegate()
\r
286 Parcels_OnParcelProperties(simulator, parcel, result, selectedPrims, sequenceID, snapSelection);
\r
292 tlblParcel.Text = parcel.Name;
\r
293 tlblParcel.ToolTipText = parcel.Desc;
\r
295 if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)
\r
296 icoNoFly.Visible = true;
\r
298 icoNoFly.Visible = false;
\r
300 if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)
\r
301 icoNoBuild.Visible = true;
\r
303 icoNoBuild.Visible = false;
\r
305 if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)
\r
306 icoNoScript.Visible = true;
\r
308 icoNoScript.Visible = false;
\r
310 if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)
\r
311 icoNoPush.Visible = true;
\r
313 icoNoPush.Visible = false;
\r
315 if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)
\r
316 icoHealth.Visible = true;
\r
318 icoHealth.Visible = false;
\r
320 if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)
\r
321 icoNoVoice.Visible = true;
\r
323 icoNoVoice.Visible = false;
\r
326 private void RefreshStatusBar()
\r
328 if (netcom.IsLoggedIn)
\r
330 tlblLoginName.Text = netcom.LoginOptions.FullName;
\r
331 tlblMoneyBalance.Text = client.Self.Balance.ToString();
\r
332 icoHealth.Text = client.Self.Health.ToString() + "%";
\r
334 tlblRegionInfo.Text =
\r
335 client.Network.CurrentSim.Name +
\r
336 " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +
\r
337 Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +
\r
338 Math.Floor(client.Self.SimPosition.Z).ToString() + ")";
\r
342 tlblLoginName.Text = "Offline";
\r
343 tlblMoneyBalance.Text = "0";
\r
344 icoHealth.Text = "0%";
\r
345 tlblRegionInfo.Text = "No Region";
\r
346 tlblParcel.Text = "No Parcel";
\r
348 icoHealth.Visible = false;
\r
349 icoNoBuild.Visible = false;
\r
350 icoNoFly.Visible = false;
\r
351 icoNoPush.Visible = false;
\r
352 icoNoScript.Visible = false;
\r
353 icoNoVoice.Visible = false;
\r
357 private void RefreshWindowTitle()
\r
359 StringBuilder sb = new StringBuilder();
\r
360 sb.Append("Radegast - ");
\r
362 if (netcom.IsLoggedIn)
\r
364 sb.Append("[" + netcom.LoginOptions.FullName + "]");
\r
366 if (instance.State.IsAway)
\r
368 sb.Append(" - Away");
\r
369 if (instance.State.IsBusy) sb.Append(", Busy");
\r
371 else if (instance.State.IsBusy)
\r
373 sb.Append(" - Busy");
\r
376 if (instance.State.IsFollowing)
\r
378 sb.Append(" - Following ");
\r
379 sb.Append(instance.State.FollowName);
\r
384 sb.Append("Logged Out");
\r
387 this.Text = sb.ToString();
\r
391 private void InitializeStatusTimer()
\r
393 statusTimer = new System.Timers.Timer(250);
\r
394 statusTimer.SynchronizingObject = this;
\r
395 statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed);
\r
398 private void statusTimer_Elapsed(object sender, ElapsedEventArgs e)
\r
400 RefreshWindowTitle();
\r
401 RefreshStatusBar();
\r
405 #region Initialization, configuration, and key shortcuts
\r
406 private void InitializeTabsConsole()
\r
408 tabsConsole = new TabsConsole(instance);
\r
409 tabsConsole.Dock = DockStyle.Fill;
\r
410 toolStripContainer1.ContentPanel.Controls.Add(tabsConsole);
\r
413 private void frmMain_KeyDown(object sender, KeyEventArgs e)
\r
415 if (e.Control && e.Alt && e.KeyCode == Keys.D)
\r
417 e.Handled = e.SuppressKeyPress = true;
\r
420 if (e.Control && e.KeyCode == Keys.O && client.Network.Connected)
\r
422 e.Handled = e.SuppressKeyPress = true;
\r
425 if (e.Control && e.KeyCode == Keys.G)
\r
427 e.Handled = e.SuppressKeyPress = true;
\r
430 if (e.Control && e.KeyCode == Keys.M && Clipboard.ContainsText() && client.Network.Connected)
\r
432 e.Handled = e.SuppressKeyPress = true;
\r
435 if (e.Control && e.KeyCode == Keys.Right)
\r
437 e.Handled = e.SuppressKeyPress = true;
\r
440 if (e.Control && e.KeyCode == Keys.Left)
\r
442 e.Handled = e.SuppressKeyPress = true;
\r
447 private void frmMain_KeyUp(object sender, KeyEventArgs e)
\r
449 // ctrl-o, open objects finder
\r
450 if (e.Control && e.KeyCode == Keys.O && client.Network.Connected)
\r
452 tbnObjects_Click(this, EventArgs.Empty);
\r
453 e.Handled = e.SuppressKeyPress = true;
\r
456 // ctrl-g, goto slurl
\r
457 if (e.Control && e.KeyCode == Keys.G && Clipboard.ContainsText() && client.Network.Connected)
\r
459 if (!ProcessLink(Clipboard.GetText(), true))
\r
460 MapToCurrentLocation();
\r
461 e.Handled = e.SuppressKeyPress = true;
\r
464 // ctrl-m, open map
\r
465 if (e.Control && e.KeyCode == Keys.M && Clipboard.ContainsText() && client.Network.Connected)
\r
467 MapToCurrentLocation();
\r
468 e.Handled = e.SuppressKeyPress = true;
\r
471 // ctrl-right_arrow, select next tab
\r
472 if (e.Control && e.KeyCode == Keys.Right)
\r
474 TabConsole.SelectNextTab();
\r
475 e.Handled = e.SuppressKeyPress = true;
\r
478 // ctrl-right_arrow, select previous tab
\r
479 if (e.Control && e.KeyCode == Keys.Left)
\r
481 TabConsole.SelectPreviousTab();
\r
482 e.Handled = e.SuppressKeyPress = true;
\r
487 private void frmMain_Load(object sender, EventArgs e)
\r
489 tabsConsole.SelectTab("login");
\r
490 ResourceManager rm = Properties.Resources.ResourceManager;
\r
491 ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
\r
492 System.Collections.IDictionaryEnumerator de = set.GetEnumerator();
\r
493 while (de.MoveNext() == true)
\r
495 if (de.Entry.Value is Image)
\r
497 Bitmap bitMap = de.Entry.Value as Bitmap;
\r
498 ResourceImages.Images.Add(bitMap);
\r
499 ImageNames.Add(de.Entry.Key.ToString());
\r
502 StartUpdateCheck(false);
\r
506 #region Public methods
\r
508 private Dictionary<UUID, frmProfile> shownProfiles = new Dictionary<UUID, frmProfile>();
\r
510 public void ShowAgentProfile(string name, UUID agentID)
\r
512 lock (shownProfiles)
\r
514 frmProfile profile = null;
\r
515 if (shownProfiles.TryGetValue(agentID, out profile))
\r
517 profile.WindowState = FormWindowState.Normal;
\r
522 profile = new frmProfile(instance, name, agentID);
\r
524 profile.Disposed += (object sender, EventArgs e) =>
\r
526 lock (shownProfiles)
\r
528 frmProfile agentProfile = (frmProfile)sender;
\r
529 if (shownProfiles.ContainsKey(agentProfile.AgentID))
\r
530 shownProfiles.Remove(agentProfile.AgentID);
\r
536 shownProfiles.Add(agentID, profile);
\r
541 private Dictionary<UUID, frmGroupInfo> shownGroupProfiles = new Dictionary<UUID, frmGroupInfo>();
\r
543 public void ShowGroupProfile(OpenMetaverse.Group group)
\r
545 lock (shownGroupProfiles)
\r
547 frmGroupInfo profile = null;
\r
548 if (shownGroupProfiles.TryGetValue(group.ID, out profile))
\r
550 profile.WindowState = FormWindowState.Normal;
\r
555 profile = new frmGroupInfo(instance, group);
\r
557 profile.Disposed += (object sender, EventArgs e) =>
\r
559 lock (shownGroupProfiles)
\r
561 frmGroupInfo groupProfile = (frmGroupInfo)sender;
\r
562 if (shownGroupProfiles.ContainsKey(groupProfile.Group.ID))
\r
563 shownGroupProfiles.Remove(groupProfile.Group.ID);
\r
569 shownGroupProfiles.Add(group.ID, profile);
\r
574 public void ProcessLink(string link)
\r
576 ProcessLink(link, false);
\r
579 public bool ProcessLink(string link, bool onlyMap)
\r
581 if (!link.Contains("://"))
\r
583 link = "http://" + link;
\r
586 Regex r = new Regex(@"^(http://slurl.com/secondlife/|secondlife://)([^/]+)/(\d+)/(\d+)(/(\d+))?");
\r
587 Match m = r.Match(link);
\r
591 string region = HttpUtility.UrlDecode(m.Groups[2].Value);
\r
592 int x = int.Parse(m.Groups[3].Value);
\r
593 int y = int.Parse(m.Groups[4].Value);
\r
596 if (m.Groups.Count > 5 && m.Groups[6].Value != String.Empty)
\r
598 z = int.Parse(m.Groups[6].Value);
\r
602 WorldMap.DisplayLocation(region, x, y, z);
\r
607 System.Diagnostics.Process.Start(link);
\r
613 #region Notifications
\r
614 CircularList<Control> notifications = new CircularList<Control>();
\r
616 public Color NotificationBackground
\r
618 get { return pnlDialog.BackColor; }
\r
621 void ResizeNotificationByControl(Control active)
\r
623 int Width = active.Size.Width + 6;
\r
624 int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3;
\r
625 pnlDialog.Size = new Size(Width, Height);
\r
627 pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width;
\r
629 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
\r
630 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
\r
632 btnDialogNextControl.BringToFront();
\r
635 public void AddNotification(Control control)
\r
637 if (InvokeRequired)
\r
639 BeginInvoke(new MethodInvoker(delegate()
\r
641 AddNotification(control);
\r
647 FormFlash.StartFlash(this);
\r
648 pnlDialog.Visible = true;
\r
649 pnlDialog.BringToFront();
\r
651 foreach (Control existing in notifications)
\r
653 existing.Visible = false;
\r
656 notifications.Add(control);
\r
657 control.Visible = true;
\r
658 control.Anchor = AnchorStyles.Top | AnchorStyles.Left;
\r
661 pnlDialog.Controls.Add(control);
\r
662 ResizeNotificationByControl(control);
\r
664 btnDialogNextControl.Visible = notifications.Count > 1;
\r
667 public void RemoveNotification(Control control)
\r
669 pnlDialog.Controls.Remove(control);
\r
670 notifications.Remove(control);
\r
673 if (notifications.HasNext)
\r
675 pnlDialog.Visible = true;
\r
676 Control active = notifications.Next;
\r
677 active.Visible = true;
\r
678 ResizeNotificationByControl(active);
\r
682 pnlDialog.Visible = false;
\r
685 btnDialogNextControl.Visible = notifications.Count > 1;
\r
688 private void btnDialogNextControl_Click(object sender, EventArgs e)
\r
690 foreach (Control existing in notifications)
\r
692 existing.Visible = false;
\r
695 if (notifications.HasNext)
\r
697 pnlDialog.Visible = true;
\r
698 Control active = notifications.Next;
\r
699 active.Visible = true;
\r
700 ResizeNotificationByControl(active);
\r
704 pnlDialog.Visible = false;
\r
708 #endregion Notifications
\r
710 #region Menu click handlers
\r
712 private void tbtnTeleport_Click(object sender, EventArgs e)
\r
714 (new frmTeleport(instance)).ShowDialog();
\r
717 private void tmnuStatusAway_Click(object sender, EventArgs e)
\r
719 instance.State.SetAway(tmnuStatusAway.Checked);
\r
722 private void tmnuHelpReadme_Click(object sender, EventArgs e)
\r
724 System.Diagnostics.Process.Start(Application.StartupPath + @"\Readme.txt");
\r
727 private void tmnuStatusBusy_Click(object sender, EventArgs e)
\r
729 instance.State.SetBusy(tmnuStatusBusy.Checked);
\r
732 private void tmnuControlFly_Click(object sender, EventArgs e)
\r
734 instance.State.SetFlying(tmnuControlFly.Checked);
\r
737 private void tmnuControlAlwaysRun_Click(object sender, EventArgs e)
\r
739 instance.State.SetAlwaysRun(tmnuControlAlwaysRun.Checked);
\r
742 private void tmnuPrefs_Click(object sender, EventArgs e)
\r
744 (new frmSettings(instance)).ShowDialog();
\r
747 private void tbtnAppearance_Click(object sender, EventArgs e)
\r
749 client.Appearance.RequestSetAppearance(false);
\r
752 private void importObjectToolStripMenuItem_Click(object sender, EventArgs e)
\r
754 PrimDeserializer.ImportFromFile(client);
\r
757 private void autopilotToolStripMenuItem_Click(object sender, EventArgs e)
\r
761 ap = new AutoPilot(client);
\r
763 ap.InsertWaypoint(new Vector3(66, 163, 21));
\r
764 ap.InsertWaypoint(new Vector3(66, 98, 21));
\r
766 ap.InsertWaypoint(new Vector3(101, 98, 21));
\r
767 ap.InsertWaypoint(new Vector3(101, 45, 21));
\r
768 ap.InsertWaypoint(new Vector3(93, 27, 21));
\r
769 ap.InsertWaypoint(new Vector3(106, 12, 21));
\r
770 ap.InsertWaypoint(new Vector3(123, 24, 21));
\r
771 ap.InsertWaypoint(new Vector3(114, 45, 21));
\r
772 ap.InsertWaypoint(new Vector3(114, 98, 21));
\r
774 ap.InsertWaypoint(new Vector3(130, 98, 21));
\r
775 ap.InsertWaypoint(new Vector3(130, 163, 21));
\r
777 ap.InsertWaypoint(new Vector3(64, 68, 21));
\r
778 ap.InsertWaypoint(new Vector3(65, 20, 21));
\r
779 ap.InsertWaypoint(new Vector3(33, 23, 21));
\r
780 ap.InsertWaypoint(new Vector3(17, 39, 21));
\r
781 ap.InsertWaypoint(new Vector3(17, 62, 21));
\r
785 if (AutoPilotActive)
\r
787 AutoPilotActive = false;
\r
792 AutoPilotActive = true;
\r
798 private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)
\r
800 client.Assets.Cache.Clear();
\r
801 DirectoryInfo di = new DirectoryInfo(instance.AnimCacheDir);
\r
802 FileInfo[] files = di.GetFiles();
\r
805 foreach (FileInfo file in files)
\r
811 Logger.Log("Wiped out " + num + " files from the anim cache directory.", Helpers.LogLevel.Debug);
\r
815 private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e)
\r
817 client.Appearance.RequestSetAppearance(true);
\r
820 public void MapToCurrentLocation()
\r
822 if (MapTab != null && client.Network.Connected)
\r
825 WorldMap.DisplayLocation(client.Network.CurrentSim.Name,
\r
826 (int)client.Self.SimPosition.X,
\r
827 (int)client.Self.SimPosition.Y,
\r
828 (int)client.Self.SimPosition.Z);
\r
832 private void standToolStripMenuItem_Click(object sender, EventArgs e)
\r
834 client.Self.Stand();
\r
837 private void groundSitToolStripMenuItem_Click(object sender, EventArgs e)
\r
839 client.Self.SitOnGround();
\r
842 private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
\r
844 try { System.Diagnostics.Process.Start(Application.ExecutablePath); }
\r
845 catch (Exception) { }
\r
848 private void tmnuExit_Click(object sender, EventArgs e)
\r
853 private void tlblRegionInfo_Click(object sender, EventArgs e)
\r
855 if (WorldMap != null && client.Network.Connected)
\r
861 private void scriptEditorToolStripMenuItem_Click(object sender, EventArgs e)
\r
863 ScriptEditor se = new ScriptEditor(instance);
\r
864 se.Dock = DockStyle.Fill;
\r
868 private void tmnuSetHome_Click(object sender, EventArgs e)
\r
870 client.Self.SetHome();
\r
873 private void tmnuCreateLandmark_Click(object sender, EventArgs e)
\r
875 string location = string.Format(", {0} ({1}, {2}, {3})",
\r
876 client.Network.CurrentSim.Name,
\r
877 (int)client.Self.SimPosition.X,
\r
878 (int)client.Self.SimPosition.Y,
\r
879 (int)client.Self.SimPosition.Z
\r
882 string name = tlblParcel.Text;
\r
883 int maxLen = 63 - location.Length;
\r
885 if (name.Length > maxLen)
\r
886 name = name.Substring(0, maxLen);
\r
890 client.Inventory.RequestCreateItem(
\r
891 client.Inventory.FindFolderForType(AssetType.Landmark),
\r
893 tlblParcel.ToolTipText,
\r
894 AssetType.Landmark,
\r
896 InventoryType.Landmark,
\r
897 PermissionMask.All,
\r
898 (bool success, InventoryItem item) =>
\r
902 BeginInvoke(new MethodInvoker(() =>
\r
904 Landmark ln = new Landmark(instance, (InventoryLandmark)item);
\r
905 ln.Dock = DockStyle.Fill;
\r
906 ln.Detached = true;
\r
913 private void tmnuTeleportHome_Click(object sender, EventArgs e)
\r
915 if (WorldMap != null)
\r
921 private TimeZoneInfo SLTime;
\r
923 private void GetSLTimeZone()
\r
927 foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones())
\r
929 if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles")
\r
936 catch (Exception) { }
\r
939 private void timerWorldClock_Tick(object sender, EventArgs e)
\r
944 if (SLTime != null)
\r
945 now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, SLTime);
\r
947 now = DateTime.UtcNow.AddHours(-7);
\r
951 now = DateTime.UtcNow.AddHours(-7);
\r
953 lblTime.Text = now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture);
\r
956 private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e)
\r
958 ProcessLink("http://jira.openmetaverse.org/browse/RAD");
\r
961 private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e)
\r
963 (new frmAbout(instance)).ShowDialog();
\r
966 #region Update Checking
\r
967 private UpdateChecker updateChecker = null;
\r
968 private bool ManualUpdateCheck = false;
\r
970 public void StartUpdateCheck(bool userInitiated)
\r
972 ManualUpdateCheck = userInitiated;
\r
974 if (updateChecker != null)
\r
976 if (ManualUpdateCheck)
\r
977 tabsConsole.DisplayNotificationInChat("Update check already in progress.");
\r
981 if (ManualUpdateCheck)
\r
982 tabsConsole.DisplayNotificationInChat("Checking for updates...", ChatBufferTextStyle.StatusBlue);
\r
983 updateChecker = new UpdateChecker();
\r
984 updateChecker.OnUpdateInfoReceived += new UpdateChecker.UpdateInfoCallback(OnUpdateInfoReceived);
\r
985 updateChecker.StartCheck();
\r
988 private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
\r
990 tabsConsole.SelectTab("chat");
\r
991 StartUpdateCheck(true);
\r
994 void OnUpdateInfoReceived(object sender, UpdateCheckerArgs e)
\r
996 if (InvokeRequired)
\r
998 BeginInvoke(new MethodInvoker(() => OnUpdateInfoReceived(sender, e)));
\r
1004 if (ManualUpdateCheck)
\r
1005 tabsConsole.DisplayNotificationInChat("Error: Failed connecting to the update site.", ChatBufferTextStyle.StatusBlue);
\r
1009 if (!ManualUpdateCheck && e.Info.DisplayMOTD)
\r
1011 tabsConsole.DisplayNotificationInChat(e.Info.MOTD, ChatBufferTextStyle.StatusBlue);
\r
1014 if (e.Info.UpdateAvailable)
\r
1016 tabsConsole.DisplayNotificationInChat("New version available at " + e.Info.DownloadSite, ChatBufferTextStyle.Alert);
\r
1020 if (ManualUpdateCheck)
\r
1021 tabsConsole.DisplayNotificationInChat("Your version is up to date.", ChatBufferTextStyle.StatusBlue);
\r
1025 updateChecker.Dispose();
\r
1026 updateChecker = null;
\r
1030 private void ToggleHidden(string tabName)
\r
1032 if (!tabsConsole.TabExists(tabName)) return;
\r
1034 RadegastTab tab = tabsConsole.Tabs[tabName];
\r
1042 if (!tab.Selected)
\r
1053 private void tbtnFriends_Click(object sender, EventArgs e)
\r
1055 ToggleHidden("friends");
\r
1058 private void tbtnInventory_Click(object sender, EventArgs e)
\r
1060 ToggleHidden("inventory");
\r
1063 private void tbtnSearch_Click(object sender, EventArgs e)
\r
1065 ToggleHidden("search");
\r
1068 private void tbtnGroups_Click(object sender, EventArgs e)
\r
1070 ToggleHidden("groups");
\r
1073 private void tbtnMedia_Click(object sender, EventArgs e)
\r
1075 if (tabsConsole.TabExists("media"))
\r
1077 ToggleHidden("media");
\r
1081 RadegastTab tab = tabsConsole.AddTab("media", "Media", mediaConsole);
\r
1082 tab.AllowClose = false;
\r
1083 tab.AllowHide = true;
\r
1088 private void tbnObjects_Click(object sender, EventArgs e)
\r
1090 if (tabsConsole.TabExists("objects"))
\r
1092 RadegastTab tab = tabsConsole.Tabs["objects"];
\r
1093 if (!tab.Selected)
\r
1096 ((ObjectsConsole)tab.Control).RefreshObjectList();
\r
1105 RadegastTab tab = tabsConsole.AddTab("objects", "Objects", new ObjectsConsole(instance));
\r
1106 tab.AllowClose = true;
\r
1107 tab.AllowDetach = true;
\r
1108 tab.Visible = true;
\r
1109 tab.AllowHide = false;
\r
1111 ((ObjectsConsole)tab.Control).RefreshObjectList();
\r
1115 private void tbtnMap_Click(object sender, EventArgs e)
\r
1117 ToggleHidden("map");
\r
1118 if (!MapTab.Hidden)
\r
1119 MapToCurrentLocation();
\r