public static ITabSwitchStrategy StrategyFromTypeName(String typeName) { if (Strategies == null) { List <ITabSwitchStrategy> strats = new List <ITabSwitchStrategy> { new VisualOrderTabSwitchStrategy(), new OpenOrderTabSwitchStrategy(), new MRUTabSwitchStrategy() }; Strategies = strats.ToArray(); } ITabSwitchStrategy strategy = Strategies[0]; try { Type t = Type.GetType(typeName); if (t != null) { strategy = (ITabSwitchStrategy)Activator.CreateInstance(t); } } catch (Exception ex) { Log.Error("Error parsing strategy, defaulting to Visual: typeName=" + typeName, ex); } return(strategy); }
public static ITabSwitchStrategy StrategyFromTypeName(String typeName) { ITabSwitchStrategy strategy = Strategies[0]; try { Type t = Type.GetType(typeName); if (t != null) { strategy = (ITabSwitchStrategy)Activator.CreateInstance(t); } } catch (Exception ex) { Log.Error("Error parsing strategy, defaulting to Visual: typeName=" + typeName, ex); } return(strategy); }
public dlgFindPutty() { InitializeComponent(); string puttyExe = SuperPuTTY.Settings.PuttyExe; string pscpExe = SuperPuTTY.Settings.PscpExe; bool firstExecution = String.IsNullOrEmpty(puttyExe); textBoxFilezillaLocation.Text = getPathExe(@"\FileZilla FTP Client\filezilla.exe", SuperPuTTY.Settings.FileZillaExe, firstExecution); textBoxWinSCPLocation.Text = getPathExe(@"\WinSCP\WinSCP.exe", SuperPuTTY.Settings.WinSCPExe, firstExecution); textBoxVNCLocation.Text = getPathExe(@"\TightVNC\tvnviewer.exe", SuperPuTTY.Settings.VNCExe, firstExecution); textBoxRDPLocation.Text = getPathExe(Environment.ExpandEnvironmentVariables("%systemroot%\\system32\\mstsc.exe"), SuperPuTTY.Settings.RDPExe, firstExecution); // check for location of putty/pscp if (!String.IsNullOrEmpty(puttyExe) && File.Exists(puttyExe)) { textBoxPuttyLocation.Text = puttyExe; if (!String.IsNullOrEmpty(pscpExe) && File.Exists(pscpExe)) { textBoxPscpLocation.Text = pscpExe; } } else if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("ProgramFiles(x86)"))) { if (File.Exists(Environment.GetEnvironmentVariable("ProgramFiles(x86)") + @"\PuTTY\putty.exe")) { textBoxPuttyLocation.Text = Environment.GetEnvironmentVariable("ProgramFiles(x86)") + @"\PuTTY\putty.exe"; openFileDialog1.InitialDirectory = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); } if (File.Exists(Environment.GetEnvironmentVariable("ProgramFiles(x86)") + @"\PuTTY\pscp.exe")) { textBoxPscpLocation.Text = Environment.GetEnvironmentVariable("ProgramFiles(x86)") + @"\PuTTY\pscp.exe"; } } else if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("ProgramFiles"))) { if (File.Exists(Environment.GetEnvironmentVariable("ProgramFiles") + @"\PuTTY\putty.exe")) { textBoxPuttyLocation.Text = Environment.GetEnvironmentVariable("ProgramFiles") + @"\PuTTY\putty.exe"; openFileDialog1.InitialDirectory = Environment.GetEnvironmentVariable("ProgramFiles"); } if (File.Exists(Environment.GetEnvironmentVariable("ProgramFiles") + @"\PuTTY\pscp.exe")) { textBoxPscpLocation.Text = Environment.GetEnvironmentVariable("ProgramFiles") + @"\PuTTY\pscp.exe"; } } else { openFileDialog1.InitialDirectory = Application.StartupPath; } if (String.IsNullOrEmpty(SuperPuTTY.Settings.MinttyExe)) { if (File.Exists(@"C:\cygwin\bin\mintty.exe")) { this.textBoxMinttyLocation.Text = @"C:\cygwin\bin\mintty.exe"; } if (File.Exists(@"C:\cygwin64\bin\mintty.exe")) { this.textBoxMinttyLocation.Text = @"C:\cygwin64\bin\mintty.exe"; } } else { this.textBoxMinttyLocation.Text = SuperPuTTY.Settings.MinttyExe; } // super putty settings (sessions and layouts) if (String.IsNullOrEmpty(SuperPuTTY.Settings.SettingsFolder)) { // Set a default string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SuperPuTTY"); if (!Directory.Exists(dir)) { Log.InfoFormat("Creating default settings dir: {0}", dir); Directory.CreateDirectory(dir); } this.textBoxSettingsFolder.Text = dir; } else { this.textBoxSettingsFolder.Text = SuperPuTTY.Settings.SettingsFolder; } this.OrigSettingsFolder = SuperPuTTY.Settings.SettingsFolder; // tab text foreach (String s in Enum.GetNames(typeof(frmSuperPutty.TabTextBehavior))) { this.comboBoxTabText.Items.Add(s); } this.comboBoxTabText.SelectedItem = SuperPuTTY.Settings.TabTextBehavior; // tab switcher ITabSwitchStrategy selectedItem = null; foreach (ITabSwitchStrategy strat in TabSwitcher.Strategies) { this.comboBoxTabSwitching.Items.Add(strat); if (strat.GetType().FullName == SuperPuTTY.Settings.TabSwitcher) { selectedItem = strat; } } this.comboBoxTabSwitching.SelectedItem = selectedItem ?? TabSwitcher.Strategies[0]; // activator types this.comboBoxActivatorType.Items.Add(typeof(KeyEventWindowActivator).FullName); this.comboBoxActivatorType.Items.Add(typeof(CombinedWindowActivator).FullName); this.comboBoxActivatorType.Items.Add(typeof(SetFGWindowActivator).FullName); this.comboBoxActivatorType.Items.Add(typeof(RestoreWindowActivator).FullName); this.comboBoxActivatorType.Items.Add(typeof(SetFGAttachThreadWindowActivator).FullName); this.comboBoxActivatorType.SelectedItem = SuperPuTTY.Settings.WindowActivator; // search types foreach (string name in Enum.GetNames(typeof(SessionTreeview.SearchMode))) { this.comboSearchMode.Items.Add(name); } this.comboSearchMode.SelectedItem = SuperPuTTY.Settings.SessionsSearchMode; // default layouts InitLayouts(); this.checkSingleInstanceMode.Checked = SuperPuTTY.Settings.SingleInstanceMode; this.checkConstrainPuttyDocking.Checked = SuperPuTTY.Settings.RestrictContentToDocumentTabs; this.checkRestoreWindow.Checked = SuperPuTTY.Settings.RestoreWindowLocation; this.checkExitConfirmation.Checked = SuperPuTTY.Settings.ExitConfirmation; this.checkExpandTree.Checked = SuperPuTTY.Settings.ExpandSessionsTreeOnStartup; this.checkMinimizeToTray.Checked = SuperPuTTY.Settings.MinimizeToTray; this.checkSessionsTreeShowLines.Checked = SuperPuTTY.Settings.SessionsTreeShowLines; this.checkConfirmTabClose.Checked = SuperPuTTY.Settings.MultipleTabCloseConfirmation; this.checkEnableControlTabSwitching.Checked = SuperPuTTY.Settings.EnableControlTabSwitching; this.checkEnableKeyboardShortcuts.Checked = SuperPuTTY.Settings.EnableKeyboadShortcuts; this.btnFont.Font = SuperPuTTY.Settings.SessionsTreeFont; this.btnFont.Text = ToShortString(SuperPuTTY.Settings.SessionsTreeFont); this.numericUpDownOpacity.Value = (decimal)SuperPuTTY.Settings.Opacity * 100; this.checkQuickSelectorCaseSensitiveSearch.Checked = SuperPuTTY.Settings.QuickSelectorCaseSensitiveSearch; this.checkShowDocumentIcons.Checked = SuperPuTTY.Settings.ShowDocumentIcons; this.checkRestrictFloatingWindows.Checked = SuperPuTTY.Settings.DockingRestrictFloatingWindows; this.checkSessionsShowSearch.Checked = SuperPuTTY.Settings.SessionsShowSearch; this.checkFilterWhileTyping.Checked = SuperPuTTY.Settings.FilterSessionsOnChange; this.checkPuttyEnableNewSessionMenu.Checked = SuperPuTTY.Settings.PuttyPanelShowNewSessionMenu; this.checkBoxCheckForUpdates.Checked = SuperPuTTY.Settings.AutoUpdateCheck; this.textBoxHomeDirPrefix.Text = SuperPuTTY.Settings.PscpHomePrefix; this.textBoxRootDirPrefix.Text = SuperPuTTY.Settings.PscpRootHomePrefix; this.checkSessionTreeFoldersFirst.Checked = SuperPuTTY.Settings.SessiontreeShowFoldersFirst; this.checkBoxPersistTsHistory.Checked = SuperPuTTY.Settings.PersistCommandBarHistory; this.numericUpDown1.Value = SuperPuTTY.Settings.SaveCommandHistoryDays; this.checkBoxAllowPuttyPWArg.Checked = SuperPuTTY.Settings.AllowPlainTextPuttyPasswordArg; this.textBoxPuttyDefaultParameters.Text = SuperPuTTY.Settings.PuttyDefaultParameters; if (SuperPuTTY.IsFirstRun) { this.ShowIcon = true; this.ShowInTaskbar = true; } // shortcuts this.Shortcuts = new BindingList <KeyboardShortcut>(); foreach (KeyboardShortcut ks in SuperPuTTY.Settings.LoadShortcuts()) { this.Shortcuts.Add(ks); } this.dataGridViewShortcuts.DataSource = this.Shortcuts; }