예제 #1
0
        private void lbxFriends_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbxFriends.SelectedItem == null)
            {
                return;
            }

            FriendsListItem item = (FriendsListItem)lbxFriends.SelectedItem;

            SetFriend(item.Friend);
        }
예제 #2
0
        private void lbxFriends_MouseDown(object sender, MouseEventArgs e)
        {
            lbxFriends_SelectedIndexChanged(null, null);

            Point pt    = new Point(e.X, e.Y);
            int   index = lbxFriends.IndexFromPoint(pt);

            // Starts a drag-and-drop operation.
            if (index >= 0 && index < lbxFriends.Items.Count)
            {
                FriendsListItem dltm = (FriendsListItem)lbxFriends.Items[index];

                lbxFriends.DoDragDrop(dltm, DragDropEffects.Copy);
            }
        }
예제 #3
0
        private void lbxFriends_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (e.Index < 0)
            {
                return;
            }

            FriendsListItem itemToDraw = (FriendsListItem)lbxFriends.Items[e.Index];

            Brush textBrush = null;
            Font  textFont  = null;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText));
                textFont  = new Font(e.Font, FontStyle.Bold);
            }
            else
            {
                textBrush = new SolidBrush(Color.FromKnownColor(KnownColor.ControlText));
                textFont  = new Font(e.Font, FontStyle.Regular);
            }

            SizeF stringSize = e.Graphics.MeasureString(itemToDraw.Friend.Name, textFont);
            float stringX    = e.Bounds.Left + 4 + Properties.Resources.green_orb.Width;
            float stringY    = e.Bounds.Top + 2 + ((Properties.Resources.green_orb.Height / 2) - (stringSize.Height / 2));

            if (itemToDraw.Friend.IsOnline)
            {
                e.Graphics.DrawImage(Properties.Resources.green_orb, e.Bounds.Left + 2, e.Bounds.Top + 2);
            }
            else
            {
                e.Graphics.DrawImage(Properties.Resources.green_orb_off, e.Bounds.Left + 2, e.Bounds.Top + 2);
            }

            e.Graphics.DrawString(" " + itemToDraw.Friend.Name, textFont, textBrush, stringX, stringY);

            e.DrawFocusRectangle();

            textFont.Dispose();
            textBrush.Dispose();
            textFont  = null;
            textBrush = null;
        }
예제 #4
0
        private void textBox2_DragDrop(object sender, DragEventArgs e)
        {
            if (lbGroups.SelectedIndex == -1)
            {
                MessageBox.Show("You must select a group from the list first.", "METAbolt", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            FriendsListItem node = e.Data.GetData(typeof(FriendsListItem)) as FriendsListItem;

            if (node == null)
            {
                return;
            }

            if (e.Data.GetDataPresent(typeof(FriendsListItem)))
            {
                fconfig.AddFriendToGroup(lbGroups.SelectedItem.ToString(), node.Friend.Name, node.Friend.UUID.ToString());
                MessageBox.Show(node.Friend.Name + " has been added to your '" + lbGroups.SelectedItem.ToString() + "' group.", "METAbolt", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }