OSDN Git Service

Avoid crashing when detaching image not fully downloaded. Other consistency improvement
authorLatif Khalifa <latifer@streamgrid.net>
Wed, 15 Jul 2009 17:59:36 +0000 (17:59 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Wed, 15 Jul 2009 17:59:36 +0000 (17:59 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@111 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Consoles/Assets/Notecard.Designer.cs
Radegast/GUI/Consoles/Assets/Notecard.cs
Radegast/GUI/Consoles/Assets/SLImageHandler.cs
Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs
Radegast/GUI/Consoles/Inventory/InventoryConsole.cs

index 2f12a18..e4fe762 100644 (file)
@@ -68,6 +68,7 @@
             this.tbtnExit = new System.Windows.Forms.ToolStripMenuItem();\r
             this.tbtnAttachments = new System.Windows.Forms.ToolStripDropDownButton();\r
             this.tbtnAttach = new System.Windows.Forms.ToolStripButton();\r
+            this.tlblStatus = new System.Windows.Forms.ToolStripLabel();\r
             this.toolStrip1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
@@ -90,7 +91,8 @@
             this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
             this.tbtnFile,\r
             this.tbtnAttachments,\r
-            this.tbtnAttach});\r
+            this.tbtnAttach,\r
+            this.tlblStatus});\r
             this.toolStrip1.Location = new System.Drawing.Point(0, 0);\r
             this.toolStrip1.Name = "toolStrip1";\r
             this.toolStrip1.Size = new System.Drawing.Size(382, 25);\r
             // tbtnSave\r
             // \r
             this.tbtnSave.Name = "tbtnSave";\r
-            this.tbtnSave.Size = new System.Drawing.Size(152, 22);\r
+            this.tbtnSave.Size = new System.Drawing.Size(146, 22);\r
             this.tbtnSave.Text = "Save";\r
             this.tbtnSave.Click += new System.EventHandler(this.tbtnSave_Click);\r
             // \r
             // tbtnSaveToDisk\r
             // \r
             this.tbtnSaveToDisk.Name = "tbtnSaveToDisk";\r
-            this.tbtnSaveToDisk.Size = new System.Drawing.Size(152, 22);\r
+            this.tbtnSaveToDisk.Size = new System.Drawing.Size(146, 22);\r
             this.tbtnSaveToDisk.Text = "Save to Disk...";\r
             // \r
             // sprtExit\r
             // \r
             this.sprtExit.Name = "sprtExit";\r
-            this.sprtExit.Size = new System.Drawing.Size(149, 6);\r
+            this.sprtExit.Size = new System.Drawing.Size(143, 6);\r
             // \r
             // tbtnExit\r
             // \r
             this.tbtnExit.Enabled = false;\r
             this.tbtnExit.Name = "tbtnExit";\r
-            this.tbtnExit.Size = new System.Drawing.Size(152, 22);\r
+            this.tbtnExit.Size = new System.Drawing.Size(146, 22);\r
             this.tbtnExit.Text = "Exit";\r
             this.tbtnExit.Click += new System.EventHandler(this.tbtnExit_Click);\r
             // \r
             this.tbtnAttach.Text = "Detach";\r
             this.tbtnAttach.Click += new System.EventHandler(this.tbtnAttach_Click);\r
             // \r
+            // tlblStatus\r
+            // \r
+            this.tlblStatus.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;\r
+            this.tlblStatus.Name = "tlblStatus";\r
+            this.tlblStatus.Size = new System.Drawing.Size(38, 22);\r
+            this.tlblStatus.Text = "status";\r
+            // \r
             // Notecard\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
         private System.Windows.Forms.ToolStripMenuItem tbtnExit;\r
         private System.Windows.Forms.ToolStripDropDownButton tbtnAttachments;\r
         private System.Windows.Forms.ToolStripButton tbtnAttach;\r
+        private System.Windows.Forms.ToolStripLabel tlblStatus;\r
     }\r
 }\r
index 66052c9..dc0fecd 100644 (file)
@@ -58,11 +58,12 @@ namespace Radegast
             Text = notecard.Name;\r
 \r
             rtbContent.DetectUrls = false;\r
-            rtbContent.Text = "Loading...";\r
 \r
             // Callbacks\r
             client.Assets.OnAssetReceived += new AssetManager.AssetReceivedCallback(Assets_OnAssetReceived);\r
 \r
+            rtbContent.Text = " ";\r
+            UpdateStatus("Loading...");\r
             client.Assets.RequestInventoryAsset(notecard, true);\r
         }\r
 \r
@@ -139,9 +140,11 @@ namespace Radegast
                         tbtnAttachments.DropDownItems.Add(titem);\r
                     }\r
                 }\r
+                UpdateStatus("OK");\r
             }\r
             else\r
             {\r
+                UpdateStatus("Failed");\r
                 rtbContent.Text = "Failed to download notecard.";\r
             }\r
         }\r
@@ -240,14 +243,41 @@ namespace Radegast
 \r
             n.Encode();\r
 \r
+            UpdateStatus("Saving...");\r
+\r
+\r
             client.Inventory.RequestUploadNotecardAsset(n.AssetData, notecard.UUID,\r
                 delegate(bool uploadSuccess, string status, UUID itemID, UUID assetID)\r
                 {\r
                     success = uploadSuccess;\r
+                    if (itemID == notecard.UUID)\r
+                    {\r
+                        if (success)\r
+                        {\r
+                            UpdateStatus("OK");\r
+                            notecard.AssetUUID = assetID;\r
+                        }\r
+                        else\r
+                        {\r
+                            UpdateStatus("Failed");\r
+                        }\r
+\r
+                    }\r
                     message = status ?? "Unknown error uploading notecard asset";\r
                 }\r
             );\r
         }\r
 \r
+        void UpdateStatus(string status)\r
+        {\r
+            if (InvokeRequired)\r
+            {\r
+                BeginInvoke(new MethodInvoker(delegate() { UpdateStatus(status); }));\r
+                return;\r
+            }\r
+\r
+            tlblStatus.Text = status;\r
+        }\r
+\r
     }\r
 }\r
index 74b98b3..2c16990 100644 (file)
@@ -110,7 +110,7 @@ namespace Radegast
                 {\r
                     // DisplayPartialImage(assetTexture);\r
                 }\r
-            }, true);\r
+            });\r
         }\r
 \r
         void SLImageHandler_Disposed(object sender, EventArgs e)\r
@@ -208,7 +208,10 @@ namespace Radegast
         protected override void Detach()\r
         {\r
             base.Detach();\r
-            ClientSize = pictureBox1.Size = new Size(image.Width, image.Height);\r
+            if (image != null)\r
+            {\r
+                ClientSize = pictureBox1.Size = new Size(image.Width, image.Height);\r
+            }\r
         }\r
 \r
         private void saveToolStripMenuItem_Click(object sender, EventArgs e)\r
index 4513b2d..d777870 100644 (file)
@@ -76,7 +76,7 @@
             this.pnlDetail = new System.Windows.Forms.Panel();\r
             this.panel1 = new System.Windows.Forms.Panel();\r
             this.btnProfile = new System.Windows.Forms.Button();\r
-            this.txtCreator = new System.Windows.Forms.TextBox();\r
+            this.txtCreator = new Radegast.AgentNameTextBox();\r
             this.txtCreated = new System.Windows.Forms.TextBox();\r
             this.txtAssetID = new System.Windows.Forms.TextBox();\r
             this.lblCreated = new System.Windows.Forms.Label();\r
         private System.Windows.Forms.TextBox txtItemName;\r
         private System.Windows.Forms.Label lblCreator;\r
         private System.Windows.Forms.Label lblItemName;\r
-        private System.Windows.Forms.TextBox txtCreator;\r
+        private Radegast.AgentNameTextBox txtCreator;\r
         private System.Windows.Forms.TextBox txtAssetID;\r
         private System.Windows.Forms.Label lblAsset;\r
         private System.Windows.Forms.Panel pnlDetail;\r
index 468f2da..77868e9 100644 (file)
@@ -110,7 +110,6 @@ namespace Radegast
             _EditTimer = new System.Threading.Timer(OnLabelEditTimer, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);\r
 \r
             // Callbacks\r
-            client.Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);\r
             Inventory.OnInventoryObjectAdded += new Inventory.InventoryObjectAdded(Store_OnInventoryObjectAdded);\r
             Inventory.OnInventoryObjectUpdated += new Inventory.InventoryObjectUpdated(Store_OnInventoryObjectUpdated);\r
             Inventory.OnInventoryObjectRemoved += new Inventory.InventoryObjectRemoved(Store_OnInventoryObjectRemoved);\r
@@ -120,7 +119,6 @@ namespace Radegast
 \r
         void InventoryConsole_Disposed(object sender, EventArgs e)\r
         {\r
-            client.Avatars.OnAvatarNames -= new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);\r
             Inventory.OnInventoryObjectAdded -= new Inventory.InventoryObjectAdded(Store_OnInventoryObjectAdded);\r
             Inventory.OnInventoryObjectUpdated -= new Inventory.InventoryObjectUpdated(Store_OnInventoryObjectUpdated);\r
             Inventory.OnInventoryObjectRemoved -= new Inventory.InventoryObjectRemoved(Store_OnInventoryObjectRemoved);\r
@@ -324,24 +322,6 @@ namespace Radegast
                 AddBase(parent, newObject);\r
             }\r
         }\r
-\r
-        void Avatars_OnAvatarNames(Dictionary<UUID, string> names)\r
-        {\r
-            if (txtCreator.Tag == null) return;\r
-            if (InvokeRequired)\r
-            {\r
-                BeginInvoke(new MethodInvoker(delegate()\r
-                {\r
-                    Avatars_OnAvatarNames(names);\r
-                }));\r
-                return;\r
-            }\r
-\r
-            if (names.ContainsKey((UUID)txtCreator.Tag))\r
-            {\r
-                txtCreator.Text = names[(UUID)txtCreator.Tag];\r
-            }\r
-        }\r
         #endregion\r
 \r
         #region Node manipulation\r
@@ -646,7 +626,7 @@ namespace Radegast
 \r
         private void btnProfile_Click(object sender, EventArgs e)\r
         {\r
-            (new frmProfile(instance, txtCreator.Text, (UUID)txtCreator.Tag)).Show();\r
+            (new frmProfile(instance, txtCreator.Text, txtCreator.AgentID)).Show();\r
             \r
         }\r
 \r
@@ -654,7 +634,7 @@ namespace Radegast
         {\r
             btnProfile.Enabled = true;\r
             txtItemName.Text = item.Name;\r
-            txtCreator.Text = instance.getAvatarName(item.CreatorID);\r
+            txtCreator.AgentID = item.CreatorID;\r
             txtCreator.Tag = item.CreatorID;\r
             txtCreated.Text = item.CreationDate.ToString();\r
 \r