Exemple #1
0
        private static void deleteColl_click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            string            path = item.Tag.ToString();

            CollectionTool.RemoveByPath(path);
        }
Exemple #2
0
 private void Delete_click(object sender, EventArgs e)
 {
     foreach (ListViewItem item in listView.CheckedItems)
     {
         string path = item.SubItems[3].Text;
         CollectionTool.RemoveByPath(path);
         listView.Items.RemoveAt(item.Index);
     }
 }
Exemple #3
0
        private void CollDelete_click(object sender, EventArgs e)
        {
            ToolStripMenuItem item      = (ToolStripMenuItem)sender;
            TreeNode          node      = (TreeNode)item.Tag;
            ImageTree         imageTree = (ImageTree)node.Tag;
            string            path      = imageTree.FullPath;

            treeViewImg.Nodes.Remove(node);
            CollectionTool.RemoveByPath(path);
        }
Exemple #4
0
        private void CreateListView()
        {
            listView        = new System.Windows.Forms.ListView();
            listView.Bounds = new Rectangle(new Point(0, 0), panelListView.Size);


            // Set the view to show details.
            listView.View = View.Details;
            // Allow the user to edit item text.
            listView.LabelEdit = true;
            // Allow the user to rearrange columns.
            listView.AllowColumnReorder = true;
            // Display check boxes.
            listView.CheckBoxes = true;
            // Select the item and subitems when selection is made.
            listView.FullRowSelect = true;
            // Display grid lines.
            listView.GridLines = true;
            // Sort the items in the list in ascending order.
            //listView1.Sorting = SortOrder.Ascending;

            // Width of -2 indicates auto-size.
            listView.Columns.Add("Index", -2, HorizontalAlignment.Center);
            listView.Columns.Add("Id", -2, HorizontalAlignment.Center);
            listView.Columns.Add("Date", -2, HorizontalAlignment.Center);
            listView.Columns.Add("     Path", 100, HorizontalAlignment.Left);
            listView.Columns.Add("Type", -2, HorizontalAlignment.Center);

            listView.Items.Clear();

            allCollection = CollectionTool.GetAllCollection();

            int index = 1;

            foreach (CollectionDetail coll in allCollection)
            {
                ListViewItem item = new ListViewItem(index.ToString());
                item.SubItems.Add(coll.Id);
                item.SubItems.Add(coll.Date);
                item.SubItems.Add(coll.Path);
                item.SubItems.Add(coll.Type);
                listView.Items.Add(item);
                index++;
            }
            listView.ItemChecked += new ItemCheckedEventHandler(listView_ItemChecked);

            listView.ItemSelectionChanged += new ListViewItemSelectionChangedEventHandler(listView_ItemSelectionChanged);

            listView.MouseDown += new MouseEventHandler(this.listView_MouseDown);

            panelListView.Controls.Add(listView);
        }
Exemple #5
0
        private void Collection_click(object sender, EventArgs e)
        {
            ToolStripMenuItem item      = (ToolStripMenuItem)sender;
            TreeNode          node      = (TreeNode)item.Tag;
            ImageTree         imageTree = (ImageTree)node.Tag;
            string            type      = imageTree.NodeType.ToString();
            string            path      = imageTree.FullPath;
            string            date      = DateTime.Now.ToString();
            Collection        coll      = new Collection(type, path, date);

            CollectionTool.Add(coll);
            LoadCollectionTree();
        }
Exemple #6
0
        private static void addColl_click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            string            path = item.Tag.ToString();
            Collection        coll = new Collection()
            {
                Type = "Image",
                Path = path,
                Date = DateTime.Now.ToString()
            };

            CollectionTool.Add(coll);
        }
Exemple #7
0
        private void LoadCollectionTree()
        {
            if (FindNode("我的收藏") == null)
            {
                ImageTree nodeTag = new ImageTree("我的收藏", "", NodeType.NodeTag);
                TreeNode  node    = new TreeNode("我的收藏");
                node.Tag              = nodeTag;
                node.ImageKey         = "folder.png";
                node.SelectedImageKey = "folder-select.png";
                treeViewImg.Nodes.Add(node);
            }
            TreeNode collNode = FindNode("我的收藏");

            collNode.Nodes.Clear();
            List <string> allPath = CollectionTool.GetALlPath();

            foreach (string path in allPath)
            {
                if (Directory.Exists(path)) //文件夹
                {
                    ImageTree fodler     = new ImageTree(Path.GetFileName(path), path, NodeType.Collection);
                    TreeNode  folderNode = new TreeNode(Path.GetFileName(path));
                    folderNode.Tag              = fodler;
                    folderNode.ImageKey         = "folder.png";
                    folderNode.SelectedImageKey = "folder-select.png";
                    collNode.Nodes.Add(folderNode);
                    LoadTreeView(path, folderNode);
                }
                else if (File.Exists(path)) //文件
                {
                    ImageTree image   = new ImageTree(Path.GetFileName(path), path, NodeType.Collection);
                    TreeNode  imgNode = new TreeNode(Path.GetFileName(path));
                    imgNode.Tag              = image;
                    imgNode.ImageKey         = "img.png";
                    imgNode.SelectedImageKey = "img-select.png";
                    collNode.Nodes.Add(imgNode);
                }
                else
                {
                    return;
                }
            }
        }
Exemple #8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            MainConfig.StartTreePath = @"F:\- PicViewTest";
            MainConfig.ImageSize     = new Size(16 * 10, 9 * 10);
            MainConfig.PanelTreeSize = panelTree.Size;
            MainConfig.PanelMainSize = panelMain.Size;
            MainConfig.ShowView      = ShowView.SmallView;
            MainConfig.CurNodeText   = "";

            CollectionTool.CreateJsonFile();


            AllowDrop  = true;
            KeyPreview = true;
            CenterToScreen();
            LoadTreeView();
            LoadUserControl();
            SetTsbBtnChecked();
        }
Exemple #9
0
        /// <summary>
        /// 在 pictureBox 上的图片上创建 ContextMenuStrip (添加到收藏,从收藏删除)
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static ContextMenuStrip CreateContextMenuStrip(string path)
        {
            ContextMenuStrip  contextMenuStrip;
            ToolStripMenuItem deleteColl;
            ToolStripMenuItem addColl;
            ToolStripMenuItem deleteFile;

            contextMenuStrip      = new ContextMenuStrip();
            contextMenuStrip.Name = "contextMenuStrip";

            addColl        = new ToolStripMenuItem();
            addColl.Name   = "AddCollection";
            addColl.Text   = "添加收藏";
            addColl.Click += new EventHandler(addColl_click);
            addColl.Tag    = path;

            contextMenuStrip.Items.Add(addColl);


            if (CollectionTool.FindByPath(path) == true)
            {
                deleteColl        = new ToolStripMenuItem();
                deleteColl.Name   = "DelCollection";
                deleteColl.Text   = "删除收藏";
                deleteColl.Click += new EventHandler(deleteColl_click);
                deleteColl.Tag    = path;
                contextMenuStrip.Items.Add(deleteColl);
            }


            deleteFile        = new ToolStripMenuItem();
            deleteFile.Name   = "Collection";
            deleteFile.Text   = "删除文件";
            deleteFile.Click += new EventHandler(deleteFile_click);
            deleteFile.Tag    = path;


            return(contextMenuStrip);
        }
Exemple #10
0
 private void button2_Click(object sender, EventArgs e)
 {
     CollectionTool.CreateJsonFile();
 }