IseHg.psm1
#region Custom Prompt class # Declare custom class. Used code from here: http://stackoverflow.com/questions/5427020/prompt-dialog-in-windows-forms try { [SullivanSoft.Prompt] } catch { $CustomPrompt = @" using System.Windows.Forms; namespace SullivanSoft { public static class Prompt { public static string ShowDialog(string text, string caption) { Form prompt = new Form(); prompt.Width = 500; prompt.Height = 150; prompt.Text = caption; prompt.StartPosition = FormStartPosition.CenterScreen; Label textLabel = new Label() { Left = 50, Top=20, Text=text }; TextBox textBox = new TextBox() { Left = 50, Top=50, Width=400 }; Button confirmation = new Button() { Text = "Ok", Left=350, Width=100, Top=70 }; confirmation.Click += (sender, e) => { prompt.Close(); }; prompt.Controls.Add(textBox); prompt.Controls.Add(confirmation); prompt.Controls.Add(textLabel); prompt.AcceptButton = confirmation; prompt.ShowDialog(); return textBox.Text; } } } "@ Add-Type -TypeDefinition $CustomPrompt -ReferencedAssemblies System.Windows.Forms; } #endregion #region Import supporting scripts $FileList = Get-ChildItem -Path $PSScriptRoot\MenuItems -Filter *.ps1 | Sort-Object -Property Name; foreach ($File in $FileList) { #Write-Host -Object ('Importing file: {0}' -f $File.FullName) -ForegroundColor Green; . $File.FullName; } #endregion #region Register OnRemove event for module cleanup $ExecutionContext.SessionState.Module.OnRemove = { [void]($psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Where({ $PSItem.DisplayName -match '^_Mercurial'; }) | % { $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Remove($PSItem); }); }; #endregion |