private void CreateRDPFile(string rdpPath, RemoteAppLib.New.RemoteApp remoteApp)
        {
            // Dim App As New RemoteAppLib.New.RemoteApp = RemoteApp
            // App = RemoteApp
            var ServerAddress    = this.ServerAddress.Text;
            var AltServerAddress = this.AltServerAddress.Text;
            var ServerPort       = this.ServerPort.Text;
            var FlatFileTypes    = "";

            if (remoteApp.FileTypeAssociations != null)
            {
                FlatFileTypes = remoteApp.FileTypeAssociations.GetFlatFileTypes();
            }
            var rdPfile = new RDPFileLib.New.RDPFile()
            {
                FullAddress               = ServerAddress,
                AlternateFullAddress      = AltServerAddress,
                ServerPort                = (int)Math.Round(double.Parse(ServerPort)),
                RemoteApplicationName     = remoteApp.FullName,
                RemoteApplicationProgram  = "||" + remoteApp.Name,
                RemoteApplicationMode     = 1,
                DisableRemoteAppCapsCheck = 1,
                AlternateShell            = "rdpinit.exe"
            };

            if (UseRDGatewayCheckBox.Checked)
            {
                rdPfile.GatewayHostname           = GatewayAddress.Text;
                rdPfile.GatewayUsageMethod        = AttemptDirectCheckBox.Checked ? 2 : 1;
                rdPfile.GatewayProfileUsageMethod = 1;
            }

            rdPfile.PromptForCredentialsOnClient = 1;
            rdPfile.PromptCredentialOnce         = 0;
            rdPfile.DeviceStoreDirect            = "*";
            rdPfile.DriveStoreDirect             = "*";
            rdPfile.RedirectComPorts             = 1;
            rdPfile.RedirectDrives                  = 1;
            rdPfile.AllowDesktopComposition         = 1;
            rdPfile.AllowFontSmoothing              = 1;
            rdPfile.SpanMonitors                    = 1;
            rdPfile.UseMultimonitor                 = 1;
            rdPfile.RemoteApplicationFileExtensions = FlatFileTypes;
            rdPfile.SaveRdpFile(rdpPath);
            if (CheckBoxSignRDPEnabled.Checked)
            {
                var rdpSign    = new RDPSign.New.RDPSign();
                var Thumbprint = rdpSign.GetThumbprint(CertificateComboBox.Text);
                rdpSign.SignRDP(Thumbprint, rdpPath, CheckBoxCreateSignedAndUnsigned.Checked);
            }
        }
        public void CreateClientConnection(RemoteAppLib.New.RemoteApp selectedRemoteApp)
        {
            _remoteApp = selectedRemoteApp;
            var rdpSign            = new RDPSign.New.RDPSign();
            var RemoteAppShortName = _remoteApp.Name;

            Text = "Create Client Connection for " + RemoteAppShortName;
            RdpsignErrorLabel.Text = "";
            CertificateComboBox.Items.AddRange(rdpSign.GetCertificateFriendlyName().ToArray());
            SetCcWindowSettings();
            if (string.IsNullOrEmpty(ServerAddress.Text))
            {
                ServerAddress.Text = System.Net.Dns.GetHostName();
            }
            if (string.IsNullOrEmpty(AltServerAddress.Text))
            {
                AltServerAddress.Text = ServerAddress.Text;
            }
            if (ServerPort.Text == "0")
            {
                ServerPort.Text = "3389";
            }
            if (!File.Exists(_remoteApp.IconPath))
            {
                CreateRAWebIcon.Checked = false;
                CreateRAWebIcon.Enabled = false;
            }
            else
            {
                CreateRAWebIcon.Enabled = RDPRadioButton.Checked;
            }

            var wx = new RDP2MSIlib.New.RDP();

            if (!wx.WixInstalled())
            {
                RDPRadioButton.Checked = true;
                MSIRadioButton.Enabled = false;
                MSIRadioButton.Text    = "MSI installer (requires WiX Toolset)";
            }

            if (!File.Exists(rdpSign.GetRdpsignExeLocation()))
            {
                SigningTabPage.Enabled                  = false;
                RdpsignErrorLabel.Text                 += " * Requires rdpsign.exe.";
                SigningTabPage.Tag                      = "noexe";
                CheckBoxSignRDPEnabled.Checked          = false;
                CheckBoxCreateSignedAndUnsigned.Checked = false;
                CertificateComboBox.Text                = "";
            }

            if (_remoteApp.FileTypeAssociations != null)
            {
                FTACountLabel.Text = "Count: " + _remoteApp.FileTypeAssociations.Count;
            }
            RDPRadioButton.Focus();
            HelpSystem.SetupTips(this);
            ShowDialog();
            Forms.RemoteAppMainWindow.ReloadApps();
            //Dispose();
        }