public static GetIconForSession ( SessionData session ) : |
||
session | SessionData | The session configuration data |
리턴 |
public static ctlPuttyPanel FromPersistString(String persistString) { ctlPuttyPanel panel = null; if (persistString.StartsWith(typeof(ctlPuttyPanel).FullName)) { int idx = persistString.IndexOf("?"); if (idx != -1) { NameValueCollection data = HttpUtility.ParseQueryString(persistString.Substring(idx + 1)); string sessionId = data["SessionId"] ?? data["SessionName"]; string tabName = data["TabName"]; Log.InfoFormat("Restoring putty session, sessionId={0}, tabName={1}", sessionId, tabName); SessionData session = SuperPuTTY.GetSessionById(sessionId); if (session != null) { panel = ctlPuttyPanel.NewPanel(session); if (panel == null) { Log.WarnFormat("Could not restore putty session, sessionId={0}", sessionId); } else { panel.Icon = SuperPuTTY.GetIconForSession(session); panel.Text = tabName; panel.TextOverride = tabName; } } else { Log.WarnFormat("Session not found, sessionId={0}", sessionId); } } else { idx = persistString.IndexOf(":"); if (idx != -1) { string sessionId = persistString.Substring(idx + 1); Log.InfoFormat("Restoring putty session, sessionId={0}", sessionId); SessionData session = SuperPuTTY.GetSessionById(sessionId); if (session != null) { panel = ctlPuttyPanel.NewPanel(session); } else { Log.WarnFormat("Session not found, sessionId={0}", sessionId); } } } } return(panel); }
private void UpdateTitle() { ctlPuttyPanel panel = (ctlPuttyPanel)this.Parent; int length = NativeMethods.SendMessage(m_AppWin, NativeMethods.WM_GETTEXTLENGTH, 0, 0) + 1; StringBuilder sb = new StringBuilder(length + 1); NativeMethods.SendMessage(m_AppWin, NativeMethods.WM_GETTEXT, sb.Capacity, sb); string controlText = sb.ToString(); string parentText = panel.TextOverride; switch ((SuperPutty.frmSuperPutty.TabTextBehavior)Enum.Parse(typeof(frmSuperPutty.TabTextBehavior), SuperPuTTY.Settings.TabTextBehavior)) { case frmSuperPutty.TabTextBehavior.Static: this.Parent.Text = parentText; break; case frmSuperPutty.TabTextBehavior.Dynamic: this.Parent.Text = controlText; break; case frmSuperPutty.TabTextBehavior.Mixed: this.Parent.Text = parentText + ": " + controlText; break; } // putty/kitty tab became inactive if (!panel.inactive && controlText.EndsWith("TTY (inactive)")) { Icon icon = null; string imageKey = (SuperPuTTY.Images.Images.ContainsKey("dead")) ? "dead" : null; try { Image img = SuperPuTTY.Images.Images[imageKey]; Bitmap bmp = img as Bitmap; if (bmp != null) { icon = Icon.FromHandle(bmp.GetHicon()); } } catch (Exception ex) { Log.Error("Error getting icon for dead tab", ex); } panel.inactive = true; panel.Icon = icon; panel.AdjustMenu(); panel.Pane.Refresh(); } else if (panel.inactive && !controlText.EndsWith("TTY (inactive)")) { panel.inactive = false; panel.Icon = SuperPuTTY.GetIconForSession(panel.Session); panel.AdjustMenu(); panel.Pane.Refresh(); } }