Example #1
0
        public void Initialise()
        {
            if (!Directory.Exists(configFolder))
            {
                throw new ArgumentException($"Config folder does not exist at {configFolder}.");
            }

            var configFiles = Directory.GetFiles(configFolder, "*.yaml");

            foreach (var file in configFiles)
            {
                var config = ContextConfiguration.ImportFromFile(file);

                if (ConfigurationValidator(config))
                {
                    configs.Add(config);
                }
                else
                {
                    logger.Warning($"{config.ApplicationName} context already exists.");
                }
            }

            Reload();
        }
        private void ButtonImportConfigration_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog
            {
                Filter           = "YAML files (*.yaml)|*.yaml",
                Title            = "Select configuration files",
                Multiselect      = true,
                InitialDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName
            };

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                var config = ContextConfiguration.ImportFromFile(fileDialog.FileName);
                if (configurationValidator(config))
                {
                    ConfigurationList.Add(config);
                    ListBoxConfigurations.SetSelected(ConfigurationList.Count - 1, true);
                }
                else
                {
                    MessageBox.Show("Configuration already exists!", "InTray Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }