/// <summary>
        /// Writes a list of settings to a file
        /// </summary>
        /// <param name="fileRoute">Full route of the file to be written</param>
        /// <param name="controls">List of objects, settings to be written on the file</param>
        /// <returns>True if written successfully. False if not.</returns>
        public bool SaveSettings(string fileRoute, List <object> controls)
        {
            if (File.Exists(fileRoute))
            {
                File.Delete(fileRoute);
            }
            FormAttributes fAttributes = new FormAttributes();

            try
            {
                fAttributes.pluginsRoute  = (string)controls.ElementAt(0);
                fAttributes.pluginName    = (string)controls.ElementAt(1);
                fAttributes.reticlesRoute = (string)controls.ElementAt(2);
                fAttributes.reticleName   = (string)controls.ElementAt(3);
                fAttributes.mouseControl  = (bool)controls.ElementAt(4);
                fAttributes.clickTime     = (int)controls.ElementAt(5);
                fAttributes.saveData      = (bool)controls.ElementAt(6);
                fAttributes.fileName      = (string)controls.ElementAt(7);
                fAttributes.fileRoute     = (string)controls.ElementAt(8);
                string jsonConfig = JsonConvert.SerializeObject(fAttributes);
                logSettings.CreateLogTarget(fileRoute, "");
                logSettings.WriteToLog(jsonConfig);
                logSettings.CloseLogTarget();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method for initializating IntermediateClasss, receives the parameters contained in a configuration.
        /// </summary>
        /// <param name="pluginName">Full route to the plugin to be loaded as an assembly</param>
        /// <param name="reticleRoute">Full route to the image to be used as a reticle</param>
        /// <param name="mouseControl">Bool value that indicates if the user will control the mouse with its gaze</param>
        /// <param name="countdown">Number of seconds to be used as the countdown for generating a click</param>
        /// <param name="saveData">Bool value that indicates if the eye tracking data will be saved to a file</param>
        /// <param name="saveRoute">Route where the files will be saved</param>
        /// <param name="fileName">Name of the file to be generated</param>
        public void InitializeClass(string pluginName, string reticleRoute, bool mouseControl, int countdown, bool saveData, string saveRoute, string fileName)
        {
            proxyInstance.CreateAppDomain(pluginName);
            ClickTimer        = countdown * 1000;
            this.mouseControl = mouseControl;
            this.saveData     = saveData;

            //  If a reticle is selected, the class for managing its drawing is created
            if (reticleRoute != null)
            {
                if (drawingClass != null)
                {
                    drawingClass.ClearUp();
                }
                drawingClass = new ReticleDrawing(reticleRoute);
            }
            else if (reticleRoute == null && drawingClass != null)
            {
                drawingClass.ClearUp();
                drawingClass = null;
            }

            //  If saveData was selected, a file where contents will be written is created, after checking if a file has been
            //  created before (in which case, it's closed before creating the new file).
            if (saveData)
            {
                if (logging != null)
                {
                    logging.CloseLogTarget();
                }
                logging  = new StandardLogging();
                fileName = fileName + " - " + DateTime.Now.ToString("dd-M-yyyy_HH-mm-ss");
                logging.CreateLogTarget(saveRoute, fileName + ".csv");
            }

            //  If mouseControl was selected, the class for controlling the mouse through eye movements is instantiated
            if (mouseControl)
            {
                if (controller == null)
                {
                    controller = new MouseControl();
                }
                clickRegister = 0;
            }
        }