Exemplo n.º 1
0
        private void selectImage()
        {
            DateTime captureTime = DateTime.MinValue;

            try
            {
                Image img = PhotoSortMgr.GetImageFromFile(selectedFileName, ref captureTime);
                if (captureTime != DateTime.MinValue)
                {
                    DisplayImage(img);
                }
                else
                {
                    img.Dispose();
                }

                selectedFileCaptureTime = captureTime;
                dateTimePicker1.Value   = captureTime;
            }
            catch (Exception ex)
            {
                selectedFileName = "";
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        //ToDo: Worker thread should no access UI elements
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            backgroundWorker1.ReportProgress(0);

            if (backGroundWork == BackgroundWork.Sort)
            {
                List <PhotoInfo> photoInfos = PhotoSortMgr.GetPhotosFromDirectory(photoDirectory, txtFiler.Text, cameraFilter, sender as BackgroundWorker, e);
                photoInfos.Sort();
                PhotoSortMgr.Rename(photoInfos, txtPrefix.Text, txtStartIndex.Text, sender as BackgroundWorker, e);
            }
            else if (backGroundWork == BackgroundWork.AddConstantTime)
            {
                PhotoSortMgr.LongTimeSpan lts;

                try
                {
                    lts = PhotoSortMgr.LongTimeSpan.FromStrings(txtAddConstant_Y.Text, txtAddConstant_Mon.Text, txtAddConstant_D.Text, txtAddConstant_h.Text, txtAddConstant_min.Text, txtAddConstant_s.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("error: can not convert the given time span!!!");
                    return;
                }

                PhotoSortMgr.ChangeCaptureDate(photoDirectory, lts, txtFiler2.Text, cameraFilter, sender as BackgroundWorker, e);
            }
            else if (backGroundWork == BackgroundWork.FromKnownImage)
            {
                TimeSpan difference           = dateTimePicker1.Value.Subtract(selectedFileCaptureTime);
                PhotoSortMgr.LongTimeSpan lts = PhotoSortMgr.LongTimeSpan.FromTimeSpan(difference);

                PhotoSortMgr.ChangeCaptureDate(photoDirectory, lts, txtFiler3.Text, cameraFilter, sender as BackgroundWorker, e);
            }
            else if (backGroundWork == BackgroundWork.ScanCameras)
            {
                camerasFound = PhotoSortMgr.GetListOfCamersFromDirectory(photoDirectory, txtFiler.Text + "|" + txtFiler2.Text + "|" + txtFiler3.Text, sender as BackgroundWorker, e);
            }

            backgroundWorker1.ReportProgress(100);
        }