Exemplo n.º 1
0
        private void ChangeTrigger()
        {
            if (InputValid())
            {
                TrimInput();

                if (TriggerCollection.GetByName(textBoxTriggerName.Text) != null && NameChanged())
                {
                    MessageBox.Show("A trigger with this name already exists.", "Duplicate Name Conflict", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    TriggerCollection.Get(TriggerObject).Name          = textBoxTriggerName.Text;
                    TriggerCollection.Get(TriggerObject).ConditionType = (TriggerConditionType)listBoxCondition.SelectedIndex;
                    TriggerCollection.Get(TriggerObject).ActionType    = (TriggerActionType)listBoxAction.SelectedIndex;
                    TriggerCollection.Get(TriggerObject).Active        = checkBoxActive.Checked;
                    TriggerCollection.Get(TriggerObject).Date          = dateTimePickerDate.Value;
                    TriggerCollection.Get(TriggerObject).Time          = dateTimePickerTime.Value;
                    TriggerCollection.Get(TriggerObject).Day           = comboBoxDay.Text;
                    TriggerCollection.Get(TriggerObject).Days          = (int)numericUpDownDays.Value;

                    if (textBoxTriggerValue.Visible)
                    {
                        TriggerCollection.Get(TriggerObject).Value = textBoxTriggerValue.Text.Trim();
                    }
                    else
                    {
                        if (listBoxModuleItemList.SelectedItem != null)
                        {
                            TriggerCollection.Get(TriggerObject).Value = listBoxModuleItemList.SelectedItem.ToString();
                        }
                        else
                        {
                            TriggerCollection.Get(TriggerObject).Value = string.Empty;
                        }
                    }

                    int screenCaptureInterval = _dataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value,
                                                                                     (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value,
                                                                                     (int)numericUpDownMillisecondsInterval.Value);

                    TriggerCollection.Get(TriggerObject).ScreenCaptureInterval = screenCaptureInterval;

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

                    if (TriggerCollection.GetByName(textBoxTriggerName.Text) != null && NameChanged())
                    {
                        MessageBox.Show("A trigger with this name already exists.", "Duplicate Name Conflict", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        TriggerCollection.Get(TriggerObject).Name          = textBoxTriggerName.Text;
                        TriggerCollection.Get(TriggerObject).ConditionType = (TriggerConditionType)listBoxCondition.SelectedIndex;
                        TriggerCollection.Get(TriggerObject).ActionType    = (TriggerActionType)listBoxAction.SelectedIndex;
                        TriggerCollection.Get(TriggerObject).Active        = checkBoxActive.Checked;
                        TriggerCollection.Get(TriggerObject).Date          = dateTimePickerDate.Value;
                        TriggerCollection.Get(TriggerObject).Time          = dateTimePickerTime.Value;

                        if (listBoxEditor.Enabled)
                        {
                            TriggerCollection.Get(TriggerObject).Editor = listBoxEditor.SelectedItem.ToString();
                        }
                        else
                        {
                            TriggerCollection.Get(TriggerObject).Editor = string.Empty;
                        }

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

                if (TriggerCollection.GetByName(textBoxTriggerName.Text) == null)
                {
                    int screenCaptureInterval = DataConvert.ConvertIntoMilliseconds((int)numericUpDownHoursInterval.Value,
                                                                                    (int)numericUpDownMinutesInterval.Value, (int)numericUpDownSecondsInterval.Value,
                                                                                    (int)numericUpDownMillisecondsInterval.Value);

                    Trigger trigger = new Trigger()
                    {
                        Name                  = textBoxTriggerName.Text,
                        ConditionType         = (TriggerConditionType)listBoxCondition.SelectedIndex,
                        ActionType            = (TriggerActionType)listBoxAction.SelectedIndex,
                        Active                = checkBoxActive.Checked,
                        Date                  = dateTimePickerDate.Value,
                        Time                  = dateTimePickerTime.Value,
                        Day                   = comboBoxDay.Text,
                        Days                  = (int)numericUpDownDays.Value,
                        ScreenCaptureInterval = screenCaptureInterval,
                        ModuleItem            = listBoxModuleItemList.SelectedItem != null?listBoxModuleItemList.SelectedItem.ToString() : string.Empty
                    };

                    TriggerCollection.Add(trigger);

                    Okay();
                }
                else
                {
                    MessageBox.Show("A trigger 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.º 4
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();
            }
        }
Exemplo n.º 5
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.º 6
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();
            }
        }