/// <summary> /// Find solvers in given @path and save them to the solvers collection /// </summary> /// <param name="path">Path where the solvers are stored (as dll libraries)</param> private void loadSolverPlugins(string path) { Solvers = new List<string>(); foreach (string fileOn in Directory.GetFiles(path)) { FileInfo file = new FileInfo(fileOn); if (file.Extension.Equals(".dll")) { string solverName = System.IO.Path.GetFileNameWithoutExtension(file.FullName); SolverLibrary lib = new SolverLibrary(solverName, file.FullName, this.parentWindow); lib.Load(); Solvers.Add(solverName); solversDictionary.Add(solverName, lib); if (currentSolver == null) { currentSolver = solverName; } } } }
/// <summary> /// Handler of SolverLibrary.StatusCallback event /// </summary> /// <param name="sp"></param> /// <param name="message"></param> /// <param name="parameter"></param> private void solverStatusChange(SolverLibrary.StatusPriority sp, SolverLibrary.AlertCodes ac, string solver, string message, object parameter) { if (sp == SolverLibrary.StatusPriority.FunctionStatusChange) { if (ac == SolverLibrary.AlertCodes.TerminationInMoment) { SolverStatus = "Solver is terminating. It may take a while."; } addItemToMessageLog(0, solver, message); // 0 means that we don't want to display the moves } }
/// <summary> /// Unregister the callback fror all Solvers (plugins). Method may be called whenever after creation of SolversManager object /// </summary> /// <param name="callback"></param> public void UnRegisterStatusChangeCallback(SolverLibrary.StatusCallbackDel callback) { foreach (KeyValuePair<string, SolverLibrary> pair in solversDictionary) { if (pair.Value != null) { pair.Value.StatusCallback -= callback; } } }