FText FLandscapeEditorDetails::GetCurrentBrushFalloffName() const
{
	FEdModeLandscape* LandscapeEdMode = GetEditorMode();
	if (LandscapeEdMode != NULL && LandscapeEdMode->CurrentBrush != NULL)
	{
		const FName CurrentBrushName = LandscapeEdMode->CurrentBrush->GetBrushName();
		return GetLocalizedName(CurrentBrushName);
	}

	return LOCTEXT("Unknown", "Unknown");
}
FText FLandscapeEditorDetails::GetCurrentToolName() const
{
	FEdModeLandscape* LandscapeEdMode = GetEditorMode();
	if (LandscapeEdMode != NULL && LandscapeEdMode->CurrentTool != NULL)
	{
		const TCHAR* CurrentToolName = LandscapeEdMode->CurrentTool->GetToolName();
		return GetLocalizedName(FString("ToolSet_") + CurrentToolName);
	}

	return LOCTEXT("Unknown", "Unknown");
}
FText FLandscapeEditorDetails::GetCurrentBrushName() const
{
	FEdModeLandscape* LandscapeEdMode = GetEditorMode();
	if (LandscapeEdMode != NULL && LandscapeEdMode->CurrentBrush != NULL)
	{
		const FName CurrentBrushSetName = LandscapeEdMode->LandscapeBrushSets[LandscapeEdMode->CurrentBrushSetIndex].BrushSetName;
		return GetLocalizedName(CurrentBrushSetName.ToString());
	}

	return LOCTEXT("Unknown", "Unknown");
}
HRESULT GetFontFamilyName(IDWriteFontFamily* fontFamily, const WCHAR* locale, OUT std::wstring& familyName)
{
    HRESULT hr = S_OK;

    IDWriteLocalizedStrings* familyNames = NULL;

    hr = fontFamily->GetFamilyNames(&familyNames);

    if (SUCCEEDED(hr))
    {
        hr = GetLocalizedName(familyNames, locale, familyName);
    }

    SafeRelease(&familyNames);

    return hr;
}
// -----------------------------------------------------------------------------
// CAknFileSelectionModel::UpdateItemListL
// -----------------------------------------------------------------------------
//
TInt CAknFileSelectionModel::UpdateItemListL()
    {
    iEntryArray->Reset();
    iImageIndexArray.Reset();

    CDir* entryArray = ReadDirectory( iCurrentPath.DriveAndPath() );
    if ( !entryArray )
        {
        return KErrNotFound;
        }
    CleanupStack::PushL( entryArray );

    TInt itemCount( entryArray->Count() );
    if ( itemCount > 0 )
        {
        TInt filterCount( iFilterArray->Count() );
        TInt filterIndex;
        TBool accepted;
        CDesC16Array* desC16FoldersArray = new ( ELeave )
                           CDesC16ArrayFlat( KEntryArrayGranularity );
        CleanupStack::PushL( desC16FoldersArray );
        CDesC16Array* desC16FilesArray = new ( ELeave )
                           CDesC16ArrayFlat( KEntryArrayGranularity );
        CleanupStack::PushL( desC16FilesArray );
        CArrayPakFlat<TEntry>* tmpFoldersArray = new( ELeave ) 
            CArrayPakFlat<TEntry>( KEntryArrayGranularity );
        CleanupStack::PushL( tmpFoldersArray );
        CArrayPakFlat<TEntry>* tmpFilesArray = new( ELeave ) 
            CArrayPakFlat<TEntry>( KEntryArrayGranularity );
        CleanupStack::PushL( tmpFilesArray );
            
        tmpFoldersArray->Reset();
        desC16FoldersArray->Reset();
        tmpFilesArray->Reset();
        desC16FilesArray->Reset();
        
        for ( TInt i( 0 ); i < itemCount; i++ ) // Generate filtered list
            {
            accepted = ETrue; // If there are no filters, accept the entry
            TEntry entry = ( *entryArray )[i];
            filterIndex = 0;
            // Go thru the filters while the entry is accepted
            while( ( filterIndex < filterCount ) && ( accepted ) )
                {
                accepted = iFilterArray->At( filterIndex )->Accept(
                    iCurrentPath.DriveAndPath(), entry );
                filterIndex++;
                }
            if ( accepted ) // Directory entry has passed all filters
                {
                 // Add filename to filtered list
                if ( entry.IsDir() )
                    {
                    desC16FoldersArray->AppendL( GetLocalizedName( entry.iName ) );
                    tmpFoldersArray->AppendL( entry, sizeof( TEntry ) );
                    }
                else
                    {
                    desC16FilesArray->AppendL( GetLocalizedName( entry.iName ) );
                    tmpFilesArray->AppendL( entry, sizeof( TEntry ) );
                    }
                }
            }
        
        TInt entryCount = 0;
        TInt index;
        TKeyArrayPak key( _FOFF( TEntry, iName ), ECmpCollated );
        
        // Add folder entries
        desC16FoldersArray->Sort( ECmpCollated );
        entryCount = desC16FoldersArray->MdcaCount();
        for( TInt j( 0 ); j < entryCount; j++ )
            {
            for( TInt k( 0 ); k < entryCount; k++ )
                {
                if( ( *desC16FoldersArray )[j] == 
                        GetLocalizedName( ( *tmpFoldersArray )[k].iName ) &&
                    iEntryArray->Find( ( *tmpFoldersArray )[k], key, index ) != 0 )
                    {
                    TEntry tmpEntry = ( *tmpFoldersArray )[k];
                    
                    iEntryArray->AppendL( tmpEntry, sizeof( TEntry ) );
                    
                    // Entry is a directory
                    TFileTypeIcon folderIcon( EFolderIcon );
                    
                    if( !AknCFDUtility::IsRemoteDrive( iCurrentPath.Drive() ) )
                        {
                        if ( ContainsSubfolders( tmpEntry.iName ) )
                            {
                            folderIcon = ESubFolderIcon;
                            }
                        else if ( !ContainsFiles( tmpEntry.iName ) )
                            {
                            folderIcon = EFolderEmptyIcon;
                            }
                        }
                    iImageIndexArray.Append( folderIcon );
                    
                    break;
                    }
                }
            }
        
        // Add file entries
        desC16FilesArray->Sort( ECmpCollated );
        entryCount = desC16FilesArray->MdcaCount();
        for( TInt j( 0 ); j < entryCount; j++ )
            {
            for( TInt k( 0 ); k < entryCount; k++ )
                {
                if( ( *desC16FilesArray )[j] == 
                        GetLocalizedName( ( *tmpFilesArray )[k].iName ) &&
                    iEntryArray->Find( ( *tmpFilesArray )[k], key, index ) != 0 )
                    {
                    TEntry tmpFile = ( *tmpFilesArray )[k];
                    
                    iEntryArray->AppendL( tmpFile, sizeof( TEntry ) );
                    
                    // Entry is a file
                    AppendIconForFileL( tmpFile.iName );
                    
                    break;
                    }
                }
            }
        
        CleanupStack::PopAndDestroy( tmpFilesArray );
        CleanupStack::PopAndDestroy( tmpFoldersArray );
        CleanupStack::Pop( desC16FilesArray );
        desC16FilesArray->Reset();
        delete desC16FilesArray;
        CleanupStack::Pop( desC16FoldersArray );
        desC16FoldersArray->Reset();
        delete desC16FoldersArray;
        }
    
    CleanupStack::PopAndDestroy( entryArray );
    
    if ( AknCFDUtility::DirectoriesOnly( iDialogType ) )
        {
        // Set the current folder name as first item.
        // Current folder is for example "E:\Images\Holiday\"
        // Remove trailing backslash, we get "E:\Images\Holiday"
        // Parse the path with TParse and ask for NameAndExt().
        // TParse interpretes "Holiday" as file name and returns it.

        HBufC * bufFolder = HBufC::NewLC(KMaxPath);
        * bufFolder = iCurrentPath.DriveAndPath() ;
        TPtr folder = bufFolder->Des();

        AknCFDUtility::RemoveTrailingBackslash( folder ); // ignore error

        TParsePtr parsedFolder(folder);

        folder = parsedFolder.NameAndExt();
        iFolderEntry.iName = folder;
        iEntryArray->InsertL( 0, iFolderEntry, sizeof( TEntry ) );
        iImageIndexArray.Insert( EThisFolderIcon, 0 );

        CleanupStack::PopAndDestroy(); //bufFolder
        }
    
    return iEntryArray->Count();
    }