public static void Initialize(ObjectModelRoot root) { IseRoot = root; InitializeMenus(root); InitializeMEFComponents(); }
public CreateNewFile() { host = Config.ObjectModelRoot; if (host == null) { throw new ArgumentNullException("ObjectModelRoot not set in config"); } }
public SaveAllItems() { host = Config.ObjectModelRoot; if (host == null) { throw new ArgumentNullException("ObjectModelRoot not set in config"); } }
public CreateNewFile() { host = Config.ObjectModelRoot; if (host == null) { throw new ArgumentNullException("ObjectModelRoot not set in config"); } }
public SaveAllItems() { host = Config.ObjectModelRoot; if (host == null) { throw new ArgumentNullException("ObjectModelRoot not set in config"); } }
public void Start(ObjectModelRoot objectModelRoot) { this.iseIntegrator.setHostObject(objectModelRoot); this.workspaceDirectoryModel.PropertyChanged += this.RecreateSearchTreeOnWorkspaceDirectoryChanged; this.iseIntegrator.FileTabChanged += this.ResetWorkspaceOnFileTabChanged; this.fileSystemChangeWatcher.RegisterOnChangeCallback(this.ReindexOnFileSystemChanged); this.iseFileReloader.startWatching(); this.commandExecutor.ExecuteWithParam <ResetWorkspaceDirectoryCommand, bool>(true); }
public void Start(ObjectModelRoot objectModelRoot) { this.iseIntegrator.setHostObject(objectModelRoot); this.workspaceDirectoryModel.PropertyChanged += this.RecreateSearchTreeOnWorkspaceDirectoryChanged; this.iseIntegrator.FileTabChanged += this.ResetWorkspaceOnFileTabChanged; this.fileSystemChangeWatcher.RegisterOnChangeCallback(this.ReindexOnFileSystemChanged); this.iseFileReloader.startWatching(); this.commandExecutor.ExecuteWithParam<ResetWorkspaceDirectoryCommand, bool>(true); }
public DscResourceAddOn() { InitializeComponent(); this.DataContext = this; ResourceAndModule = LoadAllDscResources(); DataGridObject.ItemsSource = ResourceAndModule; hostObject = null; }
public DscResourceAddOn() { InitializeComponent(); this.DataContext = this; ResourceAndModule = LoadAllDscResources(); DataGridObject.ItemsSource = ResourceAndModule; hostObject = null; }
public void setHostObject(ObjectModelRoot hostObject) { if (hostObject == null) { throw new ArgumentNullException("hostObject"); } this.hostObject = hostObject; this.hostObject.CurrentPowerShellTab.PropertyChanged += OnIseTabChanged; }
public IseIntegrator(ObjectModelRoot hostObject) { if (hostObject == null) { throw new ArgumentNullException("hostObject"); } HostObject = hostObject; HostObject.CurrentPowerShellTab.PropertyChanged += OnIseTabChanged; }
public IseIntegrator(ObjectModelRoot hostObject) { if (hostObject == null) { throw new ArgumentNullException("hostObject"); } this.HostObject = hostObject; this.HostObject.CurrentPowerShellTab.PropertyChanged += OnIseTabChanged; }
public SubscribeToChanges(string filePath, Action Callback) { host = Config.ObjectModelRoot; if (host == null) { throw new ArgumentNullException("ObjectModelRoot not set in config"); } callbackAction = Callback; System.IO.FileSystemWatcher watcher = new System.IO.FileSystemWatcher(filePath); watcher.Changed += Watcher_Changed; watcher.EnableRaisingEvents = true; }
public SubscribeToChanges(string filePath, Action Callback) { host = Config.ObjectModelRoot; if (host == null) { throw new ArgumentNullException("ObjectModelRoot not set in config"); } callbackAction = Callback; System.IO.FileSystemWatcher watcher = new System.IO.FileSystemWatcher(filePath); watcher.Changed += Watcher_Changed; watcher.EnableRaisingEvents = true; }
public static void FormatCurrentDocument(ObjectModelRoot psIse, FormatRange range) { //Cached IseRoot is not sync? ISERoot.CurrentFile may be null when multiple PowerShell tab opened. var currentFile = psIse.CurrentFile; if (currentFile == null) { return; } //TODO:Reflection Performance var viewHost = (IWpfTextViewHost)typeof(ISEEditor).GetProperty("EditorViewHost", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(currentFile.Editor); var textView = (ITextView)viewHost.TextView; if (textView == null || textView.TextBuffer == null) { return; } var analyzer = _codeAnalyzerFactory.Create(textView); var formatter = _codeFormatterFactory.Create(textView.TextBuffer); var analyzedResult = analyzer.Analyze(); var formatResult = formatter.FormatCode(analyzedResult); try { //Need to execute operation in UI thread? to avoid ISE crashed by ArgumentOutOfRangeException Application.Current.Dispatcher.Invoke(() => { //If refresh needed. retry operation in UI thread if (textView.TextSnapshot.Version != analyzedResult.TextSnapshot.Version) { formatResult = formatter.FormatCode(analyzer.Analyze()); } formatResult.Commit(_undoManagerProvider); }); } catch (Exception ex) { LastException = ex; throw; //TODO:Support ErrorMessage //Console.WriteLine(ex.Message); //Output to ISE ConsoleWindow } }
/// <summary> /// Adds a given command to the current File of the ISE /// </summary> /// <param name="hostObject"></param> /// <param name="command"></param> public static void AddLine(ObjectModelRoot hostObject, string command) { try { var lineRow = hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.CaretLine; var lineColumn = hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.CaretColumn; var lineCountStart = hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.LineCount; hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.SetCaretPosition(lineRow, 1); hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.InsertText(command + "\n"); var lineCountEnd = hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.LineCount; var offset = lineCountEnd - lineCountStart; hostObject.CurrentPowerShellTab.Files.SelectedFile.Editor.SetCaretPosition(lineRow + offset, 1); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
private static void InitializeMenus(ObjectModelRoot root) { var menus = (ISEMenuItemCollection)root.CurrentPowerShellTab.AddOnsMenu.Submenus; //Add MenuItem(FormatDocument) { const string name = "Format Document"; var gesture = new MultiKeyGesture(new[] { new KeyGesture(Key.K, ModifierKeys.Control), new KeyGesture(Key.D, ModifierKeys.Control), }, "Ctrl+K, Ctrl+D"); var scriptBlock = ScriptBlock.Create("Format-CurrentDocument -Range Document"); var item = menus.SingleOrDefault(p => p.DisplayName == name); if (item != null) { menus.Remove(item); } menus.Add(name, scriptBlock, gesture); } //typeof(PowerShellTab).GetProperty("StatusText").SetValue(root.CurrentPowerShellTab, "TestTest"); //TODO:Support RangeFormatter //Add MenuItem(FormatDocument) { const string name = "Format Selection"; var gesture = new MultiKeyGesture(new[] { new KeyGesture(Key.K, ModifierKeys.Control), new KeyGesture(Key.F, ModifierKeys.Control), }, "Ctrl+K, Ctrl+F"); var scriptBlock = ScriptBlock.Create("Format-CurrentDocument -Range Selection"); var item = menus.SingleOrDefault(p => p.DisplayName == name); if (item != null) { menus.Remove(item); } menus.Add(name, scriptBlock, gesture); } }
public IseInstance(ObjectModelRoot root) { HostObject = root; CurrentFileName = HostObject.CurrentPowerShellTab.Files.SelectedFile.FullPath; }
public GetCurrentFileContent() { host = Config.ObjectModelRoot; }
public GetCurrentFileContent() { host = Config.ObjectModelRoot; }