OSDN Git Service

Add user control for handling landmarks
authorLatif Khalifa <latifer@streamgrid.net>
Fri, 26 Jun 2009 07:27:02 +0000 (07:27 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Fri, 26 Jun 2009 07:27:02 +0000 (07:27 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@74 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Consoles/Assets/Landmark.Designer.cs [new file with mode: 0644]
Radegast/GUI/Consoles/Assets/Landmark.cs [new file with mode: 0644]
Radegast/GUI/Consoles/Assets/Landmark.resx [new file with mode: 0644]

diff --git a/Radegast/GUI/Consoles/Assets/Landmark.Designer.cs b/Radegast/GUI/Consoles/Assets/Landmark.Designer.cs
new file mode 100644 (file)
index 0000000..ea2ab9a
--- /dev/null
@@ -0,0 +1,172 @@
+// \r
+// Radegast Metaverse Client\r
+// Copyright (c) 2009, Radegast Development Team\r
+// All rights reserved.\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+//     * Redistributions of source code must retain the above copyright notice,\r
+//       this list of conditions and the following disclaimer.\r
+//     * Redistributions in binary form must reproduce the above copyright\r
+//       notice, this list of conditions and the following disclaimer in the\r
+//       documentation and/or other materials provided with the distribution.\r
+//     * Neither the name of the application "Radegast", nor the names of its\r
+//       contributors may be used to endorse or promote products derived from\r
+//       this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+// $Id$\r
+//\r
+namespace Radegast\r
+{\r
+    partial class Landmark\r
+    {\r
+        /// <summary> \r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary> \r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Component Designer generated code\r
+\r
+        /// <summary> \r
+        /// Required method for Designer support - do not modify \r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.pnlControls = new System.Windows.Forms.Panel();\r
+            this.btnShowOnMap = new System.Windows.Forms.Button();\r
+            this.btnTeleport = new System.Windows.Forms.Button();\r
+            this.pnlDetail = new System.Windows.Forms.Panel();\r
+            this.pnlDetailInfo = new System.Windows.Forms.Panel();\r
+            this.txtParcelDescription = new System.Windows.Forms.TextBox();\r
+            this.txtParcelName = new System.Windows.Forms.TextBox();\r
+            this.pnlControls.SuspendLayout();\r
+            this.pnlDetail.SuspendLayout();\r
+            this.pnlDetailInfo.SuspendLayout();\r
+            this.SuspendLayout();\r
+            // \r
+            // pnlControls\r
+            // \r
+            this.pnlControls.Controls.Add(this.btnShowOnMap);\r
+            this.pnlControls.Controls.Add(this.btnTeleport);\r
+            this.pnlControls.Dock = System.Windows.Forms.DockStyle.Bottom;\r
+            this.pnlControls.Location = new System.Drawing.Point(0, 281);\r
+            this.pnlControls.Name = "pnlControls";\r
+            this.pnlControls.Size = new System.Drawing.Size(320, 38);\r
+            this.pnlControls.TabIndex = 0;\r
+            // \r
+            // btnShowOnMap\r
+            // \r
+            this.btnShowOnMap.Enabled = false;\r
+            this.btnShowOnMap.Location = new System.Drawing.Point(84, 8);\r
+            this.btnShowOnMap.Name = "btnShowOnMap";\r
+            this.btnShowOnMap.Size = new System.Drawing.Size(97, 23);\r
+            this.btnShowOnMap.TabIndex = 2;\r
+            this.btnShowOnMap.Text = "Show on map";\r
+            this.btnShowOnMap.UseVisualStyleBackColor = true;\r
+            // \r
+            // btnTeleport\r
+            // \r
+            this.btnTeleport.Enabled = false;\r
+            this.btnTeleport.Location = new System.Drawing.Point(3, 8);\r
+            this.btnTeleport.Name = "btnTeleport";\r
+            this.btnTeleport.Size = new System.Drawing.Size(75, 23);\r
+            this.btnTeleport.TabIndex = 1;\r
+            this.btnTeleport.Text = "Teleport";\r
+            this.btnTeleport.UseVisualStyleBackColor = true;\r
+            this.btnTeleport.Click += new System.EventHandler(this.btnTeleport_Click);\r
+            // \r
+            // pnlDetail\r
+            // \r
+            this.pnlDetail.Controls.Add(this.pnlDetailInfo);\r
+            this.pnlDetail.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.pnlDetail.Location = new System.Drawing.Point(0, 0);\r
+            this.pnlDetail.Name = "pnlDetail";\r
+            this.pnlDetail.Size = new System.Drawing.Size(320, 281);\r
+            this.pnlDetail.TabIndex = 1;\r
+            this.pnlDetail.Visible = false;\r
+            // \r
+            // pnlDetailInfo\r
+            // \r
+            this.pnlDetailInfo.Controls.Add(this.txtParcelDescription);\r
+            this.pnlDetailInfo.Controls.Add(this.txtParcelName);\r
+            this.pnlDetailInfo.Dock = System.Windows.Forms.DockStyle.Bottom;\r
+            this.pnlDetailInfo.Location = new System.Drawing.Point(0, 223);\r
+            this.pnlDetailInfo.Name = "pnlDetailInfo";\r
+            this.pnlDetailInfo.Size = new System.Drawing.Size(320, 58);\r
+            this.pnlDetailInfo.TabIndex = 0;\r
+            // \r
+            // txtParcelDescription\r
+            // \r
+            this.txtParcelDescription.BorderStyle = System.Windows.Forms.BorderStyle.None;\r
+            this.txtParcelDescription.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.txtParcelDescription.Location = new System.Drawing.Point(0, 13);\r
+            this.txtParcelDescription.Multiline = true;\r
+            this.txtParcelDescription.Name = "txtParcelDescription";\r
+            this.txtParcelDescription.ReadOnly = true;\r
+            this.txtParcelDescription.Size = new System.Drawing.Size(320, 45);\r
+            this.txtParcelDescription.TabIndex = 1;\r
+            // \r
+            // txtParcelName\r
+            // \r
+            this.txtParcelName.BorderStyle = System.Windows.Forms.BorderStyle.None;\r
+            this.txtParcelName.Dock = System.Windows.Forms.DockStyle.Top;\r
+            this.txtParcelName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.txtParcelName.Location = new System.Drawing.Point(0, 0);\r
+            this.txtParcelName.Name = "txtParcelName";\r
+            this.txtParcelName.ReadOnly = true;\r
+            this.txtParcelName.Size = new System.Drawing.Size(320, 13);\r
+            this.txtParcelName.TabIndex = 0;\r
+            // \r
+            // Landmark\r
+            // \r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
+            this.Controls.Add(this.pnlDetail);\r
+            this.Controls.Add(this.pnlControls);\r
+            this.Name = "Landmark";\r
+            this.Size = new System.Drawing.Size(320, 319);\r
+            this.pnlControls.ResumeLayout(false);\r
+            this.pnlDetail.ResumeLayout(false);\r
+            this.pnlDetailInfo.ResumeLayout(false);\r
+            this.pnlDetailInfo.PerformLayout();\r
+            this.ResumeLayout(false);\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.Panel pnlControls;\r
+        private System.Windows.Forms.Button btnShowOnMap;\r
+        private System.Windows.Forms.Button btnTeleport;\r
+        private System.Windows.Forms.Panel pnlDetail;\r
+        private System.Windows.Forms.Panel pnlDetailInfo;\r
+        private System.Windows.Forms.TextBox txtParcelName;\r
+        private System.Windows.Forms.TextBox txtParcelDescription;\r
+    }\r
+}\r
diff --git a/Radegast/GUI/Consoles/Assets/Landmark.cs b/Radegast/GUI/Consoles/Assets/Landmark.cs
new file mode 100644 (file)
index 0000000..a46d54c
--- /dev/null
@@ -0,0 +1,133 @@
+// \r
+// Radegast Metaverse Client\r
+// Copyright (c) 2009, Radegast Development Team\r
+// All rights reserved.\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+//     * Redistributions of source code must retain the above copyright notice,\r
+//       this list of conditions and the following disclaimer.\r
+//     * Redistributions in binary form must reproduce the above copyright\r
+//       notice, this list of conditions and the following disclaimer in the\r
+//       documentation and/or other materials provided with the distribution.\r
+//     * Neither the name of the application "Radegast", nor the names of its\r
+//       contributors may be used to endorse or promote products derived from\r
+//       this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+// $Id$\r
+//\r
+using System;\r
+using System.Collections.Generic;\r
+using System.ComponentModel;\r
+using System.Drawing;\r
+using System.Data;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Windows.Forms;\r
+using OpenMetaverse;\r
+using OpenMetaverse.Assets;\r
+\r
+namespace Radegast\r
+{\r
+    public partial class Landmark : UserControl\r
+    {\r
+        private RadegastInstance instance;\r
+        private GridClient client { get { return instance.Client; } }\r
+        private InventoryLandmark landmark;\r
+        private AssetLandmark decodedLandmark;\r
+        private UUID parcelID;\r
+        private ParcelInfo parcel;\r
+\r
+        public Landmark(RadegastInstance instance, InventoryLandmark landmark)\r
+        {\r
+            InitializeComponent();\r
+            Disposed += new EventHandler(Landmark_Disposed);\r
+\r
+            this.instance = instance;\r
+            this.landmark = landmark;\r
+\r
+            // Callbacks\r
+            client.Assets.OnAssetReceived += new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);\r
+            client.Grid.OnRegionHandleReply += new GridManager.RegionHandleReplyCallback(Grid_OnRegionHandleReply);\r
+            client.Parcels.OnParcelInfo += new ParcelManager.ParcelInfoCallback(Parcels_OnParcelInfo);\r
+            client.Assets.RequestInventoryAsset(landmark, true);\r
+        }\r
+\r
+        void Landmark_Disposed(object sender, EventArgs e)\r
+        {\r
+            client.Assets.OnAssetReceived -= new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);\r
+            client.Grid.OnRegionHandleReply -= new GridManager.RegionHandleReplyCallback(Grid_OnRegionHandleReply);\r
+            client.Parcels.OnParcelInfo -= new ParcelManager.ParcelInfoCallback(Parcels_OnParcelInfo);\r
+        }\r
+\r
+        void Parcels_OnParcelInfo(ParcelInfo parcel)\r
+        {\r
+            if (parcel.ID != parcelID) return;\r
+\r
+            if (InvokeRequired)\r
+            {\r
+                BeginInvoke(new MethodInvoker(delegate()\r
+                    {\r
+                        Parcels_OnParcelInfo(parcel);\r
+                    }\r
+                ));\r
+                return;\r
+            }\r
+\r
+            this.parcel = parcel;\r
+\r
+            pnlDetail.Visible = true;\r
+            if (parcel.SnapshotID != UUID.Zero)\r
+            {\r
+                SLImageHandler img = new SLImageHandler(instance, parcel.SnapshotID, "");\r
+                img.Dock = DockStyle.Fill;\r
+                pnlDetail.Controls.Add(img);\r
+                img.BringToFront();\r
+            }\r
+            btnTeleport.Enabled = true;\r
+            btnShowOnMap.Enabled = true;\r
+            txtParcelName.Text = string.Format("{0} - {1} ({2}, {3}, {4}) ", parcel.Name, parcel.SimName, (int)decodedLandmark.Position.X, (int)decodedLandmark.Position.Y, (int)decodedLandmark.Position.Z);\r
+            txtParcelDescription.Text = parcel.Description;\r
+        }\r
+\r
+        void Grid_OnRegionHandleReply(UUID regionID, ulong regionHandle)\r
+        {\r
+            if (decodedLandmark != null && decodedLandmark.RegionID != regionID) return;\r
+\r
+            parcelID = client.Parcels.RequestRemoteParcelID(decodedLandmark.Position, regionHandle, regionID);\r
+            if (parcelID != UUID.Zero)\r
+            {\r
+                client.Parcels.InfoRequest(parcelID);\r
+            }\r
+        }\r
+\r
+        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)\r
+        {\r
+            if (transfer.AssetID != landmark.AssetUUID) return;\r
+\r
+            if (transfer.Success && asset.AssetType == AssetType.Landmark)\r
+            {\r
+                decodedLandmark = (AssetLandmark)asset;\r
+                decodedLandmark.Decode();\r
+                client.Grid.RequestRegionHandle(decodedLandmark.RegionID);\r
+            }\r
+        }\r
+\r
+        private void btnTeleport_Click(object sender, EventArgs e)\r
+        {\r
+            client.Self.RequestTeleport(landmark.AssetUUID);\r
+        }\r
+    }\r
+}\r
diff --git a/Radegast/GUI/Consoles/Assets/Landmark.resx b/Radegast/GUI/Consoles/Assets/Landmark.resx
new file mode 100644 (file)
index 0000000..ff31a6d
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file