public CommandResult ShowChangePassphraseDialog()
        {
            ChangePassphrase dlg = new ChangePassphrase();

            GCUtil.ShowModalDialog(_frame, dlg);
            return(CommandResult.Success);
        }
        public CommandResult CopyToFile()
        {
            if (GEnv.TextSelection.IsEmpty)
            {
                return(CommandResult.Ignored);
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.InitialDirectory = GApp.Options.DefaultFileDir;
            dlg.Title            = GApp.Strings.GetString("Util.DestinationToSave");
            dlg.Filter           = "All Files(*.*)|*.*";
            string selectedtext = GEnv.TextSelection.GetSelectedText();             //このファイル選択ダイアログを閉じた直後にOnGotFocusが発生し、テキスト選択がクリアされることがあるので事前に取得しておく

            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
            {
                GApp.Options.DefaultFileDir = GUtil.FileToDir(dlg.FileName);
                try {
                    StreamWriter wr = new StreamWriter(new FileStream(dlg.FileName, FileMode.Create), Encoding.Default);
                    wr.Write(selectedtext);
                    wr.Close();
                    return(CommandResult.Success);
                }
                catch (Exception ex) {
                    GUtil.Warning(GApp.Frame, ex.Message);
                    return(CommandResult.Failed);
                }
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
        public CommandResult ShowOptionDialog()
        {
            OptionDialog dlg = new OptionDialog();

            GCUtil.ShowModalDialog(_frame, dlg);
            return(CommandResult.Success);
        }
        public CommandResult ShowKeyGenWizard()
        {
            KeyGenWizard dlg = new KeyGenWizard();

            GCUtil.ShowModalDialog(_frame, dlg);
            return(CommandResult.Success);
        }
        public CommandResult NewSFUConnectionWithDialog(SFUTerminalParam param)
        {
            if (!CheckPaneCount())
            {
                return(CommandResult.Denied);
            }

            if (SFUUtil.GuessRootDirectory().Length == 0)
            {
                return(CommandResult.Failed);
            }

            LocalShellLoginDialog dlg = new LocalShellLoginDialog();

            if (param != null)
            {
                dlg.ApplyParam(param);
            }
            else
            {
                dlg.ApplyParam(GApp.ConnectionHistory.TopSFUParam);
            }

            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
            {
                ConnectionTag con = dlg.Result;
                if (con != null)
                {
                    AddNewTerminal(con);
                    return(CommandResult.Success);
                }
            }

            return(CommandResult.Cancelled);
        }
        public CommandResult SaveShortCut()
        {
            //コネクションがあればファイルを尋ねる
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title            = GApp.Strings.GetString("Util.SaveShortcut");
            dlg.InitialDirectory = GApp.Options.DefaultFileDir;
            dlg.DefaultExt       = "gts";
            dlg.AddExtension     = true;
            dlg.Filter           = "Terminal Shortcut(*.gts)|*.gts";
            if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK)
            {
                try {
                    ConfigNode cn = new ConfigNode("poderosa-shortcut");
                    _connection.Param.Export(cn);
                    XmlWriter wr = XMLUtil.CreateDefaultWriter(dlg.FileName);
                    DOMNodeConverter.Write(wr, cn);
                    wr.WriteEndDocument();
                    wr.Close();
                    GApp.Options.DefaultFileDir = GUtil.FileToDir(dlg.FileName);
                    return(CommandResult.Success);
                }
                catch (Exception ex) {
                    MessageBox.Show(GEnv.Frame, ex.Message, GApp.Strings.GetString("Message.SaveError"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    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));
            }
        }
 public CommandResult RenameTab()
 {
     try {
         InputBox box = new InputBox();
         box.AllowsZeroLenString = false;
         box.Text    = GApp.Strings.GetString("Util.RenameTab");
         box.Content = _connection.Param.Caption;
         if (GCUtil.ShowModalDialog(GApp.Frame, box) == DialogResult.OK)
         {
             _connection.Param.Caption = box.Content;
             GApp.ConnectionHistory.ReplaceIdenticalParam(_connection.Param);
             GApp.Frame.AdjustMRUMenu();
             GApp.Frame.RefreshConnection(GEnv.Connections.FindTag(_connection));
             return(CommandResult.Success);
         }
         else
         {
             return(CommandResult.Cancelled);
         }
     }
     catch (Exception ex) {
         Debug.WriteLine(ex.StackTrace);
         GUtil.Warning(GApp.Frame, ex.Message);
         return(CommandResult.Failed);
     }
 }
        public CommandResult SerialConfig()
        {
            SerialTerminalConnection stc = _connection as SerialTerminalConnection;

            if (stc == null)
            {
                return(CommandResult.Failed);
            }

            try {
                SerialConfigForm f = new SerialConfigForm();
                f.ApplyParam(stc);
                if (GCUtil.ShowModalDialog(GApp.Frame, f) == DialogResult.OK)
                {
                    return(CommandResult.Success);
                }
                else
                {
                    return(CommandResult.Cancelled);
                }
            }
            catch (NotSupportedException) {
                GUtil.Warning(GApp.Frame, GApp.Strings.GetString("Message.SerialConfigIsSerialOnly"));
                return(CommandResult.Failed);
            }
        }
        public CommandResult ShowServerInfo()
        {
            ServerInfo dlg = new ServerInfo(_connection);

            GCUtil.ShowModalDialog(GApp.Frame, dlg);
            return(CommandResult.Success);
        }
        public CommandResult NewConnectionWithDialog(TCPTerminalParam param)
        {
            if (!CheckPaneCount())
            {
                return(CommandResult.Denied);
            }

            ConnectionHistory hst = GApp.ConnectionHistory;
            LoginDialog       dlg = new LoginDialog();

            if (param != null)
            {
                dlg.ApplyParam(param);
            }
            else
            {
                dlg.ApplyParam(hst.TopTCPParam);
            }

            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)            //ダイアログを出さないなら無条件で接続を開く
            {
                AddNewTerminal(dlg.Result);
                return(CommandResult.Success);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
        public CommandResult ShowMacroConfigDialog()
        {
            MacroList dlg = new MacroList();

            GCUtil.ShowModalDialog(_frame, dlg);
            return(CommandResult.Success);
        }
        public CommandResult ShowLineFeedRuleDialog()
        {
            LineFeedStyleDialog dlg = new LineFeedStyleDialog(_connection);

            if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK)
            {
                _connection.Param.LineFeedRule = dlg.LineFeedRule;
            }
            return(CommandResult.Success);
        }
        public CommandResult ShowAboutBox()
        {
            AboutBox dlg = new AboutBox();

            GCUtil.ShowModalDialog(_frame, dlg);
            if (dlg.CreditButtonClicked)
            {
                GCUtil.ShowModalDialog(_frame, new Credits());
            }
            return(CommandResult.Success);
        }
        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 CommandResult CommentLog()
        {
            LogNoteForm dlg = new LogNoteForm();

            if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK)
            {
                _connection.CommentLog(dlg.ResultText);
                return(CommandResult.Success);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
        public CommandResult ChangeLogWithDialog()
        {
            ChangeLogDialog dlg = new ChangeLogDialog(_connection);

            if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK)
            {
                GApp.Frame.AdjustTerminalUI(true, GEnv.Connections.FindTag(_connection));
                return(CommandResult.Success);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
        public CommandResult ShowWelcomeDialog()
        {
            WelcomeDialog dlg = new WelcomeDialog();
            DialogResult  r   = GCUtil.ShowModalDialog(_frame, dlg);

            if (r == DialogResult.OK)
            {
                if (dlg.CID != CID.NOP)
                {
                    GApp.GlobalCommandTarget.Exec(dlg.CID);
                }
            }
            return(CommandResult.Success);
        }
Beispiel #19
0
        //既存のファイルであったり、書き込み不可能だったら警告する
        public static LogFileCheckResult CheckLogFileName(string path, Form parent)
        {
            try {
                if (path.Length == 0)
                {
                    GUtil.Warning(parent, GApp.Strings.GetString("Message.CheckLogFileName.EmptyPath"));
                    return(LogFileCheckResult.Cancel);
                }

                if (File.Exists(path))
                {
                    if ((FileAttributes.ReadOnly & File.GetAttributes(path)) != (FileAttributes)0)
                    {
                        GUtil.Warning(parent, String.Format(GApp.Strings.GetString("Message.CheckLogFileName.NotWritable"), path));
                        return(LogFileCheckResult.Cancel);
                    }

                    Poderosa.Forms.ThreeButtonMessageBox mb = new Poderosa.Forms.ThreeButtonMessageBox();
                    mb.Message          = String.Format(GApp.Strings.GetString("Message.CheckLogFileName.AlreadyExist"), path);
                    mb.Text             = GApp.Strings.GetString("Util.CheckLogFileName.Caption");
                    mb.YesButtonText    = GApp.Strings.GetString("Util.CheckLogFileName.OverWrite");
                    mb.NoButtonText     = GApp.Strings.GetString("Util.CheckLogFileName.Append");
                    mb.CancelButtonText = GApp.Strings.GetString("Util.CheckLogFileName.Cancel");
                    switch (GCUtil.ShowModalDialog(parent, mb))
                    {
                    case DialogResult.Cancel:
                        return(LogFileCheckResult.Cancel);

                    case DialogResult.Yes:                             //上書き
                        return(LogFileCheckResult.Create);

                    case DialogResult.No:                              //追記
                        return(LogFileCheckResult.Append);

                    default:
                        break;
                    }
                }

                return(LogFileCheckResult.Create);                //!!書き込み可能なディレクトリにあることを確認すればなおよし
            }
            catch (Exception ex) {
                GUtil.Warning(parent, ex.Message);
                return(LogFileCheckResult.Error);
            }
        }
        public CommandResult NewConnection(TerminalParam p)
        {
            if (!CheckPaneCount())
            {
                return(CommandResult.Denied);
            }

            ConnectionTag con = null;

            if (p is TCPTerminalParam)
            {
                TCPTerminalParam param = (TCPTerminalParam)p;
                if (param.IsSSH)
                {
                    SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog((SSHTerminalParam)param);
                    if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
                    {
                        con = dlg.Result;
                    }
                }
                else
                {
                    con = CommunicationUtil.CreateNewConnection(param);
                }
            }
            else if (p is SerialTerminalParam)
            {
                SerialTerminalParam param = (SerialTerminalParam)p;
                con = CommunicationUtil.CreateNewSerialConnection(_frame, param);
            }
            else if (p is LocalShellTerminalParam)
            {
                LocalShellTerminalParam param = (LocalShellTerminalParam)p;
                con = CommunicationUtil.CreateNewLocalShellConnection(_frame, param);
            }

            if (con != null)
            {
                AddNewTerminal(con);
                return(CommandResult.Success);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
Beispiel #21
0
        //ダイアログでログファイルを開く
        public static string SelectLogFileByDialog(Form parent)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.AddExtension = true;
            dlg.DefaultExt   = "log";
            dlg.Title        = GApp.Strings.GetString("Util.SelectLogFileByDialog.Caption");
            dlg.Filter       = "Log Files(*.log)|*.log|All Files(*.*)|*.*";
            if (GCUtil.ShowModalDialog(parent, dlg) == DialogResult.OK)
            {
                return(dlg.FileName);
            }
            else
            {
                return(null);
            }
        }
        public CommandResult EmulateUsingLog()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title       = "Emulation Using Log";
            dlg.Multiselect = false;
            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
            {
                //エミュレートによるテスト
                FakeConnection fc = new FakeConnection(TCPTerminalParam.Fake);
                //!!new ConnectionTag()はpublicにしたくない
                AddNewTerminal(new ConnectionTag(fc));
                TestUtil.EmulateWithLog(dlg.FileName, GEnv.Connections.FindTag(fc));
                return(CommandResult.Success);
            }

            return(CommandResult.Cancelled);
        }
        public CommandResult OpenShortCutWithDialog()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title            = GApp.Strings.GetString("Util.OpenShortcutFile");
            dlg.Multiselect      = false;
            dlg.InitialDirectory = GApp.Options.DefaultFileDir;
            dlg.DefaultExt       = "gts";
            dlg.AddExtension     = true;
            dlg.Filter           = "Terminal Shortcut(*.gts)|*.gts|All Files(*.*)|*.*";
            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
            {
                GApp.Options.DefaultFileDir = GUtil.FileToDir(dlg.FileName);
                return(OpenShortCut(dlg.FileName));
            }

            return(CommandResult.Cancelled);
        }
Beispiel #24
0
        public static string SelectPrivateKeyFileByDialog(Form parent)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.CheckFileExists  = true;
            dlg.Multiselect      = false;
            dlg.InitialDirectory = GApp.Options.DefaultKeyDir;
            dlg.Title            = GApp.Strings.GetString("Util.SelectPrivateKey.Caption");
            dlg.Filter           = "Key Files(*.bin;*)|*.bin;*";
            if (GCUtil.ShowModalDialog(parent, dlg) == DialogResult.OK)
            {
                GApp.Options.DefaultKeyDir = FileToDir(dlg.FileName);
                return(dlg.FileName);
            }
            else
            {
                return(null);
            }
        }
        public CommandResult EditRenderProfile()
        {
            ConnectionTag     tag = GEnv.Connections.FindTag(_connection);
            EditRenderProfile dlg = new EditRenderProfile(tag.RenderProfile);

            if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK)
            {
                tag.RenderProfile = dlg.Result;
                GApp.ConnectionHistory.ReplaceIdenticalParam(tag.Connection.Param);
                if (tag.AttachedPane != null)
                {
                    tag.AttachedPane.ApplyRenderProfile(dlg.Result);
                }
                GApp.Frame.AdjustMRUMenu();
                return(CommandResult.Success);
            }
            else
            {
                return(CommandResult.Cancelled);
            }
        }
        public CommandResult NewSerialConnectionWithDialog(SerialTerminalParam param)
        {
            if (!CheckPaneCount())
            {
                return(CommandResult.Denied);
            }

            SerialLoginDialog dlg = new SerialLoginDialog();

            if (param != null)
            {
                dlg.ApplyParam(param);
            }
            else
            {
                dlg.ApplyParam(GApp.ConnectionHistory.TopSerialParam);
            }

            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
            {
                ConnectionTag con = dlg.Result;
                if (con != null)
                {
                    AddNewTerminal(con);
                    return(CommandResult.Success);
                }
            }

            return(CommandResult.Cancelled);


            //XModemReceiver xmodem = new XModemReceiver(GEnv.Connections.ActiveTag, "C:\\IOPort\\xmodemresult.txt");
            //XModemSender xmodem = new XModemSender(GEnv.Connections.ActiveTag, "C:\\IOPort\\xslt.cs");
            //xmodem.Start();

            //return CommandResult.Success;
        }