public MessageControlUIWPF(MessageControlParameters parameters) { _parameters = parameters; InitializeComponent(); DataContext = this; _messages = new ObservableCollection <MessageToUI>(); _messageControl = PluginLoader.MessageControll; _messageControl.MessageReceived += _messageControl_MessageReceived; }
/// <summary> /// Sets the used pluginfolder to the given path /// </summary> /// /// /// <param name="currentExeFolder"></param> /// <returns>if the path is a valid usable folder path -> true, otherwise -> false</returns> public bool Inititialize(string currentExeFolder) { try { var settings = ConfigurationManager.AppSettings; lock (_lockObj) { if (!IsPathFolder(currentExeFolder) || !Directory.Exists(currentExeFolder)) { return(false); } CurrentExeFolder = CheckDirectoryPath(currentExeFolder); // Configuration folder: if (settings[FolderSettingsKeys.ConfigurationFolderKey] == null) { settings.Add(FolderSettingsKeys.ConfigurationFolderKey, @".\Configuration\"); } ConfigurationFolder = CreateFinalPath(CurrentExeFolder, settings[FolderSettingsKeys.ConfigurationFolderKey], nameof(ConfigurationFolder)); if (!IsPathFolder(ConfigurationFolder) || !Directory.Exists(ConfigurationFolder)) { return(false); } // Plugins folder: if (settings[FolderSettingsKeys.PluginsFolderKey] == null) { settings.Add(FolderSettingsKeys.PluginsFolderKey, @".\Plugins\"); } PluginsFolder = CreateFinalPath(CurrentExeFolder, settings[FolderSettingsKeys.PluginsFolderKey], nameof(PluginsFolder)); if (!IsPathFolder(PluginsFolder) || !Directory.Exists(PluginsFolder)) { return(false); } // Specification folder: if (settings[FolderSettingsKeys.SpecificactionFolderKey] == null) { settings.Add(FolderSettingsKeys.SpecificactionFolderKey, @".\Configuration\Specifications\"); } SpecificationFolder = CreateFinalPath(CurrentExeFolder, settings[FolderSettingsKeys.SpecificactionFolderKey], nameof(SpecificationFolder)); if (!IsPathFolder(SpecificationFolder) || !Directory.Exists(SpecificationFolder)) { return(false); } // Reference folder: if (settings[FolderSettingsKeys.ReferenceFolderKey] == null) { settings.Add(FolderSettingsKeys.ReferenceFolderKey, @".\Configuration\References\"); } ReferenceFolder = CreateFinalPath(CurrentExeFolder, settings[FolderSettingsKeys.ReferenceFolderKey], nameof(ReferenceFolder)); if (!IsPathFolder(ReferenceFolder) || !Directory.Exists(ReferenceFolder)) { return(false); } // measurement data: if (settings[FolderSettingsKeys.MeasurementDataFolderKey] == null) { settings.Add(FolderSettingsKeys.MeasurementDataFolderKey, @".\Configuration\Measurements\"); } MeasurementDataFolder = CreateFinalPath(CurrentExeFolder, settings[FolderSettingsKeys.MeasurementDataFolderKey], nameof(MeasurementDataFolder)); if (!IsPathFolder(MeasurementDataFolder) || !Directory.Exists(MeasurementDataFolder)) { return(false); } // Result folder: if (settings[FolderSettingsKeys.ResultFolderKey] == null) { settings.Add(FolderSettingsKeys.ResultFolderKey, @".\Results\"); } ResultFolder = CreateFinalPath(CurrentExeFolder, settings[FolderSettingsKeys.ResultFolderKey], nameof(ResultFolder)); if (!IsPathFolder(ResultFolder) || !Directory.Exists(ResultFolder)) { return(false); } ConfigManager = new ConfigManager(ConfigurationFolder); if (!LoadPlugins()) { return(Initialized = false); } MessageControll = new UIMessageControl(); return(Initialized = true); } } catch (ConfigurationErrorsException ex) { _logger.Error($"Problem during configuration folder loading from App settings: {ex.Message}"); return(false); } catch (ArgumentNullException ex) { SendToErrorLogAndConsole($"Problem with input variable: {ex.Message}"); return(false); } catch (Exception ex) { SendToErrorLogAndConsole($"Exception occured: {ex.Message}"); return(false); } }