コード例 #1
0
        public async Task <BlockDto> GetBlockedUsers(BlockParams blockParams)
        {
            var users        = _context.Users.OrderBy(u => u.UserName).AsQueryable();
            var blockedUsers = _context.Blocked.AsQueryable();

            if (blockParams.Predicate == "blockedby")
            {
                blockedUsers = blockedUsers.Where(blocked => blocked.BlockedUserId == blockParams.UserId);
                blockedUsers = blockedUsers.Where(blocked => blocked.SourceUser.UserName == blockParams.Username);
                users        = blockedUsers.Select(blocked => blocked.SourceUser);
            }

            var blockedUser = await users.Select(user => new BlockDto
            {
                Username = user.UserName,
                KnownAs  = user.KnownAs,
                Age      = user.DateOfBirth.CalculateAge(),
                PhotoUrl = user.Photos.FirstOrDefault(p => p.IsMain).Url,
                City     = user.City,
                Id       = user.Id
            }).FirstOrDefaultAsync();

            if (blockedUser == null)
            {
                return(null);
            }
            else
            {
                return(blockedUser);
            }
        }
コード例 #2
0
        public async Task <ActionResult <BlockDto> > GetBlockedUsers([FromQuery] BlockParams blockParams)
        {
            blockParams.UserId = User.GetUserId();

            var user = await _unitOfWork.blockRepository.GetBlockedUsers(blockParams);

            return(Ok(user));
        }
コード例 #3
0
 private bool EdgesHaveColor( BlockParams par, Color color )
 {
     for ( int n = 0; n < BlockPixelSize; ++n ) {
         var points = new Complex[] { new Complex( 0, n ), new Complex( BlockPixelSize, n ), new Complex( n, 0 ), new Complex( n, BlockPixelSize ) };
         foreach ( var point in points ) {
             if ( FunctionColor( par.Origin + point * PixelStep ) != color ) return false;
         }
     }
     acceleratedBlocks++;
     return true;
 }
コード例 #4
0
 private void DrawBlock( BlockParams par )
 {
     if ( _cancellationToken.IsCancellationRequested ) return;
     totalBlocks++;
     // Quick method: if edges of the block are same color, then internal must be also (speeds up black areas)
     var topLeftColor = FunctionColor( par.Origin );
     Color? singleColor = EdgesHaveColor( par, topLeftColor ) ? (Color?) topLeftColor : null;
     byte[] buffer = new byte[BlockPixelSize * BlockPixelSize * 4];
     for ( int y = 0; y < BlockPixelSize; ++y ) {
         for ( int x = 0; x < BlockPixelSize; ++x ) {
             if ( _cancellationToken.IsCancellationRequested ) return;
             var color = singleColor.HasValue ? singleColor.Value : FunctionColor( par.Origin + new Complex( x, y ) * PixelStep );
             var bufferOffset = ( y * BlockPixelSize + x ) * 4;
             buffer[bufferOffset] = color.B;
             buffer[bufferOffset + 1] = color.G;
             buffer[bufferOffset + 2] = color.R;
             buffer[bufferOffset + 3] = color.A;
         }
     }
     Dispatcher.BeginInvoke( new Action( ( ) => {
         if ( par.PixelOffsetX + BlockPixelSize <= Bmp.Width && par.PixelOffsetY + BlockPixelSize <= Bmp.Height ) {
             Bmp.WritePixels( new Int32Rect( 0, 0, BlockPixelSize, BlockPixelSize ), buffer, 4 * BlockPixelSize, par.PixelOffsetX, par.PixelOffsetY );
         }
     } ), DispatcherPriority.Background );
 }
コード例 #5
0
 private void Draw( )
 {
     var start = DateTime.Now;
     int BlockCountX = PixelWidth / BlockPixelSize;
     int BlockCountY = PixelHeight / BlockPixelSize;
     if ( _cancellationSource != null ) _cancellationSource.Cancel( );
     _cancellationSource = new CancellationTokenSource( );
     _cancellationToken = _cancellationSource.Token;
     var tasks = new List<Task>( );
     for ( int y_block = 0; y_block < BlockCountY; ++y_block ) {
         for ( int x_block = 0; x_block < BlockCountX; ++x_block ) {
             var blockOrigin = Origin + new Complex( x_block, y_block ) * BlockRealSize;
             var blockParams = new BlockParams { Origin = blockOrigin, PixelOffsetX = x_block * BlockPixelSize, PixelOffsetY = y_block * BlockPixelSize };
             tasks.Add( Task.Factory.StartNew( new Action( ( ) => DrawBlock( blockParams ) ), _cancellationToken ) );
         }
     }
     Task.Factory.ContinueWhenAll( tasks.ToArray( ), new Action<Task[]>( t => {
         Dispatcher.BeginInvoke( new Action( ( ) => {
             var duration = DateTime.Now - start;
             Debug.Print("Finished: Scale {0}, duration {1:0.0} sec, Normal/accelerated blocks {2}/{3}",
                 RealHeight, duration.TotalSeconds, acceleratedBlocks, totalBlocks );
             acceleratedBlocks = 0;
             totalBlocks = 0;
         } ) );
     } ) );
 }
コード例 #6
0
 public void SetBlockParams(BlockParams blockParams, Cell parentCell)
 {
     BlockParams = blockParams;
     Cell        = parentCell;
 }
コード例 #7
0
 public Block(BlockParams blockParams, Cell parentCell)
 {
     SetBlockParams(blockParams, parentCell);
 }