private async Task ChangeUserSponsor(UserMultiAccount userMultiAccount, MatrixPosition matrixPosition) { var parentPosition = await _matrixPositionRepository.GetAsync(matrixPosition.ParentId.Value); userMultiAccount.ChangeSponsor(parentPosition.UserMultiAccountId.Value); await _userMultiAccountRepository.UpdateAsync(userMultiAccount); }
private static void ExportTextShape(RadDiagramTextShape shape, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle), true); containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize())); if (shape.Content != null) { var center = bounds.Center(); ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return(new Point(bounds.Center().X - s.Width / 2, center.Y - s.Height / 2)); }); } }
private async Task PreValidation() { if (_multiAccount is null) { throw new ValidationException("User with given ID was not found."); } _userMatrixPositionOnLowerMatrix = await _matrixPositionHelper.GetPositionForAccountAtLevelAsync(_multiAccount.Id, _lowerLevelMatrix); if (_userMatrixPositionOnLowerMatrix is null) { throw new ValidationException($"User does not have position in the lower level matrix: {_lowerLevelMatrix}."); } var alreadyUpgraded = await _matrixPositionHelper.GetPositionForAccountAtLevelAsync(_multiAccount.Id, _command.MatrixLevel); if (alreadyUpgraded != null) { throw new ValidationException("User has already been upgraded to this level."); } if (await _paymentHistoryHelper.DoesUserPaidForMatrixLevelAsync(_command.MatrixLevel, _multiAccount.Id) == false) { throw new ValidationException("User didn't pay for the upgraded structure yet."); } }
private async Task AddTwoEmptyChildToBoughtPosition(MatrixPosition matrixPositionBought) { var newDepthLevel = matrixPositionBought.DepthLevel + 1; var matricesToAdd = new List <MatrixPosition>() { new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: matrixPositionBought.MatrixLevel, depthLevel: newDepthLevel, left: matrixPositionBought.Left + 1, right: matrixPositionBought.Left + 2, parentId: matrixPositionBought.Id, userMultiAccountId: null ), new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: matrixPositionBought.MatrixLevel, depthLevel: newDepthLevel, left: matrixPositionBought.Left + 3, right: matrixPositionBought.Left + 4, parentId: matrixPositionBought.Id, userMultiAccountId: null ) }; _context.Set <MatrixPosition>().AddRange(matricesToAdd); await _context.SaveChangesAsync(); }
private async Task <MatrixPosition> GetMatrixPositionUnderAdminBasedOnStructureSide(int matrixLevel, AdminStructureSide adminStructureSide, MatrixPosition topAdmin) { if (adminStructureSide == AdminStructureSide.Skipped) { return(topAdmin); } MatrixPosition position = topAdmin; switch (adminStructureSide) { case AdminStructureSide.Left: topAdmin = await _context.Set <MatrixPosition>() .Where(x => x.Left == position.Left + 1) .Where(x => x.ParentId == position.Id) .Where(x => x.MatrixLevel == matrixLevel) .SingleAsync(); break; case AdminStructureSide.Right: topAdmin = await _context.Set <MatrixPosition>() .Where(x => x.Right == position.Right - 1) .Where(x => x.ParentId == position.Id) .Where(x => x.MatrixLevel == matrixLevel) .SingleAsync(); break; } return(topAdmin); }
private static void ExportConnection(RadDiagramConnection connection, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(connection.Bounds.X - enclosingBounds.X, connection.Bounds.Y - enclosingBounds.Y, connection.Bounds.Width, connection.Bounds.Height); var pathGeometry = connection.Geometry as PathGeometry; var pathBounds = connection.ConnectionType == ConnectionType.Bezier ? pathGeometry.Bounds : new Rect(); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X - pathBounds.X, Y = bounds.Y - pathBounds.Y }); var position = new MatrixPosition(transformGroup.Value); EditorInfo info = new EditorInfo(page, position, connection, bounds, connection.Stroke, 0); FixedContentEditor editor = CreateEditor(info, false); FixedContentEditor filledEditor = CreateEditor(info, true); ExportGeometry(editor, filledEditor, pathGeometry, true); if (connection.Content != null) { var center = bounds.Center(); ExportContent(connection, bounds, 0, page, (s) => { return(new Point(bounds.Center().X - s.Width / 2, center.Y - s.Height / 2)); }); } }
private void MatrixPositionTrasform() { #region radpdfprocessing-concepts-position_0 MatrixPosition matrixPosition = new MatrixPosition(); matrixPosition.Translate(20, 20); // Translates the position by (20, 20) matrixPosition.Translate(30, 30); // Translates the position by (30, 30). #endregion }
public Task <MatrixPosition> GetTopParentAsync(MatrixPosition matrixPosition, int matrixLevel = 0) { return(_context.Set <MatrixPosition>() .Where(x => x.Left < matrixPosition.Left) .Where(x => x.Right > matrixPosition.Right) .Where(x => x.DepthLevel == matrixPosition.DepthLevel - 2) .Where(x => x.MatrixLevel == matrixLevel) .SingleOrDefaultAsync()); }
public async Task <IEnumerable <MatrixPosition> > GetMatrixAsync(MatrixPosition matrixPosition, int matrixLevel = 0) { return(await _context.Set <MatrixPosition>() .Where(x => x.Left >= matrixPosition.Left) .Where(x => x.Right <= matrixPosition.Right) .Where(x => x.DepthLevel >= matrixPosition.DepthLevel) .Where(x => x.DepthLevel <= matrixPosition.DepthLevel + 2) // Each matrix has 2 depth level .Where(x => x.MatrixLevel == matrixLevel) .ToListAsync()); }
public void InitializeWordSlots(GameObject[,] slots) { lastOccupiedWordSlot = new MatrixPosition(0, 0); wordSlots = new WordSlot[slots.GetLength(0), slots.GetLength(1)]; for (int i = 0; i < slots.GetLength(0); i++) { for (int j = 0; j < slots.GetLength(1); j++) { wordSlots [i, j] = slots[i, j].GetComponent <WordSlot>(); } } }
private static void ExportContainerShape(RadDiagramContainerShape container, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(container.Bounds.X - enclosingBounds.X, container.Bounds.Y - enclosingBounds.Y, container.Bounds.Width, container.Bounds.Height); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new RotateTransform() { Angle = container.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, container, bounds, container.BorderBrush, container.RotationAngle), true); containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize())); containerEditor.GraphicProperties.StrokeThickness = 0.5; var headerHeight = container.ContentBounds.Y - container.Bounds.Y - DiagramConstants.ContainerMargin; containerEditor.DrawRectangle(new Rect(new Point(0, headerHeight), new Size(bounds.Width, 0.5))); if (container.IsCollapsible) { var buttonTop = headerHeight / 2 - 2.5; var buttonLeft = bounds.Width - 20; if (container.IsCollapsed) { containerEditor.DrawLine(new Point(buttonLeft, buttonTop), new Point(buttonLeft + 4, buttonTop + 4)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop + 4), new Point(buttonLeft + 8, buttonTop)); if (container.CollapsedContent != null) { var contentHeight = container.ActualHeight - headerHeight; ExportContent(container, bounds, container.RotationAngle, page, (s) => { return(new Point(bounds.Center().X - s.Width / 2, bounds.Bottom - contentHeight / 2 - s.Height / 2)); }, container.CollapsedContent.ToString()); } } else { containerEditor.DrawLine(new Point(buttonLeft, buttonTop + 4), new Point(buttonLeft + 4, buttonTop)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop), new Point(buttonLeft + 8, buttonTop + 4)); } } if (container.Content != null) { ExportContent(container, bounds, container.RotationAngle, page, (s) => { return(new Point(bounds.Center().X - s.Width / 2, bounds.Top + headerHeight / 2 - s.Height / 2)); }); } }
/// <summary> /// Shrinks matrix by number of columns (from the start / from the end.) /// </summary> public virtual Matrix ShrinkColumns(int colsToShrink, MatrixPosition pos) { int[] cols = null; if (pos == MatrixPosition.Start) { cols = Enumerable.Range(0, colsToShrink).ToArray(); } else { cols = Enumerable.Range(this.ColumnCount - colsToShrink, colsToShrink).ToArray(); } return(new Matrix(MatrixFunctions.RemoveColumns(this.InnerMatrix, cols))); }
/// <summary> /// Shrinks matrix by number of rows (from the start / from the end.) /// </summary> public virtual Matrix ShrinkRows(int rowsToShrink, MatrixPosition pos) { int[] rows = null; if (pos == MatrixPosition.Start) { rows = Enumerable.Range(0, rowsToShrink).ToArray(); } else { rows = Enumerable.Range(this.RowCount - rowsToShrink, rowsToShrink).ToArray(); } return(new Matrix(MatrixFunctions.RemoveRows(this.InnerMatrix, rows))); }
private static void ExportShape(RadDiagramShape shape, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height); var pathGeometry = shape.Geometry as PathGeometry; var transformGroup = new TransformGroup(); #if WPF if (pathGeometry == null) { var streamGeometry = shape.Geometry as StreamGeometry; if (streamGeometry != null) { pathGeometry = streamGeometry.AsPathGeometry(); } } #endif var geometrySize = shape.Geometry.Bounds.ToSize(); if (IsValidSize(geometrySize) && (geometrySize.Width != bounds.Width || geometrySize.Width != bounds.Width)) { transformGroup.Children.Add(new ScaleTransform() { ScaleX = bounds.Width / geometrySize.Width, ScaleY = bounds.Height / geometrySize.Height }); } transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); EditorInfo info = new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle); FixedContentEditor editor = CreateEditor(info, false); FixedContentEditor filledEditor = CreateEditor(info, true); ExportGeometry(editor, filledEditor, pathGeometry); if (shape.Content != null) { var center = bounds.Center(); ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return(new Point(center.X - s.Width / 2, center.Y - s.Height / 2)); }); } }
private async Task <Guid> UpgradeMatrixForUser(MatrixPosition adminPosition, AdminStructureSide adminStructure) { MatrixPosition upgradedPosition; if (!_multiAccount.SponsorId.HasValue) { throw new ValidationException("FATAL! User does not have sponsor"); } var userAccount = await _userAccountDataRepository.GetAsync(_multiAccount.UserAccountDataId); var userMultiAccountIds = userAccount.UserMultiAccounts.Select(x => x.Id).ToList(); // Need for cycles in the future var sponsorPositionOnUpgradedMatrix = await _matrixPositionHelper.GetPositionForAccountAtLevelAsync(_multiAccount.SponsorId.Value, _command.MatrixLevel); if (sponsorPositionOnUpgradedMatrix is null) { upgradedPosition = await _matrixPositionHelper.FindTheNearestEmptyPositionFromGivenAccountWhereInParentsMatrixThereIsNoAnyMultiAccountAsync( adminPosition.UserMultiAccountId.Value, userMultiAccountIds, _command.MatrixLevel, adminStructure); } else { upgradedPosition = await _matrixPositionHelper.FindTheNearestEmptyPositionFromGivenAccountWhereInParentsMatrixThereIsNoAnyMultiAccountAsync( _multiAccount.SponsorId.Value, userMultiAccountIds, _command.MatrixLevel); } if (upgradedPosition is null) { throw new ValidationException($"There is no empty space in the structure level - {_command.MatrixLevel} - where account can be assigned"); } upgradedPosition.AssignMultiAccount(_multiAccount.Id); await _matrixPositionRepository.UpdateAsync(upgradedPosition); _backgroundJobClient.Enqueue <MatrixPositionHasBeenUpgradedJob>( job => job.Execute(upgradedPosition.Id, null)); _backgroundJobClient.Enqueue <InitWithdrawalJob>( job => job.Execute(new InitWithdrawalModel { MatrixPositionId = upgradedPosition.Id, WithdrawalFor = WithdrawalForHelper.UpgradedMatrix }, null)); return(upgradedPosition.Id); }
/// <summary> /// Expands matrix by the specified number of rows (at the start / at the end.) /// </summary> public virtual Matrix ExpandRows(int rows, MatrixPosition pos) { if (rows < 0) { throw new ArgumentOutOfRangeException(nameof(rows)); } double[,] newMatrix = new double[rows, this.ColumnCount]; if (pos == MatrixPosition.Start) { return(new Matrix(newMatrix).Concat(this, MatrixDirection.Vertical)); } else { return(Concat(newMatrix, MatrixDirection.Vertical)); } }
/// <summary> /// Expands matrix by the specified number of columns (at the start / at the end.) /// </summary> public virtual Matrix ExpandColumns(int cols, MatrixPosition pos) { if (cols < 0) { throw new ArgumentOutOfRangeException(nameof(cols)); } double[,] newMatrix = new double[this.RowCount, cols]; if (pos == MatrixPosition.Start) { return(new Matrix(newMatrix).Concat(this, MatrixDirection.Horizontal)); } else { return(Concat(newMatrix, MatrixDirection.Horizontal)); } }
private async Task LeftRightValuesReindexation(MatrixPosition matrixPositionBought) { await _context.Set <MatrixPosition>() .Where(x => x.Left > matrixPositionBought.Left) .Where(x => x.MatrixLevel == matrixPositionBought.MatrixLevel) .UpdateAsync(x => new MatrixPosition { Left = x.Left + 4 }); await _context.Set <MatrixPosition>() .Where(x => x.Right >= matrixPositionBought.Right) .Where(x => x.MatrixLevel == matrixPositionBought.MatrixLevel) .UpdateAsync(x => new MatrixPosition { Right = x.Right + 4 }); }
private static void ExploreMaze(MatrixPosition position) { maze[position.Row, position.Col] = position.DistanceFromStartPosition.ToString(); MarkPossibleDirections(position); while (position.Unexplored.Count > 0) { var next = position.Next; next.DistanceFromStartPosition = position.DistanceFromStartPosition + 1; unexploredPositions.Enqueue(next); } if (unexploredPositions.Count > 0) { ExploreMaze(unexploredPositions.Dequeue()); } }
private static void ExportTextShape(RadDiagramTextShape shape, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle), true); containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize())); if (shape.Content != null) { var center = bounds.Center(); ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, center.Y - s.Height / 2); }); } }
async Task AndGivenCreatedDefaultAccountsAndMatricesInDatabase() { var fakerGenerator = new FakerGenerator(); var existingUserAccountData = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var otherUser = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); _context.UserAccountsData.AddRange(existingUserAccountData, otherUser); await _context.SaveChangesAsync(); // Multi accounts var otherMultiAccount = fakerGenerator.GetUserMultiAccountFakerGenerator() .RuleFor(x => x.Id, Guid.Parse("d4887060-fb76-429b-95db-113fef65d68d")) .RuleFor(x => x.UserAccountDataId, otherUser.Id) .RuleFor(x => x.IsMainAccount, true) .Generate(); var otherMultiAccount2 = fakerGenerator.GetUserMultiAccountFakerGenerator() .RuleFor(x => x.UserAccountDataId, otherUser.Id) .Generate(); var otherMultiAccount3 = fakerGenerator.GetUserMultiAccountFakerGenerator() .RuleFor(x => x.UserAccountDataId, otherUser.Id) .Generate(); var myMultiAccount = fakerGenerator.GetUserMultiAccountFakerGenerator() .RuleFor(x => x.Id, Guid.Parse("032d748c-9cef-4a5a-92bd-3fd9a4a0e499")) .RuleFor(x => x.UserAccountDataId, existingUserAccountData.Id) .RuleFor(x => x.SponsorId, otherMultiAccount.Id) .RuleFor(x => x.RefLink, null as string) .RuleFor(x => x.IsMainAccount, true) .Generate(); _context.UserMultiAccounts.AddRange(myMultiAccount, otherMultiAccount, otherMultiAccount2, otherMultiAccount3); await _context.SaveChangesAsync(); // Payments var payment = fakerGenerator.GetPaymentHistoryFakerGenerator() .RuleFor(x => x.PaymentFor, PaymentForHelper.MatrixLevelPositionsDictionary[0]) .RuleFor(x => x.Status, PaymentStatusHelper.Paid) .RuleFor(x => x.OrderId, Guid.Parse("032d748c-9cef-4a5a-92bd-3fd9a4a0e499")) .Generate(); _context.PaymentHistories.Add(payment); await _context.SaveChangesAsync(); // Matrices var topMatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount.Id, parentId: null, matrixLevel: 0, depthLevel: 0, left: 1, right: 18 ); _context.MatrixPositions.Add(topMatrixPosition); await _context.SaveChangesAsync(); var positionLineA1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount2.Id, parentId: topMatrixPosition.Id, matrixLevel: 0, depthLevel: 1, left: 2, right: 11 ); _context.MatrixPositions.Add(positionLineA1); await _context.SaveChangesAsync(); var positionLineA2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount2.Id, parentId: topMatrixPosition.Id, matrixLevel: 0, depthLevel: 1, left: 12, right: 17 ); _context.MatrixPositions.Add(positionLineA2); await _context.SaveChangesAsync(); var positionLineB1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount3.Id, parentId: positionLineA1.Id, matrixLevel: 0, depthLevel: 2, left: 3, right: 4 ); _context.MatrixPositions.Add(positionLineB1); await _context.SaveChangesAsync(); var positionLineB2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount3.Id, parentId: positionLineA1.Id, matrixLevel: 0, depthLevel: 2, left: 5, right: 8 ); _context.MatrixPositions.Add(positionLineB2); await _context.SaveChangesAsync(); var positionLineC1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB2.Id, matrixLevel: 0, depthLevel: 3, left: 6, right: 7 ); _context.MatrixPositions.Add(positionLineC1); await _context.SaveChangesAsync(); var positionLineC2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB2.Id, matrixLevel: 0, depthLevel: 3, left: 8, right: 9 ); _context.MatrixPositions.Add(positionLineC2); await _context.SaveChangesAsync(); var positionLineB3 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount3.Id, parentId: positionLineA2.Id, matrixLevel: 0, depthLevel: 3, left: 13, right: 14 ); _context.MatrixPositions.Add(positionLineB3); await _context.SaveChangesAsync(); var positionLineB4 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount3.Id, parentId: positionLineA2.Id, matrixLevel: 0, depthLevel: 3, left: 15, right: 16 ); _context.MatrixPositions.Add(positionLineB4); await _context.SaveChangesAsync(); }
void Start() { matrixPos = GetComponent <MatrixPosition>(); aStar = GetComponent <AStar>(); InvokeRepeating("RunAStar", 0f, 1f); }
/// <summary> /// updates the coordinates so that the provided position is included in the area /// </summary> /// <param name="pos"></param> public void IncludePosition(MatrixPosition pos) { if (pos.Row < Top) { Top = pos.Row; } if (pos.Col < Left) { Left = pos.Col; } if (pos.Row > Bottom) { Bottom = pos.Row; } if (pos.Col > Right) { Right = pos.Col; } }
async Task AndGivenCreatedDefaultAccountsAndMatricesInDatabase() { var fakerGenerator = new FakerGenerator(); var adminUserAccountData1 = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.Admin) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var adminUserAccountData2 = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.Admin) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var adminUserAccountData3 = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.Admin) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var adminUserAccountData4 = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.Admin) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var rootUser = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.Root) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var sponsorUser = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.User) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var user1 = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.User) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var testUser = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Role, UserRolesHelper.User) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); _context.UserAccountsData.AddRange(adminUserAccountData1, adminUserAccountData2, adminUserAccountData3, adminUserAccountData4, rootUser, sponsorUser, testUser, user1); await _context.SaveChangesAsync(); // Multi accounts var rootMultiAccount1 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: rootUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName" ); rootMultiAccount1.SetReflink("otherUserReflink12345"); rootMultiAccount1.SetAsMainAccount(); var rootMultiAccount2 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: rootUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName2" ); rootMultiAccount2.SetReflink("otherUserReflink123456789"); var rootMultiAccount3 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: rootUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName3" ); rootMultiAccount3.SetReflink("3"); var adminMultiAccount1 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: adminUserAccountData1.Id, sponsorId: rootMultiAccount2.Id, multiAccountName: "myMultiAccountName" ); adminMultiAccount1.SetAsMainAccount(); var adminMultiAccount2 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: adminUserAccountData2.Id, sponsorId: rootMultiAccount2.Id, multiAccountName: "myMultiAccountName" ); adminMultiAccount2.SetAsMainAccount(); var adminMultiAccount3 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: adminUserAccountData3.Id, sponsorId: rootMultiAccount3.Id, multiAccountName: "myMultiAccountName" ); adminMultiAccount3.SetAsMainAccount(); var adminMultiAccount4 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: adminUserAccountData4.Id, sponsorId: rootMultiAccount3.Id, multiAccountName: "myMultiAccountName" ); adminMultiAccount4.SetAsMainAccount(); var sponsorMultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: sponsorUser.Id, sponsorId: rootMultiAccount3.Id, multiAccountName: "sponsorMultiAccountName" ); sponsorMultiAccount.SetAsMainAccount(); var userMultiAccount1 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: user1.Id, sponsorId: adminMultiAccount4.Id, multiAccountName: "userMultiAccountName1" ); userMultiAccount1.SetAsMainAccount(); var testUserMultiAccount = new UserMultiAccount ( id: _userMultiAccountId, userAccountDataId: testUser.Id, sponsorId: sponsorMultiAccount.Id, multiAccountName: "testUserMultiAccountName" ); testUserMultiAccount.SetAsMainAccount(); _context.UserMultiAccounts.AddRange(adminMultiAccount1, adminMultiAccount2, adminMultiAccount3, adminMultiAccount4, rootMultiAccount1, rootMultiAccount2, rootMultiAccount3, sponsorMultiAccount, userMultiAccount1, testUserMultiAccount); await _context.SaveChangesAsync(); // Matrices // LVL 0 var topMatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: rootMultiAccount1.Id, parentId: null, matrixLevel: 0, depthLevel: 0, left: 1, right: 38 ); _context.MatrixPositions.Add(topMatrixPosition); var positionLineA1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: rootMultiAccount2.Id, parentId: topMatrixPosition.Id, matrixLevel: 0, depthLevel: 1, left: 2, right: 15 ); _context.MatrixPositions.Add(positionLineA1); var positionLineA2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: rootMultiAccount3.Id, parentId: topMatrixPosition.Id, matrixLevel: 0, depthLevel: 1, left: 16, right: 37 ); _context.MatrixPositions.Add(positionLineA2); var positionLineB1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount1.Id, // TESTED parentId: positionLineA1.Id, matrixLevel: 0, depthLevel: 2, left: 3, right: 8 ); _context.MatrixPositions.Add(positionLineB1); var positionLineB2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount2.Id, parentId: positionLineA1.Id, matrixLevel: 0, depthLevel: 2, left: 9, right: 14 ); _context.MatrixPositions.Add(positionLineB2); var positionLineB3 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount3.Id, parentId: positionLineA2.Id, matrixLevel: 0, depthLevel: 2, left: 17, right: 22 ); _context.MatrixPositions.Add(positionLineB3); var positionLineB4 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount4.Id, parentId: positionLineA2.Id, matrixLevel: 0, depthLevel: 2, left: 23, right: 36 ); _context.MatrixPositions.Add(positionLineB4); var positionLineC1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB1.Id, matrixLevel: 0, depthLevel: 3, left: 4, right: 5 ); _context.MatrixPositions.Add(positionLineC1); var positionLineC2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB1.Id, matrixLevel: 0, depthLevel: 3, left: 6, right: 7 ); _context.MatrixPositions.Add(positionLineC2); var positionLineC3 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB2.Id, matrixLevel: 0, depthLevel: 3, left: 10, right: 11 ); _context.MatrixPositions.Add(positionLineC3); var positionLineC4 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB2.Id, matrixLevel: 0, depthLevel: 3, left: 12, right: 13 ); _context.MatrixPositions.Add(positionLineC4); var positionLineC5 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB3.Id, matrixLevel: 0, depthLevel: 3, left: 18, right: 19 ); _context.MatrixPositions.Add(positionLineC5); var positionLineC6 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB3.Id, matrixLevel: 0, depthLevel: 3, left: 20, right: 21 ); _context.MatrixPositions.Add(positionLineC6); var positionLineC7 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB4.Id, matrixLevel: 0, depthLevel: 3, left: 24, right: 25 ); _context.MatrixPositions.Add(positionLineC7); var positionLineC8 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: sponsorMultiAccount.Id, parentId: positionLineB4.Id, matrixLevel: 0, depthLevel: 3, left: 26, right: 35 ); _context.MatrixPositions.Add(positionLineC8); var positionLineD1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: userMultiAccount1.Id, parentId: positionLineC8.Id, matrixLevel: 0, depthLevel: 4, left: 27, right: 32 ); _context.MatrixPositions.Add(positionLineD1); var positionLineD2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineC8.Id, matrixLevel: 0, depthLevel: 4, left: 33, right: 34 ); _context.MatrixPositions.Add(positionLineD2); var positionLineE1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: testUserMultiAccount.Id, parentId: positionLineD1.Id, matrixLevel: 0, depthLevel: 5, left: 28, right: 29 ); _context.MatrixPositions.Add(positionLineE1); var positionLineE2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineD1.Id, matrixLevel: 0, depthLevel: 5, left: 30, right: 31 ); _context.MatrixPositions.Add(positionLineE2); // LVL 1 var topMatrixPositionLvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: rootMultiAccount1.Id, parentId: null, matrixLevel: 1, depthLevel: 0, left: 1, right: 34 ); _context.MatrixPositions.Add(topMatrixPositionLvl1); var positionLineA1Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: rootMultiAccount2.Id, parentId: topMatrixPositionLvl1.Id, matrixLevel: 1, depthLevel: 1, left: 2, right: 15 ); _context.MatrixPositions.Add(positionLineA1Lvl1); var positionLineA2Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: rootMultiAccount3.Id, parentId: topMatrixPositionLvl1.Id, matrixLevel: 1, depthLevel: 1, left: 16, right: 33 ); _context.MatrixPositions.Add(positionLineA2Lvl1); var positionLineB1Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount2.Id, parentId: positionLineA1Lvl1.Id, matrixLevel: 1, depthLevel: 2, left: 3, right: 8 ); _context.MatrixPositions.Add(positionLineB1Lvl1); var positionLineB2Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount2.Id, parentId: positionLineA1Lvl1.Id, matrixLevel: 1, depthLevel: 2, left: 9, right: 14 ); _context.MatrixPositions.Add(positionLineB2Lvl1); var positionLineB3Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount3.Id, parentId: positionLineA2Lvl1.Id, matrixLevel: 1, depthLevel: 2, left: 17, right: 26 ); _context.MatrixPositions.Add(positionLineB3Lvl1); var positionLineB4Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: adminMultiAccount4.Id, parentId: positionLineA2Lvl1.Id, matrixLevel: 1, depthLevel: 2, left: 27, right: 32 ); _context.MatrixPositions.Add(positionLineB4Lvl1); var positionLineC1Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB1Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 4, right: 5 ); _context.MatrixPositions.Add(positionLineC1Lvl1); var positionLineC2Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB1Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 6, right: 7 ); _context.MatrixPositions.Add(positionLineC2Lvl1); var positionLineC3Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB2Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 10, right: 11 ); _context.MatrixPositions.Add(positionLineC3Lvl1); var positionLineC4Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB2Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 12, right: 13 ); _context.MatrixPositions.Add(positionLineC4Lvl1); var positionLineC5Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB3Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 18, right: 19 ); _context.MatrixPositions.Add(positionLineC5Lvl1); var positionLineC6Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: userMultiAccount1.Id, parentId: positionLineB3Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 20, right: 25 ); _context.MatrixPositions.Add(positionLineC6Lvl1); var positionLineC7Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB4Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 28, right: 29 ); _context.MatrixPositions.Add(positionLineC7Lvl1); var positionLineC8Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineB4Lvl1.Id, matrixLevel: 1, depthLevel: 3, left: 30, right: 31 ); _context.MatrixPositions.Add(positionLineC8Lvl1); var positionLineD1Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineC6Lvl1.Id, matrixLevel: 1, depthLevel: 4, left: 21, right: 22 ); _context.MatrixPositions.Add(positionLineD1Lvl1); var positionLineD2Lvl1 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: positionLineC6Lvl1.Id, matrixLevel: 1, depthLevel: 4, left: 23, right: 24 ); _context.MatrixPositions.Add(positionLineD2Lvl1); await _context.SaveChangesAsync(); // Payments var paymentHistory = fakerGenerator.GetPaymentHistoryFakerGenerator() .RuleFor(x => x.OrderId, _userMultiAccountId) .RuleFor(x => x.AmountToPay, 10M) .RuleFor(x => x.PaidAmount, 10M) .RuleFor(x => x.Status, PaymentStatusHelper.Completed) .RuleFor(x => x.PaymentFor, PaymentForHelper.MatrixLevelPositionsDictionary[1]) .Generate(); _context.PaymentHistories.Add(paymentHistory); await _context.SaveChangesAsync(); }
private static int MarkPossibleDirections(MatrixPosition matrixPosition) { int rowsLength = maze.GetLength(0), colsLength = maze.GetLength(1); MatrixPosition[] allPositions = { new MatrixPosition(matrixPosition.Row - 1, matrixPosition.Col), new MatrixPosition(matrixPosition.Row, matrixPosition.Col + 1), new MatrixPosition(matrixPosition.Row + 1, matrixPosition.Col), new MatrixPosition(matrixPosition.Row, matrixPosition.Col - 1) }; int unexploredCount = 0; foreach (var position in allPositions) { if (position.IsWithinRange(rowsLength, colsLength)) { if (maze[position.Row, position.Col].Equals("0", StringComparison.Ordinal)) { matrixPosition.Unexplored.Push(position); unexploredCount++; } } } return unexploredCount; }
private async Task <IEnumerable <MatrixPosition> > GetMatrixPositionWhereGivenPositionIsInLineBAsync(MatrixPosition matrixPosition, int matrixLevel = 0) { var parentPosition = await GetTopParentAsync(matrixPosition, matrixLevel); var parentsMatrix = await _matrixPositionRepository.GetMatrixAsync(parentPosition, matrixLevel); return(parentsMatrix); }
async Task AndGivenCreatedDefaultAccountsAndMatricesInDatabase() { var fakerGenerator = new FakerGenerator(); var myUserAccountData = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Id, Guid.Parse("042d748c-9cef-4a5a-92bd-3fd9a4a0e499")) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var otherUser = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); _context.UserAccountsData.AddRange(myUserAccountData, otherUser); await _context.SaveChangesAsync(); // Multi accounts var otherMultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName" ); otherMultiAccount.SetReflink("FIRST_REFLINK"); otherMultiAccount.SetAsMainAccount(); var otherMultiAccount2 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName2" ); otherMultiAccount2.SetReflink("SECOND_REFLINK"); var otherMultiAccount3 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName3" ); otherMultiAccount3.SetReflink("THIRD_REFLINK"); var otherMultiAccount4 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName4" ); otherMultiAccount4.SetReflink("FOURTH_REFLINK"); var otherMultiAccount5 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName5" ); otherMultiAccount5.SetReflink("FIFTH_REFLINK"); var otherMultiAccount6 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName6" ); otherMultiAccount6.SetReflink("SIXTH_REFLINK"); var otherMultiAccount7 = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName7" ); otherMultiAccount7.SetReflink("SEVENTH_REFLINK"); var myMultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: myUserAccountData.Id, sponsorId: otherMultiAccount.Id, multiAccountName: "myMultiAccountName" ); myMultiAccount.SetReflink("myReflink12345"); myMultiAccount.SetAsMainAccount(); _context.UserMultiAccounts.AddRange(otherMultiAccount, otherMultiAccount2, otherMultiAccount3, otherMultiAccount4, otherMultiAccount5, otherMultiAccount6, otherMultiAccount7, myMultiAccount); await _context.SaveChangesAsync(); // Matrices var rootMatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount.Id, parentId: null, matrixLevel: 0, depthLevel: 0, left: 1, right: 20 ); _context.MatrixPositions.Add(rootMatrixPosition); await _context.SaveChangesAsync(); var otherMatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount2.Id, parentId: rootMatrixPosition.Id, matrixLevel: 0, depthLevel: 1, left: 2, right: 11 ); _context.MatrixPositions.Add(otherMatrixPosition); await _context.SaveChangesAsync(); var otherMatrixPosition2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount4.Id, parentId: otherMatrixPosition.Id, matrixLevel: 0, depthLevel: 2, left: 3, right: 8 ); _context.MatrixPositions.Add(otherMatrixPosition2); await _context.SaveChangesAsync(); var otherMatrixPosition3 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: otherMatrixPosition2.Id, matrixLevel: 0, depthLevel: 3, left: 4, right: 5 ); _context.MatrixPositions.Add(otherMatrixPosition3); await _context.SaveChangesAsync(); var otherMatrixPosition4 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: myMultiAccount.Id, parentId: otherMatrixPosition2.Id, matrixLevel: 0, depthLevel: 3, left: 6, right: 7 ); _context.MatrixPositions.Add(otherMatrixPosition4); await _context.SaveChangesAsync(); var otherMatrixPosition5 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount5.Id, parentId: otherMatrixPosition.Id, matrixLevel: 0, depthLevel: 2, left: 9, right: 10 ); _context.MatrixPositions.Add(otherMatrixPosition5); await _context.SaveChangesAsync(); var otherMatrixPosition6 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount3.Id, parentId: rootMatrixPosition.Id, matrixLevel: 0, depthLevel: 1, left: 12, right: 19 ); _context.MatrixPositions.Add(otherMatrixPosition6); await _context.SaveChangesAsync(); var otherMatrixPosition7 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount6.Id, parentId: otherMatrixPosition6.Id, matrixLevel: 0, depthLevel: 2, left: 13, right: 14 ); _context.MatrixPositions.Add(otherMatrixPosition7); await _context.SaveChangesAsync(); var otherMatrixPosition8 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount7.Id, parentId: otherMatrixPosition6.Id, matrixLevel: 0, depthLevel: 2, left: 15, right: 18 ); _context.MatrixPositions.Add(otherMatrixPosition8); await _context.SaveChangesAsync(); var otherMatrixPosition9 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: otherMatrixPosition8.Id, matrixLevel: 0, depthLevel: 3, left: 16, right: 17 ); _context.MatrixPositions.Add(otherMatrixPosition9); await _context.SaveChangesAsync(); }
// find the best path with the AStar public Path GeneratePath(MatrixPosition start, MatrixPosition end) { var pathes = new List<Path>(); var startVertex = vertices[start.x, start.z, start.k]; var first = new Path {frontier = startVertex}; pathes.Add(first); return Find(pathes, end); }
private Path Find(List<Path> pathes, MatrixPosition end) { // find the path with cheaper frontier var orderedPathes = pathes.OrderBy(p => p.Cost(end.x, end.z)); var current = orderedPathes.First(); if (current.frontier.position.x == end.x && current.frontier.position.z == end.z) { return current; } // explore current frontier foreach (var v in current.frontier.Output) { if (!CheckVertexExplored(v.To, pathes)) { var newPath = new Path { actions = new List<Edge>(current.actions) { v }, frontier = v.To }; pathes.Add(newPath); } } // remove current, it is not needed more pathes.Remove(current); return Find(pathes, end); }
public async Task <AdminStructureSide> GetAdminStructureSide(Guid userMultiAccountId, int matrixLevel, MatrixPosition admin = null) { var position = await GetPositionForAccountAtLevelAsync(userMultiAccountId, matrixLevel); if (position is null) { throw new ValidationException($"There is no user multi account position - {userMultiAccountId} - in matrix lvl: {matrixLevel}"); } if (admin is null) { admin = await FindHighestAdminPositionAsync(userMultiAccountId, matrixLevel); } var underAdmin = await _context.Set <MatrixPosition>() .Where(x => x.Left <= position.Left) .Where(x => x.Right >= position.Right) .Where(x => x.MatrixLevel == matrixLevel) .Where(x => x.DepthLevel == 3) // Position under admin .SingleAsync(); if (underAdmin.Left - 1 == admin.Left) { return(AdminStructureSide.Left); } return(AdminStructureSide.Right); }
public Task UpdateAsync(MatrixPosition matrixPosition) { _context.Set <MatrixPosition>().Attach(matrixPosition); return(_context.SaveChangesAsync()); }
private static void ExportShape(RadDiagramShape shape, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height); var pathGeometry = shape.Geometry as PathGeometry; var transformGroup = new TransformGroup(); #if WPF if (pathGeometry == null) { var streamGeometry = shape.Geometry as StreamGeometry; if (streamGeometry != null) pathGeometry = streamGeometry.AsPathGeometry(); } #endif var geometrySize = shape.Geometry.Bounds.ToSize(); if (IsValidSize(geometrySize) && (geometrySize.Width != bounds.Width || geometrySize.Width != bounds.Width)) transformGroup.Children.Add(new ScaleTransform() { ScaleX = bounds.Width / geometrySize.Width, ScaleY = bounds.Height / geometrySize.Height }); transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); EditorInfo info = new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle); FixedContentEditor editor = CreateEditor(info, false); FixedContentEditor filledEditor = CreateEditor(info, true); ExportGeometry(editor, filledEditor, pathGeometry); if (shape.Content != null) { var center = bounds.Center(); ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return new Point(center.X - s.Width / 2, center.Y - s.Height / 2); }); } }
private static void ExportContainerShape(RadDiagramContainerShape container, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(container.Bounds.X - enclosingBounds.X, container.Bounds.Y - enclosingBounds.Y, container.Bounds.Width, container.Bounds.Height); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new RotateTransform() { Angle = container.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 }); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y }); var position = new MatrixPosition(transformGroup.Value); FixedContentEditor containerEditor = CreateEditor(new EditorInfo(page, position, container, bounds, container.BorderBrush, container.RotationAngle), true); containerEditor.DrawRectangle(new Rect(new Point(), bounds.ToSize())); containerEditor.GraphicProperties.StrokeThickness = 0.5; var headerHeight = container.ContentBounds.Y - container.Bounds.Y - DiagramConstants.ContainerMargin; containerEditor.DrawRectangle(new Rect(new Point(0, headerHeight), new Size(bounds.Width, 0.5))); if (container.IsCollapsible) { var buttonTop = headerHeight / 2 - 2.5; var buttonLeft = bounds.Width - 20; if (container.IsCollapsed) { containerEditor.DrawLine(new Point(buttonLeft, buttonTop), new Point(buttonLeft + 4, buttonTop + 4)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop + 4), new Point(buttonLeft + 8, buttonTop)); if (container.CollapsedContent != null) { var contentHeight = container.ActualHeight - headerHeight; ExportContent(container, bounds, container.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, bounds.Bottom - contentHeight / 2 - s.Height / 2); }, container.CollapsedContent.ToString()); } } else { containerEditor.DrawLine(new Point(buttonLeft, buttonTop + 4), new Point(buttonLeft + 4, buttonTop)); containerEditor.DrawLine(new Point(buttonLeft + 4, buttonTop), new Point(buttonLeft + 8, buttonTop + 4)); } } if (container.Content != null) { ExportContent(container, bounds, container.RotationAngle, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, bounds.Top + headerHeight / 2 - s.Height / 2); }); } }
public void SetSelection(MatrixPosition position) { SetSelection(position.line, position.channel, position.dataColumn, false); }
public void SeedField(IList <string> inputMatrix, string firstNinjaName, string secondNinjaName) { for (int i = 0; i < inputMatrix.Count; i++) { List <IGameObject> currentRow = new List <IGameObject>(); string currentInputRow = inputMatrix[i]; for (int j = 0; j < currentInputRow.Length; j++) { char currentElement = currentInputRow[j]; IVegetable newVegetable = null; IBlankSpace newBlanckSpace = null; INinja newNinja = null; IMatrixPosition position = new MatrixPosition(i, j); switch (currentElement) { case 'A': newVegetable = new Asparagus(position); break; case 'B': newVegetable = new Broccoli(position); break; case 'C': newVegetable = new CherryBerry(position); break; case 'M': newVegetable = new Mushroom(position); break; case 'R': newVegetable = new Royal(position); break; case '*': newVegetable = new MeloLemonMelon(position); break; case '-': newBlanckSpace = new BlankSpace(position, -1, VegetableType.Blank); break; } if (currentElement.Equals(firstNinjaName[0])) { newNinja = new Ninja(position, firstNinjaName); } if (currentElement.Equals(secondNinjaName[0])) { newNinja = new Ninja(position, secondNinjaName); } if (newVegetable != null) { this.AddVegetable(newVegetable); currentRow.Add(newVegetable); } if (newNinja != null) { this.AddNinja(newNinja); currentRow.Add(newNinja); } if (newBlanckSpace != null) { currentRow.Add(newBlanckSpace); } } this.gameField.Add(currentRow); } }
public static void Seed(this ModelBuilder modelBuilder) { var root = new UserAccountData ( Guid.NewGuid(), login: "******", email: "*****@*****.**", firstName: "FirstNameRoot", lastName: "LastNameRoot", street: "StreetRoot", city: "CityRoot", zipCode: "ZipCodeRoot", country: "CountryRoot", btcWalletAddress: "BtcWalletAddressRoot", role: UserRolesHelper.Root ); var hashSaltForRoot = Security.PasswordUtilities.PasswordEncryptionUtilities.GenerateSaltedHash("test$123"); root.SetPassword(hashSaltForRoot.Salt, hashSaltForRoot.Hash); root.PaidMembershipFee(); var admin = new UserAccountData ( Guid.NewGuid(), login: "******", email: "*****@*****.**", firstName: "FirstNameAdmin", lastName: "LastNameAdmin", street: "StreetAdmin", city: "CityAdmin", zipCode: "ZipCodeAdmin", country: "CountryAdmin", btcWalletAddress: "BtcWalletAddressAdmin", role: UserRolesHelper.Admin ); var hashSaltForAdmin = Security.PasswordUtilities.PasswordEncryptionUtilities.GenerateSaltedHash("test$123"); admin.SetPassword(hashSaltForAdmin.Salt, hashSaltForAdmin.Hash); admin.PaidMembershipFee(); modelBuilder.Entity <UserAccountData>().HasData(root, admin); var root1MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: root.Id, sponsorId: null, multiAccountName: "root-001" ); root1MultiAccount.SetAsMainAccount(); var root2MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: root.Id, sponsorId: null, multiAccountName: "root-002" ); var root3MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: root.Id, sponsorId: null, multiAccountName: "root-003" ); var admin1MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: admin.Id, sponsorId: null, multiAccountName: "admin-001" ); admin1MultiAccount.SetReflink("xm3dgjTbckuxSfk0"); admin1MultiAccount.SetAsMainAccount(); var admin2MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: admin.Id, sponsorId: null, multiAccountName: "admin-002" ); admin2MultiAccount.SetReflink("CbJGE3bl65zWhUwK"); var admin3MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: admin.Id, sponsorId: null, multiAccountName: "admin-003" ); admin3MultiAccount.SetReflink("nB1Mw99LCQuKXUY2"); var admin4MultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: admin.Id, sponsorId: null, multiAccountName: "admin-004" ); admin4MultiAccount.SetReflink("2ERrHKzmA7bigBeY"); modelBuilder.Entity <UserMultiAccount>().HasData( root1MultiAccount, root2MultiAccount, root3MultiAccount, admin1MultiAccount, admin2MultiAccount, admin3MultiAccount, admin4MultiAccount); #region Seed Matrix Level 0 var root1MatrixPosition = new MatrixPosition ( // root-001 id: Guid.NewGuid(), matrixLevel: 0, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 30 ); var root2MatrixPosition = new MatrixPosition ( // root-002 id: Guid.NewGuid(), matrixLevel: 0, parentId: root1MatrixPosition.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 15 ); var root3MatrixPosition = new MatrixPosition ( // root-003 id: Guid.NewGuid(), matrixLevel: 0, parentId: root1MatrixPosition.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 16, right: 29 ); var admin1MatrixPosition = new MatrixPosition ( // admin-001 id: Guid.NewGuid(), matrixLevel: 0, parentId: root2MatrixPosition.Id, userMultiAccountId: admin1MultiAccount.Id, depthLevel: 2, left: 3, right: 8 ); var admin2MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: root2MatrixPosition.Id, userMultiAccountId: admin2MultiAccount.Id, depthLevel: 2, left: 9, right: 14 ); var admin3MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: root3MatrixPosition.Id, userMultiAccountId: admin3MultiAccount.Id, depthLevel: 2, left: 17, right: 22 ); var admin4MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: root3MatrixPosition.Id, userMultiAccountId: admin4MultiAccount.Id, depthLevel: 2, left: 23, right: 28 ); var empty1MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin1MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 4, right: 5 ); var empty2MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin1MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 6, right: 7 ); var empty3MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin2MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 10, right: 11 ); var empty4MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin2MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 12, right: 13 ); var empty5MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin3MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 18, right: 19 ); var empty6MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin3MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 20, right: 21 ); var empty7MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin4MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 24, right: 25 ); var empty8MatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 0, parentId: admin4MatrixPosition.Id, userMultiAccountId: null, depthLevel: 3, left: 26, right: 27 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPosition, root2MatrixPosition, root3MatrixPosition, admin1MatrixPosition, admin2MatrixPosition, admin3MatrixPosition, admin4MatrixPosition, empty1MatrixPosition, empty2MatrixPosition, empty3MatrixPosition, empty4MatrixPosition, empty5MatrixPosition, empty6MatrixPosition, empty7MatrixPosition, empty8MatrixPosition ); #endregion #region Seed Matrix Level 1 var root1MatrixPositionLvl1 = new MatrixPosition ( // root-001 id: Guid.NewGuid(), matrixLevel: 1, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 14 ); var root2MatrixPositionLvl1 = new MatrixPosition ( // root-002 id: Guid.NewGuid(), matrixLevel: 1, parentId: root1MatrixPositionLvl1.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 7 ); var root3MatrixPositionLvl1 = new MatrixPosition ( // root-003 id: Guid.NewGuid(), matrixLevel: 1, parentId: root1MatrixPositionLvl1.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 8, right: 13 ); var empty1MatrixPositionLvl1 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 1, parentId: root2MatrixPositionLvl1.Id, userMultiAccountId: null, depthLevel: 2, left: 3, right: 4 ); var empty2MatrixPositionLvl1 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 1, parentId: root2MatrixPositionLvl1.Id, userMultiAccountId: null, depthLevel: 2, left: 5, right: 6 ); var empty3MatrixPositionLvl1 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 1, parentId: root3MatrixPositionLvl1.Id, userMultiAccountId: null, depthLevel: 2, left: 9, right: 10 ); var empty4MatrixPositionLvl1 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 1, parentId: root3MatrixPositionLvl1.Id, userMultiAccountId: null, depthLevel: 2, left: 11, right: 12 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPositionLvl1, root2MatrixPositionLvl1, root3MatrixPositionLvl1, empty1MatrixPositionLvl1, empty2MatrixPositionLvl1, empty3MatrixPositionLvl1, empty4MatrixPositionLvl1 ); #endregion #region Seed Matrix Level 2 var root1MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 14 ); var root2MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: root1MatrixPositionLvl2.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 7 ); var root3MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: root1MatrixPositionLvl2.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 8, right: 13 ); var empty1MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: root2MatrixPositionLvl2.Id, userMultiAccountId: null, depthLevel: 2, left: 3, right: 4 ); var empty2MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: root2MatrixPositionLvl2.Id, userMultiAccountId: null, depthLevel: 2, left: 5, right: 6 ); var empty3MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: root3MatrixPositionLvl2.Id, userMultiAccountId: null, depthLevel: 2, left: 9, right: 10 ); var empty4MatrixPositionLvl2 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 2, parentId: root3MatrixPositionLvl2.Id, userMultiAccountId: null, depthLevel: 2, left: 11, right: 12 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPositionLvl2, root2MatrixPositionLvl2, root3MatrixPositionLvl2, empty1MatrixPositionLvl2, empty2MatrixPositionLvl2, empty3MatrixPositionLvl2, empty4MatrixPositionLvl2 ); #endregion #region Seed Matrix Level 3 var root1MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 14 ); var root2MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: root1MatrixPositionLvl3.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 7 ); var root3MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: root1MatrixPositionLvl3.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 8, right: 13 ); var empty1MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: root2MatrixPositionLvl3.Id, userMultiAccountId: null, depthLevel: 2, left: 3, right: 4 ); var empty2MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: root2MatrixPositionLvl3.Id, userMultiAccountId: null, depthLevel: 2, left: 5, right: 6 ); var empty3MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: root3MatrixPositionLvl3.Id, userMultiAccountId: null, depthLevel: 2, left: 9, right: 10 ); var empty4MatrixPositionLvl3 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 3, parentId: root3MatrixPositionLvl3.Id, userMultiAccountId: null, depthLevel: 2, left: 11, right: 12 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPositionLvl3, root2MatrixPositionLvl3, root3MatrixPositionLvl3, empty1MatrixPositionLvl3, empty2MatrixPositionLvl3, empty3MatrixPositionLvl3, empty4MatrixPositionLvl3 ); #endregion #region Seed Matrix Level 4 var root1MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 14 ); var root2MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: root1MatrixPositionLvl4.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 7 ); var root3MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: root1MatrixPositionLvl4.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 8, right: 13 ); var empty1MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: root2MatrixPositionLvl4.Id, userMultiAccountId: null, depthLevel: 2, left: 3, right: 4 ); var empty2MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: root2MatrixPositionLvl4.Id, userMultiAccountId: null, depthLevel: 2, left: 5, right: 6 ); var empty3MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: root3MatrixPositionLvl4.Id, userMultiAccountId: null, depthLevel: 2, left: 9, right: 10 ); var empty4MatrixPositionLvl4 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 4, parentId: root3MatrixPositionLvl4.Id, userMultiAccountId: null, depthLevel: 2, left: 11, right: 12 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPositionLvl4, root2MatrixPositionLvl4, root3MatrixPositionLvl4, empty1MatrixPositionLvl4, empty2MatrixPositionLvl4, empty3MatrixPositionLvl4, empty4MatrixPositionLvl4 ); #endregion #region Seed Matrix Level 5 var root1MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 14 ); var root2MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: root1MatrixPositionLvl5.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 7 ); var root3MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: root1MatrixPositionLvl5.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 8, right: 13 ); var empty1MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: root2MatrixPositionLvl5.Id, userMultiAccountId: null, depthLevel: 2, left: 3, right: 4 ); var empty2MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: root2MatrixPositionLvl5.Id, userMultiAccountId: null, depthLevel: 2, left: 5, right: 6 ); var empty3MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: root3MatrixPositionLvl5.Id, userMultiAccountId: null, depthLevel: 2, left: 9, right: 10 ); var empty4MatrixPositionLvl5 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 5, parentId: root3MatrixPositionLvl5.Id, userMultiAccountId: null, depthLevel: 2, left: 11, right: 12 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPositionLvl5, root2MatrixPositionLvl5, root3MatrixPositionLvl5, empty1MatrixPositionLvl5, empty2MatrixPositionLvl5, empty3MatrixPositionLvl5, empty4MatrixPositionLvl5 ); #endregion #region Seed Matrix Level 6 var root1MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: null, userMultiAccountId: root1MultiAccount.Id, depthLevel: 0, left: 1, right: 14 ); var root2MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: root1MatrixPositionLvl6.Id, userMultiAccountId: root2MultiAccount.Id, depthLevel: 1, left: 2, right: 7 ); var root3MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: root1MatrixPositionLvl6.Id, userMultiAccountId: root3MultiAccount.Id, depthLevel: 1, left: 8, right: 13 ); var empty1MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: root2MatrixPositionLvl6.Id, userMultiAccountId: null, depthLevel: 2, left: 3, right: 4 ); var empty2MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: root2MatrixPositionLvl6.Id, userMultiAccountId: null, depthLevel: 2, left: 5, right: 6 ); var empty3MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: root3MatrixPositionLvl6.Id, userMultiAccountId: null, depthLevel: 2, left: 9, right: 10 ); var empty4MatrixPositionLvl6 = new MatrixPosition ( id: Guid.NewGuid(), matrixLevel: 6, parentId: root3MatrixPositionLvl6.Id, userMultiAccountId: null, depthLevel: 2, left: 11, right: 12 ); modelBuilder.Entity <MatrixPosition>().HasData( root1MatrixPositionLvl6, root2MatrixPositionLvl6, root3MatrixPositionLvl6, empty1MatrixPositionLvl6, empty2MatrixPositionLvl6, empty3MatrixPositionLvl6, empty4MatrixPositionLvl6 ); #endregion }
private static void ExportConnection(RadDiagramConnection connection, Rect enclosingBounds, RadFixedPage page) { var bounds = new Rect(connection.Bounds.X - enclosingBounds.X, connection.Bounds.Y - enclosingBounds.Y, connection.Bounds.Width, connection.Bounds.Height); var pathGeometry = connection.Geometry as PathGeometry; var pathBounds = connection.ConnectionType == ConnectionType.Bezier ? pathGeometry.Bounds : new Rect(); var transformGroup = new TransformGroup(); transformGroup.Children.Add(new TranslateTransform() { X = bounds.X - pathBounds.X, Y = bounds.Y - pathBounds.Y }); var position = new MatrixPosition(transformGroup.Value); EditorInfo info = new EditorInfo(page, position, connection, bounds, connection.Stroke, 0); FixedContentEditor editor = CreateEditor(info, false); FixedContentEditor filledEditor = CreateEditor(info, true); ExportGeometry(editor, filledEditor, pathGeometry, true); if (connection.Content != null) { var center = bounds.Center(); ExportContent(connection, bounds, 0, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, center.Y - s.Height / 2); }); } }
private async Task CreateUserAndMultiAccountAndMatrixPositionsInDatabase() { var fakerGenerator = new FakerGenerator(); var existingUserAccountData = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.Id, f => Guid.Parse("042d748c-9cef-4a5a-92bd-3fd9a4a0e499")) .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); var otherUser = fakerGenerator.GetUserAccountDataFakerGenerator() .RuleFor(x => x.IsMembershipFeePaid, true) .Generate(); _context.UserAccountsData.AddRange(existingUserAccountData, otherUser); await _context.SaveChangesAsync(); var myMultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: existingUserAccountData.Id, sponsorId: null, multiAccountName: "myMultiAccountName" ); myMultiAccount.SetReflink("myReflink12345"); myMultiAccount.SetAsMainAccount(); var otherMultiAccount = new UserMultiAccount ( id: Guid.NewGuid(), userAccountDataId: otherUser.Id, sponsorId: null, multiAccountName: "otherMultiAccountName" ); otherMultiAccount.SetReflink("otherUserReflink12345"); otherMultiAccount.SetAsMainAccount(); _context.UserMultiAccounts.AddRange(myMultiAccount, otherMultiAccount); await _context.SaveChangesAsync(); // Matrices var myMatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: myMultiAccount.Id, parentId: null, matrixLevel: 0, depthLevel: 0, left: 1, right: 6 ); _context.MatrixPositions.Add(myMatrixPosition); var otherMatrixPosition = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: otherMultiAccount.Id, parentId: myMatrixPosition.Id, matrixLevel: 0, depthLevel: 2, // Level 2 (Line B of the main account so it's ok) left: 2, right: 5 ); _context.MatrixPositions.Add(otherMatrixPosition); var otherMatrixPosition2 = new MatrixPosition ( id: Guid.NewGuid(), userMultiAccountId: null, parentId: otherMatrixPosition.Id, matrixLevel: 0, depthLevel: 3, // Line C left: 3, right: 4 ); _context.MatrixPositions.Add(otherMatrixPosition2); await _context.SaveChangesAsync(); }
internal SamplingPoint(MatrixPosition position, int radius) { this.Position = position; this.Radius = radius; }