crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianUtils/Colour/ColourUtils.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 using System;
       
    18 using System.Collections.Generic;
       
    19 using System.Text;
       
    20 using System.Drawing;
       
    21 using System.Windows.Forms;
       
    22 
       
    23 namespace SymbianUtils.Colour
       
    24 {
       
    25     public static class ColourUtils
       
    26     {
       
    27         public static Color Lighten( Color aColour )
       
    28         {
       
    29             Color ret = ControlPaint.Light( aColour );
       
    30             return ret;
       
    31         }
       
    32 
       
    33         public static Color LightenMore( Color aColour )
       
    34         {
       
    35             Color ret = ControlPaint.LightLight( aColour );
       
    36             return ret;
       
    37         }
       
    38 
       
    39         public static Color Darken( Color aColour )
       
    40         {
       
    41             Color ret = ControlPaint.Dark( aColour );
       
    42             return ret;
       
    43         }
       
    44 
       
    45         public static Color Lighten( Color aColour, float aPercentage )
       
    46         {
       
    47             int r = aColour.R;
       
    48             int g = aColour.G;
       
    49             int b = aColour.B;
       
    50             //
       
    51             int amount = (int) ( 255.0f * aPercentage );
       
    52             //
       
    53             r = Math.Min( r + amount, 255 );
       
    54             g = Math.Min( g + amount, 255 );
       
    55             b = Math.Min( b + amount, 255 );
       
    56             //
       
    57             Color ret = Color.FromArgb( r, g, b );
       
    58             return ret;
       
    59         }
       
    60 
       
    61         public static Color Darken( Color aColour, float aPercentage )
       
    62         {
       
    63             int r = aColour.R;
       
    64             int g = aColour.G;
       
    65             int b = aColour.B;
       
    66             //
       
    67             int amount = (int) ( 255.0f * aPercentage );
       
    68             //
       
    69             r = Math.Max( r - amount, 0 );
       
    70             g = Math.Max( g - amount, 0 );
       
    71             b = Math.Max( b - amount, 0 );
       
    72             //
       
    73             Color ret = Color.FromArgb( r, g, b );
       
    74             return ret;
       
    75         }
       
    76     }
       
    77 }