Ejemplo n.º 1
0
        private void imageListView1_DropFiles(object sender, DropFileEventArgs e)
        {
            if (treeView1.SelectedNode.GetType().Name == "NodeCategory")
              {
              NodeCategory nCat = (NodeCategory)treeView1.SelectedNode;
              if (nCat.IsLeaf() == false)
              {
                  MessageBox.Show("You can't drop on a category with child ");
                  e.Cancel = true;
                  return;
              }
            FChoosePhotographer choosePhotographer = new FChoosePhotographer(nodephotographer);
            if (choosePhotographer.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                FilenamePhotoProvider fpp = new FilenamePhotoProvider(choosePhotographer.Photographe);

                ImageListView.ImageListViewSelectedItemCollection selected = imageListView1.SelectedItems;
                String DirectoryDst = nCat.getDirectory();
                List<string> Lfile = fpp.getPossibleFilename(DirectoryDst, e.FileNames.Length);

                string[] fileDst = new String[Lfile.Count];

                int n = 0;
                foreach (String s in Lfile)
                {
                    fileDst[n] = s;
                    n++;
                }

                this.Cursor = Cursors.WaitCursor;
                ShellFileOperation sfo = new ShellFileOperation();
                sfo.Operation = ShellFileOperation.FileOperations.FO_COPY;
                sfo.OwnerWindow = this.Handle;
                sfo.SourceFiles = e.FileNames;
                sfo.DestFiles =fileDst;
                sfo.ProgressTitle = "Import...";
                sfo.DoOperation();

                toolStripProgressBarThumb.Visible = true;
                toolStripProgressBarThumb.Minimum = 0;
                toolStripProgressBarThumb.Maximum = sfo.DestFiles.Length;
                ThumbMaker tm = new ThumbMaker();

                  tm.processFiles(sfo.DestFiles, DirectoryDst + "\\miniatures\\", delegate(int f, string m)
                  {
                        if (f == -1)
                        {
                           toolStripStatusLabel1.Text = m;
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = " Processing thumbnail File " + f.ToString();
                            toolStripProgressBarThumb.Value = f;
                            if (toolStripProgressBarThumb.Maximum-1 == f)
                            {
                                tabControl1.SelectedIndex = 0;
                                try
                                {
                                    PopulateListView(new DirectoryInfo(nCat.getDirectory()));
                                }
                                catch (Exception exp)
                                {
                                    MessageBox.Show("Error in category " + exp.Message);
                                }
                                FillGuiCategory(nCat);
                                //TreeNode node = (TreeNode)nodeCategory;
                                //ExpandNode(nodeCategory, node);
                                //nodeCategory.Expand();
                            }
                        }
                    });
                    this.Cursor = Cursors.Arrow;
                    toolStripProgressBarThumb.Visible = false;
                }
                else
                {
                    MessageBox.Show("Error Happen in the wizard configuration please try again ");
                }

                 }
             e.Cancel = true;
        }
Ejemplo n.º 2
0
        private void toolStripButtonImportPhoto_Click(object sender, EventArgs e)
        {
            FWizardImport wizard = new FWizardImport(nodephotographer,nodeCategory);
            if (wizard.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (wizard.hasError == false)
                {
                    this.Cursor = Cursors.WaitCursor;
                    ShellFileOperation sfo = new ShellFileOperation();
                    sfo.Operation = ShellFileOperation.FileOperations.FO_COPY;
                    //sfo.OperationFlags = ShellFileOperation.ShellFileOperationFlags.FOF_SIMPLEPROGRESS;
                    sfo.OwnerWindow = this.Handle;
                    sfo.SourceFiles = wizard.ListImage;
                    sfo.DestFiles = wizard.DstImage;
                    sfo.ProgressTitle = "Import...";
                    sfo.DoOperation();

                    toolStripProgressBarThumb.Visible = true;
                    toolStripProgressBarThumb.Minimum = 0;
                    toolStripProgressBarThumb.Maximum = sfo.DestFiles.Length;
                    ThumbMaker tm = new ThumbMaker();
                    tm.processFiles(sfo.DestFiles, wizard.DirectoryDst + "\\miniatures\\", delegate(int f, string m)
                    {
                        if (f == -1)
                        {
                           toolStripStatusLabel1.Text = m;
                          //treeView1.SelectedNode = ncat;
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = " Processing thumbnail File " + f.ToString();
                            toolStripProgressBarThumb.Value = f;
                            if (toolStripProgressBarThumb.Maximum-1 == f)
                            {

                                NodeCategory ncat = wizard.getSelectedCategory();
                                tabControl1.SelectedIndex = 0;
                                try
                                {
                                    PopulateListView(new DirectoryInfo(ncat.getDirectory()));
                                }
                                catch (Exception exp)
                                {
                                    MessageBox.Show("Error in category " + exp.Message);
                                }
                                FillGuiCategory(ncat);
                                //TreeNode node = (TreeNode)nodeCategory;
                                //ExpandNode(nodeCategory, node);
                                //nodeCategory.Expand();
                            }
                        }
                    });
                    this.Cursor = Cursors.Arrow;
                    toolStripProgressBarThumb.Visible = false;
                }
                else
                {
                    MessageBox.Show("Error Happen in the wizard configuration please try again ");
                }
            }
        }