예제 #1
0
        public ntfGroupNotice(METAboltInstance instance, InstantMessage msg)
            : base(NotificationType.GroupNotice)
        {
            InitializeComponent();
            Disposed += new System.EventHandler(ntfGroupNotice_Disposed);

            this.instance = instance;
            this.msg      = msg;
            client.Groups.GroupProfile += new System.EventHandler <GroupProfileEventArgs>(Groups_GroupProfile);

            if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0)
            {
                type = (AssetType)msg.BinaryBucket[1];
                destinationFolderID = client.Inventory.FindFolderForType(type);
                int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower());
                if (icoIndx >= 0)
                {
                    icnItem.Image   = frmMain.ResourceImages.Images[icoIndx];
                    icnItem.Visible = true;
                }
                txtItemName.Text = Utils.BytesToString(msg.BinaryBucket, 18, msg.BinaryBucket.Length - 19);
                btnSave.Enabled  = true;
                btnSave.Visible  = icnItem.Visible = txtItemName.Visible = true;
            }


            if (msg.BinaryBucket.Length >= 18)
            {
                groupID = new UUID(msg.BinaryBucket, 2);
            }
            else
            {
                groupID = msg.FromAgentID;
            }

            int    pos   = msg.Message.IndexOf('|');
            string title = msg.Message.Substring(0, pos);

            lblTitle.Text = title;
            string text = msg.Message.Replace("\n", System.Environment.NewLine);

            text = text.Remove(0, pos + 1);

            lblSentBy.Text = string.Format("Sent by {0}", msg.FromAgentName);
            txtNotice.Text = text;

            if (instance.Groups.ContainsKey(groupID))
            {
                group = instance.Groups[groupID];
                ShowNotice();
            }
            else
            {
                client.Groups.RequestGroupProfile(groupID);
            }
        }
예제 #2
0
        void Assets_OnAssetReceived(AssetDownload transfer, Asset asset)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                {
                    BeginInvoke(new MethodInvoker(() => Assets_OnAssetReceived(transfer, asset)));
                }
                return;
            }

            if (transfer.Success)
            {
                AssetNotecard n = (AssetNotecard)asset;
                n.Decode();
                receivedNotecard = n;

                string noteText = string.Empty;
                rtbContent.Clear();

                for (int i = 0; i < n.BodyText.Length; i++)
                {
                    char c = n.BodyText[i];

                    if ((int)c == 0xdbc0)
                    {
                        int           index = (int)n.BodyText[++i] - 0xdc00;
                        InventoryItem e     = n.EmbeddedItems[index];
                        rtbContent.AppendText(noteText);
                        rtbContent.InsertLink(e.Name, string.Format("metabolt://embeddedasset/{0}", index));
                        noteText = string.Empty;
                    }
                    else
                    {
                        noteText += c;
                    }
                }

                rtbContent.Text += noteText;

                if (n.EmbeddedItems != null && n.EmbeddedItems.Count > 0)
                {
                    tbtnAttachments.Enabled = true;
                    tbtnAttachments.Visible = true;
                    foreach (InventoryItem item in n.EmbeddedItems)
                    {
                        int ix = InventoryConsole.GetItemImageIndex(item.AssetType.ToString().ToLower());
                        ToolStripMenuItem titem = new ToolStripMenuItem(item.Name);

                        if (ix != -1)
                        {
                            titem.Image        = frmMain.ResourceImages.Images[ix];
                            titem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                        }
                        else
                        {
                            titem.DisplayStyle = ToolStripItemDisplayStyle.Text;
                        }

                        titem.Name   = item.UUID.ToString();;
                        titem.Tag    = item;
                        titem.Click += new EventHandler(attachmentMenuItem_Click);

                        var saveToInv = new ToolStripMenuItem("Save to inventory");
                        saveToInv.Click += (object xsender, EventArgs xe) =>
                        {
                            client.Inventory.RequestCopyItemFromNotecard(UUID.Zero,
                                                                         notecard.UUID,
                                                                         client.Inventory.FindFolderForType(item.AssetType),
                                                                         item.UUID,
                                                                         Inventory_OnInventoryItemCopied);
                        };

                        titem.DropDownItems.Add(saveToInv);
                        tbtnAttachments.DropDownItems.Add(titem);
                    }
                }
                UpdateStatus("OK");
                rtbContent.Focus();
            }
            else
            {
                UpdateStatus("Failed");
                rtbContent.Text = "Failed to download notecard. " + transfer.Status;
            }
        }