public override void RightMouseUp(NSEvent theEvent) { base.RightMouseUp(theEvent); if (!Connected) { return; } var pasteboard = NSPasteboard.GeneralPasteboard; Class [] classArray = { new Class("NSString") }; if (pasteboard.CanReadObjectForClasses(classArray, null)) { NSObject[] objectsToPaste = pasteboard.ReadObjectsForClasses(classArray, null); NSString text = (NSString)objectsToPaste[0]; var buffer = Encoding.UTF8.GetBytes(text.ToString()); Task.Run(() => { VtConnection.SendData(buffer); }); } }
private void OnSendData(object sender, SendDataEventArgs e) { if (Connected) { Task.Run(() => VtConnection.SendData(e.Data)); } }
private void ProcessTextFormat(NSStringAttributes attributes) { var str = new NSString("A"); var bounds = str.BoundingRectWithSize( new CGSize(1000, 1000), 0, attributes.Dictionary); if ((nfloat)CharacterWidth != bounds.Width || (nfloat)CharacterHeight != bounds.Height) { CharacterWidth = bounds.Right; CharacterHeight = //bounds.Bottom attributes.Font.Ascender - attributes.Font.Descender; } int columns = Convert.ToInt32(Math.Floor(Frame.Width / CharacterWidth)); int rows = Convert.ToInt32(Math.Floor(Frame.Height / CharacterHeight)); if (Columns != columns || Rows != rows) { Columns = columns; Rows = rows; ResizeTerminal(); if (VtConnection != null) { VtConnection.SetTerminalWindowSize(columns, rows, 800, 600); } } }
private void ProcessTextFormat(CanvasDrawingSession drawingSession, CanvasTextFormat format) { CanvasTextLayout textLayout = new CanvasTextLayout(drawingSession, "Q", format, 0.0f, 0.0f); if (CharacterWidth != textLayout.DrawBounds.Width || CharacterHeight != textLayout.DrawBounds.Height) { CharacterWidth = textLayout.DrawBounds.Right; CharacterHeight = textLayout.DrawBounds.Bottom; } int columns = Convert.ToInt32(Math.Floor(canvas.RenderSize.Width / CharacterWidth)); int rows = Convert.ToInt32(Math.Floor(canvas.RenderSize.Height / CharacterHeight)); if (Columns != columns || Rows != rows) { Columns = columns; Rows = rows; ResizeTerminal(); if (VtConnection != null) { VtConnection.SetTerminalWindowSize(columns, rows, 800, 600); } } }
private void OnSendData(object sender, SendDataEventArgs e) { if (!Connected) { return; } Task.Run(() => { VtConnection.SendData(e.Data); }); }
public void Disconnect() { if (!Connected) { return; } VtConnection.Disconnect(); VtConnection.DataReceived -= OnDataReceived; VtConnection = null; }
private void PasteText(string text) { if (VtConnection == null) { return; } Task.Run(() => { var buffer = Encoding.UTF8.GetBytes(text); Task.Run(() => { VtConnection.SendData(buffer); }); }); }
public bool ConnectTo(string uri, string username, string password) { if (Connected) { return(false); // Already connected } var credentials = new UsernamePasswordCredentials { Username = username, Password = password }; var destination = new Uri(uri); VtConnection = Connection.CreateConnection(destination); VtConnection.SetTerminalWindowSize(Columns, Rows, 800, 600); VtConnection.DataReceived += OnDataReceived; var result = VtConnection.Connect(destination, credentials); return(result); }