Beispiel #1
0
        private void RealDeleteOperation(PortableDevice device, PortableDeviceFile item, List <ImageItem> deletedFiles, List <ImageItem> willbeuploaded)
        {
            try
            {
                foreach (ImageItem imageItem in deletedFiles)
                {
                    if (imageItem.UniqueIdentifier == item.Id)
                    {
                        deleteoperationcanbedone = true;
                        _imgManager.DeleteImageFromDirectory(imageItem);
                        device.DeleteFile((PortableDeviceFile)item);
                        deleteditem++;
                        Action action = () => ImageNumber(deleteditem, deletedFiles.Count);
                        Dispatcher.CurrentDispatcher.Invoke(action);
                        Thread.Sleep(100);
                        break;
                    }
                }

                if (!deleteoperationcanbedone && willbeuploaded.Count > 0)
                {
                    SetNotification(1, PhotoUploader.Properties.Resources.main_msg_imagenoexist);

                    Action action1 = () => ImageNumber(-1, deletedFiles.Count);
                    Dispatcher.CurrentDispatcher.Invoke(action1);
                    Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                Logger.Basic.Error("PWDManager Delete Operation : " + ex.ToString(), ex);
            }
        }
Beispiel #2
0
        }     // end of  public void GetAllImagesFromCamera()

        private void DisplayObject(PortableDevice device, PortableDeviceObject portableDeviceObject)
        {
            if (portableDeviceObject is PortableDeviceFolder)
            {
                DisplayFolderContents(device, (PortableDeviceFolder)portableDeviceObject);
            }
        }
Beispiel #3
0
        private void DisplayFolderContents(PortableDevice device, PortableDeviceFolder folder)
        {
            if (isdeleteoperation == false && isfetchingrunning == true)
            {
                foreach (var item in folder.Files)
                {
                    //Console.WriteLine(item.Id);

                    if (item is PortableDeviceFolder)
                    {
                        DisplayFolderContents(device, (PortableDeviceFolder)item);
                    }
                    if (item is PortableDeviceFile)
                    {
                        if (!devicestate)
                        {
                            break;
                        }
                        RealDownloadOperation(device, (PortableDeviceFile)item);
                    }
                }
            }

            if (isdeleteoperation == true && isfetchingrunning == false)
            {
                foreach (var item in folder.Files)
                {
                    if (item is PortableDeviceFolder)
                    {
                        DisplayFolderContents(device, (PortableDeviceFolder)item);
                    }



                    if (item is PortableDeviceFile)
                    {
                        if (!devicestate)
                        {
                            break;
                        }

                        RealDeleteOperation(device, (PortableDeviceFile)item, _deletedFiles, _willbeuploaded);
                    }
                }
            }
        }
Beispiel #4
0
        private int GetCountOfImageRec(PortableDevice device, PortableDeviceObject portableDeviceObject)
        {
            int count = 0;

            foreach (var item in ((PortableDeviceFolder)portableDeviceObject).Files)
            {
                if (item is PortableDeviceFolder)
                {
                    count = count + GetCountOfImageRec(device, (PortableDeviceFolder)item);
                }


                if (item is PortableDeviceFile)
                {
                    count++;
                }
            }

            return(count);
        }
Beispiel #5
0
        private void RealDownloadOperation(PortableDevice device, PortableDeviceFile item)
        {
            ImageItem imageItem = null;

            IPortableDeviceContent content = device.GetContentofDevice();

            DateTime createddate = device.GetObjectCreationTime(content, item.Id);

            imageItem = new ImageItem(0, item.Id, item.Id, createddate);

            if (_imageList.Exists((ImageItem t) => { return(t.UniqueIdentifier == item.Id); }))
            {
                countofimg++;
                Action action = () => FetchImageCount(countofimg, totalimagecount);
                Dispatcher.CurrentDispatcher.Invoke(action);
                Thread.Sleep(200);
            }
            else if ((!_imageList.Exists((ImageItem t) => { return(t.UniqueIdentifier == item.Id); }) ||
                      _imageList.Count == 0))
            {
                countofimg++;
                _imageList.Add(imageItem);

                bool isok = device.DownloadFile((PortableDeviceFile)item, ImageFolder);

                if (isok)
                {
                    Action action = () => FetchImageCount(countofimg, totalimagecount);
                    Dispatcher.CurrentDispatcher.Invoke(action);
                    Thread.Sleep(200);
                }
            }

            if (countofimg >= totalimagecount)
            {
                countofimg      = 0;
                totalimagecount = 0;
            }

            //else if (totalimagecount > 0 && countofimg < totalimagecount)
            //{

            //    countofimg++;
            //    Action action = () => FetchImageCount(countofimg, totalimagecount);
            //    Dispatcher.CurrentDispatcher.Invoke(action);
            //    Thread.Sleep(200);

            //    if (countofimg == totalimagecount)
            //    {
            //        countofimg = 0;
            //        totalimagecount = 0;
            //    }


            //}

            //if (totalimagecount > 0)
            //{
            //    if (countofimg == totalimagecount)
            //    {
            //        countofimg = 0;
            //        totalimagecount = 0;
            //    }
            //    device.DownloadFile((PortableDeviceFile)item, ImageFolder);
            //}
        }