示例#1
0
        private void CheckIca()
        {
            pnlCheck4.Visible = true;

            try
            {
                using (var ica = new AxICAClient {
                    Parent = this
                })
                {
                    ica.CreateControl();

                    while (!ica.Created)
                    {
                        Thread.Sleep(10);
                        System.Windows.Forms.Application.DoEvents();
                    }

                    pbCheck4.Image      = Resources.Good_Symbol;
                    lblCheck4.ForeColor = Color.DarkOliveGreen;
                    lblCheck4.Text      = @"ICA (Citrix ICA) " + Language.strCcCheckSucceeded;
                    txtCheck4.Text      = string.Format(Language.strCcICAOK, ica.Version);
                }
            }
            catch (Exception ex)
            {
                pbCheck4.Image      = Resources.Bad_Symbol;
                lblCheck4.ForeColor = Color.Firebrick;
                lblCheck4.Text      = @"ICA (Citrix ICA) " + Language.strCcCheckFailed;
                txtCheck4.Text      = Language.strCcICAFailed;

                Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "ICA " + Language.strCcNotInstalledProperly, true);
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, ex.Message, true);
            }
        }
示例#2
0
        private void CheckIca()
        {
            pnlCheck4.Visible = true;

            try
            {
                using (var ica = new AxICAClient())
                {
                    ica.Parent = this;

                    pbCheck4.Image      = Resources.Good_Symbol;
                    lblCheck4.ForeColor = Color.DarkOliveGreen;
                    lblCheck4.Text      = @"ICA (Citrix ICA) " + Language.strCcCheckSucceeded;
                    txtCheck4.Text      = string.Format(Language.strCcICAOK, ica.Version);
                    Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "ICA installed", true);
                }
            }
            catch (Exception ex)
            {
                pbCheck4.Image      = Resources.Bad_Symbol;
                lblCheck4.ForeColor = Color.Firebrick;
                lblCheck4.Text      = @"ICA (Citrix ICA) " + Language.strCcCheckFailed;
                txtCheck4.Text      = Language.strCcICAFailed;

                Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "ICA " + Language.strCcNotInstalledProperly, true);
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, ex.Message, true);
            }
        }
示例#3
0
        public override bool Initialize()
        {
            base.Initialize();

            try
            {
                _icaClient = (AxICAClient)Control;
                _info      = InterfaceControl.Info;
                _icaClient.CreateControl();

                while (!_icaClient.Created)
                {
                    Thread.Sleep(10);
                    Application.DoEvents();
                }

                _icaClient.Address = _info.Hostname;
                SetCredentials();
                SetResolution();
                SetColors();
                SetSecurity();

                //Disable hotkeys for international users
                _icaClient.Hotkey1Shift  = null;
                _icaClient.Hotkey1Char   = null;
                _icaClient.Hotkey2Shift  = null;
                _icaClient.Hotkey2Char   = null;
                _icaClient.Hotkey3Shift  = null;
                _icaClient.Hotkey3Char   = null;
                _icaClient.Hotkey4Shift  = null;
                _icaClient.Hotkey4Char   = null;
                _icaClient.Hotkey5Shift  = null;
                _icaClient.Hotkey5Char   = null;
                _icaClient.Hotkey6Shift  = null;
                _icaClient.Hotkey6Char   = null;
                _icaClient.Hotkey7Shift  = null;
                _icaClient.Hotkey7Char   = null;
                _icaClient.Hotkey8Shift  = null;
                _icaClient.Hotkey8Char   = null;
                _icaClient.Hotkey9Shift  = null;
                _icaClient.Hotkey9Char   = null;
                _icaClient.Hotkey10Shift = null;
                _icaClient.Hotkey10Char  = null;
                _icaClient.Hotkey11Shift = null;
                _icaClient.Hotkey11Char  = null;

                _icaClient.PersistentCacheEnabled = _info.CacheBitmaps;
                _icaClient.Title = _info.Name;
                return(true);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
                                                    Language.strIcaSetPropsFailed + Environment.NewLine + ex.Message,
                                                    true);
                return(false);
            }
        }
示例#4
0
 private void TryDisposeICaClient(bool isDisposing)
 {
     this.connected = false;
     // should be redundant because it is assigned as control
     if (isDisposing && !this.iIcaClient.IsDisposed)
     {
         this.iIcaClient.Dispose();
         this.iIcaClient = null;
     }
 }
 public ProtocolICA()
 {
     try
     {
         Control = new AxICAClient();
     }
     catch (Exception ex)
     {
         Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaControlFailed + Environment.NewLine + ex.Message, true);
     }
 }
 public ProtocolICA()
 {
     try
     {
         Control = new AxICAClient();
     }
     catch (Exception ex)
     {
         Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaControlFailed + Environment.NewLine + ex.Message, true);
     }
 }
示例#7
0
        // http://blogs.citrix.com/2010/03/02/fun-with-the-ica-client-object-ico-and-net-console-applications/
        public override bool Connect()
        {
            this.connected = false;

            try
            {
                this.iIcaClient = new AxICAClient();

                // Register the event callbacks
                ((Control) this.iIcaClient).DragEnter += this.ICAConnection_DragEnter;
                ((Control) this.iIcaClient).DragDrop += this.ICAConnection_DragDrop;
                this.iIcaClient.OnDisconnect += this.iIcaClient_OnDisconnect;

                // Embed the control
                this.Embed(this.iIcaClient);

                // Set the color mode
                iIcaClient.InvokeIfNecessary(() => this.iIcaClient.Address = this.Favorite.ServerName);

                switch (this.Favorite.Colors)
                {
                    case Colors.Bit16:
                        this.iIcaClient.SetProp("DesiredColor", "16");
                        break;
                    case Colors.Bits32:
                        this.iIcaClient.SetProp("DesiredColor", "32");
                        break;
                    case Colors.Bits8:
                        this.iIcaClient.SetProp("DesiredColor", "16");
                        break;
                    default:
                        this.iIcaClient.SetProp("DesiredColor", "24");
                        break;
                }

                // Set the application name
                this.iIcaClient.Application = AssemblyInfo.Title;

                // Set the path to the config files
                this.iIcaClient.AppsrvIni = this.Favorite.IcaServerIni;
                this.iIcaClient.WfclientIni = this.Favorite.IcaClientIni;

                // Set the encryption level
                this.iIcaClient.Encrypt = this.Favorite.IcaEnableEncryption;
                string specifiedLevel = this.Favorite.IcaEncryptionLevel.Trim();

                if (specifiedLevel.Contains(" "))
                {
                    string encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (!string.IsNullOrEmpty(encryptLevel)) this.iIcaClient.EncryptionLevelSession = encryptLevel;
                }

                //Set credentials
                this.iIcaClient.Domain = this.Favorite.Credential.DomainName;
                this.iIcaClient.Username = this.Favorite.Credential.UserName;
                this.iIcaClient.SetProp("ClearPassword", this.Favorite.Credential.Password);

                // Set the server
                this.iIcaClient.Address = this.Favorite.ServerName;

                this.ChangeDesktopSize();

                //Set to false to embed the session, rather than to launch externally.
                this.iIcaClient.Launch = false;

                // Diable inter process communication
                this.iIcaClient.IPCLaunch = false;

                //Enable seamless
                this.iIcaClient.TWIMode = true;

                //Set Server locator
                this.iIcaClient.BrowserProtocol = "UDP";
                this.iIcaClient.TCPBrowserAddress = this.Favorite.ServerName;
                    // this is a metaframe server that has a UDP listener running.

                // Set the protocol and timeout
                this.iIcaClient.TransportDriver = "TCP/IP";
                this.iIcaClient.SessionExitTimeout = 120;

                // Fit to window = 3, 2 ... Size, 1 ... Percent, 0 ... Disabled (default)
                this.iIcaClient.SetProp("ScalingMode", "3");

                if (this.Favorite.IcaApplicationName != "")
                {
                    // Start setting properties
                    this.iIcaClient.InitialProgram = "#" + this.Favorite.IcaApplicationName;
                }

                this.InvokeIfNecessary(() => this.Text = "Connecting to the Citrix ICA server ...");
                
                this.iIcaClient.Connect();

                this.InvokeIfNecessary(() => this.iIcaClient.Focus());
                
                return this.connected = true;
            }
            catch (Exception ex)
            {
                Log.Fatal(string.Format("Terminals was unable to create the {0} connection.", this.Favorite.Protocol), ex);
                return this.connected = false;
            }
        }
        public override bool Initialize()
        {
            base.Initialize();

            try
            {
                _ICAClient = (AxICAClient)Control;
                _Info = InterfaceControl.Info;
                _ICAClient.CreateControl();

                while (!_ICAClient.Created)
                {
                    Thread.Sleep(10);
                    Application.DoEvents();
                }

                _ICAClient.Address = _Info.Hostname;
                SetCredentials();
                SetResolution();
                SetColors();
                SetSecurity();

                //Disable hotkeys for international users
                _ICAClient.Hotkey1Shift = null;
                _ICAClient.Hotkey1Char = null;
                _ICAClient.Hotkey2Shift = null;
                _ICAClient.Hotkey2Char = null;
                _ICAClient.Hotkey3Shift = null;
                _ICAClient.Hotkey3Char = null;
                _ICAClient.Hotkey4Shift = null;
                _ICAClient.Hotkey4Char = null;
                _ICAClient.Hotkey5Shift = null;
                _ICAClient.Hotkey5Char = null;
                _ICAClient.Hotkey6Shift = null;
                _ICAClient.Hotkey6Char = null;
                _ICAClient.Hotkey7Shift = null;
                _ICAClient.Hotkey7Char = null;
                _ICAClient.Hotkey8Shift = null;
                _ICAClient.Hotkey8Char = null;
                _ICAClient.Hotkey9Shift = null;
                _ICAClient.Hotkey9Char = null;
                _ICAClient.Hotkey10Shift = null;
                _ICAClient.Hotkey10Char = null;
                _ICAClient.Hotkey11Shift = null;
                _ICAClient.Hotkey11Char = null;

                _ICAClient.PersistentCacheEnabled = _Info.CacheBitmaps;
                _ICAClient.Title = _Info.Name;
                return true;
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaSetPropsFailed + Environment.NewLine + ex.Message, true);
                return false;
            }
        }
        private void CheckIca()
        {
            pnlCheck4.Visible = true;

            try
            {
                using (var ica = new AxICAClient())
                {
                    ica.Parent = this;

                    pbCheck4.Image = Resources.Good_Symbol;
                    lblCheck4.ForeColor = Color.DarkOliveGreen;
                    lblCheck4.Text = @"ICA (Citrix ICA) " + Language.strCcCheckSucceeded;
                    txtCheck4.Text = string.Format(Language.strCcICAOK, ica.Version);
                    Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "ICA installed", true);
                }
            }
            catch (Exception ex)
            {
                pbCheck4.Image = Resources.Bad_Symbol;
                lblCheck4.ForeColor = Color.Firebrick;
                lblCheck4.Text = @"ICA (Citrix ICA) " + Language.strCcCheckFailed;
                txtCheck4.Text = Language.strCcICAFailed;

                Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "ICA " + Language.strCcNotInstalledProperly, true);
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, ex.Message, true);
            }
        }
        public override bool SetProps()
        {
            base.SetProps();

            try
            {
                ICA_Client = (AxICAClient)this.Control;
                Info = this.InterfaceControl.Info;

                ICA_Client.CreateControl();

                while (!this.ICA_Client.Created)
                {
                    Thread.Sleep(10);
                    System.Windows.Forms.Application.DoEvents();
                }

                ICA_Client.Address = Info.Hostname;

                this.SetCredentials();

                this.SetResolution();
                this.SetColors();

                this.SetSecurity();

                //Disable hotkeys for international users
                ICA_Client.Hotkey1Shift = null;
                ICA_Client.Hotkey1Char = null;
                ICA_Client.Hotkey2Shift = null;
                ICA_Client.Hotkey2Char = null;
                ICA_Client.Hotkey3Shift = null;
                ICA_Client.Hotkey3Char = null;
                ICA_Client.Hotkey4Shift = null;
                ICA_Client.Hotkey4Char = null;
                ICA_Client.Hotkey5Shift = null;
                ICA_Client.Hotkey5Char = null;
                ICA_Client.Hotkey6Shift = null;
                ICA_Client.Hotkey6Char = null;
                ICA_Client.Hotkey7Shift = null;
                ICA_Client.Hotkey7Char = null;
                ICA_Client.Hotkey8Shift = null;
                ICA_Client.Hotkey8Char = null;
                ICA_Client.Hotkey9Shift = null;
                ICA_Client.Hotkey9Char = null;
                ICA_Client.Hotkey10Shift = null;
                ICA_Client.Hotkey10Char = null;
                ICA_Client.Hotkey11Shift = null;
                ICA_Client.Hotkey11Char = null;

                ICA_Client.PersistentCacheEnabled = Info.CacheBitmaps;

                ICA_Client.Title = Info.Name;

                return true;
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
                                                    Language.strIcaSetPropsFailed + Constants.vbNewLine + ex.Message,
                                                    true);
                return false;
            }
        }
示例#11
0
        public override bool Connect()
        {
            try
            {
                iIcaClient = new AxICAClient();
                ((Control)iIcaClient).DragEnter += new DragEventHandler(ICAConnection_DragEnter);
                ((Control)iIcaClient).DragDrop  += new DragEventHandler(ICAConnection_DragDrop);
                iIcaClient.OnDisconnect         += new EventHandler(iIcaClient_OnDisconnect);
                iIcaClient.Dock = DockStyle.Fill;


                Controls.Add(iIcaClient);

                IGuardedSecurity resolved = this.ResolveFavoriteCredentials();

                //rd.SendSpecialKeys(VncSharp.SpecialKeys);
                iIcaClient.Parent = this.Parent;
                iIcaClient.Dock   = DockStyle.Fill;

                iIcaClient.Address = Favorite.ServerName;
                switch (Favorite.Display.Colors)
                {
                case Colors.Bit16:
                    iIcaClient.SetProp("DesiredColor", "16");
                    break;

                case Colors.Bits32:
                    iIcaClient.SetProp("DesiredColor", "32");
                    break;

                case Colors.Bits8:
                    iIcaClient.SetProp("DesiredColor", "16");
                    break;

                default:
                    iIcaClient.SetProp("DesiredColor", "24");
                    break;
                }
                //             iIcaClient.Application = "Terminals " + Program.TerminalsVersion.ToString();

                // This line causes the following misleading error.
                // To log on to this remote computer, you must have Terminal Server User Access permissions on this computer.
                // By default, members of the Remote Desktop Users group have these permissions. If you are not a member of the
                // Remote Desktop Users group or another group that has these permissions, or if the Remote Desktop User group
                // does not have these permissions, you must be granted these permissions manually."

                ICAOptions icaOptions = this.Favorite.ProtocolProperties as ICAOptions;
                iIcaClient.AppsrvIni   = icaOptions.ServerINI;
                iIcaClient.WfclientIni = icaOptions.ClientINI;
                iIcaClient.Encrypt     = icaOptions.EnableEncryption;
                string encryptLevel   = "Encrypt";
                string specifiedLevel = icaOptions.EncryptionLevel.Trim();
                if (specifiedLevel.Contains(" "))
                {
                    encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (encryptLevel != "")
                    {
                        iIcaClient.EncryptionLevelSession = encryptLevel;
                    }
                }



                iIcaClient.Domain   = resolved.Domain;
                iIcaClient.Address  = Favorite.ServerName;
                iIcaClient.Username = resolved.UserName;
                iIcaClient.SetProp("ClearPassword", resolved.Password);
                if (icaOptions.ApplicationName != "")
                {
                    iIcaClient.ConnectionEntry = icaOptions.ApplicationName;
                    iIcaClient.InitialProgram  = icaOptions.ApplicationName;
                    iIcaClient.Application     = icaOptions.ApplicationPath;
                    iIcaClient.WorkDirectory   = icaOptions.ApplicationWorkingFolder;
                }


                Text = "Connecting to ICA Server...";

                iIcaClient.Visible = true;

                iIcaClient.SetProp("ScalingMode", "3");
                iIcaClient.Launch          = false;
                iIcaClient.TransportDriver = "TCP/IP";
                iIcaClient.Connect();
                iIcaClient.Focus();


                return(true);
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to ICA", exc);
                return(false);
            }
        }
        public override bool Connect()
        {
            try
            {
                iIcaClient = new AxICAClient();
                ((Control)iIcaClient).DragEnter += new DragEventHandler(ICAConnection_DragEnter);
                ((Control)iIcaClient).DragDrop += new DragEventHandler(ICAConnection_DragDrop);
                iIcaClient.OnDisconnect += new EventHandler(iIcaClient_OnDisconnect);
                iIcaClient.Dock = DockStyle.Fill;

                Controls.Add(iIcaClient);

                ISecurityOptions security = this.Favorite.Security.GetResolvedCredentials();

                //rd.SendSpecialKeys(VncSharp.SpecialKeys);
                iIcaClient.Parent = this.Parent;
                iIcaClient.Dock = DockStyle.Fill;

                iIcaClient.Address = Favorite.ServerName;
                switch (Favorite.Display.Colors)
                {
                    case Colors.Bit16:
                        iIcaClient.SetProp("DesiredColor", "16");
                        break;
                    case Colors.Bits32:
                        iIcaClient.SetProp("DesiredColor", "32");
                        break;
                    case Colors.Bits8:
                        iIcaClient.SetProp("DesiredColor", "16");
                        break;
                    default:
                        iIcaClient.SetProp("DesiredColor", "24");
                        break;

                }
                //             iIcaClient.Application = "Terminals " + Program.TerminalsVersion.ToString();

                // This line causes the following misleading error.
                // To log on to this remote computer, you must have Terminal Server User Access permissions on this computer.
                // By default, members of the Remote Desktop Users group have these permissions. If you are not a member of the
                // Remote Desktop Users group or another group that has these permissions, or if the Remote Desktop User group
                // does not have these permissions, you must be granted these permissions manually."

                ICAOptions icaOptions = this.Favorite.ProtocolProperties as ICAOptions;
                iIcaClient.AppsrvIni = icaOptions.ServerINI;
                iIcaClient.WfclientIni = icaOptions.ClientINI;
                iIcaClient.Encrypt = icaOptions.EnableEncryption;
                string encryptLevel = "Encrypt";
                string specifiedLevel = icaOptions.EncryptionLevel.Trim();
                if (specifiedLevel.Contains(" "))
                {
                    encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (encryptLevel != "") iIcaClient.EncryptionLevelSession = encryptLevel;
                }

                iIcaClient.Domain = security.Domain;
                iIcaClient.Address = Favorite.ServerName;
                iIcaClient.Username = security.UserName;
                iIcaClient.SetProp("ClearPassword", security.Password);
                if (icaOptions.ApplicationName != "")
                {
                    iIcaClient.ConnectionEntry = icaOptions.ApplicationName;
                    iIcaClient.InitialProgram = icaOptions.ApplicationName;
                    iIcaClient.Application = icaOptions.ApplicationPath;
                    iIcaClient.WorkDirectory = icaOptions.ApplicationWorkingFolder;
                }

                Text = "Connecting to ICA Server...";

                iIcaClient.Visible = true;

                iIcaClient.SetProp("ScalingMode", "3");
                iIcaClient.Launch = false;
                iIcaClient.TransportDriver = "TCP/IP";
                iIcaClient.Connect();
                iIcaClient.Focus();

                return true;
            }
            catch (Exception exc)
            {
                Logging.Fatal("Connecting to ICA", exc);
                return false;
            }
        }
 private void TryDisposeICaClient(bool isDisposing)
 {
     this.connected = false;
     // should be redundant because it is assigned as control
     if (isDisposing && !this.iIcaClient.IsDisposed)
     {
         this.iIcaClient.Dispose();
         this.iIcaClient = null;
     }
 }
示例#14
0
        public override bool SetProps()
        {
            base.SetProps();

            try
            {
                ICA_Client = (AxICAClient)this.Control;
                Info       = this.InterfaceControl.Info;

                ICA_Client.CreateControl();

                while (!this.ICA_Client.Created)
                {
                    Thread.Sleep(10);
                    System.Windows.Forms.Application.DoEvents();
                }

                ICA_Client.Address = Info.Hostname;

                this.SetCredentials();

                this.SetResolution();
                this.SetColors();

                this.SetSecurity();

                //Disable hotkeys for international users
                ICA_Client.Hotkey1Shift  = null;
                ICA_Client.Hotkey1Char   = null;
                ICA_Client.Hotkey2Shift  = null;
                ICA_Client.Hotkey2Char   = null;
                ICA_Client.Hotkey3Shift  = null;
                ICA_Client.Hotkey3Char   = null;
                ICA_Client.Hotkey4Shift  = null;
                ICA_Client.Hotkey4Char   = null;
                ICA_Client.Hotkey5Shift  = null;
                ICA_Client.Hotkey5Char   = null;
                ICA_Client.Hotkey6Shift  = null;
                ICA_Client.Hotkey6Char   = null;
                ICA_Client.Hotkey7Shift  = null;
                ICA_Client.Hotkey7Char   = null;
                ICA_Client.Hotkey8Shift  = null;
                ICA_Client.Hotkey8Char   = null;
                ICA_Client.Hotkey9Shift  = null;
                ICA_Client.Hotkey9Char   = null;
                ICA_Client.Hotkey10Shift = null;
                ICA_Client.Hotkey10Char  = null;
                ICA_Client.Hotkey11Shift = null;
                ICA_Client.Hotkey11Char  = null;

                ICA_Client.PersistentCacheEnabled = Info.CacheBitmaps;

                ICA_Client.Title = Info.Name;

                return(true);
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg,
                                                    Language.strIcaSetPropsFailed + Constants.vbNewLine + ex.Message,
                                                    true);
                return(false);
            }
        }
示例#15
0
        // http://blogs.citrix.com/2010/03/02/fun-with-the-ica-client-object-ico-and-net-console-applications/
        public override bool Connect()
        {
            this.connected = false;

            try
            {
                this.iIcaClient = new AxICAClient();

                // Register the event callbacks
                ((Control)this.iIcaClient).DragEnter += this.ICAConnection_DragEnter;
                ((Control)this.iIcaClient).DragDrop  += this.ICAConnection_DragDrop;
                this.iIcaClient.OnDisconnect         += this.iIcaClient_OnDisconnect;

                // Embed the control
                this.Embed(this.iIcaClient);

                // Set the color mode
                iIcaClient.InvokeIfNecessary(() => this.iIcaClient.Address = this.Favorite.ServerName);

                switch (this.Favorite.Colors)
                {
                case Colors.Bit16:
                    this.iIcaClient.SetProp("DesiredColor", "16");
                    break;

                case Colors.Bits32:
                    this.iIcaClient.SetProp("DesiredColor", "32");
                    break;

                case Colors.Bits8:
                    this.iIcaClient.SetProp("DesiredColor", "16");
                    break;

                default:
                    this.iIcaClient.SetProp("DesiredColor", "24");
                    break;
                }

                // Set the application name
                this.iIcaClient.Application = AssemblyInfo.Title;

                // Set the path to the config files
                this.iIcaClient.AppsrvIni   = this.Favorite.IcaServerIni;
                this.iIcaClient.WfclientIni = this.Favorite.IcaClientIni;

                // Set the encryption level
                this.iIcaClient.Encrypt = this.Favorite.IcaEnableEncryption;
                string specifiedLevel = this.Favorite.IcaEncryptionLevel.Trim();

                if (specifiedLevel.Contains(" "))
                {
                    string encryptLevel = specifiedLevel.Substring(0, specifiedLevel.IndexOf(" ")).Trim();
                    if (!string.IsNullOrEmpty(encryptLevel))
                    {
                        this.iIcaClient.EncryptionLevelSession = encryptLevel;
                    }
                }

                //Set credentials
                this.iIcaClient.Domain   = this.Favorite.Credential.DomainName;
                this.iIcaClient.Username = this.Favorite.Credential.UserName;
                this.iIcaClient.SetProp("ClearPassword", this.Favorite.Credential.Password);

                // Set the server
                this.iIcaClient.Address = this.Favorite.ServerName;

                this.ChangeDesktopSize();

                //Set to false to embed the session, rather than to launch externally.
                this.iIcaClient.Launch = false;

                // Diable inter process communication
                this.iIcaClient.IPCLaunch = false;

                //Enable seamless
                this.iIcaClient.TWIMode = true;

                //Set Server locator
                this.iIcaClient.BrowserProtocol   = "UDP";
                this.iIcaClient.TCPBrowserAddress = this.Favorite.ServerName;
                // this is a metaframe server that has a UDP listener running.

                // Set the protocol and timeout
                this.iIcaClient.TransportDriver    = "TCP/IP";
                this.iIcaClient.SessionExitTimeout = 120;

                // Fit to window = 3, 2 ... Size, 1 ... Percent, 0 ... Disabled (default)
                this.iIcaClient.SetProp("ScalingMode", "3");

                if (this.Favorite.IcaApplicationName != "")
                {
                    // Start setting properties
                    this.iIcaClient.InitialProgram = "#" + this.Favorite.IcaApplicationName;
                }

                this.InvokeIfNecessary(() => this.Text = "Connecting to the Citrix ICA server ...");

                this.iIcaClient.Connect();

                this.InvokeIfNecessary(() => this.iIcaClient.Focus());

                return(this.connected = true);
            }
            catch (Exception ex)
            {
                Log.Fatal(string.Format("Terminals was unable to create the {0} connection.", this.Favorite.Protocol), ex);
                return(this.connected = false);
            }
        }