Browse Source

Additional settings, config refactoring, session caching

tags/v0.4
Scott Barker 1 year ago
parent
commit
4657b3ace1

+ 1
- 0
.gitignore View File

@@ -6,3 +6,4 @@ dist
obj
*ncrunch*
.vs
.user

+ 8
- 0
CHANGELOG.md View File

@@ -1,3 +1,11 @@
v0.4
====
- Cache session names to improve performance on systems with a large number of sessions. Press F5 at the type-ahead window to refresh the cache.
- Add configuration option to limit the max items that are displayed in the suggestion dropdown
- Update the design of the configuration options dialog
- Update the storage mechanism for configuration settings. You will need re-configure the application
- Internal refactoring

v0.3
====
- Add version to config dialog title bar

+ 1
- 1
LICENSE View File

@@ -1,4 +1,4 @@
Copyright (c) 2018 Scott D. Barker
Copyright (c) 2018 Scott D. Barker / Ruckus Software, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

+ 4
- 44
PuttySessionLauncher/PuttySessionLauncher/Configuration.cs View File

@@ -1,54 +1,14 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System;
using System.Windows.Forms;

namespace PuttySessionLauncher
{
[Serializable]
public class Configuration
{
private const string DEFAULT_PUTTY_PATH = @"C:\Program Files\PuTTY\putty.exe";

public string PuttyPath
{
get => _puttyPath ?? DEFAULT_PUTTY_PATH;
set => _puttyPath = value;
}

public string PuttyPath;
public ModifierKeys ModifierKeys;
public Keys Key;
private readonly string _path;
private string _puttyPath;

public Configuration()
{
_path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.txt");
Load();
}

public void Load()
{
if (!File.Exists(_path))
{
ModifierKeys = PuttySessionLauncher.ModifierKeys.Control | PuttySessionLauncher.ModifierKeys.Alt;
Key = Keys.L;
PuttyPath = DEFAULT_PUTTY_PATH;
}
var data = File.ReadLines(_path).ToArray();

PuttySessionLauncher.ModifierKeys.TryParse(data[0], out ModifierKeys modifierKeys);
Keys.TryParse(data[1], out Keys key);
ModifierKeys = modifierKeys;
Key = key;
}

public void Save()
{
File.WriteAllLines(_path, new []
{
ModifierKeys.ToString(),
Key.ToString()
});
}
public int? MaxItems;
}
}

+ 12
- 0
PuttySessionLauncher/PuttySessionLauncher/ConfigurationChangedEventArgs.cs View File

@@ -0,0 +1,12 @@
using System.Windows.Forms;

namespace PuttySessionLauncher
{
public class ConfigurationChangedEventArgs
{
public string PuttyPath;
public ModifierKeys ModifierKeys;
public Keys Key;
public int MaxItems;
}
}

+ 101
- 6
PuttySessionLauncher/PuttySessionLauncher/ConfigurationDialog.Designer.cs View File

@@ -43,6 +43,14 @@
this.buttonPuttyLocation = new System.Windows.Forms.Button();
this.checkBoxRunAtStartup = new System.Windows.Forms.CheckBox();
this.labelRunAtStartup = new System.Windows.Forms.Label();
this.labelCopyright = new PuttySessionLauncher.DisabledLabel();
this.seperator1 = new PuttySessionLauncher.Seperator();
this.labelMaxItems = new System.Windows.Forms.Label();
this.numericUpDownLimit = new System.Windows.Forms.NumericUpDown();
this.checkboxMaxItems = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.linkUrl = new System.Windows.Forms.LinkLabel();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownLimit)).BeginInit();
this.SuspendLayout();
//
// checkboxControl
@@ -77,8 +85,9 @@
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(176, 141);
this.buttonCancel.Location = new System.Drawing.Point(264, 187);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 4;
@@ -88,8 +97,9 @@
//
// buttonSave
//
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.buttonSave.Location = new System.Drawing.Point(257, 141);
this.buttonSave.Location = new System.Drawing.Point(345, 187);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 5;
@@ -141,13 +151,14 @@
this.labelPuttyLocation.Name = "labelPuttyLocation";
this.labelPuttyLocation.Size = new System.Drawing.Size(78, 13);
this.labelPuttyLocation.TabIndex = 10;
this.labelPuttyLocation.Text = "Putty Location:";
this.labelPuttyLocation.Text = "Putty &Location:";
//
// textboxPuttyLocation
//
this.textboxPuttyLocation.Location = new System.Drawing.Point(93, 13);
this.textboxPuttyLocation.Name = "textboxPuttyLocation";
this.textboxPuttyLocation.Size = new System.Drawing.Size(158, 20);
this.textboxPuttyLocation.ReadOnly = true;
this.textboxPuttyLocation.Size = new System.Drawing.Size(246, 20);
this.textboxPuttyLocation.TabIndex = 11;
//
// openFileDialog1
@@ -156,7 +167,7 @@
//
// buttonPuttyLocation
//
this.buttonPuttyLocation.Location = new System.Drawing.Point(257, 12);
this.buttonPuttyLocation.Location = new System.Drawing.Point(345, 11);
this.buttonPuttyLocation.Name = "buttonPuttyLocation";
this.buttonPuttyLocation.Size = new System.Drawing.Size(75, 23);
this.buttonPuttyLocation.TabIndex = 12;
@@ -182,13 +193,89 @@
this.labelRunAtStartup.TabIndex = 14;
this.labelRunAtStartup.Text = "&Run at Startup";
//
// labelCopyright
//
this.labelCopyright.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.labelCopyright.Cursor = System.Windows.Forms.Cursors.Hand;
this.labelCopyright.Location = new System.Drawing.Point(2, 225);
this.labelCopyright.Name = "labelCopyright";
this.labelCopyright.Size = new System.Drawing.Size(418, 28);
this.labelCopyright.TabIndex = 15;
this.labelCopyright.Text = "Copyright © 2018 Scott D. Barker / Ruckus Software, LLC.\r\nVersion ${version}. Lic" +
"ensed under the MIT License";
this.labelCopyright.Click += new System.EventHandler(this.labelCopyright_Click);
//
// seperator1
//
this.seperator1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.seperator1.Location = new System.Drawing.Point(1, 220);
this.seperator1.MaximumSize = new System.Drawing.Size(2000, 2);
this.seperator1.MinimumSize = new System.Drawing.Size(0, 2);
this.seperator1.Name = "seperator1";
this.seperator1.Size = new System.Drawing.Size(429, 2);
this.seperator1.TabIndex = 16;
//
// labelMaxItems
//
this.labelMaxItems.AutoSize = true;
this.labelMaxItems.Location = new System.Drawing.Point(9, 142);
this.labelMaxItems.Name = "labelMaxItems";
this.labelMaxItems.Size = new System.Drawing.Size(58, 13);
this.labelMaxItems.TabIndex = 17;
this.labelMaxItems.Text = "Max Items:";
//
// numericUpDownLimit
//
this.numericUpDownLimit.Location = new System.Drawing.Point(114, 138);
this.numericUpDownLimit.Name = "numericUpDownLimit";
this.numericUpDownLimit.Size = new System.Drawing.Size(38, 20);
this.numericUpDownLimit.TabIndex = 18;
//
// checkboxMaxItems
//
this.checkboxMaxItems.AutoSize = true;
this.checkboxMaxItems.Location = new System.Drawing.Point(93, 141);
this.checkboxMaxItems.Name = "checkboxMaxItems";
this.checkboxMaxItems.Size = new System.Drawing.Size(15, 14);
this.checkboxMaxItems.TabIndex = 19;
this.checkboxMaxItems.UseVisualStyleBackColor = true;
this.checkboxMaxItems.CheckedChanged += new System.EventHandler(this.checkboxMaxItems_CheckedChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(161, 138);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(259, 42);
this.label1.TabIndex = 20;
this.label1.Text = "Limits the maxinum number of items visible in the dropdown at one time. All item" +
"s are still considered for searching.";
//
// linkUrl
//
this.linkUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkUrl.AutoSize = true;
this.linkUrl.Location = new System.Drawing.Point(2, 253);
this.linkUrl.Name = "linkUrl";
this.linkUrl.Size = new System.Drawing.Size(266, 13);
this.linkUrl.TabIndex = 21;
this.linkUrl.TabStop = true;
this.linkUrl.Text = "http://git.sdbarker.com/sdbarker/puttysessionlauncher";
this.linkUrl.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkUrl_LinkClicked);
//
// ConfigurationDialog
//
this.AcceptButton = this.buttonSave;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(344, 176);
this.ClientSize = new System.Drawing.Size(432, 272);
this.Controls.Add(this.linkUrl);
this.Controls.Add(this.label1);
this.Controls.Add(this.checkboxMaxItems);
this.Controls.Add(this.numericUpDownLimit);
this.Controls.Add(this.labelMaxItems);
this.Controls.Add(this.seperator1);
this.Controls.Add(this.labelCopyright);
this.Controls.Add(this.labelRunAtStartup);
this.Controls.Add(this.checkBoxRunAtStartup);
this.Controls.Add(this.buttonPuttyLocation);
@@ -207,6 +294,7 @@
this.Name = "ConfigurationDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Putty Session Launcher Configuration";
((System.ComponentModel.ISupportInitialize)(this.numericUpDownLimit)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

@@ -229,5 +317,12 @@
private System.Windows.Forms.Button buttonPuttyLocation;
private System.Windows.Forms.CheckBox checkBoxRunAtStartup;
private System.Windows.Forms.Label labelRunAtStartup;
private DisabledLabel labelCopyright;
private Seperator seperator1;
private System.Windows.Forms.Label labelMaxItems;
private System.Windows.Forms.NumericUpDown numericUpDownLimit;
private System.Windows.Forms.CheckBox checkboxMaxItems;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.LinkLabel linkUrl;
}
}

+ 54
- 12
PuttySessionLauncher/PuttySessionLauncher/ConfigurationDialog.cs View File

@@ -1,7 +1,10 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Win32;
using PuttySessionLauncher.Properties;

namespace PuttySessionLauncher
{
@@ -12,19 +15,27 @@ namespace PuttySessionLauncher

private const string RUN_REGISTRY_PATH = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
private const string REGISTRY_APP_NAME = "PuttySessionLauncher";
private RegistryKey _runRegistryKey = Registry.CurrentUser.OpenSubKey(RUN_REGISTRY_PATH, true);
private const string PUTTY_EXECUTABLE_FILTER = "putty.exe|putty.exe";
private const string PUTTY_EXECUTABLE_NAME = "putty.exe";

private readonly RegistryKey _runRegistryKey = Registry.CurrentUser.OpenSubKey(RUN_REGISTRY_PATH, true);

public ConfigurationDialog()
{
InitializeComponent();

openFileDialog1.Filter = PUTTY_EXECUTABLE_FILTER;
openFileDialog1.FileName = PUTTY_EXECUTABLE_NAME;

foreach (var k in Enum.GetNames(typeof(Keys)))
{
comboboxKey.Items.Add(k);
}

var version = Assembly.GetExecutingAssembly().GetName().Version;
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
Text = $"{Text} - {version}";

labelCopyright.Text = labelCopyright.Text.Replace("${version}", version);
}

public ConfigurationDialog(Configuration config) : this()
@@ -51,6 +62,19 @@ namespace PuttySessionLauncher
checkboxShift.Checked = true;
}

if (config.MaxItems != null)
{
checkboxMaxItems.Checked = true;
numericUpDownLimit.Value = config.MaxItems.Value;
numericUpDownLimit.Enabled = true;
}
else
{
checkboxMaxItems.Checked = false;
numericUpDownLimit.Enabled = false;
numericUpDownLimit.Value = 0;
}

checkBoxRunAtStartup.Checked = !string.IsNullOrEmpty(_runRegistryKey?.GetValue(REGISTRY_APP_NAME)?.ToString());

comboboxKey.SelectedIndex = comboboxKey.FindStringExact(config.Key.ToString());
@@ -84,17 +108,25 @@ namespace PuttySessionLauncher

if (checkBoxRunAtStartup.Checked)
{
_runRegistryKey.SetValue("PuttySessionLauncher", Application.ExecutablePath);
_runRegistryKey.SetValue(REGISTRY_APP_NAME, Application.ExecutablePath);
}
else
{
_runRegistryKey.DeleteValue("PuttySessionLauncher", false);
_runRegistryKey.DeleteValue(REGISTRY_APP_NAME, false);
}

int maxItems = 0;
if (checkboxMaxItems.Checked)
{
maxItems = Convert.ToInt16(numericUpDownLimit.Value);
}

ConfigurationChangedEvent?.Invoke(this, new ConfigurationChangedEventArgs
{
PuttyPath = textboxPuttyLocation.Text,
ModifierKeys = modifierMask,
Key = key
Key = key,
MaxItems = maxItems
});

Close();
@@ -111,13 +143,23 @@ namespace PuttySessionLauncher
{
textboxPuttyLocation.Text = openFileDialog1.FileName;
}

buttonSave.Enabled = File.Exists(textboxPuttyLocation.Text);
}
}

public class ConfigurationChangedEventArgs
{
public string PuttyPath { get; set; }
public ModifierKeys ModifierKeys;
public Keys Key;
private void labelCopyright_Click(object sender, EventArgs e)
{
Process.Start(Resources.Url);
}

private void checkboxMaxItems_CheckedChanged(object sender, EventArgs e)
{
numericUpDownLimit.Enabled = checkboxMaxItems.Checked;
}

private void linkUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start(Resources.Url);
}
}
}
}

+ 74
- 0
PuttySessionLauncher/PuttySessionLauncher/ConfigurationManager.cs View File

@@ -0,0 +1,74 @@
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using PuttySessionLauncher.Properties;

namespace PuttySessionLauncher
{
public class ConfigurationManager
{
private const string DEFAULT_PUTTY_PATH = @"C:\Program Files\PuTTY\putty.exe";

public Configuration Config
{
get => _config;
set => _config = value;
}

private readonly string _configFilePath;

private Configuration _config = new Configuration();

public ConfigurationManager()
{
_configFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.psl");
Load();
}

public void Load()
{
_config = new Configuration
{
PuttyPath = DEFAULT_PUTTY_PATH,
ModifierKeys = ModifierKeys.Control | ModifierKeys.Alt,
Key = Keys.L,
MaxItems = null
};

if (!File.Exists(_configFilePath))
{
return;
}

try
{
using (var fs = File.Open(_configFilePath, FileMode.Open, FileAccess.Read))
{
var bf = new BinaryFormatter();
_config = (Configuration) bf.Deserialize(fs);
fs.Flush();
}
}
catch (IOException)
{
MessageBox.Show(Resources.ConfigurationManagerIOExceptionText, Resources.ConfigurationManagerErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (SerializationException)
{
MessageBox.Show(Resources.ConfigurationManagerSerializationExceptionText, Resources.ConfigurationManagerErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

public void Save()
{
using (var fs = File.Open(_configFilePath, FileMode.Create, FileAccess.Write))
{
var bf = new BinaryFormatter();
bf.Serialize(fs, _config);
fs.Flush();
}
}
}
}

+ 17
- 0
PuttySessionLauncher/PuttySessionLauncher/DisabledLabel.cs View File

@@ -0,0 +1,17 @@
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Windows.Forms;

namespace PuttySessionLauncher
{
[ExcludeFromCodeCoverage]
public class DisabledLabel : Label
{
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.Clear(BackColor);
e.Graphics.DrawString(Text, Font, SystemBrushes.ControlLightLight, new PointF(1, 1));
e.Graphics.DrawString(Text, Font, SystemBrushes.ControlDark, new PointF(0, 0));
}
}
}

+ 45
- 29
PuttySessionLauncher/PuttySessionLauncher/Main.cs View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using PuttySessionLauncher.MatchingAlgorithms;
@@ -14,7 +16,9 @@ namespace PuttySessionLauncher
private readonly IMatchingAlgorithm _matcher = new JaccardCoefficient();

private KeyboardHook _hook = new KeyboardHook();
private readonly Configuration _config = new Configuration();
private readonly ConfigurationManager _configManager = new ConfigurationManager();

private string _lastSession;

public Main()
{
@@ -32,13 +36,17 @@ namespace PuttySessionLauncher

comboBoxSessions.Items.AddRange(sessions);

var icon = File.Exists(_configManager.Config.PuttyPath)
? Icon.ExtractAssociatedIcon(_configManager.Config.PuttyPath)
: Icon;

_notifyIcon = new NotifyIcon
{
Icon = Icon.ExtractAssociatedIcon(_config.PuttyPath),
Icon = icon,
ContextMenu = new ContextMenu(new[]
{
new MenuItem("Show/Hide", notifyIcon_ShowHide_Click),
new MenuItem("Config", notifyIcon_Config_Click),
new MenuItem("Configuration", notifyIcon_Config_Click),
new MenuItem("Exit", notifyIcon_Exit_Click)
}),
Visible = true
@@ -55,19 +63,23 @@ namespace PuttySessionLauncher
{
_hook.Dispose();
_hook = new KeyboardHook();
_hook.RegisterHotKey(_config.ModifierKeys, _config.Key);
_hook.RegisterHotKey(_configManager.Config.ModifierKeys, _configManager.Config.Key);
_hook.KeyPressed += showTypeAhead_HotkeyPressed;

_puttySessionProvider.PuttyPath = _config.PuttyPath;
_puttySessionProvider.PuttyPath = _configManager.Config.PuttyPath;
}

private void configurationChanged(ConfigurationChangedEventArgs args)
{
_config.ModifierKeys = args.ModifierKeys;
_config.Key = args.Key;
_config.PuttyPath = args.PuttyPath;
_configManager.Config = new Configuration
{
PuttyPath = args.PuttyPath,
ModifierKeys = args.ModifierKeys,
Key = args.Key,
MaxItems = args.MaxItems,
};

_config.Save();
_configManager.Save();
applyConfiguration();
}

@@ -79,7 +91,7 @@ namespace PuttySessionLauncher
return;
}

setAutocomplete();
setAutocomplete(_lastSession, true);
showWindow();
}

@@ -101,14 +113,14 @@ namespace PuttySessionLauncher
comboBoxSessions.DroppedDown = true;
}

private void setAutocomplete(string search = "")
private void setAutocomplete(string search = "", bool usingLastSession = false)
{
while (comboBoxSessions.Items.Count > 0)
{
comboBoxSessions.Items.RemoveAt(0);
}

ScoredComboxItem[] sessions;
IEnumerable<ScoredComboxItem> sessions;
if (string.IsNullOrEmpty(search))
{
sessions = _puttySessionProvider
@@ -117,8 +129,7 @@ namespace PuttySessionLauncher
{
DisplayText = s,
Value = s
})
.ToArray();
});
}
else
{
@@ -127,15 +138,26 @@ namespace PuttySessionLauncher
.OrderByDescending(s => _matcher.Score(s, search))
.Select(s => new ScoredComboxItem
{
// Enabling this will show the score after the item
// DisplayText = $"{s} [{_matcher.Score(s, search)}]",
DisplayText = s,
Value = s,
Score = _matcher.Score(s, search)
})
.ToArray();
});
}

comboBoxSessions.Items.AddRange(sessions);
if (_configManager.Config.MaxItems > 0)
{
sessions = sessions.Take(_configManager.Config.MaxItems.Value);
}

comboBoxSessions.Items.AddRange(sessions.ToArray());

if (usingLastSession)
{
comboBoxSessions.Text = search;
comboBoxSessions.SelectAll();
}
}

private void launchSession(string session)
@@ -174,11 +196,13 @@ namespace PuttySessionLauncher
if (e.Control)
{
var hostname = comboBoxSessions.Text;
_lastSession = hostname;
launchConnection(hostname);
}
else
{
var selectedItem = (ScoredComboxItem)comboBoxSessions.SelectedItem;
_lastSession = selectedItem.Value;
launchSession(selectedItem.Value);
}
e.Handled = true;
@@ -187,6 +211,10 @@ namespace PuttySessionLauncher
hideWindow();
e.Handled = true;
break;
case Keys.F5:
_puttySessionProvider.RefreshSessions();
e.Handled = true;
break;
}
}

@@ -210,16 +238,4 @@ namespace PuttySessionLauncher
setAutocomplete(comboBoxSessions.Text);
}
}

public class ScoredComboxItem
{
public double Score;
public string Value;
public string DisplayText;

public override string ToString()
{
return DisplayText;
}
}
}

+ 12
- 8
PuttySessionLauncher/PuttySessionLauncher/NotifyIconHandlers.cs View File

@@ -4,6 +4,8 @@ namespace PuttySessionLauncher
{
public partial class Main
{
private ConfigurationDialog _configDialog;

private void notifyIcon_ShowHide_Click(object sender, EventArgs e)
{
showTypeAhead_HotkeyPressed(null, null);
@@ -11,18 +13,20 @@ namespace PuttySessionLauncher

private void notifyIcon_Config_Click(object sender, EventArgs e)
{
var configDialog = new ConfigurationDialog(_config);
configDialog.ConfigurationChangedEvent += (o, args) =>
{
configurationChanged(args);
};
if (_configDialog == null) {
_configDialog = new ConfigurationDialog(_configManager.Config);
_configDialog.ConfigurationChangedEvent += (o, args) =>
{
configurationChanged(args);
};
}

configDialog.Show();
_configDialog.Show();
}

private static void notifyIcon_Exit_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
}
}
}

+ 1
- 1
PuttySessionLauncher/PuttySessionLauncher/Properties/AssemblyInfo.cs View File

@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.3.0")]
[assembly: AssemblyVersion("0.4.0")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]

+ 90
- 60
PuttySessionLauncher/PuttySessionLauncher/Properties/Resources.Designer.cs View File

@@ -8,64 +8,94 @@
// </auto-generated>
//------------------------------------------------------------------------------

namespace PuttySessionLauncher.Properties
{


/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{

private static global::System.Resources.ResourceManager resourceMan;

private static global::System.Globalization.CultureInfo resourceCulture;

[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}

/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PuttySessionLauncher.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}

/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
namespace PuttySessionLauncher.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PuttySessionLauncher.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Configuration Load Error.
/// </summary>
internal static string ConfigurationManagerErrorTitle {
get {
return ResourceManager.GetString("ConfigurationManagerErrorTitle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Configuration file could not be read. The configuration file either does not exist, or you may not have permissions to read it.
///
///Please close the application and retry, or reconfigure the application.
/// </summary>
internal static string ConfigurationManagerIOExceptionText {
get {
return ResourceManager.GetString("ConfigurationManagerIOExceptionText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Configuration file is corrupt. Please reconfigure the application and save your new settings..
/// </summary>
internal static string ConfigurationManagerSerializationExceptionText {
get {
return ResourceManager.GetString("ConfigurationManagerSerializationExceptionText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://git.sdbarker.com/sdbarker/puttysessionlauncher.
/// </summary>
internal static string Url {
get {
return ResourceManager.GetString("Url", resourceCulture);
}
}
}
}

+ 22
- 5
PuttySessionLauncher/PuttySessionLauncher/Properties/Resources.resx View File

@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@@ -109,9 +112,23 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ConfigurationManagerErrorTitle" xml:space="preserve">
<value>Configuration Load Error</value>
</data>
<data name="ConfigurationManagerIOExceptionText" xml:space="preserve">
<value>Configuration file could not be read. The configuration file either does not exist, or you may not have permissions to read it.

Please close the application and retry, or reconfigure the application</value>
</data>
<data name="ConfigurationManagerSerializationExceptionText" xml:space="preserve">
<value>Configuration file is corrupt. Please reconfigure the application and save your new settings.</value>
</data>
<data name="Url" xml:space="preserve">
<value>https://git.sdbarker.com/sdbarker/puttysessionlauncher</value>
</data>
</root>

+ 11
- 1
PuttySessionLauncher/PuttySessionLauncher/PuttySessionLauncher.csproj View File

@@ -49,13 +49,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration.cs" />
<Compile Include="ConfigurationChangedEventArgs.cs" />
<Compile Include="ConfigurationDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConfigurationDialog.Designer.cs">
<DependentUpon>ConfigurationDialog.cs</DependentUpon>
</Compile>
<Compile Include="Configuration.cs" />
<Compile Include="ConfigurationManager.cs" />
<Compile Include="DisabledLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="KeyPressedEventArgs.cs" />
<Compile Include="MatchingAlgorithms\DamerauLevenshteinDistance.cs" />
<Compile Include="MatchingAlgorithms\HammingDistance.cs" />
@@ -80,6 +85,10 @@
<Compile Include="PuttySessionProvider.cs" />
<Compile Include="MatchingAlgorithms\RatcliffObershelpSimilarity.cs" />
<Compile Include="MatchingAlgorithms\SorensenDiceCoefficient.cs" />
<Compile Include="ScoredComboxItem.cs" />
<Compile Include="Seperator.cs">
<SubType>UserControl</SubType>
</Compile>
<EmbeddedResource Include="ConfigurationDialog.resx">
<DependentUpon>ConfigurationDialog.cs</DependentUpon>
</EmbeddedResource>
@@ -94,6 +103,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">

+ 12
- 1
PuttySessionLauncher/PuttySessionLauncher/PuttySessionProvider.cs View File

@@ -13,14 +13,17 @@ namespace PuttySessionLauncher
public string PuttyPath { get; set; }
private readonly RegistryKey _registryKey;

private readonly List<string> _sessions = new List<string>();

public PuttySessionProvider()
{
_registryKey = Registry.CurrentUser.OpenSubKey(@"Software\SimonTatham\PuTTY\Sessions\");
RefreshSessions();
}

public IEnumerator<string> GetEnumerator()
{
return ((IEnumerable<string>) _registryKey.GetSubKeyNames()).GetEnumerator();
return _sessions.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
@@ -28,6 +31,14 @@ namespace PuttySessionLauncher
return GetEnumerator();
}

public void RefreshSessions()
{
foreach (var session in _registryKey.GetSubKeyNames())
{
_sessions.Add(session);
}
}

public void LaunchConnection(string hostname)
{
var puttyProcess = getPuttyProcess();

+ 14
- 0
PuttySessionLauncher/PuttySessionLauncher/ScoredComboxItem.cs View File

@@ -0,0 +1,14 @@
namespace PuttySessionLauncher
{
public class ScoredComboxItem
{
public double Score;
public string Value;
public string DisplayText;

public override string ToString()
{
return DisplayText;
}
}
}

+ 23
- 0
PuttySessionLauncher/PuttySessionLauncher/Seperator.cs View File

@@ -0,0 +1,23 @@
using System.Drawing;
using System.Windows.Forms;

namespace PuttySessionLauncher
{
public partial class Seperator : UserControl
{
public Seperator()
{
this.Paint += new PaintEventHandler(LineSeparator_Paint);
this.MaximumSize = new Size(2000, 2);
this.MinimumSize = new Size(0, 2);
this.Width = 350;
}

private void LineSeparator_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawLine(Pens.DarkGray, new Point(0, 0), new Point(this.Width, 0));
g.DrawLine(Pens.White, new Point(0, 1), new Point(this.Width, 1));
}
}
}

+ 0
- 1
PuttySessionLauncher/PuttySessionLauncher/app.manifest View File

@@ -16,7 +16,6 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

+ 2
- 2
install.nsi View File

@@ -26,7 +26,7 @@ InstallDir "$PROGRAMFILES\${Vendor}\${Title}"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${Vendor}\${Title}" ""

RequestExecutionLevel admin
;RequestExecutionLevel admin

;--------------------------------
;Interface Settings
@@ -58,7 +58,7 @@ Section "${Title}" SecMain
CreateDirectory "$INSTDIR"

File "PuttySessionLauncher\PuttySessionLauncher\bin\Release\${Binary}"
File "PuttySessionLauncher\PuttySessionLauncher\bin\Release\config.txt"
# File "PuttySessionLauncher\PuttySessionLauncher\bin\Release\config.txt"
SectionEnd

Section "Start Menu Shortcuts" SecShortcuts

Loading…
Cancel
Save