OSDN Git Service

Added "Give inventory" button to the profile that gives item currency on the clipboar...
authorLatif Khalifa <latifer@streamgrid.net>
Tue, 17 Nov 2009 01:52:55 +0000 (01:52 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Tue, 17 Nov 2009 01:52:55 +0000 (01:52 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@448 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/RadegastInstance.cs
Radegast/GUI/Dialogs/Profile.Designer.cs
Radegast/GUI/Dialogs/Profile.cs

index 42ec395..db173ad 100644 (file)
@@ -153,14 +153,25 @@ namespace Radegast
         /// </summary>\r
         public RadegastMovement Movement { get { return movement; } }\r
 \r
+        private InventoryClipboard inventoryClipboard;\r
         /// <summary>\r
         /// The last item that was cut or copied in the inventory, used for pasting\r
         /// in a different place on the inventory, or other places like profile\r
         /// that allow sending copied inventory items\r
         /// </summary>\r
-        public InventoryClipboard InventoryClipboard;\r
+        public InventoryClipboard InventoryClipboard\r
+        {\r
+            get { return inventoryClipboard; }\r
+            set\r
+            {\r
+                inventoryClipboard = value;\r
+                OnInventoryClipboardUpdated(EventArgs.Empty);\r
+            }\r
+        }\r
 \r
         #region Events\r
+\r
+        #region ClientChanged event\r
         /// <summary>The event subscribers, null of no subscribers</summary>\r
         private EventHandler<ClientChangedEventArgs> m_ClientChanged;\r
 \r
@@ -183,6 +194,34 @@ namespace Radegast
             add { lock (m_ClientChangedLock) { m_ClientChanged += value; } }\r
             remove { lock (m_ClientChangedLock) { m_ClientChanged -= value; } }\r
         }\r
+        #endregion ClientChanged event\r
+\r
+        #region InventoryClipboardUpdated event\r
+        /// <summary>The event subscribers, null of no subscribers</summary>\r
+        private EventHandler<EventArgs> m_InventoryClipboardUpdated;\r
+\r
+        ///<summary>Raises the InventoryClipboardUpdated Event</summary>\r
+        /// <param name="e">A EventArgs object containing\r
+        /// the old and the new client</param>\r
+        protected virtual void OnInventoryClipboardUpdated(EventArgs e)\r
+        {\r
+            EventHandler<EventArgs> handler = m_InventoryClipboardUpdated;\r
+            if (handler != null)\r
+                handler(this, e);\r
+        }\r
+\r
+        /// <summary>Thread sync lock object</summary>\r
+        private readonly object m_InventoryClipboardUpdatedLock = new object();\r
+\r
+        /// <summary>Raised when the GridClient object in the main Radegast instance is changed</summary>\r
+        public event EventHandler<EventArgs> InventoryClipboardUpdated\r
+        {\r
+            add { lock (m_InventoryClipboardUpdatedLock) { m_InventoryClipboardUpdated += value; } }\r
+            remove { lock (m_InventoryClipboardUpdatedLock) { m_InventoryClipboardUpdated -= value; } }\r
+        }\r
+        #endregion InventoryClipboardUpdated event\r
+\r
+\r
         #endregion Events\r
 \r
         public RadegastInstance(GridClient client0)\r
index 6c34a6c..84b8628 100644 (file)
@@ -104,6 +104,7 @@ namespace Radegast
             this.label7 = new System.Windows.Forms.Label();\r
             this.btnClose = new System.Windows.Forms.Button();\r
             this.textBox1 = new System.Windows.Forms.TextBox();\r
+            this.btnGive = new System.Windows.Forms.Button();\r
             this.tabProfile.SuspendLayout();\r
             this.tpgProfile.SuspendLayout();\r
             this.tpgWeb.SuspendLayout();\r
@@ -131,6 +132,7 @@ namespace Radegast
             // \r
             // tpgProfile\r
             // \r
+            this.tpgProfile.Controls.Add(this.btnGive);\r
             this.tpgProfile.Controls.Add(this.lvwGroups);\r
             this.tpgProfile.Controls.Add(this.txtFullName);\r
             this.tpgProfile.Controls.Add(this.anPartner);\r
@@ -211,9 +213,9 @@ namespace Radegast
             // btnIM\r
             // \r
             this.btnIM.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.btnIM.Location = new System.Drawing.Point(312, 427);\r
+            this.btnIM.Location = new System.Drawing.Point(269, 427);\r
             this.btnIM.Name = "btnIM";\r
-            this.btnIM.Size = new System.Drawing.Size(96, 23);\r
+            this.btnIM.Size = new System.Drawing.Size(72, 23);\r
             this.btnIM.TabIndex = 19;\r
             this.btnIM.Text = "Start IM";\r
             this.btnIM.UseVisualStyleBackColor = true;\r
@@ -222,9 +224,9 @@ namespace Radegast
             // btnFriend\r
             // \r
             this.btnFriend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
-            this.btnFriend.Location = new System.Drawing.Point(210, 427);\r
+            this.btnFriend.Location = new System.Drawing.Point(179, 427);\r
             this.btnFriend.Name = "btnFriend";\r
-            this.btnFriend.Size = new System.Drawing.Size(96, 23);\r
+            this.btnFriend.Size = new System.Drawing.Size(84, 23);\r
             this.btnFriend.TabIndex = 18;\r
             this.btnFriend.Text = "Add Friend";\r
             this.btnFriend.UseVisualStyleBackColor = true;\r
@@ -254,7 +256,7 @@ namespace Radegast
             this.btnPay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));\r
             this.btnPay.Location = new System.Drawing.Point(108, 427);\r
             this.btnPay.Name = "btnPay";\r
-            this.btnPay.Size = new System.Drawing.Size(96, 23);\r
+            this.btnPay.Size = new System.Drawing.Size(65, 23);\r
             this.btnPay.TabIndex = 15;\r
             this.btnPay.Text = "Pay...";\r
             this.btnPay.UseVisualStyleBackColor = true;\r
@@ -607,6 +609,18 @@ namespace Radegast
             this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox1_DragDrop);\r
             this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox1_DragEnter);\r
             // \r
+            // btnGive\r
+            // \r
+            this.btnGive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.btnGive.Enabled = false;\r
+            this.btnGive.Location = new System.Drawing.Point(347, 428);\r
+            this.btnGive.Name = "btnGive";\r
+            this.btnGive.Size = new System.Drawing.Size(107, 23);\r
+            this.btnGive.TabIndex = 22;\r
+            this.btnGive.Text = "&Give Inventory";\r
+            this.btnGive.UseVisualStyleBackColor = true;\r
+            this.btnGive.Click += new System.EventHandler(this.btnGive_Click);\r
+            // \r
             // frmProfile\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
@@ -683,6 +697,7 @@ namespace Radegast
         public ListViewNoFlicker lvwGroups;\r
         private System.Windows.Forms.ColumnHeader clGroupName;\r
         private System.Windows.Forms.ColumnHeader clGroupTitle;\r
+        public System.Windows.Forms.Button btnGive;\r
 \r
     }\r
 }
\ No newline at end of file
index 17978e5..7c560fb 100644 (file)
@@ -77,6 +77,11 @@ namespace Radegast
                 btnFriend.Enabled = false;\r
             }\r
 \r
+            if (instance.InventoryClipboard != null)\r
+            {\r
+                btnGive.Enabled = true;\r
+            }\r
+\r
             // Callbacks\r
             client.Avatars.AvatarPropertiesReply += new EventHandler<AvatarPropertiesReplyEventArgs>(Avatars_AvatarPropertiesReply);\r
             client.Avatars.AvatarPicksReply += new EventHandler<AvatarPicksReplyEventArgs>(Avatars_AvatarPicksReply);\r
@@ -84,7 +89,7 @@ namespace Radegast
             client.Parcels.ParcelInfoReply += new EventHandler<ParcelInfoReplyEventArgs>(Parcels_ParcelInfoReply);\r
             client.Avatars.AvatarGroupsReply += new EventHandler<AvatarGroupsReplyEventArgs>(Avatars_AvatarGroupsReply);\r
             netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);\r
-\r
+            instance.InventoryClipboardUpdated += new EventHandler<EventArgs>(instance_InventoryClipboardUpdated);\r
             InitializeProfile();\r
         }\r
 \r
@@ -96,6 +101,12 @@ namespace Radegast
             client.Parcels.ParcelInfoReply -= new EventHandler<ParcelInfoReplyEventArgs>(Parcels_ParcelInfoReply);\r
             client.Avatars.AvatarGroupsReply -= new EventHandler<AvatarGroupsReplyEventArgs>(Avatars_AvatarGroupsReply);\r
             netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);\r
+            instance.InventoryClipboardUpdated -= new EventHandler<EventArgs>(instance_InventoryClipboardUpdated);\r
+        }\r
+\r
+        void instance_InventoryClipboardUpdated(object sender, EventArgs e)\r
+        {\r
+            btnGive.Enabled = instance.InventoryClipboard != null;\r
         }\r
 \r
         void Avatars_AvatarGroupsReply(object sender, AvatarGroupsReplyEventArgs e)\r
@@ -139,7 +150,6 @@ namespace Radegast
             }\r
             gotPicks = true;\r
             DisplayListOfPicks(e.Picks);\r
-\r
         }\r
 \r
         private void DisplayListOfPicks(Dictionary<UUID, string> picks)\r
@@ -484,5 +494,26 @@ namespace Radegast
                 catch (Exception) { }\r
             }\r
         }\r
+\r
+        private void btnGive_Click(object sender, EventArgs e)\r
+        {\r
+            if (instance.InventoryClipboard == null) return;\r
+\r
+            InventoryBase inv = instance.InventoryClipboard.Item;\r
+\r
+            if (inv is InventoryItem)\r
+            {\r
+                InventoryItem item = inv as InventoryItem;\r
+                client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, agentID, true);\r
+                instance.TabConsole.DisplayNotificationInChat("Offered item " + item.Name + " to " + fullName + ".");\r
+            }\r
+            else if (inv is InventoryFolder)\r
+            {\r
+                InventoryFolder folder = inv as InventoryFolder;\r
+                client.Inventory.GiveFolder(folder.UUID, folder.Name, AssetType.Folder, agentID, true);\r
+                instance.TabConsole.DisplayNotificationInChat("Offered folder " + folder.Name + " to " + fullName + ".");\r
+            }\r
+\r
+        }\r
     }\r
 }
\ No newline at end of file