/// <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); }
/// <summary> /// Method used in the subscription to "PropertyChanged" of the eye tracking plugin, it manages all actions /// to be performed once the eye tracking device generates new data. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChangeCoordinates(object sender, PropertyChangedEventArgs e) { // The new data is extracted from the plugin currently loaded Data = proxyInstance.newData; // Then, for each action linked to the new eye tracking coordinates, the program determines what to execute and what not to. // These actions beings (up until now), drawing the reticle, saving the new data to a file and controlling the mouse's position. if (drawingClass != null) { drawingClass.UpdateData(Data["X_Coordinate"], Data["Y_Coordinate"]); } if (saveData) { string trackingData = Data["X_Coordinate"] + ", " + Data["Y_Coordinate"] + ", " + Data["Timestamp"] + "," + clickRegister.ToString(); logging.WriteToLog(trackingData); clickRegister = 0; } if (mouseControl) { controller.MoveCursor(Data["X_Coordinate"], Data["Y_Coordinate"]); } }