Exemple #1
0
        public void SaveSolution_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (module == null)
            {
                return;
            }

            FieldInfo               tabControlField = window.GetType().GetField("runspaceTabControl", BindingFlags.Instance | BindingFlags.NonPublic);
            RunspaceTabControl      tabControl      = (RunspaceTabControl)tabControlField.GetValue(window);
            PowerShellTabCollection tabCollection   = tabControl.ItemsSource as PowerShellTabCollection;

            foreach (var file in module.IseFileList())
            {
                tabCollection.SelectedPowerShellTab.Files.Where(f => f.FullPath == file).FirstOrDefault().Save();
            }
        }
Exemple #2
0
        public void OpenSolution_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                var dialog = new Microsoft.Win32.OpenFileDialog()
                {
                    Filter = "PowerShell Data Files|*.psd1",
                    Title  = "Select a PowerShell Data File"
                };
                var result = dialog.ShowDialog();

                if (result == true)
                {
                    var cmd = string.Format("Test-ModuleManifest -Path '{0}'", dialog.FileName);
                    module = (PSModuleInfo)IseHelpers.PowerShellInvoker.Invoke(cmd).FirstOrDefault().BaseObject;

                    window.Title = module.Name + " Windows PowerShell ISE";

                    foreach (var file in module.IseFileList())
                    {
                        tabCollection.SelectedPowerShellTab.Files.Add(file);
                    }

                    CommandParameter parameter = e.Parameter as CommandParameter;
                    if (parameter != null)
                    {
                        parameter.CanBeExecuted = true;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error opening solution file", "Error opening solution file", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }