using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
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 Reflection 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);
//Get the RGB values of the background and foregraound colors
string background = screenColor.GetColorRGB(bgColor);
string foreground = screenColor.GetColorRGB(fgColor);
//Write the RGB values for the background and foreground colors to the console
Console.WriteLine("This is the background color: " + background);
Console.WriteLine("This is the foreground color: " + foreground);
}
}
}