public void CanGetPointerImageFromDesktopFrame() { var mapJson = File.ReadAllText("./mocks/alignmentmap.json"); var map = JsonConvert.DeserializeObject <IList <int> >(mapJson); using var cts = new CancellationTokenSource(); var desktopDuplicator = new DesktopDuplicator(_mockLogger.Object); var settings = new MatrixSettings() { Map = map, DataFormat = DataMatrixFormat.Raw }; foreach (var desktopFrame in desktopDuplicator.DuplicateDesktop(cts.Token)) { var pointerImage = desktopFrame.GetPointerImage(); //Erm, move the mouse around to get an updated cursor image. if (pointerImage != null) { //Assert.StartsWith("data:image/png;base64,", pointerImage); cts.Cancel(); } } Assert.True(true); }
public void CanDecodeDesktopFrame() { var mapJson = File.ReadAllText("./mocks/alignmentmap.json"); var map = JsonConvert.DeserializeObject <IList <int> >(mapJson); using var cts = new CancellationTokenSource(); var desktopDuplicator = new DesktopDuplicator(_mockLogger.Object); var settings = new MatrixSettings() { Map = map, DataFormat = DataMatrixFormat.Raw }; foreach (var desktopFrame in desktopDuplicator.DuplicateDesktop(cts.Token)) { var frame = desktopFrame.DecodeMatrixFrame(settings); if (frame != null) { cts.Cancel(); } } Assert.True(true); }
public void CanCreateThumbnailFromDesktopFrame() { var mapJson = File.ReadAllText("./mocks/alignmentmap.json"); var map = JsonConvert.DeserializeObject <IList <int> >(mapJson); using var cts = new CancellationTokenSource(); var desktopDuplicator = new DesktopDuplicator(_mockLogger.Object); var settings = new MatrixSettings() { Map = map, DataFormat = DataMatrixFormat.Raw }; foreach (var desktopFrame in desktopDuplicator.DuplicateDesktop(cts.Token)) { var width = (int)Math.Ceiling(desktopFrame.DesktopWidth * 0.15); var height = (int)Math.Ceiling(desktopFrame.DesktopHeight * 0.15); var thumbby = desktopFrame.GetThumbnailImage(width, height); Assert.True(thumbby.Length > 0); cts.Cancel(); } Assert.True(true); }
/// <summary> /// Return La Valeur du Paramettre System /// </summary> /// <param name="systemSetting"></param> /// <returns></returns> public object GetMatrixSetting(MatrixSettings systemSetting) { using (var db = new Ef()) { if (db.SystemSetting.Find(MatrixConstants.SystemGuid()) == null) { db.SystemSetting.Add(new MatrixSetting()); } switch (systemSetting) { case MatrixSettings.CurrentAnneeScolaire: return(db.SystemSetting.Find(MatrixConstants.SystemGuid()).CurrentAnneeScolaireGuid); case MatrixSettings.CurrentPerodeScolaire: return(db.SystemSetting.Find(MatrixConstants.SystemGuid()).CurrentPeriodeScolaireGuid); case MatrixSettings.EtablissementName: return(db.SystemSetting.Find(MatrixConstants.SystemGuid()).EtablissementName); case MatrixSettings.EtablissementFax: return(db.SystemSetting.Find(MatrixConstants.SystemGuid()).EtablissementFax); case MatrixSettings.EtablissementLogo: return(db.SystemSetting.Find(MatrixConstants.SystemGuid()).EtablissementLogo); default: return(null); } } }
public void CanDecodeAlphaPattern() { var mapJson = File.ReadAllText("./mocks/alignmentmap.json"); var map = JsonSerializer.Deserialize <IList <int> >(mapJson); var foo = DesktopFrame.FromFile("./mocks/alphapattern.bmp"); var settings = new MatrixSettings() { Map = map, DataFormat = DataMatrixFormat.Text, }; var dataMatrix = foo.DecodeMatrixFrame(settings); var matrixJson = JsonSerializer.Serialize(dataMatrix); dataMatrix = JsonSerializer.Deserialize <MatrixFrame>(matrixJson); var testData = dataMatrix.Data.ToString(); Assert.Equal((map.Count / 2) * 3 - 6, testData.Length); Assert.Equal(120, dataMatrix.FrameId); int width = 156; int height = 46; Assert.Equal(width, dataMatrix.Metadata[0]); Assert.Equal(height, dataMatrix.Metadata[1]); var frameType = dataMatrix.Metadata[2] >> 4; var pixelSize = dataMatrix.Metadata[2] % 16; Assert.Equal(2, frameType); Assert.Equal(2, pixelSize); var errors = 0; for (int i = 0; i < testData.Length; i++) { if (testData[i] != TestPattern[i % TestPattern.Length]) { errors++; } } Assert.Equal(0, errors); }
/// <summary> /// Modifier Un Paramettre System /// </summary> /// <returns></returns> public bool SetMatrixSetting(MatrixSettings systemSetting, object newValue) { using (var db = new Ef()) { if (db.SystemSetting.Find(MatrixConstants.SystemGuid()) == null) { db.SystemSetting.Add(new MatrixSetting()); } switch (systemSetting) { case MatrixSettings.CurrentAnneeScolaire: db.SystemSetting.Find(MatrixConstants.SystemGuid()).CurrentAnneeScolaireGuid = (Guid)newValue; break; case MatrixSettings.CurrentPerodeScolaire: db.SystemSetting.Find(MatrixConstants.SystemGuid()).CurrentPeriodeScolaireGuid = (Guid)newValue; break; case MatrixSettings.EtablissementName: db.SystemSetting.Find(MatrixConstants.SystemGuid()).EtablissementName = (string)newValue; break; case MatrixSettings.EtablissementFax: db.SystemSetting.Find(MatrixConstants.SystemGuid()).EtablissementFax = (string)newValue; break; case MatrixSettings.EtablissementLogo: db.SystemSetting.Find(MatrixConstants.SystemGuid()).EtablissementLogo = (byte[])newValue; break; default: return(true); } return(db.SaveChanges() > 0); } }
public void CanDecodeMatrixEventData() { var mapJson = File.ReadAllText("./mocks/alignmentmap.json"); var map = JsonSerializer.Deserialize <IList <int> >(mapJson); var foo = DesktopFrame.FromFile("./mocks/datapattern.bmp"); var settings = new MatrixSettings() { Map = map, DataFormat = DataMatrixFormat.MatrixEvents, }; var dataMatrix = foo.DecodeMatrixFrame(settings); var matrixJson = JsonSerializer.Serialize(dataMatrix); dataMatrix = JsonSerializer.Deserialize <MatrixFrame>(matrixJson); var testData = JsonSerializer.Deserialize <IList <MatrixEvent> >(((JsonElement)dataMatrix.Data).GetRawText()); Assert.Equal(45, testData.Count); Assert.Equal(115, dataMatrix.FrameId); int width = 156; int height = 46; Assert.Equal(width, dataMatrix.Metadata[0]); Assert.Equal(height, dataMatrix.Metadata[1]); var frameType = dataMatrix.Metadata[2] >> 4; var pixelSize = dataMatrix.Metadata[2] % 16; Assert.Equal(0, frameType); Assert.Equal(2, pixelSize); var playerData = (JsonElement)testData.FirstOrDefault(td => td.Topic == "player").Data; Assert.Equal("Sleepyhead", playerData.GetProperty("n").GetString()); }
public void CanDecodeTestPattern() { var mapJson = File.ReadAllText("./mocks/alignmentmap.json"); var map = JsonSerializer.Deserialize <IList <int> >(mapJson); var foo = DesktopFrame.FromFile("./mocks/testpattern.bmp"); var settings = new MatrixSettings() { Map = map, DataFormat = DataMatrixFormat.Raw, }; var dataMatrix = foo.DecodeMatrixFrame(settings); var matrixJson = JsonSerializer.Serialize(dataMatrix); dataMatrix = JsonSerializer.Deserialize <MatrixFrame>(matrixJson); var testData = JsonSerializer.Deserialize <byte[]>(((JsonElement)dataMatrix.Data).GetRawText()); Assert.Equal((map.Count / 2) * 3, testData.Length); Assert.Equal(119, dataMatrix.FrameId); int width = 156; int height = 46; Assert.Equal(width, dataMatrix.Metadata[0]); Assert.Equal(height, dataMatrix.Metadata[1]); var frameType = dataMatrix.Metadata[2] >> 4; var pixelSize = dataMatrix.Metadata[2] % 16; Assert.Equal(1, frameType); Assert.Equal(2, pixelSize); var errors = 0; // Test the full range for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // Skip the metadata if (y == 0 && (x == 0 || x == 1)) { continue; } var ix = y * width * 3 + x * 3; var x1 = testData[ix]; var y1 = testData[ix + 1]; var z = testData[ix + 2]; if (x + 1 != x1 || y + 1 != y1 || z != 255) { errors++; } } } Assert.Equal(0, errors); }
protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); MatrixSettings.Initialize(); }
public MatrixCRUD(IOptions <MatrixSettings> settings, IMapper mapper) { // Dont forget to start a services :) this.matrixSettings = settings.Value; this.mapper = mapper; }