Beispiel #1
0
        void PVMainFormDragDrop(object sender, DragEventArgs e)
        {
            var dropItems = (string[])e.Data.GetData(DataFormats.FileDrop);
            var dropFiles = new List <string>();

            foreach (var dropItem in dropItems)
            {
                try
                {
                    var attr = File.GetAttributes(dropItem);
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        dropFiles.AddRange(Directory.EnumerateFiles(dropItem, "*.*", SearchOption.AllDirectories).OrderBy(x => x));
                    }
                    else
                    {
                        dropFiles.Add(dropItem);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    var result = MessageBox.Show(dropItem + "\n\n" + ex.Message + "\n\nContinue loading other files?", "Problem", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (result == DialogResult.OK)
                    {
                        continue;
                    }
                    return;
                }
            }
            foreach (var dropFile in dropFiles)
            {
                PVFile pvFile = null;
                try
                {
                    pvFile = PVFile.Load(dropFile);
                    pvDataViewer.AddItem(pvFile);
                }
                catch (Exception ex)
                {
                    var result = MessageBox.Show(dropFile + "\n\n" + ex.Message + "\n\nContinue loading other files?", "Problem", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (result == DialogResult.OK)
                    {
                        continue;
                    }
                    return;
                }
            }
        }
Beispiel #2
0
        public void AddItem(PVFile pvFile)
        {
            // Check if the file has already been added
            foreach (DataGridViewRow row in Rows)
            {
                var existingFile = row.Tag as PVFile;
                if (existingFile.FileName == pvFile.FileName)
                {
                    throw new Exception("The file is already in the list.");
                }
            }
            int rowIndex = Rows.Add(pvFile.FileName);

            Rows[rowIndex].Tag = pvFile;
        }
        public void AddItem(PVFile pvFile)
        {
            // Check if the file has already been added
            foreach (DataGridViewRow dgvr in Rows)
            {
                var existingFile = dgvr.Tag as PVFile;
                if (existingFile.FileName == pvFile.FileName)
                {
                    throw new Exception("The file has already been added.");
                }
            }
            int rowNum = Rows.Add(pvFile.FileName);

            Rows[rowNum].Tag = pvFile;
        }
Beispiel #4
0
        public void SetFile(PVFile newFile)
        {
            if (pvFile != null)
            {
                pvFile.Dispose();
            }

            pvFile = newFile;
            if (pvFile == null)
            {
                FileChanged.Invoke(this, new FileChangedEventArgs());
                PageChanged.Invoke(this, new PageChangedEventArgs());
            }
            else
            {
                FileChanged.Invoke(this, new FileChangedEventArgs(pvFile.FileName, pvFile.PageCount));
                SetPage(1);
                //SetPage(currentPage < 1 ? 1 : currentPage > pvFile.PageCount ? pvFile.PageCount : currentPage);
            }
        }