Exemple #1
0
        private void CopySelected()
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                int      idx  = listView1.SelectedIndices[0];
                Emoticon emot = RetrieveEmoticon(idx);
                if (emot.type == Emoticon.TYPE_ASCII)
                {
                    string text = UnicodeEncoding.UTF8.GetString(emot.data);
                    Clipboard.SetText(text);
                }
                else if (emot.type == Emoticon.TYPE_IMAGE)
                {
                    MemoryImage img = new MemoryImage(emot.data);
                    Clipboard.SetImage(img.Image);
                    img.Dispose();
                }
                store.UseEmoticon(emot.guid);

                // Refresh the view if we are in the Recent Emoticons Tab
                if (treeView1.SelectedNode != null && treeView1.SelectedNode.Name == "Recent")
                {
                    PopulateView(query);
                    // Select the first item, as that is the last used one.
                    listView1.SelectedIndices.Clear();
                    if (count > 0)
                    {
                        listView1.SelectedIndices.Add(0);
                        listView1.FocusedItem = listView1.Items[0];
                        listView1.FocusedItem.EnsureVisible();
                    }
                }
            }
        }
Exemple #2
0
        private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            Emoticon emoticon = RetrieveEmoticon(e.ItemIndex);

            if (emoticon != null)
            {
                Rectangle itemRect = this.listView1.GetItemRect(e.ItemIndex, ItemBoundsPortion.Icon);
                if (emoticon.type == Emoticon.TYPE_ASCII)
                {
                    string text = UnicodeEncoding.UTF8.GetString(emoticon.data);
                    DrawTextScaled(e.Graphics, text, listView1.Font, fontBrush, itemRect, 0.5f, 1.0f);
                }
                else if (emoticon.type == Emoticon.TYPE_IMAGE)
                {
                    MemoryImage img = new MemoryImage(emoticon.data);
                    Clipboard.SetImage(img.Image);
                    DrawImageScaled(e.Graphics, img.Image, itemRect, 0.5f, 1.0f);
                    img.Dispose();
                }
            }
            e.DrawFocusRectangle();
            if (listView1.View != View.Details)
            {
                e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.NoPrefix);
            }
        }