public void PasteTextFromClipboard() { string value = (string)Clipboard.GetDataObject().GetData("Text"); if (value == null || value.Length == 0 || this._terminalPane == null || this._terminalPane.ConnectionTag == null) { return; } PasteProcessor p = new PasteProcessor(this._terminalPane.ConnectionTag, value); p.Perform(); }
public CommandResult PasteFromFile() { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = GApp.Options.DefaultFileDir; dlg.Title = GApp.Strings.GetString("Util.SourceToLoad"); dlg.Filter = "All Files(*.*)|*.*"; ConnectionTag ct = GEnv.Connections.FindTag(_connection); if (ct.ModalTerminalTask != null) { return(CommandResult.Denied); } if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK) { GApp.Options.DefaultFileDir = GUtil.FileToDir(dlg.FileName); try { StreamReader re = new StreamReader(new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read), _connection.Param.EncodingProfile.Encoding); if (new FileInfo(dlg.FileName).Length > 0x1000) //4KB以上は非同期 { SendingLargeText dlg2 = new SendingLargeText(new PasteProcessor(ct, re)); re.Close(); if (GCUtil.ShowModalDialog(GApp.Frame, dlg2) == DialogResult.OK) { return(CommandResult.Success); } else { return(CommandResult.Cancelled); } } else { PasteProcessor p = new PasteProcessor(ct, re); p.Perform(); re.Close(); } //GEnv.Frame.StatusBar.IndicateSendData(); return(CommandResult.Success); } catch (Exception ex) { GUtil.Warning(GEnv.Frame, ex.Message); return(CommandResult.Failed); } } else { return(CommandResult.Cancelled); } }
protected CommandResult PasteMain(string value) { ConnectionTag tag = GEnv.Connections.FindTag(_connection); PasteProcessor p = new PasteProcessor(tag, value); try { p.Perform(); return(CommandResult.Success); } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); GUtil.Warning(GEnv.Frame, GEnv.Strings.GetString("Message.ConnectionCommandTarget.SendError") + ex.Message); return(CommandResult.Failed); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); _proc.LineProcessed += new PasteProcessor.EventHandler(OnLineProcessed); _proc.Perform(); }