コード例 #1
0
 // Open the currently displayed video in an external player
 private void OpenExternalPlayer_Click(object sender, RoutedEventArgs e)
 {
     // Open the currently displayed video in an external player
     if (File.Exists(Uri.UnescapeDataString(this.Video.Source.AbsolutePath)))
     {
         Uri uri = new Uri(Uri.UnescapeDataString(this.Video.Source.AbsolutePath));
         ProcessExecution.TryProcessStart(uri);
     }
 }
コード例 #2
0
        // Start an email
        private void MailButton_Click(object sender, RoutedEventArgs e)
        {
            Uri uri = new Uri(String.Format("mailto:{0}?subject={1}&body={2}", to, subject, Uri.EscapeUriString(body)));

            if (ProcessExecution.TryProcessStart(uri) == false)
            {
                this.MailButton.Content   = "Mailing failed - See 'alternate' instructions above, or press Cancel.";
                this.MailButton.IsEnabled = false;
            }
        }
コード例 #3
0
        // Receive an event containing new image processing parameters.
        // Store these parameters and then try to update the image
        public async void AdjustImage_EventHandler(object sender, ImageAdjusterEventArgs e)
        {
            if (e == null)
            {
                // Shouldn't happen, but...
                return;
            }

            string path = DataEntryHandler.TryGetFilePathFromGlobalDataHandler();

            if (String.IsNullOrEmpty(path))
            {
                // The file cannot be opened or is not displayable.
                // Signal change in image state, which essentially says there is no displayable image to adjust (consumed by ImageAdjuster)
                this.OnImageStateChanged(new ImageStateEventArgs(false)); //  Signal change in image state (consumed by ImageAdjuster)
                return;
            }

            if (e.OpenExternalViewer)
            {
                // The event says to open an external photo viewer. Try to do so.
                // Note that we don't do any image processing on this event if if this is the case.
                if (ProcessExecution.TryProcessStart(path) == false)
                {
                    // Can't open the image file with an external view. Note that file must exist at this point as we checked for that above.
                    Dialogs.MarkableCanvasCantOpenExternalPhotoViewerDialog(Util.GlobalReferences.MainWindow, Path.GetExtension(path));
                }
                return;
            }

            // Process the image based on the current image processing arguments.
            if (e.ForceUpdate == false && (e.Contrast == this.lastContrast && e.Brightness == this.lastBrightness && e.DetectEdges == this.lastDetectEdges && e.Sharpen == this.lastSharpen && e.UseGamma == this.lastUseGamma && e.GammaValue == this.lastGammaValue))
            {
                // If there is no change from the last time we processed an image, abort as it would not make any difference to what the user sees
                return;
            }
            this.contrast    = e.Contrast;
            this.brightness  = e.Brightness;
            this.detectEdges = e.DetectEdges;
            this.sharpen     = e.Sharpen;
            this.useGamma    = e.UseGamma;
            this.gammaValue  = e.GammaValue;
            this.timerImageProcessingUpdate.Start();
            await UpdateAndProcessImage().ConfigureAwait(true);
        }
コード例 #4
0
        // Tutorial guides (via your browser)
        private void MenuItemGuidesAndManuals_Click(object sender, RoutedEventArgs e)
        {
            string prefix = "https://saul.cpsc.ucalgary.ca/timelapse/uploads/Guides/";

            if (sender is MenuItem mi)
            {
                switch (mi.Name)
                {
                case "MenuItemGoToManualsPage":
                    ProcessExecution.TryProcessStart(new Uri("https://saul.cpsc.ucalgary.ca/timelapse/pmwiki.php?n=Main.UserGuide"));
                    break;

                case "MenuItemQuickStartGuide":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "TimelapseQuickStartGuide.pdf"));
                    break;

                case "MenuItemReferenceGuide":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "TimelapseReferenceGuide.pdf"));
                    break;

                case "MenuItemTemplateGuide":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "TimelapseTemplateGuide.pdf"));
                    break;

                case "MenuItemImageRecognitionGuide":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "TimelapseImageRecognitionGuide.pdf"));
                    break;

                case "MenuItemDatabaseGuide":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "TimelapseDatabaseGuide.pdf"));
                    break;

                default:
                    break;
                }
            }
        }
コード例 #5
0
        public void MenuVideoPlay_Click(object sender, RoutedEventArgs e)
        {
            string prefix = "https://saul.cpsc.ucalgary.ca/timelapse/uploads/Videos/";

            if (sender is MenuItem mi)
            {
                switch (mi.Name)
                {
                case "MenuItemVideoWhirlwindTour":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "WhirlwindTourOfTimelapse.mp4"));
                    break;

                case "MenuItemVideoImageRecognition":
                    ProcessExecution.TryProcessStart(new Uri("http://grouplab.cpsc.ucalgary.ca/grouplab/uploads/Publications/Publications/2021-05-ImageRecognition-Video.mp4"));
                    break;

                case "MenuItemVideoTemplateEditor":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "TemplateEditor.mp4"));
                    break;

                case "MenuItemVideoPlayer":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "UsingVideo.mp4"));
                    break;

                case "MenuItemVideoClassifyingDarkImages":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "Options-DarkThresholds.mp4"));
                    break;

                case "MenuItemVideoRepositionDataEntryPanel":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "RepositioningTabsAndPanels.mp4"));
                    break;

                case "MenuItemVideoUsingOverview":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "UsingTheOverview.mp4"));
                    break;

                case "MenuItemVideoPopulateEpisodeData":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "PopulateEpisodeData.mp4"));
                    break;

                case "MenuItemVideoViewingPopups":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "EpisodePopups.mp4"));
                    break;

                case "MenuItemVideoRandomSampling":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "RandomSample.mp4"));
                    break;

                case "MenuItemVideoDuplicatingRecords":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "DuplicateThisRecord.mp4"));
                    break;

                case "MenuItemVideoCompanionImageRecognition":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "Video-TimelapseImageRecognitionGuide.mp4"));
                    break;

                case "MenuItemVideoCompanionQuickStart":
                    ProcessExecution.TryProcessStart(new Uri(prefix + "Video-TimelapseQuickStartGuide.mp4"));
                    break;

                default:
                    break;
                }
            }
        }
コード例 #6
0
 // Download tutorial sample images (via your web browser)
 private void MenuDownloadSampleImages_Click(object sender, RoutedEventArgs e)
 {
     ProcessExecution.TryProcessStart(new Uri("http://saul.cpsc.ucalgary.ca/timelapse/pmwiki.php?n=Main.UserGuide"));
 }
コード例 #7
0
 // Tutorial manual (via your browser)
 private void MenuTutorialManual_Click(object sender, RoutedEventArgs e)
 {
     ProcessExecution.TryProcessStart(new Uri("http://saul.cpsc.ucalgary.ca/timelapse/uploads/Installs/Timelapse2/Timelapse2Manual.pdf"));
 }
コード例 #8
0
 // Timelapse web page (via your browser): Timelapse home page
 private void MenuTimelapseWebPage_Click(object sender, RoutedEventArgs e)
 {
     ProcessExecution.TryProcessStart(new Uri("http://saul.cpsc.ucalgary.ca/timelapse"));
 }
コード例 #9
0
 private void MenuMailToTimelapseDevelopers_Click(object sender, RoutedEventArgs e)
 {
     ProcessExecution.TryProcessStart(new Uri("mailto:[email protected]"));
 }
コード例 #10
0
 // Timelapse mailing list - Send email
 private void MenuMailToTimelapseMailingList_Click(object sender, RoutedEventArgs e)
 {
     ProcessExecution.TryProcessStart(new Uri("mailto:[email protected]"));
 }
コード例 #11
0
 // Timelapse mailing list - Join it(via your web browser)
 private void MenuJoinTimelapseMailingList_Click(object sender, RoutedEventArgs e)
 {
     ProcessExecution.TryProcessStart(new Uri("http://mailman.ucalgary.ca/mailman/listinfo/timelapse-l"));
 }
コード例 #12
0
        // Export data for this image set as a .csv file
        // Export data for this image set as a .csv file and preview in Excel
        private void MenuItemExportCsv_Click(object sender, RoutedEventArgs e)
        {
            if (this.State.SuppressSelectedCsvExportPrompt == false &&
                this.DataHandler.FileDatabase.ImageSet.FileSelection != FileSelectionEnum.All)
            {
                // Export data for this image set as a.csv file, but confirm, as only a subset will be exported since a selection is active
                if (Dialogs.MenuFileExportCSVOnSelectionDialog(this) == false)
                {
                    return;
                }
            }

            // Generate the file names/path
            string csvFileName = Path.GetFileNameWithoutExtension(this.DataHandler.FileDatabase.FileName) + ".csv";
            string csvFilePath = Path.Combine(this.FolderPath, csvFileName);

            // Backup the csv file if it exists, as the export will overwrite it.
            if (FileBackup.TryCreateBackup(this.FolderPath, csvFileName))
            {
                this.StatusBar.SetMessage("Backup of csv file made.");
            }
            else
            {
                this.StatusBar.SetMessage("No csv file backup was made.");
            }

            try
            {
                CsvReaderWriter.ExportToCsv(this.DataHandler.FileDatabase, csvFilePath, this.excludeDateTimeAndUTCOffsetWhenExporting);
            }
            catch (IOException exception)
            {
                // Can't write the spreadsheet file
                Dialogs.MenuFileCantWriteSpreadsheetFileDialog(this, csvFilePath, exception.GetType().FullName, exception.Message);
                return;
            }

            MenuItem mi = (MenuItem)sender;

            if (mi == this.MenuItemExportAsCsvAndPreview)
            {
                // Show the file in excel
                // Create a process that will try to show the file
                ProcessStartInfo processStartInfo = new ProcessStartInfo
                {
                    UseShellExecute        = true,
                    RedirectStandardOutput = false,
                    FileName = csvFilePath
                };
                if (ProcessExecution.TryProcessStart(processStartInfo) == false)
                {
                    // Can't open excel
                    Dialogs.MenuFileCantOpenExcelDialog(this, csvFilePath);
                    return;
                }
            }
            else if (this.State.SuppressCsvExportDialog == false)
            {
                Dialogs.MenuFileCSVDataExportedDialog(this, csvFileName);
            }
            this.StatusBar.SetMessage("Data exported to " + csvFileName);
        }
コード例 #13
0
 // Load the Uri provided in a web browser
 private void Link_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
 {
     ProcessExecution.TryProcessStart(e.Uri);
     e.Handled = true;
 }
コード例 #14
0
 private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
 {
     ProcessExecution.TryProcessStart(e.Uri);
     e.Handled = true;
 }
コード例 #15
0
        // Export data for this image set as a .csv file
        // Export data for this image set as a .csv file and preview in Excel
        private async void MenuItemExportCsv_Click(object sender, RoutedEventArgs e)
        {
            if (this.State.SuppressSelectedCsvExportPrompt == false &&
                this.DataHandler.FileDatabase.ImageSet.FileSelection != FileSelectionEnum.All)
            {
                // Export data for this image set as a.csv file, but confirm, as only a subset will be exported since a selection is active
                if (Dialogs.MenuFileExportCSVOnSelectionDialog(this) == false)
                {
                    return;
                }
            }

            // Generate the candidate file name/path
            string csvFileName = Path.GetFileNameWithoutExtension(this.DataHandler.FileDatabase.FileName) + ".csv";

            // Get the selected filepath from the user
            if (false == Dialogs.TryGetFileFromUserUsingSaveFileDialog(
                    "Export and save your data as a CSV file",
                    csvFileName,
                    String.Format("CSV files (*{0})|*{0}", Constant.File.CsvFileExtension),
                    Constant.File.CsvFileExtension,
                    out string selectedCSVFilePath))
            {
                // Abort, as file selection is cancelled
                this.StatusBar.SetMessage("Csv file export cancelled.");
                return;
            }

            if (File.Exists(selectedCSVFilePath) && new System.IO.FileInfo(selectedCSVFilePath).Attributes.HasFlag(System.IO.FileAttributes.ReadOnly))
            {
                // The file exists but its read only...
                Dialogs.FileCantOpen(GlobalReferences.MainWindow, selectedCSVFilePath, true);
                this.StatusBar.SetMessage("Csv file export cancelled.");
                return;
            }

            // Backup the csv file if it exists, as the export will overwrite it.
            if (FileBackup.TryCreateBackup(this.FolderPath, selectedCSVFilePath))
            {
                this.StatusBar.SetMessage("Backup of csv file made.");
            }
            else
            {
                this.StatusBar.SetMessage("No csv file backup was made.");
            }

            try
            {
                // Show the Busy indicator
                this.BusyCancelIndicator.IsBusy = true;
                if (false == await CsvReaderWriter.ExportToCsv(this.DataHandler.FileDatabase, selectedCSVFilePath, this.State.CSVDateTimeOptions, this.State.CSVInsertSpaceBeforeDates))
                {
                    Dialogs.FileCantOpen(GlobalReferences.MainWindow, selectedCSVFilePath, true);
                    return;
                }
                // Hide the Busy indicator
                this.BusyCancelIndicator.IsBusy = false;
            }
            catch (Exception exception)
            {
                // Can't write the spreadsheet file
                Dialogs.MenuFileCantWriteSpreadsheetFileDialog(this, selectedCSVFilePath, exception.GetType().FullName, exception.Message);
                return;
            }

            MenuItem mi = (MenuItem)sender;

            if (mi == this.MenuItemExportAsCsvAndPreview)
            {
                // Show the file in excel
                // Create a process that will try to show the file
                ProcessStartInfo processStartInfo = new ProcessStartInfo
                {
                    UseShellExecute        = true,
                    RedirectStandardOutput = false,
                    FileName = selectedCSVFilePath
                };
                if (ProcessExecution.TryProcessStart(processStartInfo) == false)
                {
                    // Can't open excel
                    Dialogs.MenuFileCantOpenExcelDialog(this, selectedCSVFilePath);
                    return;
                }
            }
            else if (this.State.SuppressCsvExportDialog == false)
            {
                Dialogs.MenuFileCSVDataExportedDialog(this, selectedCSVFilePath);
            }
            this.StatusBar.SetMessage("Data exported to " + selectedCSVFilePath);
        }