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; }
public override CommandResult Paste() { string value = (string)Clipboard.GetDataObject().GetData("Text"); if(value==null || value.Length==0) return CommandResult.Ignored; ConnectionTag ct = GEnv.Connections.FindTag(_connection); if(ct.ModalTerminalTask!=null) return CommandResult.Denied; if(value.Length>0x1000) { SendingLargeText dlg = new SendingLargeText(new PasteProcessor(ct, value)); if(GCUtil.ShowModalDialog(GApp.Frame, dlg)==DialogResult.OK) return CommandResult.Success; else return CommandResult.Cancelled; } else return PasteMain(value); }