C# Winform - Smiley box like messenger -


i want make smiley box live messenger.

smiley box

how can that? want selected picture?

thanks?

i use toolstrip , toolstripsplitbutton control , i'd create own control inhrited form panel show smiles contained in picturebox when happen click on toolstripsplitbutton.

i tried simulate behaviour do. here code:

public partial class form1 : form {     public form1()     {         initializecomponent();          this.suspendlayout();          list<bitmap> smiles = new list<bitmap>(); //add images          toolstripsplitbutton _toolstripsplitbutton = new toolstripsplitbutton();         _toolstripsplitbutton.size = new size(23, 23);         //_toolstripsplitbutton.image = myimage; //add image of stripsplitbutton          toolstrip _toolstrip = new toolstrip();         _toolstrip.size = new size(clientsize.width, 10);         _toolstrip.location = new point(0, this.clientsize.height - _toolstrip.height);         _toolstrip.backcolor = color.lightgray;         _toolstrip.dock = dockstyle.bottom;         _toolstrip.items.addrange(new toolstripitem[] { _toolstripsplitbutton });          smilebox smilebox = new smilebox(new point(_toolstripsplitbutton.bounds.location.x, _toolstrip.location.y - 18), 6);         smilebox.visible = false;          controls.add(smilebox);          foreach (bitmap bmp in smiles)             smilebox.additem(bmp);          _toolstripsplitbutton.click += new eventhandler(delegate(object sender, eventargs e)         {             smilebox.visible = true;         });          click += new eventhandler(delegate(object sender, eventargs e)         {             smilebox.visible = false;         });          this.controls.add(_toolstrip);         this.resumelayout();     }      void form1_click(object sender, eventargs e)     {         throw new notimplementedexception();     } }  class smilebox : panel {     public list<item> items     {         get;         set;     }      size _itemspace = new size(20, 20);     point _itemlocation;     int _rowelements = 0;      public smilebox(point location, int rowelements)     {         backcolor = color.lightgray;          height = _itemspace.height;         width = _itemspace.width * rowelements;          this.location = new point(location.x, location.y - height);         _itemlocation = new point(0, 0);         _rowelements = rowelements;     }      int count = 1;     public void additem(bitmap image)     {         item item = new item(_itemspace, _itemlocation, image);          if (_itemlocation.x + _itemspace.width >= width)             _itemlocation = new point(0, _itemlocation.y);         else             _itemlocation = new point(_itemlocation.x + _itemspace.width, _itemlocation.y);          if (count == _rowelements)         {             _itemlocation = new point(_itemlocation.x, _itemlocation.y + _itemspace.height);             height += _itemspace.height;             location = new point(location.x, location.y - _itemspace.height);              count = 0;         }          count++;          controls.add(item);     } }  class item : picturebox {     int _borderspace = 2;      public item(size size, point location, bitmap image)     {         this.size = new size(size.width - 2 * _borderspace, size.height - 2 * _borderspace);         this.location = new point(location.x + _borderspace, location.y + _borderspace);         this.image = new bitmap(image, this.clientsize);          click += new eventhandler(delegate(object sender, eventargs e)         {             //here want when user click on smile         });          mouseenter += new eventhandler(delegate(object sender, eventargs e)         {             focus();             invalidate();         });     }      protected override void onmousedown(mouseeventargs e)     {         this.focus();         base.onmousedown(e);     }      protected override void onenter(eventargs e)     {         this.invalidate();         base.onenter(e);     }      protected override void onleave(eventargs e)     {         this.invalidate();         base.onleave(e);     }      protected override void onpaint(painteventargs pe)     {         base.onpaint(pe);          if (this.focused)         {             clientrectangle.inflate(-1, -1);             rectangle rect = clientrectangle;             controlpaint.drawfocusrectangle(pe.graphics, rect);         }     } } 

here snapshot of create code:

enter image description here

and when on smile:

enter image description here

and here can click on single item.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -