private void ShowScreenshotBySlideIndex() { textBoxLabel.Text = string.Empty; textBoxScreenshotTitle.Text = string.Empty; textBoxScreenshotFormat.Text = string.Empty; textBoxScreenshotWidth.Text = string.Empty; textBoxScreenshotHeight.Text = string.Empty; textBoxScreenshotDate.Text = string.Empty; textBoxScreenshotTime.Text = string.Empty; if (tabControlViews.TabCount > 0 && tabControlViews.SelectedTab != null) { TabPage selectedTabPage = tabControlViews.SelectedTab; ToolStrip toolStrip = (ToolStrip)selectedTabPage.Controls[selectedTabPage.Name + "toolStrip"]; ToolStripTextBox toolStripTextBox = (ToolStripTextBox)toolStrip.Items[selectedTabPage.Name + "toolStripTextBoxFilename"]; PictureBox pictureBox = (PictureBox)selectedTabPage.Controls[selectedTabPage.Name + "pictureBox"]; Screenshot selectedScreenshot = new Screenshot(); if (Slideshow.Index >= 0 && Slideshow.Index <= (Slideshow.Count - 1)) { Slideshow.SelectedSlide = (Slide)listBoxScreenshots.Items[Slideshow.Index]; if (selectedTabPage.Tag.GetType() == typeof(Screen)) { Screen screen = (Screen)selectedTabPage.Tag; selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, screen.ViewId); } if (selectedTabPage.Tag.GetType() == typeof(Region)) { Region region = (Region)selectedTabPage.Tag; selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, region.ViewId); } } string path = selectedScreenshot.Path; if (!string.IsNullOrEmpty(path)) { toolStripTextBox.Text = FileSystem.GetFileName(path); toolStripTextBox.ToolTipText = path; string dirName = FileSystem.GetDirectoryName(path); if (!string.IsNullOrEmpty(dirName)) { if (FileSystem.DirectoryExists(dirName) && FileSystem.FileExists(path)) { toolStripTextBox.BackColor = Color.PaleGreen; } else { toolStripTextBox.BackColor = Color.PaleVioletRed; toolStripTextBox.ToolTipText = $"Could not find or access image file at path \"{path}\""; } } pictureBox.Image = _screenCapture.GetImageByPath(path); if (pictureBox.Image != null) { textBoxLabel.Text = selectedScreenshot.Label; textBoxScreenshotTitle.Text = selectedScreenshot.WindowTitle; textBoxScreenshotFormat.Text = selectedScreenshot.Format.Name; textBoxScreenshotWidth.Text = pictureBox.Image.Width.ToString(); textBoxScreenshotHeight.Text = pictureBox.Image.Height.ToString(); textBoxScreenshotDate.Text = selectedScreenshot.Date; textBoxScreenshotTime.Text = selectedScreenshot.Time; } } else { toolStripTextBox.Text = string.Empty; toolStripTextBox.BackColor = Color.LightYellow; toolStripTextBox.ToolTipText = string.Empty; pictureBox.Image = null; } } }
private void ShowScreenshotBySlideIndex() { _formScreenshotMetadata.textBoxLabel.Text = string.Empty; _formScreenshotMetadata.textBoxScreenshotTitle.Text = string.Empty; _formScreenshotMetadata.textBoxScreenshotFormat.Text = string.Empty; _formScreenshotMetadata.textBoxScreenshotWidth.Text = string.Empty; _formScreenshotMetadata.textBoxScreenshotHeight.Text = string.Empty; _formScreenshotMetadata.textBoxScreenshotDate.Text = string.Empty; _formScreenshotMetadata.textBoxScreenshotTime.Text = string.Empty; // Dashboard if (tabControlViews.TabCount > 0 && tabControlViews.SelectedTab != null && tabControlViews.SelectedTab.Name.Equals("tabPageDashboard")) { FlowLayoutPanel flowLayoutPanel = (FlowLayoutPanel)tabControlViews.SelectedTab.Controls["flowLayoutPanel"]; int i = 1; foreach (GroupBox groupBox in flowLayoutPanel.Controls) { PictureBox pictureBox = (PictureBox)groupBox.Controls["pictureBox" + i]; Screenshot selectedScreenshot = new Screenshot(); if (Slideshow.Index >= 0 && Slideshow.Index <= (Slideshow.Count - 1)) { Slideshow.SelectedSlide = (Slide)listBoxScreenshots.Items[Slideshow.Index]; if (groupBox.Tag.GetType() == typeof(Screen)) { Screen screen = (Screen)groupBox.Tag; selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, screen.ViewId); } if (groupBox.Tag.GetType() == typeof(Region)) { Region region = (Region)groupBox.Tag; selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, region.ViewId); } if (selectedScreenshot.ViewId.Equals(Guid.Empty)) { // *** Auto Screen Capture - Region Select / Auto Save *** selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, Guid.Empty); } } if (!string.IsNullOrEmpty(selectedScreenshot.Path)) { pictureBox.Image = _screenCapture.GetImageByPath(selectedScreenshot.Path); } else { pictureBox.Image = null; } i++; } return; } // Screens and Regions if (tabControlViews.TabCount > 0 && tabControlViews.SelectedTab != null) { TabPage selectedTabPage = tabControlViews.SelectedTab; ToolStrip toolStrip = (ToolStrip)selectedTabPage.Controls[selectedTabPage.Name + "toolStrip"]; ToolStripTextBox toolStripTextBox = (ToolStripTextBox)toolStrip.Items[selectedTabPage.Name + "toolStripTextBoxFilename"]; PictureBox pictureBox = (PictureBox)selectedTabPage.Controls[selectedTabPage.Name + "pictureBox"]; Screenshot selectedScreenshot = new Screenshot(); if (Slideshow.Index >= 0 && Slideshow.Index <= (Slideshow.Count - 1)) { Slideshow.SelectedSlide = (Slide)listBoxScreenshots.Items[Slideshow.Index]; if (selectedTabPage.Tag.GetType() == typeof(Screen)) { Screen screen = (Screen)selectedTabPage.Tag; selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, screen.ViewId); } if (selectedTabPage.Tag.GetType() == typeof(Region)) { Region region = (Region)selectedTabPage.Tag; selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, region.ViewId); } if (selectedScreenshot.ViewId.Equals(Guid.Empty)) { // *** Auto Screen Capture - Region Select / Auto Save *** selectedScreenshot = _screenshotCollection.GetScreenshot(Slideshow.SelectedSlide.Name, Guid.Empty); } } string path = selectedScreenshot.Path; if (!string.IsNullOrEmpty(path)) { toolStripTextBox.Text = FileSystem.GetFileName(path); toolStripTextBox.ToolTipText = path; string dirName = FileSystem.GetDirectoryName(path); if (!string.IsNullOrEmpty(dirName)) { if (FileSystem.DirectoryExists(dirName) && FileSystem.FileExists(path)) { toolStripTextBox.BackColor = Color.PaleGreen; } else { toolStripTextBox.BackColor = Color.PaleVioletRed; toolStripTextBox.ToolTipText = $"Could not find or access image file at path \"{path}\""; } } pictureBox.Image = _screenCapture.GetImageByPath(path); if (pictureBox.Image != null) { _formScreenshotMetadata.textBoxLabel.Text = selectedScreenshot.Label; _formScreenshotMetadata.textBoxScreenshotTitle.Text = selectedScreenshot.WindowTitle; _formScreenshotMetadata.textBoxScreenshotFormat.Text = selectedScreenshot.Format.Name; _formScreenshotMetadata.textBoxScreenshotWidth.Text = pictureBox.Image.Width.ToString(); _formScreenshotMetadata.textBoxScreenshotHeight.Text = pictureBox.Image.Height.ToString(); _formScreenshotMetadata.textBoxScreenshotDate.Text = selectedScreenshot.Date; _formScreenshotMetadata.textBoxScreenshotTime.Text = selectedScreenshot.Time; } } else { toolStripTextBox.Text = string.Empty; toolStripTextBox.BackColor = Color.LightYellow; toolStripTextBox.ToolTipText = string.Empty; pictureBox.Image = null; } } }