private void SetupCommands() { LoadGist = new DelegateCommand <GistObject>(async selectGist => { if (CurrentGist != null) { var closeItems = new ISEInterop.CloseItems(); closeItems.Invoke(); } CurrentGist = selectGist; foreach (var file in selectGist.files) { var content = await repo.GetFileContentByUri(file.raw_url); var createNewFile = new ISEInterop.CreateNewFile(); var iseFile = createNewFile.Invoke(file.filename, selectGist.id, content); } var subscribeForChanges = new ISEInterop .SubscribeToChanges(ISEInterop.CreateNewFile.GetDirPath(selectGist.id), () => { PendingChangesInCurrentGist = true; }); }); CloseGist = new DelegateCommand(async() => { if (CurrentGist == null) { return; } var closeItems = new ISEInterop.CloseItems(); closeItems.Invoke(); CurrentGist = null; CurrentGistFiles = null; await Load(); }); SaveGist = new DelegateCommand(async() => { var saveAll = new ISEInterop.SaveAllItems(); saveAll.Invoke(); foreach (var file in CurrentGist.files) { var contentFromEditor = new ISEInterop.GetCurrentFileContent().Invoke(file.filename); if (contentFromEditor == null) { continue; } await repo.Update(CurrentGist, file.filename, contentFromEditor); PendingChangesInCurrentGist = false; } }); AddFileToCurrentGist = new DelegateCommand(() => { if (String.IsNullOrEmpty(AddFileName)) { Debug.WriteLine("No file name specified."); } var CreateNewFile = new ISEInterop.CreateNewFile(); var newFile = CreateNewFile.Invoke(AddFileName, CurrentGist.id, "#" + AddFileName); UpdateCurrentGistsFiles(); }); CreateNewGist = new DelegateCommand <string>(async x => { var gist = await repo.Create(x, AddFileName, "Write-host 'hello'"); LoadGist.Execute(gist); }); OpenGistInBrowser = new DelegateCommand(() => { System.Diagnostics.Process.Start(CurrentGist.html_url); }); }
private void SetupCommands() { LoadGist = new DelegateCommand<GistObject>(async selectGist => { if (CurrentGist != null) { var closeItems = new ISEInterop.CloseItems(); closeItems.Invoke(); } CurrentGist = selectGist; foreach (var file in selectGist.files) { var content = await repo.GetFileContentByUri(file.raw_url); var createNewFile = new ISEInterop.CreateNewFile(); var iseFile = createNewFile.Invoke(file.filename, selectGist.id, content); } var subscribeForChanges = new ISEInterop .SubscribeToChanges(ISEInterop.CreateNewFile.GetDirPath(selectGist.id), () => { PendingChangesInCurrentGist = true; }); }); CloseGist = new DelegateCommand(async () => { if (CurrentGist == null) { return; } var closeItems = new ISEInterop.CloseItems(); closeItems.Invoke(); CurrentGist = null; CurrentGistFiles = null; await Load(); }); SaveGist = new DelegateCommand(async () => { var saveAll = new ISEInterop.SaveAllItems(); saveAll.Invoke(); foreach (var file in CurrentGist.files) { var contentFromEditor = new ISEInterop.GetCurrentFileContent().Invoke(file.filename); if (contentFromEditor == null) { continue; } await repo.Update(CurrentGist, file.filename, contentFromEditor); PendingChangesInCurrentGist = false; } }); AddFileToCurrentGist = new DelegateCommand(() => { if (String.IsNullOrEmpty(AddFileName)) { Debug.WriteLine("No file name specified."); } var CreateNewFile = new ISEInterop.CreateNewFile(); var newFile = CreateNewFile.Invoke(AddFileName, CurrentGist.id, "#"+AddFileName); UpdateCurrentGistsFiles(); }); CreateNewGist = new DelegateCommand<string>(async x => { var gist = await repo.Create(x, AddFileName, "Write-host 'hello'"); LoadGist.Execute(gist); }); OpenGistInBrowser = new DelegateCommand(() => { System.Diagnostics.Process.Start(CurrentGist.html_url); }); }