Beispiel #1
0
        public DateTimeSetTimeZone(FileDatabase fileDatabase, ImageRow imageToCorrect, Window owner)
        {
            // Check the arguments for null
            ThrowIf.IsNullArgument(fileDatabase, nameof(fileDatabase));
            ThrowIf.IsNullArgument(imageToCorrect, nameof(imageToCorrect));

            this.InitializeComponent();
            this.displayingPreview = false;
            this.fileDatabase      = fileDatabase;
            this.Owner             = owner;

            // get the image's current time
            DateTimeOffset currentDateTime = imageToCorrect.DateTimeIncorporatingOffset;

            this.originalDate.Content = DateTimeHandler.ToStringDisplayDateTimeUtcOffset(currentDateTime);

            // get the image filename and display it
            this.FileName.Content = imageToCorrect.File;
            this.FileName.ToolTip = this.FileName.Content;

            // display the image
            this.image.Source = imageToCorrect.LoadBitmap(this.fileDatabase.FolderPath, out bool isCorruptOrMissing);

            // configure timezone picker
            TimeZoneInfo imageSetTimeZone = this.fileDatabase.ImageSet.GetSystemTimeZone();

            this.TimeZones.SelectedItem      = imageSetTimeZone.DisplayName;
            this.TimeZones.SelectionChanged += this.TimeZones_SelectionChanged;
        }
        // Create the image
        private static Image CreateImage(ImageRow imageRow, int margin, double imageHeight)
        {
            //imageHeight = 2 * imageHeight;
            Image image = new Image
            {
                Source = imageRow.LoadBitmap(GlobalReferences.MainWindow.FolderPath, Convert.ToInt32(imageHeight), ImageDisplayIntentEnum.Persistent, ImageDimensionEnum.UseHeight, out bool isCorruptOrMissing)
            };

            // Need to scale the image to the correct height
            if (isCorruptOrMissing)
            {
                if (image.Height <= 0 || Constant.ImageValues.FileNoLongerAvailable.Value.Height <= 0)
                {
                    image.Source = null;
                }
                else
                {
                    double scale = imageHeight / Constant.ImageValues.FileNoLongerAvailable.Value.Height;
                    image.Source = new TransformedBitmap(Constant.ImageValues.FileNoLongerAvailable.Value, new ScaleTransform(scale, scale));
                }
                image.Tag = null;
            }
            else if (image.Source?.Height > 0 && image.Height != image.Source.Height)
            {
                // Need to adjust the image width due to differing dpi settings of the bitmap vs. device independent units used to actually display the bitmap
                // as otherwise it may not be the correct size. It may not be the mose efficient way to do this, but it seems to work.
                double scale = imageHeight / image.Source.Height;
                image.Source = new TransformedBitmap((BitmapSource)image.Source, new ScaleTransform(scale, scale));
            }
            image.Tag    = imageRow;
            image.Margin = new Thickness(margin);
            return(image);
        }
Beispiel #3
0
        // When the user enters a listbox item, show the image
        private void Lbi_MouseEnter(object sender, MouseEventArgs e)
        {
            if (!(sender is ListBoxItem lbi))
            {
                return;
            }
            ImageRow ir    = (ImageRow)lbi.Tag;
            Image    image = new Image()
            {
                Source = ir.LoadBitmap(this.fileDatabase.FolderPath, Constant.ImageValues.PreviewWidth384, out _),
                Height = 300,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            lbi.ToolTip = image;
        }
Beispiel #4
0
        private void DeleteCurrentImageOnly()
        {
            // The single file to delete
            ImageRow imageRow = this.filesToDelete[0];

            // Show  the deleted file name and image in the interface
            this.ShowSingleFileView();
            this.maxPathLength = 70;
            string filePath = Path.Combine(imageRow.RelativePath, imageRow.File);

            if (string.IsNullOrEmpty(filePath) == false)
            {
                filePath = filePath.Length <= this.maxPathLength ? filePath : "..." + filePath.Substring(filePath.Length - this.maxPathLength, this.maxPathLength);
            }

            this.SingleImageViewer.Source  = imageRow.LoadBitmap(this.fileDatabase.FolderPath, Constant.ImageValues.PreviewWidth480, out _);
            this.SingleFilePanel.ToolTip   = Path.Combine(imageRow.RelativePath, imageRow.File);
            this.SingleImageViewer.ToolTip = Path.Combine(imageRow.RelativePath, imageRow.File);
            this.SingleFileNameRun.Text    = filePath;

            // Populate the information pane
            string imageOrVideo = this.filesToDelete[0].IsVideo ? "video" : "image";

            this.Message.Title  = String.Format("Delete the current {0}", imageOrVideo);
            this.Message.What   = String.Format("Deletes the current {0} if it exists", imageOrVideo);
            this.Message.Result = String.Format("\u2022 The deleted {0} will be backed up in a sub-folder named {1}.{2}", imageOrVideo, Constant.File.DeletedFilesFolder, Environment.NewLine);
            this.Message.Hint   = String.Format("\u2022 Restore the deleted {0} by manually moving it ", imageOrVideo);
            if (this.deleteImageAndData == false)
            {
                // Case 1: Delete the current image, but not its data.
                this.Message.Title  += " but not its data.";
                this.Message.What   += String.Format("{0}The data entered for the {1} IS NOT deleted.", Environment.NewLine, imageOrVideo);
                this.Message.Result += String.Format("\u2022 A placeholder {0} will be shown when you try to view a deleted {0}.", imageOrVideo);
                this.Message.Hint   += "back to its original location." + Environment.NewLine;
            }
            else
            {
                // Case 2: Delete the current image and its data
                this.Message.Title  += " and its data";
                this.Message.What   += String.Format("{0}The data entered for the {1} IS deleted as well.", Environment.NewLine, imageOrVideo);
                this.Message.Result += String.Format("\u2022 However, the data associated with that {0} will be permanently deleted.", imageOrVideo);
                this.Message.Hint   += "to a new sub-folder." + Environment.NewLine + "  Then add that sub-folder back to the image set." + Environment.NewLine;
            }
            this.Message.Hint += String.Format("\u2022 See Options|Preferences to manage how files in {0} are permanently deleted.", Constant.File.DeletedFilesFolder);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Set up a progress handler that will update the progress bar
            this.InitalizeProgressHandler(this.BusyCancelIndicator);

            // Set up the initial UI and values
            this.latestImageDateTime   = DateTimeOffset.MinValue;
            this.earliestImageDateTime = DateTimeOffset.MaxValue;

            // Search the images for the two images with the earliest and latest data/time date
            ImageRow latestImageRow   = null;
            ImageRow earliestImageRow = null;

            foreach (ImageRow image in this.fileDatabase.FileTable)
            {
                DateTimeOffset currentImageDateTime = image.DateTimeIncorporatingOffset;

                // If the current image's date is later, then it is a candidate latest image
                if (currentImageDateTime >= this.latestImageDateTime)
                {
                    latestImageRow           = image;
                    this.latestImageDateTime = currentImageDateTime;
                }

                // If the current image's date is earlier, then it is a candidate earliest image
                if (currentImageDateTime <= this.earliestImageDateTime)
                {
                    earliestImageRow           = image;
                    this.earliestImageDateTime = currentImageDateTime;
                }
            }

            // At this point, we should have succeeded getting the oldest and newest data/time

            // Configure the earliest date (in datetime picker) and its image
            this.earliestImageName.Content = earliestImageRow.File;
            this.earliestImageDate.Content = DateTimeHandler.ToStringDisplayDateTime(this.earliestImageDateTime);
            this.imageEarliest.Source      = earliestImageRow.LoadBitmap(this.fileDatabase.FolderPath, out bool isCorruptOrMissing);

            // Configure the latest date (in datetime picker) and its image
            this.latestImageName.Content = latestImageRow.File;
            DataEntryHandler.Configure(this.dateTimePickerLatestDateTime, this.latestImageDateTime.DateTime);
            this.dateTimePickerLatestDateTime.ValueChanged += this.DateTimePicker_ValueChanged;
            this.imageLatest.Source = latestImageRow.LoadBitmap(this.fileDatabase.FolderPath, out isCorruptOrMissing);
        }
Beispiel #6
0
        // Set the tooltip to the image, if possible, when we enter the row
        private void Row_MouseEnter(object sender, MouseEventArgs e)
        {
            // Set the ToolTip to the image in the row's tag
            DataGridRow      row   = e.Source as DataGridRow;
            FeedbackRowTuple tuple = (FeedbackRowTuple)row?.Item;
            ImageRow         ir    = tuple?.ImageRow;

            if (row == null || tuple == null || ir == null)
            {
                return;
            }

            // Load an image from thie image row (specified in the tuple.Tag)
            Image image = new Image()
            {
                Source = ir.LoadBitmap(this.FolderPath, Constant.ImageValues.PreviewWidth480, out bool _)
            };

            row.ToolTip = image;
        }
Beispiel #7
0
        // Create the image
        private static Image CreateImage(ImageRow imageRow, int margin, double imageHeight)
        {
            Image image = new Image
            {
                Source = imageRow.LoadBitmap(GlobalReferences.MainWindow.FolderPath, Convert.ToInt32(imageHeight), ImageDisplayIntentEnum.Persistent, ImageDimensionEnum.UseHeight, out bool isCorruptOrMissing)
            };

            // Need to scale the image to the correct height
            if (isCorruptOrMissing)
            {
                if (image.Height <= 0 || Constant.ImageValues.FileNoLongerAvailable.Value.Height <= 0)
                {
                    image.Source = null;
                }
                else
                {
                    double scale = imageHeight / Constant.ImageValues.FileNoLongerAvailable.Value.Height;
                    image.Source = new TransformedBitmap(Constant.ImageValues.FileNoLongerAvailable.Value, new ScaleTransform(scale, scale));
                }
            }
            image.Margin = new Thickness(margin);
            return(image);
        }
        private void DeleteCurrentImageOnly()
        {
            // The single file to delete
            ImageRow imageRow = this.filesToDelete[0];

            // Show  the deleted file name and image in the interface
            this.ShowSingleFileView();
            this.maxPathLength = 70;
            string filePath = Path.Combine(imageRow.RelativePath, imageRow.File);

            if (string.IsNullOrEmpty(filePath) == false)
            {
                filePath = filePath.Length <= this.maxPathLength ? filePath : "..." + filePath.Substring(filePath.Length - this.maxPathLength, this.maxPathLength);
            }

            this.SingleImageViewer.Source  = imageRow.LoadBitmap(this.fileDatabase.FolderPath, Constant.ImageValues.PreviewWidth480, out _);
            this.SingleFilePanel.ToolTip   = Path.Combine(imageRow.RelativePath, imageRow.File);
            this.SingleImageViewer.ToolTip = Path.Combine(imageRow.RelativePath, imageRow.File);
            this.SingleFileNameRun.Text    = filePath;

            // Populate the information pane
            string imageOrVideo = this.filesToDelete[0].IsVideo ? "video" : "image";

            if (this.deleteImage == true)
            {
                this.Message.Title  = String.Format("Delete the current {0}", imageOrVideo);
                this.Message.What   = String.Format("Deletes the current {0} if it exists", imageOrVideo);
                this.Message.Result = String.Format("\u2022 The deleted {0} will be backed up in a sub-folder named {1}.{2}", imageOrVideo, Constant.File.DeletedFilesFolder, Environment.NewLine);
                this.Message.Hint   = String.Format("\u2022 Restore the deleted {0} by manually moving it ", imageOrVideo);
                if (this.deleteImage == true && this.deleteData == false)
                {
                    // Case 1: Delete the current image, but not its data.

                    this.Message.Title  += " but not its data.";
                    this.Message.What   += String.Format("{0}The data entered for the {1} IS NOT deleted.", Environment.NewLine, imageOrVideo);
                    this.Message.Result += String.Format("\u2022 A placeholder {0} will be shown when you try to view a deleted {0}.", imageOrVideo);
                    this.Message.Hint   += "back to its original location." + Environment.NewLine;
                }
                else if (this.deleteImage == true && this.deleteData == true)
                {
                    // Case 2: Delete the current image and its data
                    this.Message.Title  += " and its data";
                    this.Message.What   += String.Format("{0}The data entered for the {1} IS deleted as well.", Environment.NewLine, imageOrVideo);
                    this.Message.Result += String.Format("\u2022 However, the data associated with that {0} will be permanently deleted.", imageOrVideo);
                    this.Message.Hint   += "to a new sub-folder." + Environment.NewLine + "  Then add that sub-folder back to the image set." + Environment.NewLine;
                }
                this.Message.Hint += String.Format("\u2022 See Options|Preferences to manage how files in {0} are permanently deleted.", Constant.File.DeletedFilesFolder);
            }
            else
            {
                // Case: Delete the data only, leaving the image intact
                this.FileLabel.Text           = "Affected file:";
                this.ConfirmCheckBoxText.Text = "Click to confirm deletion of data for the selected file";
                this.Message.Title            = String.Format("Delete only the current {0}'s data", imageOrVideo);
                this.Message.What             = String.Format("Deletes the data associated with the current {0}, but leaves the {0} intact", imageOrVideo);
                this.Message.Result           = String.Format("\u2022 This data record will be removed.{0}", Environment.NewLine);
                this.Message.Result          += String.Format("\u2022 The {0} is still intact, but it will not be displayed in Timelapse {1}", imageOrVideo, Environment.NewLine);
                this.Message.Result          += String.Format("   unless a duplicate record exists.", imageOrVideo);
                this.Message.Hint             = "Deleting only the data is useful for removing a previously-created duplicate record of a file.";
            }
        }