Ejemplo n.º 1
0
 private void ConnectHostedConsole(VNCGraphicsClient v, XenAPI.Console console, string session_uuid)
 {
     //Program.AssertOffEventThread();
     Uri uri = new Uri(console.location);
     Stream stream = HTTP.CONNECT(uri, null, session_uuid, 0);
     InvokeConnection(v, stream, console, m_vncPassword);
 }
Ejemplo n.º 2
0
 private void InvokeConnection(VNCGraphicsClient v, Stream stream, XenAPI.Console console, char[] vncPassword)
 {
     Program.Invoke(this, delegate()
     {
         // This is the last chance that we have to make sure that we've not already
         // connected this VNCGraphicsClient.  Now that we are back on the event thread,
         // we're guaranteed that no-one will beat us to the v.connect() call.  We
         // hand over responsibility for closing the stream at that point, so we have to
         // close it ourselves if the client is already connected.
         if (v.Connected || v.Terminated)
         {
             stream.Close();
         }
         else
         {
             v.SendScanCodes = !m_sourceIsPV;
             v.SourceVM = m_sourceVM;
             v.Console = console;
             v.Focus();
             v.connect(stream, vncPassword);
         }
     }
     );
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the actual VNC client control.
        /// </summary>
        private void initSubControl(int width, int height, bool scaling, bool show_border)
        {
            Program.MainWindow = this;
            bool wasFocused = m_vncClient != null && m_vncClient.Focused;
            this.Controls.Clear();

            Size newSize;
            Size oldSize = new Size(1024, 768);
            if (width == 0 || height == 0)
                newSize = new Size(1024, 768);
            else
                newSize = new Size(width, height);

            // Kill the old client.
            if (m_vncClient != null)
            {
                oldSize = m_vncClient.DesktopSize;
                m_vncClient.Disconnect();
                m_vncClient.Dispose();
                m_vncClient = null;
            }
            // Reset
            this.AutoScroll = false;
            this.AutoScrollMinSize = new Size(0, 0);
            m_vncClient = new VNCGraphicsClient(this);
            m_vncClient.Size            = newSize;
            this.Size = newSize;
            m_vncClient.UseSource       = true;
            m_vncClient.SendScanCodes   = !this.m_sourceIsPV;
            m_vncClient.Dock            = DockStyle.Fill;
            this.m_vncClient.Scaling    = scaling; // SCVMM requires a scaled image
            m_vncClient.DisplayBorder   = show_border;
            m_vncClient.AutoScaleDimensions = newSize;
            m_vncClient.AutoScaleMode = AutoScaleMode.Inherit;

            this.m_vncClient.DesktopResized += ResolutionChangeHandler;
            //this.m_vncClient.Resize += ResizeHandler;
            //this.m_vncClient.ErrorOccurred += ErrorHandler;
            //this.m_vncClient.ConnectionSuccess += ConnectionSuccess;
            //this.m_vncClient.ErrorOccurred
            //this.m_vncClient.MouseDown += new MouseEventHandler(vncClient_MouseDown);
            //this.m_vncClient.KeyDown += new KeyEventHandler(vncClient_KeyDown);
            
            m_vncClient.KeyHandler = new ConsoleKeyHandler();
            this.m_vncClient.Unpause();

            foreach (Set<Keys> keys in extraCodes.Keys)
            {
                m_vncClient.KeyHandler.AddKeyHandler(keys, extraCodes[keys]);
            }

            foreach (Set<int> keys in extraScans.Keys)
            {
                m_vncClient.KeyHandler.AddKeyHandler(keys, extraScans[keys]);
            }
        }