Пример #1
0
        private void TSB_remove_Click(object sender, EventArgs e)
        {
            // Suspend the layout logic while we are removing items. Otherwise the control will be refreshed after each item is removed.
            ILV_photos.SuspendLayout();

            // Remove selected items
            foreach (var item in ILV_photos.SelectedItems)
            {
                ILV_photos.Items.Remove(item);
            }

            // Resume layout logic.
            ILV_photos.ResumeLayout(true);
            update_status();
        }
Пример #2
0
        /// <summary>
        /// Get items position and generate menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ILV_photos_MouseClick(object sender, MouseEventArgs e)
        {
            // Check right click
            if (e.Button == MouseButtons.Right)
            {
                // Get position hitted
                ImageListView.HitInfo hit_info;
                ILV_photos.HitTest(new Point(e.X, e.Y), out hit_info);
                int hitted = hit_info.ItemIndex;

                // Add the menu and check if an item is selected
                ContextMenuStrip cms = new ContextMenuStrip();
                if (hitted >= 0)
                {
                    cms.Items.Add("Open").Name = "open";
                    cms.Items.Add("Save").Name = "save";
                    cms.Show(ILV_photos, new Point(e.X, e.Y));
                    cms.ItemClicked += new ToolStripItemClickedEventHandler(cms_clicked);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Add person of the selected photos
        /// </summary>
        private void add_person_photos()
        {
            ILV_photos.Items.Clear();
            ILV_photos.ClearThumbnailCache();

            // Get current person name
            KeyValuePair <string, string> item = (KeyValuePair <string, string>)CB_name.SelectedItem;
            string path = Path.Combine(person_app_path, item.Key);

            if (Directory.Exists(path))
            {
                string[] files = person.get_person_photos(path);
                if (files != null)
                {
                    foreach (string file in files)
                    {
                        if (File.Exists(file))
                        {
                            ILV_photos.Items.Add(file);
                        }
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Add files in the image list view
        /// </summary>
        /// <param name="files"></param>
        private void add_files(List <string> files)
        {
            ILV_photos.ClearThumbnailCache();

            // Db error
            if (files == null)
            {
                // TODO error
            }
            else if (files.Count() > 0)
            {
                // Add file to the ImageList

                foreach (string file in files)
                {
                    // Check if full path
                    // Full => c:/
                    // Not full => /....
                    if (!check_path(file))
                    {
                        // Get photo path
                        //string photo = Path.Combine(id, file);
                        string photo = $"{identify_dir_path}{file}";

                        // If exist add it to the Image list
                        if (File.Exists(photo))
                        {
                            ILV_photos.Items.Add(photo);
                        }
                        else
                        {
                            // Locate photo in Picture Windows folder
                            MessageBox.Show("locate");
                            string loc = locate.locate_file(file);
                            if (loc != string.Empty)
                            {
                                ILV_photos.Items.Add(loc);
                            }
                        }
                    }
                    else
                    {
                        // If exist add it to the Image list
                        if (File.Exists(file))
                        {
                            ILV_photos.Items.Add(file);
                        }
                        else
                        {
                            // Locate photo in Picture Windows folder
                            MessageBox.Show("locate");
                            string loc = locate.locate_file(file);
                            if (loc != string.Empty)
                            {
                                ILV_photos.Items.Add(loc);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("No photo found.");
            }
        }