Ejemplo n.º 1
0
        private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            clsImage imageInfo = e.Item.Tag as clsImage;

            imageInfo.Selected = e.IsSelected;

            if (this.listView1.SelectedItems.Count > 0)
            {
                selectedImageInfoList = ImageInfoList.FindAll(image => image.Selected == true);
            }

            UpdateCount();
        }
Ejemplo n.º 2
0
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(ListViewItem)) == null)
            {
                return;
            }

            Point        ptScreen = new Point(e.X, e.Y);
            Point        pt       = listView1.PointToClient(ptScreen);
            ListViewItem destItem = listView1.GetItemAt(pt.X, pt.Y);

            if (destItem != null)
            {
                clsImage destImageInfo = destItem.Tag as clsImage;
                Insert(destItem, selectedImageInfoList);
            }
        }
Ejemplo n.º 3
0
        private void Insert(ListViewItem destItem, List <clsImage> selectedImageInfoList)
        {
            if (destItem == null)
            {
                return;
            }

            clsImage destImageInfo = destItem.Tag as clsImage;

            if (selectedImageInfoList == null)
            {
                return;
            }
            if (selectedImageInfoList.Count <= 0)
            {
                return;
            }
            if (selectedImageInfoList.Contains(destImageInfo) == true)
            {
                return;
            }

            ImageInfoList.RemoveAll(imageInfo => imageInfo.Selected == true);
            if (destItem.Index < ImageInfoList.Count)
            {
                ImageInfoList.InsertRange(destItem.Index, selectedImageInfoList);
            }
            else
            {
                ImageInfoList.AddRange(selectedImageInfoList);
            }

            ImageInfoList.ForEach(imageInfo => imageInfo.Selected = false);

            selectedImageInfoList = null;
            FreshListview(ImageInfoList);
        }
Ejemplo n.º 4
0
        private void LoadImagesFromPath(List <string> filePathList)
        {
            if (filePathList != null)
            {
                foreach (var filePath in filePathList)
                {
                    FileInfo file = new FileInfo(filePath);

                    if (ImageInfoList.Exists(imageInfo => imageInfo.File.Name == file.Name) == false)
                    {
                        try
                        {
                            clsImage newImage = new clsImage(file);

                            if (checkBox1.Checked == true)
                            {
                                int    headLength = newImage.Name.IndexOf('_');
                                string head       = newImage.Name.Substring(0, headLength);
                                int    id         = 0;
                                if (int.TryParse(head, out id) == true)
                                {
                                    newImage.Name = newImage.Name.Remove(0, headLength + 1);
                                }
                            }

                            ImageInfoList.Add(newImage);
                        }
                        catch
                        {
                        }
                    }
                }

                FreshListview(ImageInfoList);
            }
        }