コード例 #1
0
        public IRemoteDesktopSession Connect(
            VmInstanceReference vmInstance,
            string server,
            ushort port,
            VmInstanceSettings settings)
        {
            var rdpPane = new RemoteDesktopPane(
                this.eventService,
                this.exceptionDialog,
                vmInstance);

            rdpPane.Show(this.dockPanel, DockState.Document);

            rdpPane.Connect(server, port, settings);

            return(rdpPane);
        }
コード例 #2
0
        public VmInstanceNode(
            Instance instance,
            VmInstanceSettings settings,
            Action <VmInstanceSettings> saveSettings,
            ZoneNode parent)
            : base(
                settings.InstanceName,
                DisconnectedIconIndex,
                settings,
                changedSettings => saveSettings((VmInstanceSettings)changedSettings),
                parent)
        {
            this.InstanceId  = instance.Id.Value;
            this.Status      = instance.Status;
            this.Hostname    = instance.Hostname;
            this.MachineType = InventoryNode.ShortIdFromUrl(instance.MachineType);
            this.Tags        = instance.Tags != null && instance.Tags.Items != null
                ? string.Join(", ", instance.Tags.Items) : null;

            this.InternalIp = InternalIpFromInstance(instance);
            this.ExternalIp = ExternalIpFromInstance(instance);
        }
コード例 #3
0
        public void Connect(
            string server,
            ushort port,
            VmInstanceSettings settings
            )
        {
            using (TraceSources.IapDesktop.TraceMethod().WithParameters(server, port))
            {
                // NB. The initialization needs to happen after the pane is shown, otherwise
                // an error happens indicating that the control does not have a Window handle.
                InitializeComponent();
                UpdateLayout();

                var advancedSettings = this.rdpClient.AdvancedSettings7;
                var nonScriptable    = (IMsRdpClientNonScriptable5)this.rdpClient.GetOcx();
                var securedSettings2 = this.rdpClient.SecuredSettings2;

                //
                // Basic connection settings.
                //
                this.rdpClient.Server              = server;
                this.rdpClient.Domain              = settings.Domain;
                this.rdpClient.UserName            = settings.Username;
                advancedSettings.RDPPort           = port;
                advancedSettings.ClearTextPassword = settings.Password.AsClearText();

                //
                // Connection security settings.
                //
                advancedSettings.EnableCredSspSupport = true;
                nonScriptable.PromptForCredentials    = false;
                nonScriptable.NegotiateSecurityLayer  = true;

                switch (settings.AuthenticationLevel)
                {
                case RdpAuthenticationLevel.NoServerAuthentication:
                    advancedSettings.AuthenticationLevel = 0;
                    break;

                case RdpAuthenticationLevel.RequireServerAuthentication:
                    advancedSettings.AuthenticationLevel = 1;
                    break;

                case RdpAuthenticationLevel.AttemptServerAuthentication:
                    advancedSettings.AuthenticationLevel = 2;
                    break;
                }

                nonScriptable.AllowPromptingForCredentials =
                    settings.UserAuthenticationBehavior == RdpUserAuthenticationBehavior.PromptOnFailure;

                //
                // Advanced connection settings.
                //
                advancedSettings.keepAliveInterval    = 60000;
                advancedSettings.PerformanceFlags     = 0; // Enable all features, it's 2020.
                advancedSettings.EnableAutoReconnect  = true;
                advancedSettings.MaxReconnectAttempts = 10;

                //
                // Behavior settings.
                //
                advancedSettings.DisplayConnectionBar =
                    (settings.ConnectionBar != RdpConnectionBarState.Off);
                advancedSettings.PinConnectionBar =
                    (settings.ConnectionBar == RdpConnectionBarState.Pinned);
                advancedSettings.EnableWindowsKey   = 1;
                advancedSettings.GrabFocusOnConnect = false;

                //
                // Local resources settings.
                //
                advancedSettings.RedirectClipboard =
                    settings.RedirectClipboard == RdpRedirectClipboard.Enabled;

                switch (settings.AudioMode)
                {
                case RdpAudioMode.PlayLocally:
                    securedSettings2.AudioRedirectionMode = 0;
                    break;

                case RdpAudioMode.PlayOnServer:
                    securedSettings2.AudioRedirectionMode = 1;
                    break;

                case RdpAudioMode.DoNotPlay:
                    securedSettings2.AudioRedirectionMode = 2;
                    break;
                }

                //
                // Display settings.
                //
                this.rdpClient.FullScreen = false;

                switch (settings.ColorDepth)
                {
                case RdpColorDepth.HighColor:
                    this.rdpClient.ColorDepth = 16;
                    break;

                case RdpColorDepth.TrueColor:
                    this.rdpClient.ColorDepth = 24;
                    break;

                case RdpColorDepth.DeepColor:
                    this.rdpClient.ColorDepth = 32;
                    break;
                }

                if (settings.DesktopSize == RdpDesktopSize.ScreenSize)
                {
                    var screenSize = Screen.GetBounds(this);
                    this.rdpClient.DesktopHeight = screenSize.Height;
                    this.rdpClient.DesktopWidth  = screenSize.Width;
                }
                else
                {
                    this.rdpClient.DesktopHeight = this.Size.Height;
                    this.rdpClient.DesktopWidth  = this.Size.Width;
                }

                switch (settings.BitmapPersistence)
                {
                case RdpBitmapPersistence.Disabled:
                    advancedSettings.BitmapPersistence = 0;
                    break;

                case RdpBitmapPersistence.Enabled:
                    // This setting can cause disconnects when running more than
                    // ~4 sessions in parallel.
                    advancedSettings.BitmapPersistence = 1;
                    break;
                }

                //
                // Keyboard settings.
                //
                // NB. Apply key combinations to the remote server only when the client is running
                // in full-screen mode.
                this.rdpClient.SecuredSettings2.KeyboardHookMode = 2;

                advancedSettings.allowBackgroundInput = 1;

                this.rdpClient.Connect();
            }
        }
コード例 #4
0
 public void SetVmInstanceSettings(string projectId, VmInstanceSettings settings)
 {
     Set <VmInstanceSettings>(new[] { projectId, VmPrefix + settings.InstanceName }, settings);
 }