void BeginDrag(Transform knight) { workingArranger = arrangers.Find(t => ContainPos(t.transform as RectTransform, knight.position)); originalIndex = knight.GetSiblingIndex(); SwapKngihtHierarchy(invisibleKnight, knight); }
public PlanarMesh( Transform transform, Mesh mesh3d, Arranger arranger, int normalizationSteps, float normalizationStrength, bool showingNormalization, int neighbourRadius, bool detectOverlappingOnAllTriangles, bool detectOverlappingOnAllEdges, bool useStrength, bool alwaysBuildBestMesh) { this.neighbourRadius = neighbourRadius; this.normalizationStepMax = normalizationSteps; this.normalizationStrength = normalizationStrength; this.showingNormalization = showingNormalization; this.detectOverlappingOnAllTriangles = detectOverlappingOnAllTriangles; this.detectOverlappingOnAllEdges = detectOverlappingOnAllEdges; this.useStrength = useStrength; this.alwaysBuildBestMesh = alwaysBuildBestMesh; this.transform = transform; this.arranger = arranger; createPlanarMesh(mesh3d); createCleaningMesh(); }
/// <summary> /// Copies all pixels within the specified arranger /// </summary> /// <param name="arranger">Source to copy from</param> /// <returns></returns> public static IndexedPixelCopy CopyPixelsIndexed(this Arranger arranger) { int width = arranger.ArrangerPixelSize.Width; int height = arranger.ArrangerPixelSize.Height; return(arranger.CopyPixelsIndexed(0, 0, width, height)); }
public Role FindById(long Id) { var conn = Arranger.GetConnection(); Role role = conn.Get <Role>(Id); return(role); }
public void Delete(long Id) { var conn = Arranger.GetConnection(); Permission perm = conn.Get <Permission>(Id); conn.Delete(perm); }
public void Delete(long Id) { var conn = Arranger.GetConnection(); Role role = conn.Get <Role>(Id); conn.Delete(role); }
public void SaveImage(byte[] image, Arranger arranger, string imagePath) { var width = arranger.ArrangerPixelSize.Width; var height = arranger.ArrangerPixelSize.Height; using var outputImage = new Image <Rgba32>(width, height); var srcidx = 0; for (int y = 0; y < height; y++) { var span = outputImage.GetPixelRowSpan(y); for (int x = 0; x < width; x++, srcidx++) { if (arranger.GetElementAtPixel(x, y) is ArrangerElement el) { var pal = el.Palette; var index = image[srcidx]; var color = pal[index]; span[x] = color.ToRgba32(); } } } using var outputStream = new FileStream(imagePath, FileMode.Create, FileAccess.Write, FileShare.Read); outputImage.SaveAsPng(outputStream); }
public byte[] LoadImage(string imagePath, Arranger arranger, ColorMatchStrategy matchStrategy) { using var inputImage = SixLabors.ImageSharp.Image.Load <Rgba32>(imagePath); var width = inputImage.Width; var height = inputImage.Height; var outputImage = new byte[width * height]; int destidx = 0; for (int y = 0; y < height; y++) { var span = inputImage.GetPixelRowSpan(y); for (int x = 0; x < width; x++, destidx++) { if (arranger.GetElementAtPixel(x, y) is ArrangerElement el) { var pal = el.Palette; var color = new ColorRgba32(span[x].PackedValue); var palIndex = pal.GetIndexByNativeColor(color, matchStrategy); outputImage[destidx] = palIndex; } } } return(outputImage); }
/// <summary> /// Copies all elements within the specified arranger /// </summary> /// <param name="arranger">Source to copy from</param> /// <returns></returns> public static ElementCopy CopyElements(this Arranger arranger) { int width = arranger.ArrangerElementSize.Width; int height = arranger.ArrangerElementSize.Height; return(arranger.CopyElements(0, 0, width, height)); }
/// <summary> /// Copies all pixels within the specified arranger /// </summary> /// <param name="arranger">Source to copy from</param> /// <returns></returns> public static DirectPixelCopy CopyPixelsDirect(this Arranger arranger) { int width = arranger.ArrangerPixelSize.Width; int height = arranger.ArrangerPixelSize.Height; return(arranger.CopyPixelsDirect(0, 0, width, height)); }
public async Task ShouldBeAbleToGetCandidate() { var dbCandidate = await Arranger.CreateCandidate(); var responseCandidateDto = await ApiClient.GetCandidate(dbCandidate.Id) .AwaitGetSuccessfulResponse <CandidateDto>(); responseCandidateDto.ToLikeness(true).ShouldEqual(Mapper.Map <CandidateDto>(dbCandidate)); }
public async Task ShouldBeAbleToGetAQuestion() { var dbQuestion = await Arranger.CreateQuestion(); var responseQuestionDto = await ApiClient.GetQuestion(dbQuestion.Id) .AwaitGetSuccessfulResponse <QuestionDto>(); responseQuestionDto.ToLikeness(true).ShouldEqual(Mapper.Map <QuestionDto>(dbQuestion)); }
public DirectPixelCopy(Arranger source, int pixelX, int pixelY, int width, int height) { Source = source; X = pixelX; Y = pixelY; Width = width; Height = height; Image = new DirectImage(Source, X, Y, Width, Height); }
public override int GetHashCode() { unchecked { var hashCode = Path != null?Path.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Composer != null ? Composer.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Arranger != null ? Arranger.GetHashCode() : 0); return(hashCode); } }
public async Task ShouldBeAbleToGetAllInterviewTemplates() { var dbInterviewTemplates = await Arranger.CreateInterviewTemplates(); var responseInteviewTemplateDtos = await ApiClient.GetInterviewTemplates() .AwaitGetSuccessfulResponse <IEnumerable <InterviewTemplateDto> >(); responseInteviewTemplateDtos .CompareCollectionsUsingLikeness <InterviewTemplateDto, InterviewTemplateDto>( Mapper.Map <IEnumerable <InterviewTemplateDto> >(dbInterviewTemplates)); }
/// <summary> /// Copies pixels within the specified arranger /// </summary> /// <param name="arranger">Source to copy from</param> /// <param name="x">x-coordinate in pixel coordinates</param> /// <param name="y">y-coordinate in pixel coordinates</param> /// <param name="copyWidth">Width of copy in pixel coordinates</param> /// <param name="copyHeight">Height of copy in pixel coordinates</param> /// <returns></returns> public static IndexedPixelCopy CopyPixelsIndexed(this Arranger arranger, int x, int y, int width, int height) { if (arranger.ColorType == PixelColorType.Indexed) { return(new IndexedPixelCopy(arranger, x, y, width, height)); } else { throw new ArgumentException($"{nameof(CopyPixelsIndexed)}: Cannot copy from arranger '{arranger.Name}' with {nameof(PixelColorType)} '{arranger.ColorType}'"); } }
/// <summary> /// Translates a point to an element location in the underlying arranger /// </summary> /// <param name="location">Point in pixel coordinates</param> /// <returns>Element location in element coordinates</returns> public static Point PointToElementLocation(this Arranger arranger, Point location) { if (location.X < 0 || location.X >= arranger.ArrangerPixelSize.Width || location.Y < 0 || location.Y >= arranger.ArrangerPixelSize.Height) { throw new ArgumentOutOfRangeException($"{nameof(PointToElementLocation)} Location ({location.X}, {location.Y}) is out of range"); } int elX = location.X / arranger.ElementPixelSize.Width; int elY = location.Y / arranger.ElementPixelSize.Height; return(new Point(elX, elY)); }
void RotateTowards(Transform targetTransform) { int index = Arranger.GetEmptyLinkIndex(); Transform linkTransform = Arranger.LinkPositions[index]; Vector3 targetDir = targetTransform.position - transform.position; Vector3 toDir = linkTransform.position - transform.position; float angle = Vector3.SignedAngle(targetDir, toDir, Vector3.up); this.transform.Rotate(Vector3.up, angle); Arranger.SetLinkAtIndex(index, targetTransform); }
public async Task GetImages_FileExists_DoesNotDownload() { // ARRANGE var p = Arranger.GetCafEEFluxParametersValid(); var parameters = new CafEEFluxParameters( p.Latitude, p.Latitude, p.StartDate, p.EndDate, p.CloudinessThreshold, p.TierThreshold, $"{Directory.GetCurrentDirectory()}\\Assets\\TestZipOnly", new List <EEFluxImageTypes>() { EEFluxImageTypes.Ndvi }); var u = Arranger.GetEEFluxResponseDownloadEtofValid(); var imageMeta = new Dictionary <int, EEFluxImageMetadata>(); imageMeta.Add( 0, Arranger.GetEEFluxImageMetadataAllValid()[0]); Mock <IEEFluxClient <HttpResponseMessage> > e = new Mock <IEEFluxClient <HttpResponseMessage> >(); e.Setup(x => x.GetImageMetadataAsync(parameters)) .Returns(Task.FromResult(imageMeta)); e.Setup(x => x.GetImageUriAsync( It.IsAny <CafEEFluxParameters>(), It.IsAny <string>(), It.IsAny <EEFluxImageTypes>())) .Returns(Task.FromResult(u)); var c = new CommandLineApplication(); var o = new Mock <IParseParameters <CommandOption> >(); o.Setup(x => x.Parse( It.IsAny <IEnumerable <CommandOption> >())) .Returns(parameters); var sut = new Engine(e.Object, c, o.Object); // ACT int result = await sut.GetImages(parameters); // ASSERT e.Verify(x => x.GetImageUriAsync( parameters, It.IsAny <string>(), It.IsAny <EEFluxImageTypes>()), Times.Never); }
void EndDrag(Transform knight) { if (invisibleKnight.parent == transform) { workingArranger.InsertKnight(knight, originalIndex); workingArranger = null; originalIndex = -1; } else { SwapKngihtHierarchy(invisibleKnight, knight); } }
public async Task ShouldBeAbleToGetAllCandidates() { var dbCandidates = await Arranger.CreateCandidates(); var responseCandidateDtos = await ApiClient.GetAllCandidates() .AwaitGetSuccessfulResponse <IEnumerable <CandidateDto> >(); var responseCandidates = Mapper.Map <IEnumerable <Candidate> >(responseCandidateDtos); responseCandidates = Enumerable.Where <Candidate>(responseCandidates, rc => dbCandidates.Any(dc => dc.Id == rc.Id)); Assert.IsTrue(LikenessCompareExtensions.CompareCollectionsUsingLikeness <Candidate, Candidate>(responseCandidates, dbCandidates)); }
public async Task ShouldBeAbleToCreateInterviewFromTemplate() { var dbInterviewTemplate = await Arranger.CreateInterviewTemplate(); var requestInterview = Stubber.StubInterviewDto(); var responseInterview = await ApiClient.PostInterview(requestInterview, dbInterviewTemplate.Id) .AwaitGetSuccessfulResponse <InterviewDto>(); var dbInterviewTemplateDto = Mapper.Map <IEnumerable <QuestionDto> >(dbInterviewTemplate.Questions); Assert.IsTrue(responseInterview.Questions.CompareCollectionsUsingLikeness <QuestionDto, QuestionDto>(dbInterviewTemplateDto)); }
public async Task ShouldBeAbleToGetAllQuestions() { var dbQuestions = await Arranger.CreateQuestions(); var responseQuestionDtos = await ApiClient.GetAllQuestions() .AwaitGetSuccessfulResponse <IEnumerable <QuestionDto> >(); var responseQuestions = Mapper.Map <IEnumerable <Question> >(responseQuestionDtos); responseQuestions = Enumerable.Where <Question>(responseQuestions, rq => dbQuestions.Any(dq => dq.Id == rq.Id)); Assert.IsTrue(LikenessCompareExtensions.CompareCollectionsUsingLikeness <Question, Question>(responseQuestions, dbQuestions)); }
public async Task ShouldBeABleToUpdateQuestion() { var questionDto = Mapper.Map <QuestionDto>(await Arranger.CreateQuestion()); var questionPatchRequest = Stubber.StubQuestionPatchRequest(); questionPatchRequest.ApplyTo(questionDto); await ApiClient.PatchQuestion(questionDto.Id, questionPatchRequest); var updatedQuestionDto = Mapper.Map <QuestionDto>(await Arranger.GetQuestion(questionDto.Id)); SemanticComparisonExtensions.ToLikeness <QuestionDto>(questionDto, true).ShouldEqual(updatedQuestionDto); }
static async Task Main(string[] args) { var config = new ConfigurationBuilder() .AddJsonFile("battle.json", optional: false) .Build(); var openings = new Openings(); await openings.LoadAsync(20); var arranger = new Arranger(config.GetSection("Players"), config.GetSection("Logging")) { Openings = openings.Boards }; CancellationTokenSource cts = new CancellationTokenSource(); var task = arranger.Begin(cts.Token); string input; do { input = Console.ReadLine(); } while (input != "q"); cts.Cancel(); try { await task; } catch (OperationCanceledException) { Console.WriteLine("已取消"); } var results = arranger.BattleResults .GroupBy(r => new { r.Black, r.White }) .Select(g => new { g.Key.Black, g.Key.White, BlackWin = g.Count(r => r.Result == ChessPiece.Black), WhiteWin = g.Count(r => r.Result == ChessPiece.White), }); foreach (var r in results) { Console.WriteLine($"{r.Black} vs {r.White} {r.BlackWin}:{r.WhiteWin}"); } Console.ReadLine(); }
public async Task ShouldBeAbleToGetAnInterviewTemplate() { var dbInterviewTemplate = await Arranger.CreateInterviewTemplate(); var responseInterviewTemplate = await ApiClient.GetInterviewTemplate(dbInterviewTemplate.Id) .AwaitGetSuccessfulResponse <InterviewTemplateDto>(); var dbInterviewTemplateDto = Mapper.Map <InterviewTemplateDto>(dbInterviewTemplate); responseInterviewTemplate .ToLikeness(true) .WithCollectionSequenceEquals(o => o.QuestionIds) .ShouldEqual(dbInterviewTemplateDto); }
public async Task ShouldBeAbleToGetAllInterviews() { var dbInterviews = await Arranger.CreateInterviews(); var responseInterviewDtos = await ApiClient.GetAllInterviews() .AwaitGetSuccessfulResponse <IEnumerable <InterviewDto> >(); responseInterviewDtos = responseInterviewDtos.Where(i => dbInterviews.Any(di => di.Id == i.Id)); Assert.IsTrue(responseInterviewDtos.CompareCollectionsUsingLikeness <InterviewDto, InterviewDto>( Mapper.Map <IEnumerable <InterviewDto> >(dbInterviews), i => i .WithInnerLikeness <InterviewDto, InterviewDto, CandidateDto, CandidateDto>(o => o.Candidate, o => o.Candidate) .Without(o => o.Questions))); }
public void Parse_SingleImageType_SetsOneImageType() { // ARRANGE var parameters = Arranger.GetCommandOptionsListValid(); parameters = Arranger.ResetCommandOption(parameters, "imagetypes", "etof"); var sut = new CommandLineUtilParameterParser(); var expected = EEFluxImageTypes.Etof; // ACT var actual = sut.Parse(parameters); // ASSERT Assert.Equal(expected, actual.ImageTypes[0]); }
public async Task ShouldBeAbleToUpdateCandidate() { var candidateDto = Mapper.Map <CandidateDto>(await Arranger.CreateCandidate()); var patchRequest = Stubber.StubCandidatePatchRequest(); patchRequest.ApplyTo(candidateDto); (await ApiClient.PatchCandidate(candidateDto.Id, patchRequest)) .EnsureSuccessStatusCode(); var updatedCandidateDto = Mapper.Map <CandidateDto>(await Arranger.GetCandidate(candidateDto.Id)); SemanticComparisonExtensions.ToLikeness <CandidateDto>(candidateDto, true) .ShouldEqual(updatedCandidateDto); }
public async Task ShouldBeAbleToCreateAnInterviewTemplateWithQuestions() { var requestInterviewTemplate = Stubber.StubInterviewTemplateDto(); var questions = await Arranger.CreateQuestions(); requestInterviewTemplate.QuestionIds = questions.Select(q => q.Id); var responseInterviewTemplate = await ApiClient.PostInterviewTemplate(requestInterviewTemplate) .AwaitGetSuccessfulResponse <InterviewTemplateDto>(); responseInterviewTemplate .ToLikeness() .WithCollectionSequenceEquals(o => o.QuestionIds) .ShouldEqual(requestInterviewTemplate); }