Exemplo n.º 1
0
        /// <summary>
        /// A collection of screenshots.
        /// </summary>
        public ScreenshotCollection(ImageFormatCollection imageFormatCollection, ScreenCollection screenCollection)
        {
            StringBuilder sbScreenshots = new StringBuilder();

            sbScreenshots.Append("/");
            sbScreenshots.Append(XML_FILE_ROOT_NODE);
            sbScreenshots.Append("/");
            sbScreenshots.Append(XML_FILE_SCREENSHOTS_NODE);

            StringBuilder sbScreenshot = new StringBuilder();

            sbScreenshot.Append("/");
            sbScreenshot.Append(XML_FILE_ROOT_NODE);
            sbScreenshot.Append("/");
            sbScreenshot.Append(XML_FILE_SCREENSHOTS_NODE);
            sbScreenshot.Append("/");
            sbScreenshot.Append(XML_FILE_SCREENSHOT_NODE);

            SCREENSHOTS_XPATH = sbScreenshots.ToString();
            SCREENSHOT_XPATH  = sbScreenshot.ToString();

            _screenshotList = new List <Screenshot>();
            Log.WriteDebugMessage("Initialized screenshot list");

            _slideList = new List <Slide>();
            Log.WriteDebugMessage("Initialized slide list");

            _slideNameList = new List <string>();
            Log.WriteDebugMessage("Initialized slide name list");

            _imageFormatCollection = imageFormatCollection;
            _screenCollection      = screenCollection;
        }
Exemplo n.º 2
0
        private void AddNewScreen()
        {
            if (InputValid())
            {
                TrimInput();

                if (ScreenCollection.GetByName(textBoxName.Text) == null)
                {
                    ScreenCollection.Add(new Screen(
                                             textBoxName.Text,
                                             FileSystem.CorrectDirectoryPath(textBoxFolder.Text),
                                             textBoxMacro.Text,
                                             comboBoxScreenComponent.SelectedIndex,
                                             ImageFormatCollection.GetByName(comboBoxFormat.Text),
                                             (int)numericUpDownJpegQuality.Value,
                                             (int)numericUpDownResolutionRatio.Value,
                                             checkBoxMouse.Checked));

                    Okay();
                }
                else
                {
                    MessageBox.Show("A screen with this name already exists.", "Duplicate Name Conflict",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public static void TakeScreenshot(string path, ImageFormat format, int component, ScreenshotType screenshotType,
                                          int jpegQuality, int resolutionRatio, bool mouse, int x, int y, int width, int height, Guid viewId,
                                          string label, ScreenCollection screenCollection, RegionCollection regionCollection)
        {
            try
            {
                Bitmap bitmap = component == 0
                    ? GetActiveWindowBitmap()
                    : GetScreenBitmap(x, y, width, height, Ratio, mouse);

                if (bitmap != null && !string.IsNullOrEmpty(path))
                {
                    FileInfo fileInfo = new FileInfo(path);

                    if (fileInfo.Directory != null && fileInfo.Directory.Root.Exists)
                    {
                        DriveInfo driveInfo = new DriveInfo(fileInfo.Directory.Root.FullName);

                        if (driveInfo.IsReady)
                        {
                            double freeDiskSpacePercentage =
                                (driveInfo.AvailableFreeSpace / (float)driveInfo.TotalSize) * 100;

                            if (freeDiskSpacePercentage > MIN_FREE_DISK_SPACE_PERCENTAGE)
                            {
                                string dirName = Path.GetDirectoryName(path);

                                if (!string.IsNullOrEmpty(dirName))
                                {
                                    if (!Directory.Exists(dirName))
                                    {
                                        Directory.CreateDirectory(dirName);
                                    }

                                    SaveToFile(path, format, jpegQuality, bitmap);

                                    ScreenshotCollection.Add(new Screenshot(DateTimePreviousScreenshot, path, format,
                                                                            component, screenshotType, GetActiveWindowTitle(), viewId, label),
                                                             screenCollection, regionCollection);
                                }
                            }
                        }
                    }

                    GC.Collect();
                }
            }
            catch (Exception ex)
            {
                Log.Write(
                    "ScreenCapture::TakeScreenshot(path, format, component, jpegQuality, resolutionRatio, mouse, x, y, width, height)",
                    ex);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for FormScreen.
        /// </summary>
        public FormScreen(ScreenCapture screenCapture, MacroParser macroParser, FileSystem fileSystem, Config config, Log log)
        {
            InitializeComponent();

            _log           = log;
            _config        = config;
            _macroParser   = macroParser;
            _screenCapture = screenCapture;
            _fileSystem    = fileSystem;

            ScreenCollection = new ScreenCollection();
            RegionCollection = new RegionCollection();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor for FormScreen.
        /// </summary>
        public FormScreen(ScreenCapture screenCapture, MacroParser macroParser, FileSystem fileSystem, Log log)
        {
            InitializeComponent();

            _log           = log;
            _macroParser   = macroParser;
            _screenCapture = screenCapture;
            _fileSystem    = fileSystem;

            ScreenCollection = new ScreenCollection();
            RegionCollection = new RegionCollection();
            ScreenDictionary = new Dictionary <int, ScreenCapture.DeviceOptions>();
        }
Exemplo n.º 6
0
        private void ChangeScreen()
        {
            if (InputValid())
            {
                if (NameChanged() || InputChanged())
                {
                    TrimInput();

                    if (ScreenCollection.GetByName(textBoxScreenName.Text) != null && NameChanged())
                    {
                        MessageBox.Show("A screen with this name already exists.", "Duplicate Name Conflict",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        ScreenCollection.Get(ScreenObject).Name            = textBoxScreenName.Text;
                        ScreenCollection.Get(ScreenObject).Folder          = _fileSystem.CorrectScreenshotsFolderPath(textBoxFolder.Text);
                        ScreenCollection.Get(ScreenObject).Macro           = textBoxMacro.Text;
                        ScreenCollection.Get(ScreenObject).Component       = comboBoxScreenComponent.SelectedIndex;
                        ScreenCollection.Get(ScreenObject).Format          = ImageFormatCollection.GetByName(comboBoxFormat.Text);
                        ScreenCollection.Get(ScreenObject).JpegQuality     = (int)numericUpDownJpegQuality.Value;
                        ScreenCollection.Get(ScreenObject).Mouse           = checkBoxMouse.Checked;
                        ScreenCollection.Get(ScreenObject).Enable          = checkBoxEnable.Checked;
                        ScreenCollection.Get(ScreenObject).X               = (int)numericUpDownX.Value;
                        ScreenCollection.Get(ScreenObject).Y               = (int)numericUpDownY.Value;
                        ScreenCollection.Get(ScreenObject).Width           = (int)numericUpDownWidth.Value;
                        ScreenCollection.Get(ScreenObject).Height          = (int)numericUpDownHeight.Value;
                        ScreenCollection.Get(ScreenObject).Source          = comboBoxScreenSource.SelectedIndex;
                        ScreenCollection.Get(ScreenObject).AutoAdapt       = checkBoxAutoAdapt.Checked;
                        ScreenCollection.Get(ScreenObject).CaptureMethod   = comboBoxScreenCaptureMethod.SelectedIndex;
                        ScreenCollection.Get(ScreenObject).Encrypt         = checkBoxEncrypt.Checked;
                        ScreenCollection.Get(ScreenObject).ResolutionRatio = (int)numericUpDownResolutionRatio.Value;

                        Okay();
                    }
                }
                else
                {
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        private void AddScreen()
        {
            if (InputValid())
            {
                TrimInput();

                if (ScreenCollection.GetByName(textBoxScreenName.Text) == null)
                {
                    ScreenCollection.Add(new Screen()
                    {
                        ViewId          = Guid.NewGuid(),
                        Name            = textBoxScreenName.Text,
                        Folder          = _fileSystem.CorrectScreenshotsFolderPath(textBoxFolder.Text),
                        Macro           = textBoxMacro.Text,
                        Component       = comboBoxScreenComponent.SelectedIndex,
                        Format          = ImageFormatCollection.GetByName(comboBoxFormat.Text),
                        JpegQuality     = (int)numericUpDownJpegQuality.Value,
                        Mouse           = checkBoxMouse.Checked,
                        Enable          = checkBoxEnable.Checked,
                        X               = (int)numericUpDownX.Value,
                        Y               = (int)numericUpDownY.Value,
                        Width           = (int)numericUpDownWidth.Value,
                        Height          = (int)numericUpDownHeight.Value,
                        Source          = comboBoxScreenSource.SelectedIndex,
                        AutoAdapt       = checkBoxAutoAdapt.Checked,
                        CaptureMethod   = comboBoxScreenCaptureMethod.SelectedIndex,
                        Encrypt         = checkBoxEncrypt.Checked,
                        ResolutionRatio = (int)numericUpDownResolutionRatio.Value
                    });

                    Okay();
                }
                else
                {
                    MessageBox.Show("A screen with this name already exists.", "Duplicate Name Conflict",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void ChangeScreen()
        {
            if (InputValid())
            {
                //if (Directory.Exists(textBoxScreenFolder.Text))
                //{
                if (NameChanged() || InputChanged())
                {
                    TrimInput();

                    if (ScreenCollection.GetByName(textBoxName.Text) != null && NameChanged())
                    {
                        MessageBox.Show("A screen with this name already exists.", "Duplicate Name Conflict",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        ScreenCollection.Get(ScreenObject).Name            = textBoxName.Text;
                        ScreenCollection.Get(ScreenObject).Folder          = FileSystem.CorrectDirectoryPath(textBoxFolder.Text);
                        ScreenCollection.Get(ScreenObject).Macro           = textBoxMacro.Text;
                        ScreenCollection.Get(ScreenObject).Component       = comboBoxScreenComponent.SelectedIndex;
                        ScreenCollection.Get(ScreenObject).Format          = ImageFormatCollection.GetByName(comboBoxFormat.Text);
                        ScreenCollection.Get(ScreenObject).JpegQuality     = (int)numericUpDownJpegQuality.Value;
                        ScreenCollection.Get(ScreenObject).ResolutionRatio = (int)numericUpDownResolutionRatio.Value;
                        ScreenCollection.Get(ScreenObject).Mouse           = checkBoxMouse.Checked;

                        Okay();
                    }
                }
                else
                {
                    Close();
                }
                //}
                //else
                //{

                //}
            }
            else
            {
                MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        private void AddNewScreen()
        {
            if (InputValid())
            {
                TrimInput();

                if (ScreenCollection.GetByName(textBoxName.Text) == null)
                {
                    ScreenCollection.Add(new Screen()
                    {
                        Name            = textBoxName.Text,
                        Folder          = FileSystem.CorrectScreenshotsFolderPath(textBoxFolder.Text),
                        Macro           = textBoxMacro.Text,
                        Component       = comboBoxScreenComponent.SelectedIndex,
                        Format          = ImageFormatCollection.GetByName(comboBoxFormat.Text),
                        JpegQuality     = (int)numericUpDownJpegQuality.Value,
                        ResolutionRatio = (int)numericUpDownResolutionRatio.Value,
                        Mouse           = checkBoxMouse.Checked,
                        Active          = checkBoxActive.Checked,
                        ActiveWindowTitleCaptureCheck = checkBoxActiveWindowTitle.Checked,
                        ActiveWindowTitleCaptureText  = textBoxActiveWindowTitle.Text
                    });

                    Okay();
                }
                else
                {
                    MessageBox.Show("A screen with this name already exists.", "Duplicate Name Conflict",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Please enter valid input for each field.", "Invalid Input", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
        private static void CheckAndCreateFiles()
        {
            if (string.IsNullOrEmpty(FileSystem.CommandFile))
            {
                FileSystem.CommandFile = FileSystem.DefaultCommandFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nCommandFile=" + FileSystem.DefaultCommandFile);

                if (!FileSystem.FileExists(FileSystem.DefaultCommandFile))
                {
                    FileSystem.CreateFile(FileSystem.DefaultCommandFile);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.ApplicationSettingsFile))
            {
                FileSystem.ApplicationSettingsFile = FileSystem.DefaultApplicationSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nApplicationSettingsFile=" + FileSystem.DefaultApplicationSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.UserSettingsFile))
            {
                FileSystem.UserSettingsFile = FileSystem.DefaultUserSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nUserSettingsFile=" + FileSystem.DefaultUserSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }
            }

            Settings.Initialize();

            Log.WriteMessage("Loading user settings");
            Settings.User.Load();
            Log.WriteDebugMessage("User settings loaded");

            Log.WriteDebugMessage("Attempting upgrade of application settings from old version of application (if needed)");
            Settings.Application.Upgrade();

            Log.WriteDebugMessage("Attempting upgrade of user settings from old version of application (if needed)");
            Settings.User.Upgrade();

            if (string.IsNullOrEmpty(FileSystem.ScreenshotsFile))
            {
                ImageFormatCollection imageFormatCollection = new ImageFormatCollection();
                ScreenCollection      screenCollection      = new ScreenCollection();

                ScreenshotCollection screenshotCollection = new ScreenshotCollection(imageFormatCollection, screenCollection);
                screenshotCollection.SaveToXmlFile(0);
            }

            if (string.IsNullOrEmpty(FileSystem.EditorsFile))
            {
                // Loading the editor collection will automatically create the default editors and add them to the collection.
                EditorCollection editorCollection = new EditorCollection();
                editorCollection.LoadXmlFileAndAddEditors();
            }

            if (string.IsNullOrEmpty(FileSystem.RegionsFile))
            {
                RegionCollection regionCollection = new RegionCollection();
                regionCollection.SaveToXmlFile();
            }

            if (string.IsNullOrEmpty(FileSystem.ScreensFile))
            {
                // Loading the screen collection will automatically create the available screens and add them to the collection.
                ScreenCollection screenCollection = new ScreenCollection();
                screenCollection.LoadXmlFileAndAddScreens(new ImageFormatCollection());
            }

            if (string.IsNullOrEmpty(FileSystem.TriggersFile))
            {
                // Loading triggers will automatically create the default triggers and add them to the collection.
                TriggerCollection triggerCollection = new TriggerCollection();
                triggerCollection.LoadXmlFileAndAddTriggers();
            }

            if (string.IsNullOrEmpty(FileSystem.TagsFile))
            {
                // Loading tags will automatically create the default tags and add them to the collection.
                TagCollection tagCollection = new TagCollection();
                tagCollection.LoadXmlFileAndAddTags();
            }

            if (string.IsNullOrEmpty(FileSystem.SchedulesFile))
            {
                // Loading schedules will automatically create the default schedules and add them to the collection.
                ScheduleCollection scheduleCollection = new ScheduleCollection();
                scheduleCollection.LoadXmlFileAndAddSchedules();
            }
        }
Exemplo n.º 11
0
        public static void Add(Screenshot newScreenshot, ScreenCollection screenCollection, RegionCollection regionCollection)
        {
            _screenshotList.Add(newScreenshot);

            if (xDoc != null && newScreenshot != null && newScreenshot.Format != null && !string.IsNullOrEmpty(newScreenshot.Format.Name))
            {
                XmlElement screenshot = xDoc.CreateElement(XML_FILE_SCREENSHOT_NODE);

                XmlElement viewid = xDoc.CreateElement("viewid");
                viewid.InnerText = newScreenshot.ViewId.ToString();

                XmlElement date = xDoc.CreateElement("date");
                date.InnerText = newScreenshot.Date;

                XmlElement time = xDoc.CreateElement("time");
                time.InnerText = newScreenshot.Time;

                XmlElement path = xDoc.CreateElement("path");
                path.InnerText = newScreenshot.Path;

                XmlElement format = xDoc.CreateElement("format");
                format.InnerText = newScreenshot.Format.Name; // This keeps being null for some reason ... (??)

                XmlElement component = xDoc.CreateElement("component");
                component.InnerText = newScreenshot.Component.ToString();

                XmlElement slidename = xDoc.CreateElement("slidename");
                slidename.InnerText = newScreenshot.Slide.Name;

                XmlElement slidevalue = xDoc.CreateElement("slidevalue");
                slidevalue.InnerText = newScreenshot.Slide.Value;

                XmlElement windowtitle = xDoc.CreateElement("windowtitle");
                windowtitle.InnerText = newScreenshot.WindowTitle;

                XmlElement label = xDoc.CreateElement("label");
                label.InnerText = newScreenshot.Label;

                screenshot.AppendChild(viewid);
                screenshot.AppendChild(date);
                screenshot.AppendChild(time);
                screenshot.AppendChild(path);
                screenshot.AppendChild(format);
                screenshot.AppendChild(component);
                screenshot.AppendChild(slidename);
                screenshot.AppendChild(slidevalue);
                screenshot.AppendChild(windowtitle);
                screenshot.AppendChild(label);

                XmlNode screenshots = xDoc.SelectSingleNode("/autoscreen/screenshots");

                if (screenshots != null)
                {
                    screenshots.InsertAfter(screenshot, screenshots.LastChild);

                    xDoc.Save(FileSystem.ApplicationFolder + FileSystem.OldScreenshotsFile);
                }
            }

            System.GC.Collect();
        }
Exemplo n.º 12
0
 public static void Add(Screenshot newScreenshot, ScreenCollection screenCollection, RegionCollection regionCollection)
 {
     _screenshotList.Add(newScreenshot);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Loads the screenshots.
        /// </summary>
        public static void Load(ImageFormatCollection imageFormatCollection, ScreenCollection screenCollection, RegionCollection regionCollection)
        {
            if (Directory.Exists(FileSystem.ApplicationFolder) &&
                File.Exists(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile))
            {
                xDoc = new XmlDocument();
                xDoc.Load(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile);

                AppVersion  = xDoc.SelectSingleNode("/autoscreen").Attributes["app:version"]?.Value;
                AppCodename = xDoc.SelectSingleNode("/autoscreen").Attributes["app:codename"]?.Value;

                XmlNodeList xScreeshots = xDoc.SelectNodes(SCREENSHOT_XPATH);

                foreach (XmlNode xScreenshot in xScreeshots)
                {
                    Screenshot screenshot = new Screenshot();
                    screenshot.Slide = new Slide();

                    XmlNodeReader xReader = new XmlNodeReader(xScreenshot);

                    while (xReader.Read())
                    {
                        if (xReader.IsStartElement())
                        {
                            switch (xReader.Name)
                            {
                            case SCREENSHOT_VIEWID:
                                xReader.Read();
                                screenshot.ViewId = Guid.Parse(xReader.Value);
                                break;

                            case SCREENSHOT_DATE:
                                xReader.Read();
                                screenshot.Date = xReader.Value;
                                break;

                            case SCREENSHOT_TIME:
                                xReader.Read();
                                screenshot.Time = xReader.Value;
                                break;

                            case SCREENSHOT_PATH:
                                xReader.Read();
                                screenshot.Path = xReader.Value;
                                break;

                            case SCREENSHOT_FORMAT:
                                xReader.Read();
                                screenshot.Format = imageFormatCollection.GetByName(xReader.Value);
                                break;

                            // 2.1 used "screen" for its definition of each display/monitor whereas 2.2 uses "component".
                            // Active Window is now represented by 0 rather than 5.
                            case SCREENSHOT_SCREEN:
                                if (Settings.VersionManager.IsOldAppVersion(AppVersion, AppCodename) &&
                                    Settings.VersionManager.Versions.Get("Clara", "2.1.8.2") != null)
                                {
                                    xReader.Read();

                                    screenshot.Screen = Convert.ToInt32(xReader.Value);

                                    screenshot.Component = screenshot.Screen == 5 ? 0 : screenshot.Screen;
                                }
                                break;

                            // We still want to support "component" since this was introduced in version 2.2 as the new representation for "screen".
                            case SCREENSHOT_COMPONENT:
                                xReader.Read();
                                screenshot.Component = Convert.ToInt32(xReader.Value);

                                if (screenshot.Component == -1)
                                {
                                    screenshot.ScreenshotType = ScreenshotType.Region;
                                }
                                else if (screenshot.Component == 0)
                                {
                                    screenshot.ScreenshotType = ScreenshotType.ActiveWindow;
                                }
                                else
                                {
                                    screenshot.ScreenshotType = ScreenshotType.Screen;
                                }
                                break;

                            case SCREENSHOT_SLIDENAME:
                                xReader.Read();
                                screenshot.Slide.Name = xReader.Value;
                                break;

                            case SCREENSHOT_SLIDEVALUE:
                                xReader.Read();
                                screenshot.Slide.Value = xReader.Value;
                                break;

                            case SCREENSHOT_WINDOW_TITLE:
                                xReader.Read();
                                screenshot.WindowTitle = xReader.Value;
                                break;

                            case SCREENSHOT_LABEL:
                                xReader.Read();
                                screenshot.Label = xReader.Value;
                                break;
                            }
                        }
                    }

                    xReader.Close();

                    if (Settings.VersionManager.IsOldAppVersion(AppVersion, AppCodename))
                    {
                        if (Settings.VersionManager.Versions.Get("Clara", "2.1.8.2") != null)
                        {
                            // We need to associate the screenshot's view ID with the component's view ID
                            // because this special ID value is used for figuring out what screenshot image to display.
                            screenshot.ViewId = screenCollection.GetByComponent(screenshot.Component).ViewId;

                            string windowTitle = "*Screenshot imported from an old version of Auto Screen Capture*";

                            Regex rgxOldSlidename =
                                new Regex(
                                    @"^(?<Date>\d{4}-\d{2}-\d{2}) (?<Time>(?<Hour>\d{2})-(?<Minute>\d{2})-(?<Second>\d{2})-(?<Millisecond>\d{3}))");

                            string hour        = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Hour"].Value;
                            string minute      = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Minute"].Value;
                            string second      = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Second"].Value;
                            string millisecond = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Millisecond"]
                                                 .Value;

                            screenshot.Date = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Date"].Value;
                            screenshot.Time = hour + ":" + minute + ":" + second + "." + millisecond;

                            screenshot.Slide.Name  = "{date=" + screenshot.Date + "}{time=" + screenshot.Time + "}";
                            screenshot.Slide.Value = screenshot.Time + " [" + windowTitle + "]";

                            screenshot.WindowTitle = windowTitle;
                        }
                    }

                    if (!string.IsNullOrEmpty(screenshot.Date) &&
                        !string.IsNullOrEmpty(screenshot.Time) &&
                        !string.IsNullOrEmpty(screenshot.Path) &&
                        screenshot.Format != null &&
                        !string.IsNullOrEmpty(screenshot.Slide.Name) &&
                        !string.IsNullOrEmpty(screenshot.Slide.Value))
                    {
                        Add(screenshot, screenCollection, regionCollection);
                    }
                }

                // Write out the upgraded screenshots (if any were found).
                if (Settings.VersionManager.IsOldAppVersion(AppVersion, AppCodename))
                {
                    Save();
                }
            }
        }
Exemplo n.º 14
0
        private void CheckAndCreateFiles(Security security, ScreenCapture screenCapture, Log log)
        {
            if (string.IsNullOrEmpty(FileSystem.CommandFile))
            {
                FileSystem.CommandFile = FileSystem.DefaultCommandFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nCommandFile=" + FileSystem.DefaultCommandFile);

                if (!FileSystem.FileExists(FileSystem.DefaultCommandFile))
                {
                    FileSystem.CreateFile(FileSystem.DefaultCommandFile);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.ApplicationSettingsFile))
            {
                FileSystem.ApplicationSettingsFile = FileSystem.DefaultApplicationSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nApplicationSettingsFile=" + FileSystem.DefaultApplicationSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.SmtpSettingsFile))
            {
                FileSystem.SmtpSettingsFile = FileSystem.DefaultSmtpSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nSMTPSettingsFile=" + FileSystem.DefaultSmtpSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.SftpSettingsFile))
            {
                FileSystem.SftpSettingsFile = FileSystem.DefaultSftpSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nSFTPSettingsFile=" + FileSystem.DefaultSftpSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.UserSettingsFile))
            {
                FileSystem.UserSettingsFile = FileSystem.DefaultUserSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nUserSettingsFile=" + FileSystem.DefaultUserSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }
            }

            Settings.User.Load(Settings, FileSystem);

            Settings.SMTP.Load(Settings, FileSystem);

            Settings.SFTP.Load(Settings, FileSystem);

            Settings.VersionManager.OldApplicationSettings = Settings.Application.Clone();

            Settings.VersionManager.OldUserSettings = Settings.User.Clone();

            Settings.UpgradeApplicationSettings(Settings.Application, FileSystem);

            Settings.UpgradeUserSettings(Settings.User, screenCapture, security, FileSystem);

            Settings.UpgradeSmtpSettings(Settings.SMTP, FileSystem);

            Settings.UpgradeSftpSettings(Settings.SFTP, FileSystem);

            if (string.IsNullOrEmpty(FileSystem.ScreenshotsFile))
            {
                ImageFormatCollection imageFormatCollection = new ImageFormatCollection();
                ScreenCollection      screenCollection      = new ScreenCollection();

                ScreenshotCollection screenshotCollection = new ScreenshotCollection(imageFormatCollection, screenCollection, screenCapture, this, FileSystem, log);
                screenshotCollection.SaveToXmlFile(this);
            }

            if (string.IsNullOrEmpty(FileSystem.EditorsFile))
            {
                // Loading the editor collection will automatically create the default editors and add them to the collection.
                EditorCollection editorCollection = new EditorCollection();
                editorCollection.LoadXmlFileAndAddEditors(this, FileSystem, log);
            }

            if (string.IsNullOrEmpty(FileSystem.RegionsFile))
            {
                RegionCollection regionCollection = new RegionCollection();
                regionCollection.SaveToXmlFile(Settings, FileSystem, log);
            }

            if (string.IsNullOrEmpty(FileSystem.ScreensFile))
            {
                // Loading the screen collection will automatically create the available screens and add them to the collection.
                ScreenCollection screenCollection = new ScreenCollection();
                screenCollection.LoadXmlFileAndAddScreens(new ImageFormatCollection(), this, MacroParser, screenCapture, FileSystem, log);
            }

            if (string.IsNullOrEmpty(FileSystem.TriggersFile))
            {
                // Loading triggers will automatically create the default triggers and add them to the collection.
                TriggerCollection triggerCollection = new TriggerCollection();
                triggerCollection.LoadXmlFileAndAddTriggers(this, FileSystem, log);
            }

            if (string.IsNullOrEmpty(FileSystem.TagsFile))
            {
                // Loading tags will automatically create the default tags and add them to the collection.
                MacroTagCollection tagCollection = new MacroTagCollection();
                tagCollection.LoadXmlFileAndAddTags(this, MacroParser, FileSystem, log);
            }

            if (string.IsNullOrEmpty(FileSystem.SchedulesFile))
            {
                // Loading schedules will automatically create the default schedules and add them to the collection.
                ScheduleCollection scheduleCollection = new ScheduleCollection();
                scheduleCollection.LoadXmlFileAndAddSchedules(this, FileSystem, log);
            }
        }
Exemplo n.º 15
0
        public bool TakeScreenshot(string path, ImageFormat format, int component, ScreenshotType screenshotType,
                                   int jpegQuality, Guid viewId, Bitmap bitmap, string label, string windowTitle, string processName,
                                   ScreenCollection screenCollection, RegionCollection regionCollection, ScreenshotCollection screenshotCollection)
        {
            try
            {
                if (!string.IsNullOrEmpty(path))
                {
                    Log.Write("Attempting to write image to file at path \"" + path + "\"");

                    FileInfo fileInfo = new FileInfo(path);

                    if (fileInfo.Directory != null && fileInfo.Directory.Root.Exists)
                    {
                        DriveInfo driveInfo = new DriveInfo(fileInfo.Directory.Root.FullName);

                        if (driveInfo.IsReady)
                        {
                            double freeDiskSpacePercentage = (driveInfo.AvailableFreeSpace / (float)driveInfo.TotalSize) * 100;

                            Log.Write("Percentage of free disk space on drive " + fileInfo.Directory.Root.FullName + " is " + (int)freeDiskSpacePercentage + "%");

                            if (freeDiskSpacePercentage > MIN_FREE_DISK_SPACE_PERCENTAGE)
                            {
                                string dirName = Path.GetDirectoryName(path);

                                if (!string.IsNullOrEmpty(dirName))
                                {
                                    if (!Directory.Exists(dirName))
                                    {
                                        Directory.CreateDirectory(dirName);

                                        Log.Write("Directory \"" + dirName + "\" did not exist so it was created");
                                    }

                                    screenshotCollection.Add(new Screenshot(DateTimePreviousCycle, path, format, component, screenshotType, windowTitle, processName, viewId, label));

                                    SaveToFile(path, format, jpegQuality, bitmap);
                                }
                            }
                            else
                            {
                                Log.Write($"ERROR: Unable to save screenshot due to lack of available disk space on drive {fileInfo.Directory.Root.FullName} so screen capture session is being stopped");
                                return(false);
                            }
                        }
                        else
                        {
                            Log.Write("WARNING: Unable to save screenshot. Drive not ready");
                        }
                    }
                    else
                    {
                        Log.Write("WARNING: Unable to save screenshot. Directory root does not exist");
                    }
                }
                else
                {
                    Log.Write("No path available");
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.Write("ScreenCapture::TakeScreenshot", ex);
                return(false);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Loads the screenshots.
        /// </summary>
        public void Load(ImageFormatCollection imageFormatCollection, ScreenCollection screenCollection, RegionCollection regionCollection)
        {
            try
            {
                _mutexWriteFile.WaitOne();

                Log.Write("Loading screenshots from screenshots.xml");

                Stopwatch stopwatch = new Stopwatch();

                stopwatch.Start();

                if (_screenshotList == null)
                {
                    _screenshotList = new List <Screenshot>();
                    Log.Write("Initialized screenshot list");
                }

                if (_slideList == null)
                {
                    _slideList = new List <Slide>();
                    Log.Write("Initialized slide list");
                }

                if (_slideNameList == null)
                {
                    _slideNameList = new List <string>();
                    Log.Write("Initialized slide name list");
                }

                if (_screenshotList != null && Directory.Exists(FileSystem.ApplicationFolder) && !File.Exists(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile))
                {
                    Log.Write("Could not find \"" + FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile + "\" so creating it");

                    XmlWriterSettings xSettings = new XmlWriterSettings
                    {
                        Indent           = true,
                        CloseOutput      = true,
                        CheckCharacters  = true,
                        Encoding         = Encoding.UTF8,
                        NewLineChars     = Environment.NewLine,
                        IndentChars      = XML_FILE_INDENT_CHARS,
                        NewLineHandling  = NewLineHandling.Entitize,
                        ConformanceLevel = ConformanceLevel.Document
                    };

                    using (XmlWriter xWriter = XmlWriter.Create(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile, xSettings))
                    {
                        xWriter.WriteStartDocument();
                        xWriter.WriteStartElement(XML_FILE_ROOT_NODE);
                        xWriter.WriteAttributeString("app", "version", XML_FILE_ROOT_NODE, Settings.ApplicationVersion);
                        xWriter.WriteAttributeString("app", "codename", XML_FILE_ROOT_NODE, Settings.ApplicationCodename);
                        xWriter.WriteStartElement(XML_FILE_SCREENSHOTS_NODE);

                        xWriter.WriteEndElement();
                        xWriter.WriteEndElement();
                        xWriter.WriteEndDocument();

                        xWriter.Flush();
                        xWriter.Close();
                    }

                    Log.Write("Created \"" + FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile + "\"");
                }

                if (_screenshotList != null && Directory.Exists(FileSystem.ApplicationFolder) && File.Exists(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile))
                {
                    xDoc = new XmlDocument();

                    lock (xDoc)
                    {
                        xDoc.Load(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile);

                        AppVersion  = xDoc.SelectSingleNode("/autoscreen").Attributes["app:version"]?.Value;
                        AppCodename = xDoc.SelectSingleNode("/autoscreen").Attributes["app:codename"]?.Value;

                        Log.Write("Getting screenshots from screenshots.xml using XPath query \"" + SCREENSHOT_XPATH + "\"");

                        XmlNodeList xScreeshots = xDoc.SelectNodes(SCREENSHOT_XPATH);

                        if (xScreeshots != null)
                        {
                            Log.Write("Loading each screenshot from screenshots.xml");

                            foreach (XmlNode xScreenshot in xScreeshots)
                            {
                                Screenshot screenshot = new Screenshot();
                                screenshot.Slide = new Slide();

                                XmlNodeReader xReader = new XmlNodeReader(xScreenshot);

                                while (xReader.Read())
                                {
                                    if (xReader.IsStartElement())
                                    {
                                        switch (xReader.Name)
                                        {
                                        case SCREENSHOT_VIEWID:
                                            xReader.Read();
                                            screenshot.ViewId = Guid.Parse(xReader.Value);
                                            break;

                                        case SCREENSHOT_DATE:
                                            xReader.Read();
                                            screenshot.Date       = xReader.Value;
                                            screenshot.Slide.Date = xReader.Value;
                                            break;

                                        case SCREENSHOT_TIME:
                                            xReader.Read();
                                            screenshot.Time = xReader.Value;
                                            break;

                                        case SCREENSHOT_PATH:
                                            xReader.Read();
                                            screenshot.Path = xReader.Value;
                                            break;

                                        case SCREENSHOT_FORMAT:
                                            xReader.Read();
                                            screenshot.Format = imageFormatCollection.GetByName(xReader.Value);
                                            break;

                                        // 2.1 used "screen" for its definition of each display/monitor whereas 2.2 uses "component".
                                        // Active Window is now represented by 0 rather than 5.
                                        case SCREENSHOT_SCREEN:
                                            if (Settings.VersionManager.IsOldAppVersion(AppCodename, AppVersion) &&
                                                Settings.VersionManager.Versions.Get("Clara", "2.1.8.2") != null && string.IsNullOrEmpty(AppCodename) && string.IsNullOrEmpty(AppVersion))
                                            {
                                                xReader.Read();

                                                screenshot.Screen = Convert.ToInt32(xReader.Value);

                                                screenshot.Component = screenshot.Screen == 5 ? 0 : screenshot.Screen;
                                            }

                                            break;

                                        // We still want to support "component" since this was introduced in version 2.2 as the new representation for "screen".
                                        case SCREENSHOT_COMPONENT:
                                            xReader.Read();
                                            screenshot.Component = Convert.ToInt32(xReader.Value);

                                            if (screenshot.Component == -1)
                                            {
                                                screenshot.ScreenshotType = ScreenshotType.Region;
                                            }
                                            else if (screenshot.Component == 0)
                                            {
                                                screenshot.ScreenshotType = ScreenshotType.ActiveWindow;
                                            }
                                            else
                                            {
                                                screenshot.ScreenshotType = ScreenshotType.Screen;
                                            }

                                            break;

                                        case SCREENSHOT_SLIDENAME:
                                            xReader.Read();
                                            screenshot.Slide.Name = xReader.Value;
                                            break;

                                        case SCREENSHOT_SLIDEVALUE:
                                            xReader.Read();
                                            screenshot.Slide.Value = xReader.Value;
                                            break;

                                        case SCREENSHOT_WINDOW_TITLE:
                                            xReader.Read();
                                            screenshot.WindowTitle = xReader.Value;
                                            break;

                                        case SCREENSHOT_PROCESS_NAME:
                                            xReader.Read();
                                            screenshot.ProcessName = xReader.Value;
                                            break;

                                        case SCREENSHOT_LABEL:
                                            xReader.Read();
                                            screenshot.Label = xReader.Value;
                                            break;
                                        }
                                    }
                                }

                                xReader.Close();

                                if (Settings.VersionManager.IsOldAppVersion(AppCodename, AppVersion))
                                {
                                    if (Settings.VersionManager.Versions.Get("Clara", "2.1.8.2") != null && string.IsNullOrEmpty(AppCodename) && string.IsNullOrEmpty(AppVersion))
                                    {
                                        // We need to associate the screenshot's view ID with the component's view ID
                                        // because this special ID value is used for figuring out what screenshot image to display.
                                        screenshot.ViewId = screenCollection.GetByComponent(screenshot.Component).ViewId;

                                        string windowTitle = "*Screenshot imported from an old version of Auto Screen Capture*";

                                        Regex rgxOldSlidename = new Regex(@"^(?<Date>\d{4}-\d{2}-\d{2}) (?<Time>(?<Hour>\d{2})-(?<Minute>\d{2})-(?<Second>\d{2})-(?<Millisecond>\d{3}))");

                                        string hour        = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Hour"].Value;
                                        string minute      = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Minute"].Value;
                                        string second      = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Second"].Value;
                                        string millisecond = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Millisecond"].Value;

                                        screenshot.Date = rgxOldSlidename.Match(screenshot.Slide.Name).Groups["Date"].Value;
                                        screenshot.Time = hour + ":" + minute + ":" + second + "." + millisecond;

                                        screenshot.Slide.Name  = "{date=" + screenshot.Date + "}{time=" + screenshot.Time + "}";
                                        screenshot.Slide.Value = screenshot.Time + " [" + windowTitle + "]";

                                        screenshot.WindowTitle = windowTitle;
                                    }

                                    // Remove all the existing XML child nodes from the old XML screenshot.
                                    xScreenshot.RemoveAll();

                                    // Prepare the new XML child nodes for the old XML screenshot ...

                                    XmlElement xViewId = xDoc.CreateElement(SCREENSHOT_VIEWID);
                                    xViewId.InnerText = screenshot.ViewId.ToString();

                                    XmlElement xDate = xDoc.CreateElement(SCREENSHOT_DATE);
                                    xDate.InnerText = screenshot.Date;

                                    XmlElement xTime = xDoc.CreateElement(SCREENSHOT_TIME);
                                    xTime.InnerText = screenshot.Time;

                                    XmlElement xPath = xDoc.CreateElement(SCREENSHOT_PATH);
                                    xPath.InnerText = screenshot.Path;

                                    XmlElement xFormat = xDoc.CreateElement(SCREENSHOT_FORMAT);
                                    xFormat.InnerText = screenshot.Format.Name;

                                    XmlElement xComponent = xDoc.CreateElement(SCREENSHOT_COMPONENT);
                                    xComponent.InnerText = screenshot.Component.ToString();

                                    XmlElement xSlidename = xDoc.CreateElement(SCREENSHOT_SLIDENAME);
                                    xSlidename.InnerText = screenshot.Slide.Name;

                                    XmlElement xSlidevalue = xDoc.CreateElement(SCREENSHOT_SLIDEVALUE);
                                    xSlidevalue.InnerText = screenshot.Slide.Value;

                                    XmlElement xWindowTitle = xDoc.CreateElement(SCREENSHOT_WINDOW_TITLE);
                                    xWindowTitle.InnerText = screenshot.WindowTitle;

                                    XmlElement xProcessName = xDoc.CreateElement(SCREENSHOT_PROCESS_NAME);
                                    xProcessName.InnerText = screenshot.ProcessName;

                                    XmlElement xLabel = xDoc.CreateElement(SCREENSHOT_LABEL);
                                    xLabel.InnerText = screenshot.Label;

                                    // Create the new XML child nodes for the old XML screenshot so that it's now in the format of the new XML screenshot.
                                    xScreenshot.AppendChild(xViewId);
                                    xScreenshot.AppendChild(xDate);
                                    xScreenshot.AppendChild(xTime);
                                    xScreenshot.AppendChild(xPath);
                                    xScreenshot.AppendChild(xFormat);
                                    xScreenshot.AppendChild(xComponent);
                                    xScreenshot.AppendChild(xSlidename);
                                    xScreenshot.AppendChild(xSlidevalue);
                                    xScreenshot.AppendChild(xWindowTitle);
                                    xScreenshot.AppendChild(xProcessName);
                                    xScreenshot.AppendChild(xLabel);
                                }

                                if (!string.IsNullOrEmpty(screenshot.Date) &&
                                    !string.IsNullOrEmpty(screenshot.Time) &&
                                    !string.IsNullOrEmpty(screenshot.Path) &&
                                    screenshot.Format != null &&
                                    !string.IsNullOrEmpty(screenshot.Slide.Name) &&
                                    !string.IsNullOrEmpty(screenshot.Slide.Value) &&
                                    !string.IsNullOrEmpty(screenshot.WindowTitle))
                                {
                                    screenshot.Saved = true;
                                    Add(screenshot);
                                }
                            }
                        }
                        else
                        {
                            Log.Write("WARNING: Unable to load screenshots from screenshots.xml");
                        }

                        if (Settings.VersionManager.IsOldAppVersion(AppCodename, AppVersion))
                        {
                            Log.Write("Old application version discovered when loading screenshots.xml");

                            // We'll have to create the app:version and app:codename attributes for screenshots.xml if we're upgrading from "Clara".
                            if (Settings.VersionManager.Versions.Get("Clara", "2.1.8.2") != null && string.IsNullOrEmpty(AppCodename) && string.IsNullOrEmpty(AppVersion))
                            {
                                XmlAttribute attributeVersion  = xDoc.CreateAttribute("app", "version", "autoscreen");
                                XmlAttribute attributeCodename = xDoc.CreateAttribute("app", "codename", "autoscreen");

                                attributeVersion.Value  = Settings.ApplicationVersion;
                                attributeCodename.Value = Settings.ApplicationCodename;

                                xDoc.SelectSingleNode("/" + XML_FILE_ROOT_NODE).Attributes.Append(attributeVersion);
                                xDoc.SelectSingleNode("/" + XML_FILE_ROOT_NODE).Attributes.Append(attributeCodename);
                            }

                            // Apply the latest version and codename if the version of Auto Screen Capture is older than this version.
                            xDoc.SelectSingleNode("/" + XML_FILE_ROOT_NODE).Attributes["app:version"].Value  = Settings.ApplicationVersion;
                            xDoc.SelectSingleNode("/" + XML_FILE_ROOT_NODE).Attributes["app:codename"].Value = Settings.ApplicationCodename;

                            xDoc.Save(FileSystem.ApplicationFolder + FileSystem.ScreenshotsFile);

                            Log.Write("Upgraded screenshots.xml");
                        }
                    }
                }

                stopwatch.Stop();

                Log.Write("It took " + stopwatch.ElapsedMilliseconds + " milliseconds to load " + _screenshotList.Count + " screenshots");
            }
            catch (Exception ex)
            {
                Log.Write("ScreenshotCollection::Load", ex);
            }
            finally
            {
                _mutexWriteFile.ReleaseMutex();
            }
        }
Exemplo n.º 17
0
        private static void CheckAndCreateFiles()
        {
            if (string.IsNullOrEmpty(FileSystem.CommandFile))
            {
                FileSystem.CommandFile = FileSystem.DefaultCommandFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nCommandFile=" + FileSystem.DefaultCommandFile);

                if (!FileSystem.FileExists(FileSystem.DefaultCommandFile))
                {
                    FileSystem.CreateFile(FileSystem.DefaultCommandFile);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.ApplicationSettingsFile))
            {
                FileSystem.ApplicationSettingsFile = FileSystem.DefaultApplicationSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nApplicationSettingsFile=" + FileSystem.DefaultApplicationSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }

                SettingCollection applicationSettingsCollection = new SettingCollection
                {
                    Filepath = FileSystem.ApplicationSettingsFile
                };

                applicationSettingsCollection.Save();
            }

            if (string.IsNullOrEmpty(FileSystem.UserSettingsFile))
            {
                FileSystem.UserSettingsFile = FileSystem.DefaultUserSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nUserSettingsFile=" + FileSystem.DefaultUserSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }

                SettingCollection userSettingsCollection = new SettingCollection
                {
                    Filepath = FileSystem.ApplicationSettingsFile
                };

                userSettingsCollection.Save();
            }

            if (string.IsNullOrEmpty(FileSystem.ScreenshotsFile))
            {
                ImageFormatCollection imageFormatCollection = new ImageFormatCollection();
                ScreenCollection      screenCollection      = new ScreenCollection();

                ScreenshotCollection screenshotCollection = new ScreenshotCollection(imageFormatCollection, screenCollection);
                screenshotCollection.SaveToXmlFile(0);
            }

            if (string.IsNullOrEmpty(FileSystem.EditorsFile))
            {
                // Loading the editor collection will automatically create the default editors and add them to the collection.
                EditorCollection editorCollection = new EditorCollection();
                editorCollection.LoadXmlFileAndAddEditors();
            }

            if (string.IsNullOrEmpty(FileSystem.RegionsFile))
            {
                RegionCollection regionCollection = new RegionCollection();
                regionCollection.SaveToXmlFile();
            }

            if (string.IsNullOrEmpty(FileSystem.ScreensFile))
            {
                // Loading the screen collection will automatically create the available screens and add them to the collection.
                ScreenCollection screenCollection = new ScreenCollection();
                screenCollection.LoadXmlFileAndAddScreens(new ImageFormatCollection());
            }

            if (string.IsNullOrEmpty(FileSystem.TriggersFile))
            {
                // Loading triggers will automatically create the default triggers and add them to the collection.
                TriggerCollection triggerCollection = new TriggerCollection();
                triggerCollection.LoadXmlFileAndAddTriggers();
            }

            if (string.IsNullOrEmpty(FileSystem.TagsFile))
            {
                // Loading tags will automatically create the default tags and add them to the collection.
                TagCollection tagCollection = new TagCollection();
                tagCollection.LoadXmlFileAndAddTags();
            }

            if (string.IsNullOrEmpty(FileSystem.SchedulesFile))
            {
                // Loading schedules will automatically create the default schedules and add them to the collection.
                ScheduleCollection scheduleCollection = new ScheduleCollection();
                scheduleCollection.LoadXmlFileAndAddSchedules();
            }
        }