public void RunCombinedView() { Form form = new Form(); SessionData session = new SessionData { //SessionId = "Test/SessionId", SessionName = "Test SessionName", Username = ScpConfig.UserName, Password = ScpConfig.Password, Host = ScpConfig.KnownHost, Port = 22 }; FileTransferPresenter fileTransferPresenter = new FileTransferPresenter(ScpConfig.DefaultOptions); FileTransferView fileTransferView = new FileTransferView(fileTransferPresenter) { Dock = DockStyle.Bottom }; BrowserView localBrowserView = new BrowserView( new BrowserPresenter("Local", new LocalBrowserModel(), session, fileTransferPresenter), new BrowserFileInfo(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)))); localBrowserView.Dock = DockStyle.Fill; BrowserView remoteBrowserView = new BrowserView( new BrowserPresenter("Remote", new RemoteBrowserModel(ScpConfig.DefaultOptions), session, fileTransferPresenter), RemoteBrowserModel.NewDirectory("/home/" + ScpConfig.UserName)); remoteBrowserView.Dock = DockStyle.Fill; SplitContainer browserPanel = new SplitContainer() { Dock = DockStyle.Fill, SplitterDistance = 75, }; browserPanel.Panel1.Controls.Add(localBrowserView); browserPanel.Panel2.Controls.Add(remoteBrowserView); form.Controls.Add(browserPanel); form.Controls.Add(fileTransferView); form.Size = new Size(1024, 768); form.Show(); }
public PscpBrowserPanel(SessionData session, PscpOptions options, string localStartingDir) : this() { var fileTransferSession = (SessionData) session.Clone(); // if the session doesn't contain a host, a port, or an username // try to get them from the putty profile if ((string.IsNullOrEmpty(fileTransferSession.Username) || string.IsNullOrEmpty(fileTransferSession.Host) || fileTransferSession.Port == 0) && !string.IsNullOrEmpty(fileTransferSession.PuttySession)) { var puttyProfile = PuttyDataHelper.GetSessionData(fileTransferSession.PuttySession); fileTransferSession.Username = string.IsNullOrEmpty(fileTransferSession.Username) ? puttyProfile.Username : fileTransferSession.Username; fileTransferSession.Host = string.IsNullOrEmpty(fileTransferSession.Host) ? puttyProfile.Host : fileTransferSession.Host; fileTransferSession.Port = (fileTransferSession.Port == 0) ? puttyProfile.Port : fileTransferSession.Port; } this.Name = fileTransferSession.SessionName; this.TabText = fileTransferSession.SessionName; this.fileTransferPresenter = new FileTransferPresenter(options); this.localBrowserPresenter = new BrowserPresenter( "Local", new LocalBrowserModel(), fileTransferSession, fileTransferPresenter); this.remoteBrowserPresenter = new BrowserPresenter( "Remote", new RemoteBrowserModel(options), fileTransferSession, fileTransferPresenter); this.browserViewLocal.Initialize(this.localBrowserPresenter, new BrowserFileInfo(new DirectoryInfo(localStartingDir))); this.browserViewRemote.Initialize(this.remoteBrowserPresenter, RemoteBrowserModel.NewDirectory(ScpUtils.GetHomeDirectory(fileTransferSession))); this.fileTransferView.Initialize(this.fileTransferPresenter); }