InfoConnect API Guide
Attachmate.Reflection.Emulation.OpenSystems Namespace / IThemeColor Interface / GetForegroundColorAsInt Method
The host text attribute to get the mapped value for.
Example


In This Topic
    GetForegroundColorAsInt Method
    In This Topic
    Gets the integer value that the foreground color of a given terminal attribute is mapped to in the theme color map.
    Syntax
    'Declaration
     
    
    Function GetForegroundColorAsInt( _
       ByVal attr As TextColorMappingAttribute _
    ) As Integer
    'Usage
     
    
    Dim instance As IThemeColor
    Dim attr As TextColorMappingAttribute
    Dim value As Integer
     
    value = instance.GetForegroundColorAsInt(attr)
    int GetForegroundColorAsInt( 
       TextColorMappingAttribute attr
    )

    Parameters

    attr
    The host text attribute to get the mapped value for.

    Return Value

    The integer value that the foreground color of the specified attribute is mapped to in the color map.
    Remarks

    In Open Systems sessions, screen colors are mapped to integer values in a color map. Although you can select from only one of 16 colors, you can change the actual screen colors to any RGB values by changing the RGB values of the color map.

    For example, if the screen foreground color of normal text is mapped to 0 in the map (which has a default color of Black), you can change the default RGB value mapped to 0 to another RGB value.

    You can use this approach to change the actual screen foreground color to any RGB color. Use this method to get the integer value the foreground color is mapped to. Then use the SetColorRGB Method method to change that color to any RGB value.

    You can view the theme color map in the user interface by clicking Color Map, under Text Color Mapping in the Modify Theme dialog box.

    The default color mapped to each integer value is shown below.

    The Theme Color Map

    Integer Default Colors for Non-Graphic Terminals Default Colors for Regis Graphics Terminals
    0 Black Black
    1 Dark Red Blue
    2 Dark Green Red
    3 Dark Yellow Green
    4 Dark Blue Magenta
    5 Dark Magenta Cyan
    6 Dark Cyan Yellow
    7 Dark Grey Grey
    8 Grey Dark Grey
    9 Red Dark Blue
    10 Green Dark Red
    11 Yellow Dark Green
    12 Blue Dark Magenta
    13 Magenta Dark Cyan
    14 Cyan Dark Yellow
    15 White Light Grey

    Example
    This sample changes the screen background and foreground colors
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Attachmate.Reflection.Framework;
    using Attachmate.Reflection.Emulation.OpenSystems;
    using Attachmate.Reflection.UserInterface;
     
    namespace CreateASession
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Start a visible instance of InfoConnect or get the instance running at the given channel name
                Application app = MyReflection.CreateApplication("myWorkspace", true);
     
                //Create a terminal for an Open Systems session
                ITerminal terminal = (ITerminal)app.CreateControl(new Guid("{BE835A80-CAB2-40d2-AFC0-6848E486BF58}"));
     
                //Specify the connection type, host name (or IP address), and connect.
                IConnectionSettingsTelnet conn = (IConnectionSettingsTelnet)terminal.ConnectionSettings;
                conn.HostAddress = "sylvester";
                terminal.Connect();
                
                //Create a View to make the session visible                
                IFrame frame = (IFrame)app.GetObject("Frame");
                frame.CreateView(terminal);
     
                IThemeColor screenColor = terminal.Theme.Color;
     
                //Get integers that are mapped to the background and foreground colors
                int bgColor = screenColor.GetBackgroundColorAsInt(TextColorMappingAttribute.Plain);
                int fgColor = screenColor.GetForegroundColorAsInt(TextColorMappingAttribute.Plain);
     
                //Set the colors that are mapped to these values
                screenColor.SetColorRGB(bgColor, 255, 0,0);
                screenColor.SetColorRGB(fgColor, 0, 0, 255);
     
            }
        }
    }
    See Also