示例#1
0
        public void AddPictureAndMessageToListView(string i_pictureURL, string i_message)
        {
            if (ListViewDestination != null && ImageListSource != null)
            {
                Bitmap bitmap;
                using (WebClient client = new WebClient())
                {
                    Stream stream = client.OpenRead(i_pictureURL);
                    bitmap = new Bitmap(stream);
                }

                ListViewDestination.Invoke(new Action(() =>
                {
                    ImageListSource.Images.Add(i_pictureURL, bitmap);

                    ListViewDestination.View           = View.LargeIcon;
                    ListViewDestination.LargeImageList = ImageListSource;       ////    imageList as pictures data source
                    ListViewDestination.Items.Add(i_message, i_pictureURL);     ////    load message and picture to listView
                }));
            }
            else if (ListViewDestination == null)
            {
                throw new Exception("There is no ListView to design. Please assign ListView");
            }
            else if (ImageListSource == null)
            {
                throw new Exception("Cannot add Pictures to ListView without using ImageList. Please Assign ImageListSource");
            }
        }
示例#2
0
 public void AddMessageToListView(string i_message)
 {
     if (!string.IsNullOrEmpty(i_message) && ListViewDestination != null)
     {
         ListViewDestination.Invoke(new Action(() => ListViewDestination.Items.Add(i_message)));
     }
     else if (ListViewDestination == null)
     {
         throw new Exception("There is no ListView to design. Please assign ListView");
     }
 }