├── .gitattributes ├── .gitignore ├── Build ├── build-debug.cmd ├── build-release.cmd └── pack-release.cmd ├── Doc ├── Attributions.txt ├── Copyright-SharpDevelop.txt ├── Links.txt └── Screenshot1.png ├── LICENSE.md ├── README.md ├── Scripts ├── Empty.cs ├── Empty.csx ├── Emtpy.txt ├── Scratchpad.csx └── Tutorial.csx └── Src ├── .nuget ├── NuGet.Config ├── NuGet.exe ├── NuGet.targets └── packages.config ├── CShell.Completion ├── CSharpCompletion.cs ├── CSharpCompletionContext.cs ├── CSharpCompletionDataFactory.cs ├── CSharpInsightItem.cs ├── CSharpOverloadProvider.cs ├── CShell.Completion.csproj ├── CodeTextEditor.cs ├── DataItems │ ├── CompletionData.cs │ ├── EntityCompletionData.cs │ ├── ImportCompletionData.cs │ ├── OverrideCompletionData.cs │ └── VariableCompletionData.cs ├── Images │ ├── Class.png │ ├── CompletionImage.cs │ ├── Constructor.png │ ├── Delegate.png │ ├── Enum.png │ ├── EnumValue.png │ ├── Event.png │ ├── ExtensionMethod.png │ ├── Field.png │ ├── FieldReadOnly.png │ ├── Indexer.png │ ├── Interface.png │ ├── Literal.png │ ├── Method.png │ ├── NameSpace.png │ ├── Operator.png │ ├── OverlayInternal.png │ ├── OverlayPrivate.png │ ├── OverlayProtected.png │ ├── OverlayProtectedInternal.png │ ├── OverlayStatic.png │ ├── PInvokeMethod.png │ ├── Property.png │ ├── StaticClass.png │ ├── Struct.png │ └── VirtualMethod.png ├── Properties │ └── AssemblyInfo.cs ├── SegmentTrackingOutputFormatter.cs ├── Settings.StyleCop ├── app.config └── packages.config ├── CShell.Core ├── CShell.Core.csproj ├── Constants.cs ├── Framework │ ├── Controls │ │ ├── AutoGreyableImage.cs │ │ ├── LayoutInitializer.cs │ │ ├── Menu.cs │ │ ├── MenuItem.cs │ │ ├── PanesStyleSelector.cs │ │ ├── PanesTemplateSelector.cs │ │ └── ToolBar.cs │ ├── Converters │ │ ├── ActiveDocumentConverter.cs │ │ └── UriConverter.cs │ ├── Document.cs │ ├── IDocument.cs │ ├── IModule.cs │ ├── ISink.cs │ ├── ITextDocument.cs │ ├── ITool.cs │ ├── LICENCE.txt │ ├── LayoutItemBase.cs │ ├── Menus │ │ ├── CheckableMenuItem.cs │ │ ├── IMenu.cs │ │ ├── IToolBar.cs │ │ ├── MenuItem.cs │ │ ├── MenuItemBase.cs │ │ ├── MenuItemSeparator.cs │ │ ├── MenuModel.cs │ │ ├── StandardMenuItem.cs │ │ └── ToolBarModel.cs │ ├── ModuleBase.cs │ ├── RelayCommand.cs │ ├── Results │ │ ├── ChangeWorkspaceResult.cs │ │ ├── CloseShellResult.cs │ │ ├── IOpenResult.cs │ │ ├── OpenDocumentResult.cs │ │ ├── OpenResultBase.cs │ │ ├── ResultBase.cs │ │ ├── ResultExtensions.cs │ │ ├── Run.cs │ │ ├── RunCodeResult.cs │ │ ├── SaveDocumentResult.cs │ │ ├── Show.cs │ │ ├── ShowCommonDialogResult.cs │ │ ├── ShowDialogResult.cs │ │ ├── ShowFolderDialogResult.cs │ │ └── ShowToolResult.cs │ ├── Services │ │ ├── Execute.cs │ │ ├── ExtensionMethods.cs │ │ ├── IDocumentProvider.cs │ │ ├── IInputManager.cs │ │ ├── IOutput.cs │ │ ├── IPropertyGrid.cs │ │ ├── IReplOutput.cs │ │ ├── IResourceManager.cs │ │ ├── IShell.cs │ │ ├── ISinkProvider.cs │ │ ├── IStatusBar.cs │ │ ├── InputBindingTrigger.cs │ │ ├── InputManager.cs │ │ ├── LoggerDebug.cs │ │ ├── LoggerNLog.cs │ │ ├── PaneLocation.cs │ │ ├── ResourceManager.cs │ │ └── WorkspaceActivator.cs │ ├── Sink.cs │ └── Tool.cs ├── ICompletion.cs ├── IDefaultReferences.cs ├── IReplExecutorFactory.cs ├── IReplScriptExecutor.cs ├── Properties │ └── AssemblyInfo.cs ├── References.cs ├── Scripts.cs ├── Shell.Documents.cs ├── Shell.Sinks.cs ├── Shell.Tools.cs ├── Shell.Workspace.cs ├── Shell.cs ├── Test.cs ├── Util │ ├── FusionNative.cs │ ├── GlobalAssemblyCache.cs │ └── PathHelper.cs ├── Workspace.Serialization.cs ├── Workspace.cs ├── WorkspaceEvents.cs ├── WorkspaceException.cs ├── app.config └── packages.config ├── CShell.Hosting.Tests ├── CShell.Hosting.Tests.csproj ├── Properties │ └── AssemblyInfo.cs ├── ReplScriptExecutorTests.cs ├── TestObjFactory.cs ├── app.config └── packages.config ├── CShell.Hosting ├── CShell.Hosting.csproj ├── DefaultReferences.cs ├── FileSystem.cs ├── HostingHelpers.cs ├── ObjectSerializer.cs ├── Package │ ├── NugetInstallationProvider.cs │ ├── NugetMachineWideSettings.cs │ ├── PackageContainer.cs │ ├── PackageInstaller.cs │ └── PackageObject.cs ├── Properties │ └── AssemblyInfo.cs ├── ReplCommands │ ├── ClearCommand.cs │ ├── HelpCommand.cs │ ├── InstallCommand.cs │ └── ResetCommand.cs ├── ReplLogProvider.cs ├── ReplScriptExecutor.cs ├── ReplScriptExecutorFactory.cs ├── ReplScriptHost.cs ├── ScriptResultExtensions.cs ├── app.config └── packages.config ├── CShell.Sinks.Chart ├── CShell.Sinks.Charting.csproj ├── ChartSink.cs ├── ChartSinkProvider.cs ├── ChartSinkView.xaml ├── ChartSinkView.xaml.cs ├── ChartSinkViewModel.cs ├── HistogramChartHelper.cs ├── Module.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── CShell.Sinks.Grid ├── CShell.Sinks.Grid.csproj ├── GridSink.cs ├── GridSinkProvider.cs ├── GridSinkView.xaml ├── GridSinkView.xaml.cs ├── GridSinkViewModel.cs ├── Module.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config └── packages.config ├── CShell.Sinks.Xhtml ├── CShell.Sinks.Xhtml.csproj ├── Module.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Resources │ └── StyleSheet.css ├── XhtmlDumper │ ├── BasicXhtmlRenderer.cs │ ├── IXhtmlRenderer.cs │ ├── ObjectXhtmlRenderer.cs │ └── XhtmlDumper.cs ├── XhtmlSink.cs ├── XhtmlSinkProvider.cs ├── XhtmlSinkView.xaml ├── XhtmlSinkView.xaml.cs ├── XhtmlSinkViewModel.cs ├── app.config └── packages.config ├── CShell.Tests ├── CShell.Tests.csproj ├── CommandQueueTest.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── CShell.sln ├── CShell.sln.DotSettings ├── CShell ├── App.xaml ├── App.xaml.cs ├── AppBootstrapper.cs ├── CShell.csproj ├── Default │ └── Default.cshell ├── Icon.ico ├── Modules │ ├── Editors │ │ ├── Controls │ │ │ └── CodeCompletionTextEditor.cs │ │ ├── EditorProvider.cs │ │ ├── Module.cs │ │ ├── ViewModels │ │ │ └── EditorViewModel.cs │ │ └── Views │ │ │ ├── EditorView.xaml │ │ │ └── EditorView.xaml.cs │ ├── Help │ │ ├── Module.cs │ │ ├── ViewModels │ │ │ └── AboutViewModel.cs │ │ └── Views │ │ │ ├── AboutView.xaml │ │ │ └── AboutView.xaml.cs │ ├── Repl │ │ ├── Controls │ │ │ ├── CSRepl.xaml │ │ │ ├── CSRepl.xaml.cs │ │ │ ├── CSReplTextEditor.cs │ │ │ ├── CommandHistory.cs │ │ │ ├── CommandQueue.cs │ │ │ ├── ConsoleStream.cs │ │ │ └── OffsetColorizer.cs │ │ ├── Module.cs │ │ ├── ViewModels │ │ │ ├── OutputViewModel.cs │ │ │ └── ReplViewModel.cs │ │ └── Views │ │ │ ├── IOutputView.cs │ │ │ ├── IReplView.cs │ │ │ ├── OutputView.xaml │ │ │ ├── OutputView.xaml.cs │ │ │ ├── ReplView.xaml │ │ │ └── ReplView.xaml.cs │ ├── Shell │ │ ├── Module.cs │ │ ├── ViewModels │ │ │ ├── MainMenuViewModel.cs │ │ │ ├── ShellViewModel.cs │ │ │ ├── StatusBarViewModel.cs │ │ │ └── ToolBarViewModel.cs │ │ └── Views │ │ │ ├── IShellView.cs │ │ │ ├── ShellView.xaml │ │ │ └── ShellView.xaml.cs │ └── Workspace │ │ ├── Controls │ │ ├── EditableTextBlock.xaml │ │ └── EditableTextBlock.xaml.cs │ │ ├── Module.cs │ │ ├── Results │ │ ├── AddFilesResult.cs │ │ ├── AddFolderResult.cs │ │ ├── AddReferencesResult.cs │ │ └── CopyReferencesResult.cs │ │ ├── ViewModels │ │ ├── AssemblyGacViewModel.cs │ │ ├── AssemblyPackagesViewModel.cs │ │ ├── AssemblyReferenceViewModel.cs │ │ ├── AssemblyReferencesViewModel.cs │ │ ├── FilePackagesViewModel.cs │ │ ├── FileViewModel.cs │ │ ├── FolderBinViewModel.cs │ │ ├── FolderPackagesViewModel.cs │ │ ├── FolderRootViewModel.cs │ │ ├── FolderViewModel.cs │ │ ├── TreeViewModel.cs │ │ └── WorkspaceViewModel.cs │ │ └── Views │ │ ├── AssemblyGacView.xaml │ │ ├── AssemblyGacView.xaml.cs │ │ ├── AssemblyPackagesView.xaml │ │ ├── AssemblyPackagesView.xaml.cs │ │ ├── RootFolderSettingsView.xaml │ │ ├── RootFolderSettingsView.xaml.cs │ │ ├── WorkspaceView.xaml │ │ └── WorkspaceView.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── Icon.png │ ├── Icons │ │ ├── ClearOutputWindow.png │ │ ├── FileBrowser.png │ │ ├── Folder.Closed.png │ │ ├── Folder.Open.png │ │ ├── Icons.16x16.Assembly.png │ │ ├── Icons.16x16.CSFile.png │ │ ├── Icons.16x16.CommentRegion.png │ │ ├── Icons.16x16.CopyIcon.png │ │ ├── Icons.16x16.CutIcon.png │ │ ├── Icons.16x16.DeleteIcon.png │ │ ├── Icons.16x16.FindIcon.png │ │ ├── Icons.16x16.Indent.png │ │ ├── Icons.16x16.MiscFiles.png │ │ ├── Icons.16x16.PasteIcon.png │ │ ├── Icons.16x16.Property.png │ │ ├── Icons.16x16.RedoIcon.png │ │ ├── Icons.16x16.Reference.png │ │ ├── Icons.16x16.ReferenceModule.png │ │ ├── Icons.16x16.RunAllIcon.png │ │ ├── Icons.16x16.RunProgramIcon.png │ │ ├── Icons.16x16.SaveAllIcon.png │ │ ├── Icons.16x16.SaveIcon.png │ │ ├── Icons.16x16.TextFileIcon.png │ │ ├── Icons.16x16.UndoIcon.png │ │ ├── Icons.16x16.XMLFileIcon.png │ │ ├── Open.png │ │ ├── Output.png │ │ ├── ReferenceFolder.Closed.png │ │ ├── ReferenceFolder.Open.png │ │ ├── Toolbar.Refresh.png │ │ ├── page_go.png │ │ └── page_white_go.png │ ├── Menu.xaml │ └── Styles.xaml ├── SplashScreen.png ├── Templates │ └── Empty.cshell ├── app.config └── packages.config ├── NuGet.config └── SetupProject ├── LicenseAgreement.rtf ├── LicenseAgreement.rtf.docx ├── Product.wxs └── SetupProject.wixproj /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | *.resharper 58 | 59 | # NCrunch 60 | *.ncrunch* 61 | .*crunch*.local.xml 62 | 63 | # Installshield output folder 64 | [Ee]xpress 65 | 66 | # DocProject is a documentation generator add-in 67 | DocProject/buildhelp/ 68 | DocProject/Help/*.HxT 69 | DocProject/Help/*.HxC 70 | DocProject/Help/*.hhc 71 | DocProject/Help/*.hhk 72 | DocProject/Help/*.hhp 73 | DocProject/Help/Html2 74 | DocProject/Help/html 75 | 76 | # Click-Once directory 77 | publish 78 | 79 | # Publish Web Output 80 | *.Publish.xml 81 | 82 | # NuGet Packages Directory 83 | packages 84 | 85 | # Windows Azure Build Output 86 | csx 87 | *.build.csdef 88 | 89 | # Windows Store app package directory 90 | AppPackages/ 91 | 92 | # Others 93 | [Ll]ib 94 | [Bb]in 95 | [Oo]bj 96 | sql 97 | TestResults 98 | [Tt]est[Rr]esult* 99 | *.Cache 100 | ClientBin 101 | [Ss]tyle[Cc]op.* 102 | ~$* 103 | *.dbmdl 104 | Generated_Code #added for RIA/Silverlight projects 105 | Ankh.NoLoad 106 | Thumbs.db 107 | 108 | # Backup & report files from converting an old project file to a newer 109 | # Visual Studio version. Backup files are not needed, because we have git ;-) 110 | _UpgradeReport_Files/ 111 | Backup*/ 112 | UpgradeLog*.XML 113 | -------------------------------------------------------------------------------- /Build/build-debug.cmd: -------------------------------------------------------------------------------- 1 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 2 | 3 | MSBuild ../Src/CShell.sln /t:Build /p:Configuration=Debug 4 | -------------------------------------------------------------------------------- /Build/build-release.cmd: -------------------------------------------------------------------------------- 1 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 2 | 3 | MSBuild ../Src/CShell.sln /t:Build /p:Configuration=Release 4 | -------------------------------------------------------------------------------- /Build/pack-release.cmd: -------------------------------------------------------------------------------- 1 | rmdir /S /Q "../Bin/Release/de" 2 | rmdir /S /Q "../Bin/Release/es" 3 | rmdir /S /Q "../Bin/Release/fr" 4 | rmdir /S /Q "../Bin/Release/hu" 5 | rmdir /S /Q "../Bin/Release/it" 6 | rmdir /S /Q "../Bin/Release/pt-BR" 7 | rmdir /S /Q "../Bin/Release/ro" 8 | rmdir /S /Q "../Bin/Release/ru" 9 | rmdir /S /Q "../Bin/Release/sv" 10 | rmdir /S /Q "../Bin/Release/zh-Hans" 11 | rmdir /S /Q "../Bin/Release/Logs" 12 | 13 | "C:\Program Files\7-Zip\7z.exe" a -tzip "..\Bin\CShell.zip" "..\Bin\Release\*" -------------------------------------------------------------------------------- /Doc/Attributions.txt: -------------------------------------------------------------------------------- 1 | Many thanks to everybody who contributed to the opensource projects that made CShell possible! 2 | 3 | WPF Framework 4 | ============================= 5 | Carliburn.Micro: http://caliburnmicro.codeplex.com/ 6 | Gemini: https://github.com/tgjones/gemini 7 | AvalonDock: http://avalondock.codeplex.com/ 8 | 9 | Scripting 10 | ============================= 11 | The project builds on ScriptCS for most scripting and REPL stuff 12 | http://scriptcs.net/ 13 | Which uses Roslyn and/or the mono compiler under the hood. 14 | 15 | Text Editor & Code Completion 16 | ============================= 17 | Avalon Edit: https://github.com/icsharpcode/SharpDevelop/wiki/AvalonEdit 18 | NRefactory: https://github.com/icsharpcode/NRefactory 19 | 20 | Others 21 | ============================= 22 | GAC Interop: From SharpDevelop: https://github.com/icsharpcode/SharpDevelop 23 | Some Icons: From SharpDevelop: https://github.com/icsharpcode/SharpDevelop 24 | 25 | Application Icon 26 | ============================= 27 | Part of 'FS Icons Ubuntu' icon set. 28 | http://franksouza183.deviantart.com/ 29 | http://www.iconfinder.com/icondetails/79650/128/arrow_right_icon -------------------------------------------------------------------------------- /Doc/Copyright-SharpDevelop.txt: -------------------------------------------------------------------------------- 1 | For the code copied from SharpDevelop & NRefactory 2 | 3 | Copyright 2002-2012 by 4 | 5 | AlphaSierraPapa, Christoph Wille 6 | Vordernberger Strasse 27/8 7 | A-8700 Leoben 8 | Austria 9 | 10 | email: office@alphasierrapapa.com 11 | court of jurisdiction: Landesgericht Leoben 12 | 13 | -------------------------------------------------------------------------------- /Doc/Links.txt: -------------------------------------------------------------------------------- 1 | mono 2 | http://tirania.org/blog/archive/2008/Aug-26.html Line editor 3 | https://github.com/mono/mono/tree/master/mcs/tools/csharp csharp repl source 4 | 5 | avalon edit code completion 6 | - http://community.sharpdevelop.net/forums/t/15802.aspx 7 | - http://nuget.org/packages/SharpDevelopCodeCompletion 8 | 9 | - https://github.com/icsharpcode/NRefactory 10 | - http://www.codeproject.com/Articles/408663/Using-NRefactory-for-analyzing-Csharp-code 11 | Read: 12 | - http://stackoverflow.com/questions/12506646/c-sharp-code-completion-with-nrefactory-5 13 | 14 | avalon edit 15 | - http://community.sharpdevelop.net/forums/t/14310.aspx (remove ctrl-x) 16 | 17 | controls 18 | http://www.codeproject.com/Articles/173509/A-Universal-WPF-Find-Replace-Dialog 19 | 20 | 21 | app domains 22 | http://stackoverflow.com/questions/1277346/net-problem-with-raising-and-handling-events-using-appdomains 23 | http://msdn.microsoft.com/en-us/library/dd153782.aspx 24 | 25 | tree view 26 | http://www.codeproject.com/Articles/31592/Editable-TextBlock-in-WPF-for-In-place-Editing 27 | 28 | 29 | settings are saved here: 30 | %USERPROFILE%\AppData\Local\ 31 | 32 | 33 | time series 34 | http://opentsdb.net/ 35 | http://code.google.com/p/timeseriesdb/ 36 | http://www.codeproject.com/Articles/382245/Time-Series-Analysis-in-Csharp-NET-Part-II 37 | 38 | f# 39 | http://fsxplat.codeplex.com/SourceControl/changeset/view/4d371abd932f#samples/compiler/fsintellisense/Program.fs 40 | http://stackoverflow.com/questions/11589990/f-intellisense-in-a-custom-editor 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Doc/Screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Doc/Screenshot1.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2015 Lukas Buhler 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CShell Readme 2 | ============= 3 | 4 | **Website and binaries:** http://cshell.net 5 | 6 | CShell is an interactive C# scripting environment. It allows you to use C# without any fluff right in a console like environment called a read-eval-print-loop (REPL). Your code is directly evaluated and executed in a shell window, no separate executable has to be compiled and then run in a different process. More elaborate code can be written in a C# script and then evaluated as one file, only one line, or a selection. Then, your results can be easily dumped to HTML (like LINQPad) or viewed as a data grid or plotted to a chart. 7 | 8 | CShell is perfect to explore data and quickly drill deeper into information since you can write one line of code, evaluate it, check out the results, and then write some more code, evaluate it again, and so forth. 9 | 10 | If you just want to test one or two lines of C# code without creating a new console project in Visual Studio just fire up CShell, type the code you wanna test and you immediately can see if it works the way you want. 11 | 12 | ![Screenshot](https://raw.githubusercontent.com/lukebuehler/CShell/master/Doc/Screenshot1.png) 13 | 14 | System Requirements 15 | ------------ 16 | CShell needs the .NET Framework 4.5 installed. Supported Windows versions: Windows 7, 8, 8.1 and Vista SP2. Windows XP is not supported. 17 | 18 | How to Build 19 | ------------ 20 | To build Visual Studio 2013 or higher is required. Open the solution and build the project or configure the build script in the /Build folder to point to the right Visual Studio 'vcvarsall' script. 21 | 22 | For the first build some NuGet packages have to be downloaded make sure you have NuGet installed and package restore enabled (Tools>Options>Package Manager>Package Restore). 23 | 24 | License 25 | ------- 26 | CShell is released under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0). 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Scripts/Empty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using CShell; 6 | 7 | public class NewClass 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /Scripts/Empty.csx: -------------------------------------------------------------------------------- 1 | // C# Script 2 | // Press Alt+Enter to evaluate a single line or selection 3 | // Press Alt+Shift+Enter to evaluate the whole script -------------------------------------------------------------------------------- /Scripts/Emtpy.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Scripts/Emtpy.txt -------------------------------------------------------------------------------- /Scripts/Scratchpad.csx: -------------------------------------------------------------------------------- 1 | // C# Script 2 | // Press Alt+Enter to evaluate a single line or selection 3 | // Press Alt+Shift+Enter to evaluate the whole script -------------------------------------------------------------------------------- /Src/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Src/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/.nuget/NuGet.exe -------------------------------------------------------------------------------- /Src/.nuget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Src/CShell.Completion/DataItems/ImportCompletionData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using ICSharpCode.NRefactory.CSharp.Refactoring; 5 | using ICSharpCode.NRefactory.CSharp.Resolver; 6 | using ICSharpCode.NRefactory.CSharp.TypeSystem; 7 | using ICSharpCode.NRefactory.TypeSystem; 8 | 9 | namespace CShell.Completion.DataItems 10 | { 11 | /// 12 | /// Completion item that introduces a using declaration. 13 | /// 14 | class ImportCompletionData : EntityCompletionData 15 | { 16 | string insertUsing; 17 | string insertionText; 18 | 19 | public ImportCompletionData(ITypeDefinition typeDef, CSharpTypeResolveContext contextAtCaret, bool useFullName) 20 | : base(typeDef) 21 | { 22 | this.Description = "using " + typeDef.Namespace + ";"; 23 | if (useFullName) 24 | { 25 | var astBuilder = new TypeSystemAstBuilder(new CSharpResolver(contextAtCaret)); 26 | insertionText = astBuilder.ConvertType(typeDef).GetText(); 27 | } 28 | else 29 | { 30 | insertionText = typeDef.Name; 31 | insertUsing = typeDef.Namespace; 32 | } 33 | } 34 | } //end class ImportCompletionData 35 | } 36 | -------------------------------------------------------------------------------- /Src/CShell.Completion/DataItems/VariableCompletionData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) 2 | // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) 3 | 4 | using System; 5 | using CShell.Completion.Images; 6 | using ICSharpCode.NRefactory.Completion; 7 | using ICSharpCode.NRefactory.CSharp; 8 | using ICSharpCode.NRefactory.TypeSystem; 9 | 10 | namespace CShell.Completion.DataItems 11 | { 12 | internal class VariableCompletionData : CompletionData, IVariableCompletionData 13 | { 14 | public VariableCompletionData(IVariable variable) 15 | { 16 | if (variable == null) throw new ArgumentNullException("variable"); 17 | Variable = variable; 18 | 19 | IAmbience ambience = new CSharpAmbience(); 20 | DisplayText = variable.Name; 21 | Description = ambience.ConvertVariable(variable); 22 | CompletionText = Variable.Name; 23 | this.Image = CompletionImage.Field.BaseImage; 24 | } 25 | 26 | public IVariable Variable { get; private set; } 27 | } //end class VariableCompletionData 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Class.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Constructor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Constructor.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Delegate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Delegate.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Enum.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/EnumValue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/EnumValue.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Event.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/ExtensionMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/ExtensionMethod.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Field.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/FieldReadOnly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/FieldReadOnly.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Indexer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Indexer.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Interface.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Literal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Literal.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Method.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Method.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/NameSpace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/NameSpace.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Operator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Operator.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/OverlayInternal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/OverlayInternal.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/OverlayPrivate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/OverlayPrivate.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/OverlayProtected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/OverlayProtected.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/OverlayProtectedInternal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/OverlayProtectedInternal.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/OverlayStatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/OverlayStatic.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/PInvokeMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/PInvokeMethod.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Property.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/StaticClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/StaticClass.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/Struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/Struct.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Images/VirtualMethod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell.Completion/Images/VirtualMethod.png -------------------------------------------------------------------------------- /Src/CShell.Completion/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Completion")] 9 | [assembly: AssemblyDescription("A Simple C# Scripting IDE")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Arnova")] 12 | [assembly: AssemblyProduct("CShell")] 13 | [assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("380faaad-c726-4460-8667-998e05e10c33")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.1.3.*")] 36 | [assembly: AssemblyFileVersion("0.1.3.*")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Completion/SegmentTrackingOutputFormatter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Text; 4 | using ICSharpCode.AvalonEdit.Document; 5 | using ICSharpCode.NRefactory.CSharp; 6 | 7 | namespace CShell.Completion 8 | { 9 | /// 10 | /// Output formatter that creates a dictionary from AST nodes to segments in the output text. 11 | /// 12 | public class SegmentTrackingOutputFormatter : TextWriterTokenWriter 13 | { 14 | Dictionary segments = new Dictionary(); 15 | Stack startOffsets = new Stack(); 16 | readonly StringWriter stringWriter; 17 | 18 | public IDictionary Segments 19 | { 20 | get { return segments; } 21 | } 22 | 23 | public SegmentTrackingOutputFormatter(StringWriter stringWriter) 24 | : base(stringWriter) 25 | { 26 | this.stringWriter = stringWriter; 27 | } 28 | 29 | public static IDictionary WriteNode(StringWriter writer, AstNode node, CSharpFormattingOptions policy, ICSharpCode.AvalonEdit.TextEditorOptions options) 30 | { 31 | var formatter = new SegmentTrackingOutputFormatter(writer); 32 | formatter.IndentationString = options.IndentationString; 33 | var visitor = new CSharpOutputVisitor(formatter, policy); 34 | node.AcceptVisitor(visitor); 35 | return formatter.Segments; 36 | } 37 | 38 | public override void StartNode(AstNode node) 39 | { 40 | base.StartNode(node); 41 | startOffsets.Push(stringWriter.GetStringBuilder().Length); 42 | } 43 | 44 | public override void EndNode(AstNode node) 45 | { 46 | int startOffset = startOffsets.Pop(); 47 | StringBuilder b = stringWriter.GetStringBuilder(); 48 | int endOffset = b.Length; 49 | while (endOffset > 0 && b[endOffset - 1] == '\r' || b[endOffset - 1] == '\n') 50 | endOffset--; 51 | segments.Add(node, new TextSegment { StartOffset = startOffset, EndOffset = endOffset }); 52 | base.EndNode(node); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Src/CShell.Completion/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Src/CShell.Completion/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Src/CShell.Completion/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Src/CShell.Core/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell 7 | { 8 | public static class Constants 9 | { 10 | public const string CShellHelp = "https://github.com/ArnovaAssetManagement/CShell"; 11 | 12 | 13 | public const string FileFilter = "C# Files|*.csx;*.cs;|All Files|*.*"; 14 | public const string FileTypes = "C# Script|*.csx|C# File|*.cs|Text File|*.txt|Other|*.*"; 15 | public const string DefaultExtension = ".csx"; 16 | 17 | public const string AssemblyFileFilter = "Component Files|*.dll;*.exe|All Files|*.*"; 18 | public const string AssemblyFileExtension = ".dll"; 19 | 20 | public const string WorkspaceFileExtension = ".xml"; 21 | public const string WorkspaceFilter = "*.xml *.dll *.cshell"; 22 | 23 | public const string ModulesPath = "Modules"; 24 | public const string TemplatesPath = "Templates"; 25 | public const string DefaultWorkspacePath = "Default\\"; 26 | public const string ReferencesFile = "references.csx"; 27 | public const string LayoutFile = "layout.config"; 28 | public const string ConfigFile = "config.csx"; 29 | 30 | public const string PackagesFile = "packages.config"; 31 | public const string NugetFile = "nuget.config"; 32 | public const string PackagesFolder = "packages"; 33 | public const string DefaultRepositoryUrl = "https://nuget.org/api/v2/"; 34 | 35 | public const string BinFolder = "bin"; 36 | public const string DllCacheFolder = "cache"; 37 | 38 | public const string NetFrameworkName = ".NETFramework,Version=v4.5"; 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Controls/Menu.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace CShell.Framework.Controls 4 | { 5 | public class Menu : System.Windows.Controls.Menu 6 | { 7 | private object _currentItem; 8 | 9 | protected override bool IsItemItsOwnContainerOverride(object item) 10 | { 11 | _currentItem = item; 12 | return base.IsItemItsOwnContainerOverride(item); 13 | } 14 | 15 | protected override DependencyObject GetContainerForItemOverride() 16 | { 17 | return MenuItem.GetContainer(this, _currentItem); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Controls/MenuItem.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using CShell.Framework.Menus; 4 | 5 | namespace CShell.Framework.Controls 6 | { 7 | public class MenuItem : System.Windows.Controls.MenuItem 8 | { 9 | private object _currentItem; 10 | 11 | protected override bool IsItemItsOwnContainerOverride(object item) 12 | { 13 | _currentItem = item; 14 | return base.IsItemItsOwnContainerOverride(item); 15 | } 16 | 17 | protected override DependencyObject GetContainerForItemOverride() 18 | { 19 | return GetContainer(this, _currentItem); 20 | } 21 | 22 | internal static DependencyObject GetContainer(FrameworkElement frameworkElement, object item) 23 | { 24 | if (item is MenuItemSeparator) 25 | return new Separator { Style = (Style)frameworkElement.FindResource(SeparatorStyleKey) }; 26 | 27 | string styleKey = (item is CheckableMenuItem) ? "CheckableMenuItem" : "MenuItem"; 28 | return new MenuItem { Style = (Style)frameworkElement.FindResource(styleKey) }; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Controls/PanesStyleSelector.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace CShell.Framework.Controls 5 | { 6 | public class PanesStyleSelector : StyleSelector 7 | { 8 | public Style ToolStyle 9 | { 10 | get; 11 | set; 12 | } 13 | 14 | public Style DocumentStyle 15 | { 16 | get; 17 | set; 18 | } 19 | 20 | public override Style SelectStyle(object item, DependencyObject container) 21 | { 22 | if (item is ITool) 23 | return ToolStyle; 24 | 25 | if (item is IDocument) 26 | return DocumentStyle; 27 | 28 | return base.SelectStyle(item, container); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Controls/PanesTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | 9 | namespace CShell.Framework.Controls 10 | { 11 | public class PanesTemplateSelector : DataTemplateSelector 12 | { 13 | public DataTemplate ToolTemplate 14 | { 15 | get; 16 | set; 17 | } 18 | 19 | public DataTemplate DocumentTemplate 20 | { 21 | get; 22 | set; 23 | } 24 | 25 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 26 | { 27 | if (item is ITool) 28 | return ToolTemplate; 29 | 30 | if (item is IDocument) 31 | return DocumentTemplate; 32 | 33 | return base.SelectTemplate(item, container); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Controls/ToolBar.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using CShell.Framework.Menus; 4 | 5 | namespace CShell.Framework.Controls 6 | { 7 | public class ToolBar : System.Windows.Controls.ToolBar 8 | { 9 | private object _currentItem; 10 | 11 | protected override bool IsItemItsOwnContainerOverride(object item) 12 | { 13 | _currentItem = item; 14 | return base.IsItemItsOwnContainerOverride(item); 15 | } 16 | 17 | protected override DependencyObject GetContainerForItemOverride() 18 | { 19 | if(_currentItem is MenuItemSeparator) 20 | return new Separator { Style = (Style)FindResource(SeparatorStyleKey) }; 21 | return base.GetContainerForItemOverride(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Converters/ActiveDocumentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace CShell.Framework.Converters 6 | { 7 | 8 | public class ActiveDocumentConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (value is IDocument) 13 | return value; 14 | 15 | return Binding.DoNothing; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | if (value is IDocument) 21 | return value; 22 | 23 | return Binding.DoNothing; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Converters/UriConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace CShell.Framework.Converters 6 | { 7 | [ValueConversion(typeof(Uri), typeof(string))] 8 | public class UriConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var uri = value as Uri; 13 | if (uri != null) 14 | return uri.ToString(); 15 | return ""; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | var uriString = value as string; 21 | if (uriString != null) 22 | { 23 | Uri uri; 24 | if (Uri.TryCreate(uriString, UriKind.RelativeOrAbsolute, out uri)) 25 | return uri; 26 | } 27 | return null; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Document.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | 4 | namespace CShell.Framework 5 | { 6 | public abstract class Document : LayoutItemBase, IDocument 7 | { 8 | private ICommand _closeCommand; 9 | public ICommand CloseCommand 10 | { 11 | get 12 | { 13 | return _closeCommand ?? (_closeCommand = new RelayCommand(p => TryClose(), p => true)); 14 | 15 | //documents can be closed all the time, if dirty, a dialog will be presented to ask if close is allowed 16 | //{ 17 | // bool canClose = false; 18 | // CanClose(r => canClose = r); 19 | // return canClose; 20 | //}); 21 | } 22 | } 23 | 24 | public virtual Uri Uri { get; set; } 25 | public virtual bool IsDirty { get; set; } 26 | 27 | public virtual void Save() 28 | { } 29 | public virtual void SaveAs(string newFile) 30 | { } 31 | } 32 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/IDocument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | using Caliburn.Micro; 4 | 5 | namespace CShell.Framework 6 | { 7 | public interface IDocument : IScreen 8 | { 9 | ICommand CloseCommand { get; } 10 | 11 | Uri Uri { get; } 12 | 13 | bool IsDirty { get; } 14 | void Save(); 15 | void SaveAs(string newFile); 16 | } 17 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/IModule.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition.Hosting; 3 | using System.Reflection; 4 | using ScriptCs.Contracts; 5 | 6 | namespace CShell.Framework 7 | { 8 | public interface IModule : System.IDisposable 9 | { 10 | int Order { get; } 11 | 12 | void Configure(); 13 | void Start(); 14 | } 15 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/ISink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Input; 6 | using CShell.Framework.Services; 7 | using Caliburn.Micro; 8 | 9 | namespace CShell.Framework 10 | { 11 | public interface ISink : IDocument 12 | { 13 | PaneLocation PreferredLocation { get; } 14 | bool IsVisible { get; set; } 15 | 16 | void Dump(object o); 17 | void Clear(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/ITextDocument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell.Framework 7 | { 8 | public interface ITextDocument : IDocument 9 | { 10 | void Undo(); 11 | void Redo(); 12 | void Cut(); 13 | void Copy(); 14 | void Paste(); 15 | void SelectAll(); 16 | 17 | /// 18 | /// Selects a section in the text. 19 | /// 20 | /// The start index of the selection. 21 | /// The length of the selection. 22 | void Select(int start, int length); 23 | 24 | void Comment(); 25 | void Uncomment(); 26 | 27 | void Append(string text); 28 | void Prepend(string text); 29 | 30 | string Text { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/ITool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | using CShell.Framework.Services; 4 | using Caliburn.Micro; 5 | 6 | namespace CShell.Framework 7 | { 8 | public interface ITool : IScreen 9 | { 10 | Uri Uri { get; } 11 | ICommand CloseCommand { get; } 12 | PaneLocation PreferredLocation { get; } 13 | bool IsVisible { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/LayoutItemBase.cs: -------------------------------------------------------------------------------- 1 | using Caliburn.Micro; 2 | 3 | namespace CShell.Framework 4 | { 5 | public abstract class LayoutItemBase : Screen 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/CheckableMenuItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Caliburn.Micro; 4 | 5 | namespace CShell.Framework.Menus 6 | { 7 | public class CheckableMenuItem : StandardMenuItem 8 | { 9 | private readonly Func> _execute; 10 | 11 | private bool _isChecked; 12 | public bool IsChecked 13 | { 14 | get { return _isChecked; } 15 | set { _isChecked = value; NotifyOfPropertyChange(() => IsChecked); } 16 | } 17 | 18 | #region Constructors 19 | 20 | public CheckableMenuItem(string text) 21 | : base(text) 22 | { 23 | 24 | } 25 | 26 | public CheckableMenuItem(string text, Func> execute) 27 | : base(text) 28 | { 29 | _execute = execute; 30 | } 31 | 32 | public CheckableMenuItem(string text, Func> execute, Func canExecute) 33 | : base(text, canExecute) 34 | { 35 | _execute = execute; 36 | } 37 | 38 | #endregion 39 | 40 | public IEnumerable Execute() 41 | { 42 | return _execute != null ? _execute(IsChecked) : new IResult[] { }; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/IMenu.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Menus 5 | { 6 | public interface IMenu : IObservableCollection 7 | { 8 | IEnumerable All { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/IToolBar.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Menus 5 | { 6 | public interface IToolBar : IObservableCollection 7 | { 8 | void Add(params MenuItemBase[] menuItems); 9 | } 10 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/MenuItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Caliburn.Micro; 4 | 5 | namespace CShell.Framework.Menus 6 | { 7 | public class MenuItem : StandardMenuItem 8 | { 9 | private readonly Func> _execute; 10 | 11 | #region Constructors 12 | 13 | public MenuItem(string text) 14 | : base(text) 15 | { 16 | 17 | } 18 | 19 | public MenuItem(string text, Func> execute) 20 | : base(text) 21 | { 22 | _execute = execute; 23 | } 24 | 25 | public MenuItem(string text, Func> execute, Func canExecute) 26 | : base(text, canExecute) 27 | { 28 | _execute = execute; 29 | } 30 | 31 | #endregion 32 | 33 | public IEnumerable Execute() 34 | { 35 | return _execute != null ? _execute() : new IResult[] { }; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/MenuItemBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using Caliburn.Micro; 4 | 5 | namespace CShell.Framework.Menus 6 | { 7 | public class MenuItemBase : PropertyChangedBase, IEnumerable 8 | { 9 | #region Static stuff 10 | 11 | public static MenuItemBase Separator 12 | { 13 | get { return new MenuItemSeparator(); } 14 | } 15 | 16 | #endregion 17 | 18 | #region Properties 19 | 20 | public IObservableCollection Children { get; private set; } 21 | 22 | public virtual string Name 23 | { 24 | get { return "-"; } 25 | } 26 | 27 | #endregion 28 | 29 | #region Constructors 30 | 31 | protected MenuItemBase() 32 | { 33 | Children = new BindableCollection(); 34 | } 35 | 36 | #endregion 37 | 38 | public void Add(params MenuItemBase[] menuItems) 39 | { 40 | menuItems.Apply(Children.Add); 41 | } 42 | 43 | public IEnumerator GetEnumerator() 44 | { 45 | return Children.GetEnumerator(); 46 | } 47 | 48 | IEnumerator IEnumerable.GetEnumerator() 49 | { 50 | return GetEnumerator(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/MenuItemSeparator.cs: -------------------------------------------------------------------------------- 1 | namespace CShell.Framework.Menus 2 | { 3 | public class MenuItemSeparator : MenuItemBase 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/MenuModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Menus 5 | { 6 | public class MenuModel : BindableCollection, IMenu 7 | { 8 | public IEnumerable All 9 | { 10 | get 11 | { 12 | var queue = new Queue(this); 13 | while (queue.Count > 0) 14 | { 15 | var current = queue.Dequeue(); 16 | foreach (var item in current) 17 | queue.Enqueue(item); 18 | yield return current; 19 | } 20 | } 21 | } 22 | 23 | public void Add(params MenuItemBase[] items) 24 | { 25 | items.Apply(Add); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Menus/ToolBarModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Menus 5 | { 6 | public class ToolBarModel : BindableCollection, IToolBar 7 | { 8 | public void Add(params MenuItemBase[] items) 9 | { 10 | items.Apply(Add); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/ModuleBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using System.ComponentModel.Composition.Hosting; 4 | using System.Reflection; 5 | using CShell.Framework.Menus; 6 | using CShell.Framework.Services; 7 | 8 | namespace CShell.Framework 9 | { 10 | public abstract class ModuleBase : IModule 11 | { 12 | [Import] 13 | private IShell _shell; 14 | 15 | protected IShell Shell 16 | { 17 | get { return _shell; } 18 | } 19 | 20 | protected IMenu MainMenu 21 | { 22 | get { return _shell.MainMenu; } 23 | } 24 | 25 | protected IToolBar ToolBar 26 | { 27 | get { return _shell.ToolBar; } 28 | } 29 | 30 | public int Order { get; set; } 31 | 32 | public virtual void Configure() 33 | {} 34 | 35 | public abstract void Start(); 36 | 37 | public void Dispose() 38 | { 39 | Dispose(true); 40 | } 41 | 42 | protected virtual void Dispose(bool disposing) 43 | {} 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows.Input; 4 | 5 | namespace CShell.Framework 6 | { 7 | /// 8 | /// Used where Caliburn.Micro needs to be interfaced to ICommand. 9 | /// 10 | public class RelayCommand : ICommand 11 | { 12 | #region Fields 13 | 14 | private readonly Action _execute; 15 | private readonly Predicate _canExecute; 16 | 17 | #endregion // Fields 18 | 19 | #region Constructors 20 | 21 | public RelayCommand(Action execute) 22 | : this(execute, null) 23 | { 24 | } 25 | 26 | public RelayCommand(Action execute, Predicate canExecute) 27 | { 28 | if (execute == null) 29 | throw new ArgumentNullException("execute"); 30 | 31 | _execute = execute; 32 | _canExecute = canExecute; 33 | } 34 | #endregion // Constructors 35 | 36 | #region ICommand Members 37 | 38 | [DebuggerStepThrough] 39 | public bool CanExecute(object parameter) 40 | { 41 | return _canExecute == null || _canExecute(parameter); 42 | } 43 | 44 | public event EventHandler CanExecuteChanged 45 | { 46 | add { CommandManager.RequerySuggested += value; } 47 | remove { CommandManager.RequerySuggested -= value; } 48 | } 49 | 50 | public void Execute(object parameter) 51 | { 52 | _execute(parameter); 53 | } 54 | 55 | #endregion // ICommand Members 56 | } 57 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ChangeWorkspaceResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Forms; 8 | using Caliburn.Micro; 9 | using CShell.Framework.Services; 10 | 11 | namespace CShell.Framework.Results 12 | { 13 | public class ChangeWorkspaceResult : ResultBase 14 | { 15 | private string workspaceDirectory; 16 | 17 | [Import] 18 | private Workspace workspace; 19 | 20 | /// 21 | /// Creates a result that will open a workspace. 22 | /// 23 | public ChangeWorkspaceResult(string workspaceDirectory) 24 | { 25 | this.workspaceDirectory = workspaceDirectory; 26 | } 27 | 28 | public override void Execute(CoroutineExecutionContext context) 29 | { 30 | 31 | try 32 | { 33 | //some of this is synchronous which can mess up the UI (especially on startup), so we execute it on a seperate thread 34 | Task.Factory.StartNew(() => workspace.SetWorkspaceDirectory(workspaceDirectory)) 35 | .ContinueWith(t2 => OnCompleted(t2.Exception)); 36 | } 37 | catch (Exception ex) 38 | { 39 | OnCompleted(ex); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/CloseShellResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using Caliburn.Micro; 8 | using Application = System.Windows.Application; 9 | 10 | namespace CShell.Framework.Results 11 | { 12 | public class CloseShellResult : ResultBase 13 | { 14 | 15 | /// 16 | /// Closes the current workspace. 17 | /// 18 | public CloseShellResult() 19 | {} 20 | 21 | public override void Execute(CoroutineExecutionContext context) 22 | { 23 | try 24 | { 25 | Caliburn.Micro.Execute.OnUIThread(() => Application.Current.MainWindow.Close()); 26 | } 27 | catch (Exception ex) 28 | { 29 | OnCompleted(ex); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/IOpenResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Results 5 | { 6 | public interface IOpenResult : IResult 7 | { 8 | Action OnConfigure { get; set; } 9 | Action OnShutDown { get; set; } 10 | 11 | //void SetData(TData data); 12 | } 13 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/OpenDocumentResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.Linq; 4 | using CShell.Framework.Services; 5 | using Caliburn.Micro; 6 | 7 | namespace CShell.Framework.Results 8 | { 9 | public class OpenDocumentResult : OpenResultBase 10 | { 11 | private IDocument document; 12 | private readonly Type documentType; 13 | private readonly Uri uri; 14 | 15 | [Import] 16 | private IShell shell; 17 | 18 | public OpenDocumentResult(IDocument document) 19 | { 20 | this.document = document; 21 | } 22 | 23 | public OpenDocumentResult(string path) 24 | { 25 | if (path == null) throw new ArgumentNullException("path"); 26 | uri = new Uri(System.IO.Path.GetFullPath(path)); 27 | } 28 | 29 | public OpenDocumentResult(Uri uri) 30 | { 31 | this.uri = uri; 32 | } 33 | 34 | public OpenDocumentResult(Type documentType) 35 | { 36 | this.documentType = documentType; 37 | } 38 | 39 | public IDocument Document 40 | { 41 | get { return document; } 42 | } 43 | 44 | public override void Execute(CoroutineExecutionContext context) 45 | { 46 | if (document == null) 47 | { 48 | document = (uri == null 49 | ? (IDocument) IoC.GetInstance(documentType, null) 50 | : Shell.GetDoc(uri)); 51 | } 52 | 53 | if (document == null) 54 | { 55 | OnCompleted(null); 56 | return; 57 | } 58 | 59 | if (_setData != null) 60 | _setData(document); 61 | 62 | if (_onConfigure != null) 63 | _onConfigure(document); 64 | 65 | document.Deactivated += (s, e) => 66 | { 67 | if (_onShutDown != null) 68 | _onShutDown(document); 69 | }; 70 | 71 | shell.OpenDocument(document); 72 | 73 | OnCompleted(null); 74 | } 75 | 76 | 77 | } 78 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/OpenResultBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Results 5 | { 6 | public abstract class OpenResultBase : IOpenResult 7 | { 8 | protected Action _setData; 9 | protected Action _onConfigure; 10 | protected Action _onShutDown; 11 | 12 | Action IOpenResult.OnConfigure 13 | { 14 | get { return _onConfigure; } 15 | set { _onConfigure = value; } 16 | } 17 | 18 | Action IOpenResult.OnShutDown 19 | { 20 | get { return _onShutDown; } 21 | set { _onShutDown = value; } 22 | } 23 | 24 | //void IOpenResult.SetData(TData data) 25 | //{ 26 | // _setData = child => 27 | // { 28 | // var dataCentric = (IDataCentric)child; 29 | // dataCentric.LoadData(data); 30 | // }; 31 | //} 32 | 33 | protected virtual void OnCompleted(Exception exception) 34 | { 35 | if (Completed != null) 36 | Completed(this, new ResultCompletionEventArgs { Error = exception }); 37 | } 38 | 39 | public abstract void Execute(CoroutineExecutionContext context); 40 | 41 | public event EventHandler Completed; 42 | } 43 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ResultBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Caliburn.Micro; 6 | 7 | namespace CShell.Framework.Results 8 | { 9 | public abstract class ResultBase : IResult 10 | { 11 | public abstract void Execute(CoroutineExecutionContext context); 12 | 13 | public event EventHandler Completed; 14 | protected virtual void OnCompleted(Exception exception) 15 | { 16 | if (Completed != null) 17 | Completed(this, new ResultCompletionEventArgs { Error = exception }); 18 | } 19 | 20 | protected virtual void OnCompleted(Exception exception, bool wasCancelled) 21 | { 22 | if (Completed != null) 23 | Completed(this, new ResultCompletionEventArgs { Error = exception, WasCancelled = wasCancelled }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ResultExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using Caliburn.Micro; 7 | 8 | namespace CShell.Framework.Results 9 | { 10 | /// 11 | /// Helps execution coroutines easier. 12 | /// 13 | public static class ResultExtensions 14 | { 15 | public static void BeginExecute(this IEnumerable results, CoroutineExecutionContext executionContext = null) 16 | { 17 | Coroutine.BeginExecute(results.GetEnumerator(), executionContext); 18 | } 19 | 20 | public static void BeginExecute(this IResult result, CoroutineExecutionContext executionContext = null) 21 | { 22 | IEnumerable results = new[] {result}; 23 | results.BeginExecute(executionContext); 24 | } 25 | 26 | public static void ExecuteSynchronized(this IResult result, CoroutineExecutionContext executionContext = null) 27 | { 28 | IoC.BuildUp(result); 29 | var reset = new ManualResetEvent(false); 30 | result.Completed+= (s,e)=>reset.Set(); 31 | result.Execute(executionContext); 32 | reset.WaitOne(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/Run.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell.Framework.Results 7 | { 8 | public static class Run 9 | { 10 | public static RunCodeResult Code(string code, string sourceFile) 11 | { 12 | return new RunCodeResult(code, sourceFile); 13 | } 14 | 15 | public static RunCodeResult Code(string code) 16 | { 17 | return new RunCodeResult(code); 18 | } 19 | 20 | public static RunCodeResult File(string file) 21 | { 22 | var fileText =System.IO.File.ReadAllText(file); 23 | return new RunCodeResult(fileText, file); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/RunCodeResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Caliburn.Micro; 8 | 9 | namespace CShell.Framework.Results 10 | { 11 | public class RunCodeResult : ResultBase 12 | { 13 | [Import] 14 | public Workspace Workspace { get; set; } 15 | 16 | private readonly string code; 17 | private readonly string sourceFile; 18 | 19 | public RunCodeResult(string code) 20 | { 21 | this.code = code; 22 | } 23 | 24 | public RunCodeResult(string code, string sourceFile) 25 | { 26 | this.code = code; 27 | this.sourceFile = sourceFile; 28 | } 29 | 30 | public override void Execute(CoroutineExecutionContext context) 31 | { 32 | if(Workspace != null && Workspace.ReplExecutor != null) 33 | { 34 | Task.Run(() => Workspace.ReplExecutor.Execute(code, sourceFile)) 35 | .ContinueWith(t => OnCompleted(t.Exception)); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/SaveDocumentResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Caliburn.Micro; 6 | 7 | namespace CShell.Framework.Results 8 | { 9 | public class SaveDocumentResult : ResultBase 10 | { 11 | private IDocument document; 12 | private string newFile; 13 | 14 | public SaveDocumentResult(IDocument document) 15 | { 16 | if (document == null) throw new ArgumentNullException("document"); 17 | this.document = document; 18 | } 19 | 20 | public SaveDocumentResult(IDocument document, string newFile) 21 | :this(document) 22 | { 23 | this.newFile = newFile; 24 | } 25 | 26 | public override void Execute(CoroutineExecutionContext context) 27 | { 28 | Exception ex = null; 29 | try 30 | { 31 | if (!String.IsNullOrEmpty(newFile)) 32 | { 33 | document.SaveAs(newFile); 34 | } 35 | else if (document.IsDirty) 36 | { 37 | document.Save(); 38 | } 39 | } 40 | catch(Exception e) 41 | { 42 | ex = e; 43 | } 44 | OnCompleted(ex); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/Show.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.Win32; 3 | 4 | namespace CShell.Framework.Results 5 | { 6 | public static class Show 7 | { 8 | public static ShowDialogResult Dialog(object dialogViewModel, IDictionary setting = null) 9 | { 10 | return new ShowDialogResult(dialogViewModel){Settings = setting}; 11 | } 12 | 13 | public static ShowDialogResult Dialog(IDictionary setting = null) 14 | { 15 | return new ShowDialogResult(typeof(TViewModel)){Settings = setting}; 16 | } 17 | 18 | public static ShowCommonDialogResult Dialog(CommonDialog commonDialog) 19 | { 20 | return new ShowCommonDialogResult(commonDialog); 21 | } 22 | 23 | public static ShowFolderDialogResult FolderDialog(string selectedFolder = null) 24 | { 25 | return new ShowFolderDialogResult(selectedFolder); 26 | } 27 | 28 | public static ShowToolResult Tool() 29 | where TTool : ITool 30 | { 31 | return new ShowToolResult(); 32 | } 33 | 34 | public static ShowToolResult Tool(TTool tool) 35 | where TTool : ITool 36 | { 37 | return new ShowToolResult(tool); 38 | } 39 | 40 | public static OpenDocumentResult Document(IDocument document) 41 | { 42 | return new OpenDocumentResult(document); 43 | } 44 | 45 | public static OpenDocumentResult Document(string path) 46 | { 47 | return new OpenDocumentResult(path); 48 | } 49 | 50 | public static OpenDocumentResult Document() 51 | where T : IDocument 52 | { 53 | return new OpenDocumentResult(typeof(T)); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ShowCommonDialogResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Caliburn.Micro; 3 | using Microsoft.Win32; 4 | 5 | namespace CShell.Framework.Results 6 | { 7 | public class ShowCommonDialogResult : IResult 8 | { 9 | public event EventHandler Completed; 10 | 11 | private readonly CommonDialog _commonDialog; 12 | 13 | public ShowCommonDialogResult(CommonDialog commonDialog) 14 | { 15 | _commonDialog = commonDialog; 16 | } 17 | 18 | public void Execute(CoroutineExecutionContext context) 19 | { 20 | var result = _commonDialog.ShowDialog().GetValueOrDefault(false); 21 | Completed(this, new ResultCompletionEventArgs { WasCancelled = !result }); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ShowDialogResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Caliburn.Micro; 6 | 7 | namespace CShell.Framework.Results 8 | { 9 | public class ShowDialogResult : ResultBase 10 | { 11 | private readonly Type dialogViewModelType; 12 | private object dialogViewModel; 13 | 14 | public IDictionary Settings { get; set; } 15 | 16 | public ShowDialogResult(object dialogViewModel) 17 | { 18 | this.dialogViewModel = dialogViewModel; 19 | } 20 | 21 | public ShowDialogResult(Type dialogViewModelType) 22 | { 23 | this.dialogViewModelType = dialogViewModelType; 24 | } 25 | 26 | public override void Execute(CoroutineExecutionContext context) 27 | { 28 | var windowManager = IoC.Get(); 29 | if(dialogViewModel == null) 30 | { 31 | dialogViewModel = IoC.GetInstance(dialogViewModelType, null); 32 | } 33 | var result = windowManager.ShowDialog(dialogViewModel, settings:Settings); 34 | OnCompleted(null, result.HasValue && !result.Value); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ShowFolderDialogResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using Caliburn.Micro; 4 | using Microsoft.Win32; 5 | 6 | namespace CShell.Framework.Results 7 | { 8 | public class ShowFolderDialogResult : IResult 9 | { 10 | public event EventHandler Completed; 11 | 12 | public ShowFolderDialogResult() 13 | { } 14 | 15 | public ShowFolderDialogResult(string selectedFolder) 16 | { 17 | this.SelectedFolder = selectedFolder; 18 | } 19 | 20 | public string SelectedFolder { get; set; } 21 | 22 | public void Execute(CoroutineExecutionContext context) 23 | { 24 | var dialog = new FolderBrowserDialog(); 25 | if(!String.IsNullOrEmpty(SelectedFolder)) 26 | dialog.SelectedPath = SelectedFolder; 27 | var result = dialog.ShowDialog(); 28 | SelectedFolder = dialog.SelectedPath; 29 | Completed(this, new ResultCompletionEventArgs { WasCancelled = result != DialogResult.OK }); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Results/ShowToolResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using CShell.Framework.Services; 4 | using Caliburn.Micro; 5 | 6 | namespace CShell.Framework.Results 7 | { 8 | public class ShowToolResult : OpenResultBase 9 | where TTool : ITool 10 | { 11 | private readonly Func _toolLocator = () => IoC.Get(); 12 | 13 | [Import] 14 | private IShell _shell; 15 | 16 | public ShowToolResult() 17 | { 18 | 19 | } 20 | 21 | public ShowToolResult(TTool tool) 22 | { 23 | _toolLocator = () => tool; 24 | } 25 | 26 | public override void Execute(CoroutineExecutionContext context) 27 | { 28 | var tool = _toolLocator(); 29 | 30 | if (_setData != null) 31 | _setData(tool); 32 | 33 | if (_onConfigure != null) 34 | _onConfigure(tool); 35 | 36 | tool.Deactivated += (s, e) => 37 | { 38 | if (_onShutDown != null) 39 | _onShutDown(tool); 40 | 41 | OnCompleted(null); 42 | }; 43 | 44 | _shell.ShowTool(tool); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/Execute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell.Framework.Services 7 | { 8 | public static class Execute 9 | { 10 | public static void OnUIThread(this Action action) 11 | { 12 | Caliburn.Micro.Execute.OnUIThread(action); 13 | } 14 | 15 | /// 16 | /// Executes an action and marshals any exceptions that occur to the calling thread. 17 | /// 18 | /// The action. 19 | public static void OnUIThreadEx(this Action action) 20 | { 21 | Exception exception = null; 22 | Caliburn.Micro.Execute.OnUIThread(()=> 23 | { 24 | try 25 | { 26 | action(); 27 | } 28 | catch (Exception ex) 29 | { 30 | exception = ex; 31 | } 32 | }); 33 | if (exception != null) 34 | throw exception; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/ExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Caliburn.Micro; 3 | 4 | namespace CShell.Framework.Services 5 | { 6 | public static class ExtensionMethods 7 | { 8 | public static string GetExecutingAssemblyName() 9 | { 10 | return Assembly.GetExecutingAssembly().GetAssemblyName(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IDocumentProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Caliburn.Micro; 4 | 5 | namespace CShell.Framework.Services 6 | { 7 | public interface IDocumentProvider 8 | { 9 | bool Handles(Uri uri); 10 | IDocument Create(Uri uri); 11 | } 12 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IInputManager.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | 4 | namespace CShell.Framework.Services 5 | { 6 | public interface IInputManager 7 | { 8 | void SetShortcut(DependencyObject view, InputGesture gesture, object handler); 9 | void SetShortcut(InputGesture gesture, object handler); 10 | } 11 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IOutput.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | using CShell.Framework; 3 | 4 | namespace CShell.Framework.Services 5 | { 6 | public interface IOutput 7 | { 8 | void Write(string text); 9 | void Write(string format, params object[] arg); 10 | void WriteLine(); 11 | void WriteLine(string text); 12 | void WriteLine(string format, params object[] arg); 13 | 14 | void Clear(); 15 | int BufferLength { get; set; } 16 | 17 | string Font { get; set; } 18 | double FontSize { get; set; } 19 | Color TextColor { get; set; } 20 | Color BackgroundColor { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IPropertyGrid.cs: -------------------------------------------------------------------------------- 1 | namespace CShell.Framework.Services 2 | { 3 | public interface IPropertyGrid : ITool 4 | { 5 | object SelectedObject { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IReplOutput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Text; 6 | using System.Windows.Media; 7 | using ScriptCs.Contracts; 8 | 9 | namespace CShell.Framework.Services 10 | { 11 | public interface IReplOutput : IOutput 12 | { 13 | void Initialize(IReplScriptExecutor replExecutor); 14 | 15 | void EvaluateStarted(string input, string sourceFile); 16 | void EvaluateCompleted(ScriptResult result); 17 | 18 | bool IsEvaluating { get; } 19 | 20 | bool ShowConsoleOutput { get; set; } 21 | Color ResultColor { get; set; } 22 | Color WarningColor { get; set; } 23 | Color ErrorColor { get; set; } 24 | void ResetColor(); 25 | 26 | //TODO: move to IReplScripExecutor? 27 | IEnumerable SuppressedWarnings { get; } 28 | void SuppressWarning(string warningCode); 29 | void ShowWarning(string warningCode); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IResourceManager.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Windows.Media.Imaging; 3 | 4 | namespace CShell.Framework.Services 5 | { 6 | public interface IResourceManager 7 | { 8 | Stream GetStream(string relativeUri, string assemblyName); 9 | BitmapImage GetBitmap(string relativeUri, string assemblyName); 10 | BitmapImage GetBitmap(string relativeUri); 11 | } 12 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IShell.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows.Media; 3 | using System.Xml; 4 | using CShell.Framework.Menus; 5 | using Caliburn.Micro; 6 | 7 | namespace CShell.Framework.Services 8 | { 9 | public interface IShell : IConductor 10 | { 11 | string Title { get; set; } 12 | ImageSource Icon { get; set; } 13 | IMenu MainMenu { get; } 14 | IToolBar ToolBar { get; } 15 | IStatusBar StatusBar { get; } 16 | 17 | IScreen ActiveItem { get; } 18 | IEnumerable Documents { get; } 19 | 20 | IEnumerable Tools { get; } 21 | void ShowTool(ITool model); 22 | 23 | void OpenDocument(IDocument model); 24 | void CloseDocument(IDocument document); 25 | void ActivateDocument(IDocument document); 26 | 27 | void Opened(string[] args); 28 | void Close(); 29 | 30 | void SaveLayout(XmlWriter xmlWriter); 31 | void LoadLayout(XmlReader xmlReader); 32 | CShell.Workspace.WindowLocation GetWindowLocation(); 33 | void RestoreWindowLocation(CShell.Workspace.WindowLocation windowLocation); 34 | } 35 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/ISinkProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace CShell.Framework.Services 4 | { 5 | public interface ISinkProvider 6 | { 7 | bool Handles(Uri uri); 8 | ISink Create(Uri uri); 9 | } 10 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/IStatusBar.cs: -------------------------------------------------------------------------------- 1 | namespace CShell.Framework.Services 2 | { 3 | public interface IStatusBar 4 | { 5 | string Message { get; } 6 | 7 | void UpdateMessage(); 8 | void UpdateMessage(string message); 9 | 10 | int Progress { get; } 11 | bool ShowingProgress { get; } 12 | 13 | void UpdateProgress(bool running); 14 | void UpdateProgress(int progress); 15 | } 16 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/InputBindingTrigger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | using System.Windows.Interactivity; 5 | 6 | namespace CShell.Framework.Services 7 | { 8 | public class InputBindingTrigger : TriggerBase, ICommand 9 | { 10 | public static readonly DependencyProperty InputBindingProperty = 11 | DependencyProperty.Register("InputBinding", typeof(InputBinding), 12 | typeof(InputBindingTrigger), new UIPropertyMetadata(null)); 13 | 14 | public InputBinding InputBinding 15 | { 16 | get { return (InputBinding)GetValue(InputBindingProperty); } 17 | set { SetValue(InputBindingProperty, value); } 18 | } 19 | 20 | protected override void OnAttached() 21 | { 22 | if (InputBinding != null) 23 | { 24 | InputBinding.Command = this; 25 | AssociatedObject.InputBindings.Add(InputBinding); 26 | } 27 | base.OnAttached(); 28 | } 29 | 30 | #region ICommand Members 31 | public bool CanExecute(object parameter) 32 | { 33 | // action is anyway blocked by Caliburn at the invoke level 34 | return true; 35 | } 36 | public event EventHandler CanExecuteChanged = delegate { }; 37 | 38 | public void Execute(object parameter) 39 | { 40 | InvokeActions(parameter); 41 | } 42 | 43 | #endregion 44 | } 45 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/InputManager.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | using System.Windows.Interactivity; 5 | using Caliburn.Micro; 6 | 7 | namespace CShell.Framework.Services 8 | { 9 | [Export(typeof(IInputManager))] 10 | public class InputManager : IInputManager 11 | { 12 | public void SetShortcut(DependencyObject view, InputGesture gesture, object handler) 13 | { 14 | var inputBindingTrigger = new InputBindingTrigger(); 15 | inputBindingTrigger.InputBinding = new InputBinding(new RoutedCommand(), gesture); 16 | 17 | //var target = ViewLocator.LocateForModel(handler, null, null); 18 | Interaction.GetTriggers(view).Add(inputBindingTrigger); 19 | 20 | inputBindingTrigger.Actions.Add(new TestTriggerAction(handler)); 21 | } 22 | 23 | public void SetShortcut(InputGesture gesture, object handler) 24 | { 25 | SetShortcut(Application.Current.MainWindow, gesture, handler); 26 | } 27 | 28 | private class TestTriggerAction : TriggerAction 29 | { 30 | private readonly object _handler; 31 | 32 | public TestTriggerAction(object handler) 33 | { 34 | _handler = handler; 35 | } 36 | 37 | protected override void Invoke(object parameter) 38 | { 39 | Action.Invoke(_handler, "Execute"); 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/PaneLocation.cs: -------------------------------------------------------------------------------- 1 | namespace CShell.Framework.Services 2 | { 3 | public enum PaneLocation 4 | { 5 | Left, 6 | Right, 7 | Bottom 8 | } 9 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/ResourceManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using System.IO; 4 | using System.Windows; 5 | using System.Windows.Media.Imaging; 6 | 7 | namespace CShell.Framework.Services 8 | { 9 | [Export(typeof(IResourceManager))] 10 | public class ResourceManager : IResourceManager 11 | { 12 | public Stream GetStream(string relativeUri, string assemblyName) 13 | { 14 | try 15 | { 16 | var resource = Application.GetResourceStream(new Uri(assemblyName + ";component/" + relativeUri, UriKind.Relative)) 17 | ?? Application.GetResourceStream(new Uri(relativeUri, UriKind.Relative)); 18 | 19 | return (resource != null) 20 | ? resource.Stream 21 | : null; 22 | } 23 | catch 24 | { 25 | return null; 26 | } 27 | } 28 | 29 | public BitmapImage GetBitmap(string relativeUri, string assemblyName) 30 | { 31 | var s = GetStream(relativeUri, assemblyName); 32 | if (s == null) return null; 33 | 34 | using (s) 35 | { 36 | var bmp = new BitmapImage(); 37 | bmp.BeginInit(); 38 | bmp.StreamSource = s; 39 | bmp.EndInit(); 40 | bmp.Freeze(); 41 | return bmp; 42 | } 43 | } 44 | 45 | public BitmapImage GetBitmap(string relativeUri) 46 | { 47 | return GetBitmap(relativeUri, ExtensionMethods.GetExecutingAssemblyName()); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Services/WorkspaceActivator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using Caliburn.Micro; 7 | 8 | namespace CShell.Framework.Services 9 | { 10 | /// 11 | /// Helper interface to activate and deactivate UI item depending if a workspace is open. 12 | /// 13 | public interface IWorkspaceActivator : IActivate, IDeactivate 14 | { } 15 | 16 | [Export(typeof(IWorkspaceActivator))] 17 | [PartCreationPolicy(CreationPolicy.Shared)] 18 | public class WorkspaceActivator : IWorkspaceActivator, IHandle 19 | { 20 | [ImportingConstructor] 21 | public WorkspaceActivator(IEventAggregator eventAggregator) 22 | { 23 | eventAggregator.Subscribe(this); 24 | } 25 | 26 | public void Activate() 27 | { 28 | isActive = true; 29 | if(Activated != null) 30 | Activated(this, new ActivationEventArgs()); 31 | } 32 | 33 | public event EventHandler Activated; 34 | 35 | private bool isActive = false; 36 | public bool IsActive 37 | { 38 | get { return isActive; } 39 | } 40 | 41 | public event EventHandler AttemptingDeactivation; 42 | 43 | public void Deactivate(bool close) 44 | { 45 | isActive = false; 46 | 47 | if (AttemptingDeactivation != null) 48 | AttemptingDeactivation(this, new DeactivationEventArgs(){WasClosed = false}); 49 | 50 | if (Deactivated != null) 51 | Deactivated(this, new DeactivationEventArgs() { WasClosed = true }); 52 | } 53 | 54 | public event EventHandler Deactivated; 55 | 56 | 57 | 58 | public void Handle(WorkspaceOpenedEventArgs message) 59 | { 60 | Activate(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Sink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Input; 6 | using CShell.Framework.Services; 7 | 8 | namespace CShell.Framework 9 | { 10 | public abstract class Sink : Document, ISink 11 | { 12 | protected Sink() 13 | { 14 | IsVisible = true; 15 | } 16 | 17 | public abstract void Dump(object o); 18 | 19 | public abstract void Clear(); 20 | 21 | public virtual Uri IconSource 22 | { 23 | get { return null; } 24 | } 25 | 26 | private bool _isVisible; 27 | public bool IsVisible 28 | { 29 | get { return _isVisible; } 30 | set 31 | { 32 | _isVisible = value; 33 | NotifyOfPropertyChange(() => IsVisible); 34 | } 35 | } 36 | 37 | public virtual PaneLocation PreferredLocation 38 | { 39 | get { return PaneLocation.Right; } 40 | } 41 | 42 | /// 43 | /// Gets the display name from the uri, which is usually the second part of the absolute path. 44 | /// 45 | /// The URI. 46 | /// Zero based index. 0 gets the first part of the path, e.g. /mypah/hello -> "mypath" 47 | /// The name of the path part if the path contains such a item, otherwise returns null. 48 | protected string GetUriPathPart(Uri uri, int pathIndex) 49 | { 50 | var pathParts = uri.AbsolutePath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 51 | if (pathParts.Length > pathIndex) 52 | return pathParts[pathIndex]; 53 | return null; 54 | } 55 | 56 | protected string GetTitle(Uri uri, string defaultTitle) 57 | { 58 | var title = GetUriPathPart(uri, 1); 59 | if (title != null) 60 | title = Uri.UnescapeDataString(title); 61 | if (String.IsNullOrEmpty(title)) 62 | title = defaultTitle; 63 | return title; 64 | } 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Src/CShell.Core/Framework/Tool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | using CShell.Framework.Services; 4 | 5 | namespace CShell.Framework 6 | { 7 | public abstract class Tool : LayoutItemBase, ITool 8 | { 9 | private ICommand _closeCommand; 10 | public ICommand CloseCommand 11 | { 12 | get { return _closeCommand ?? (_closeCommand = new RelayCommand(p => IsVisible = false, p => true)); } 13 | } 14 | 15 | public abstract PaneLocation PreferredLocation { get; } 16 | public abstract Uri Uri { get; } 17 | 18 | public virtual Uri IconSource 19 | { 20 | get { return null; } 21 | } 22 | 23 | private bool _isVisible; 24 | public bool IsVisible 25 | { 26 | get { return _isVisible; } 27 | set 28 | { 29 | _isVisible = value; 30 | NotifyOfPropertyChange(() => IsVisible); 31 | } 32 | } 33 | 34 | protected Tool() 35 | { 36 | IsVisible = true; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Src/CShell.Core/ICompletion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using ICSharpCode.AvalonEdit.CodeCompletion; 4 | using ICSharpCode.NRefactory.Editor; 5 | 6 | namespace CShell 7 | { 8 | public class CodeCompletionResult 9 | { 10 | public List CompletionData = new List(); 11 | public IOverloadProvider OverloadProvider; 12 | public ICompletionData SuggestedCompletionDataItem; 13 | public string TriggerWord; 14 | public int TriggerWordLength; 15 | } 16 | 17 | public interface ICompletion 18 | { 19 | void AddReferences(params Assembly[] references); 20 | void RemoveReferences(params Assembly[] references); 21 | void AddReferences(params string[] references); 22 | void RemoveReferences(params string[] references); 23 | 24 | //void SetVariables(string[] variables); 25 | //void ProcessExecution(string script, string file); 26 | 27 | CodeCompletionResult GetCompletions(IDocument document, int offset, bool controlSpace = false, string[] namespaces = null); 28 | ICompletion Clone(bool isRepl = false); 29 | } 30 | } -------------------------------------------------------------------------------- /Src/CShell.Core/IDefaultReferences.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace CShell 9 | { 10 | public interface IDefaultReferences 11 | { 12 | List Assemblies { get; } 13 | List AssemblyPaths { get; } 14 | List Namespaces { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/CShell.Core/IReplExecutorFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CShell.Framework.Services; 7 | 8 | namespace CShell 9 | { 10 | public interface IReplScriptExecutorFactory 11 | { 12 | IReplScriptExecutor Create(string workspaceDirectory); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/CShell.Core/IReplScriptExecutor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Security.Cryptography.X509Certificates; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using ScriptCs.Contracts; 9 | 10 | namespace CShell 11 | { 12 | public interface IReplScriptExecutor : IRepl, IScriptExecutor 13 | { 14 | event EventHandler AssemblyReferencesChanged; 15 | 16 | string WorkspaceDirectory { get; } 17 | ICompletion ReplCompletion { get; } 18 | ICompletion DocumentCompletion { get; } 19 | 20 | string[] GetReferencesAsPaths(); 21 | string[] GetVariables(); 22 | 23 | void ExecuteConfigScript(); 24 | void ExecuteReferencesScript(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/CShell.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Core")] 9 | [assembly: AssemblyDescription("A Simple C# Scripting IDE")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Arnova")] 12 | [assembly: AssemblyProduct("CShellCore")] 13 | [assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("218298d8-aa8f-4644-956f-8fd65d54a6c2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.1.3.*")] 36 | [assembly: AssemblyFileVersion("0.1.3.*")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Core/References.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell 7 | { 8 | public class References 9 | { 10 | //should the whole workspace run in a custom app domain? especially the scriptinge engine? 11 | 12 | //then the workspace could really be unloaded! 13 | // -> see how linqpad does it! 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/CShell.Core/Scripts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell 7 | { 8 | public class Scripts 9 | { 10 | //support .cs files - valid c# code 11 | //support .csx files - partial c# code, can contain only lines of code 12 | 13 | //to start, just have one list of scripts that can be opened 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/CShell.Core/Shell.Tools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using CShell.Framework; 6 | using CShell.Framework.Services; 7 | using Caliburn.Micro; 8 | 9 | namespace CShell 10 | { 11 | public static partial class Shell 12 | { 13 | /// 14 | /// Gets a specific tool based on the URI. 15 | /// If the tool URI exists or can be created the tool is opened. 16 | /// 17 | /// The tool URI. 18 | public static ITool GetTool(Uri uri) 19 | { 20 | return GetTool(uri, false); 21 | } 22 | 23 | /// 24 | /// Gets a specific tool based on the uri. 25 | /// 26 | /// The tool URI. 27 | /// If set to true tool will not be opened, but just created. 28 | /// 29 | public static ITool GetTool(Uri uri, bool suppressOpen) 30 | { 31 | var tools = UI.Tools.ToArray(); 32 | var tool = tools.FirstOrDefault(t => t.Uri == uri); 33 | if (tool == null) 34 | { 35 | tool = IoC.GetAllInstances(typeof(ITool)) 36 | .Cast() 37 | .FirstOrDefault(t=>t.Uri == uri); 38 | 39 | if (tool != null && !suppressOpen) 40 | UI.ShowTool(tool); 41 | } 42 | return tool; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Src/CShell.Core/Shell.Workspace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Caliburn.Micro; 8 | 9 | namespace CShell 10 | { 11 | public static partial class Shell 12 | { 13 | private static readonly Lazy _workspaceLazy = new Lazy(() => IoC.Get()); 14 | 15 | /// 16 | /// Gets the instance of the currently open workspace. 17 | /// 18 | public static Workspace Workspace { get { return _workspaceLazy.Value; } } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/CShell.Core/Test.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell 7 | { 8 | public static class Test 9 | { 10 | public static string Txt { get; set; } 11 | public static void Print() 12 | { 13 | Console.WriteLine(Txt); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/CShell.Core/Util/PathHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace CShell.Util 8 | { 9 | public static class PathHelper 10 | { 11 | public static String ToAbsolutePath(String fromPath, String toPath) 12 | { 13 | if (String.IsNullOrEmpty(toPath)) 14 | return null; 15 | if (String.IsNullOrEmpty(fromPath)) 16 | return toPath; 17 | 18 | Uri path2 = new Uri(toPath, UriKind.RelativeOrAbsolute); 19 | if (path2.IsAbsoluteUri) 20 | return toPath; 21 | Uri basePath = new Uri(fromPath + "/", UriKind.Absolute); 22 | Uri absPath = new Uri(basePath, toPath); 23 | return absPath.LocalPath; 24 | } 25 | 26 | /// 27 | /// Creates a relative path from one file or folder to another. 28 | /// 29 | /// Contains the directory that defines the start of the relative path. 30 | /// Contains the path that defines the endpoint of the relative path. 31 | /// The relative path from the start directory to the end path. 32 | /// 33 | public static String ToRelativePath(String fromPath, String toPath) 34 | { 35 | if (String.IsNullOrEmpty(toPath)) 36 | return null; 37 | if (String.IsNullOrEmpty(fromPath)) 38 | return toPath; 39 | 40 | Uri uri1 = new Uri(toPath, UriKind.RelativeOrAbsolute); 41 | if (uri1.IsAbsoluteUri) 42 | { 43 | Uri uri2 = new Uri(fromPath + "/", UriKind.Absolute); 44 | Uri relativeUri = uri2.MakeRelativeUri(uri1); 45 | return Uri.UnescapeDataString(relativeUri.ToString()).Replace('/', Path.DirectorySeparatorChar); 46 | } 47 | // else it is already a relative path 48 | return toPath; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Src/CShell.Core/Workspace.Serialization.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Text; 9 | using System.Xml; 10 | using System.Xml.Serialization; 11 | using CShell.Framework.Services; 12 | using Caliburn.Micro; 13 | 14 | namespace CShell 15 | { 16 | public sealed partial class Workspace 17 | { 18 | private void SaveLayout() 19 | { 20 | var path = Path.Combine(WorkspaceDirectory, Constants.LayoutFile); 21 | var settings = new XmlWriterSettings(); 22 | settings.Indent = true; 23 | var windowLocation = shell.GetWindowLocation(); 24 | 25 | var serializer = new XmlSerializer(typeof(WindowLocation)); 26 | using (var xmlWriter = XmlWriter.Create(path, settings)) 27 | { 28 | xmlWriter.WriteStartDocument(); 29 | xmlWriter.WriteStartElement("CShellLayout"); 30 | serializer.Serialize(xmlWriter, windowLocation); 31 | shell.SaveLayout(xmlWriter); 32 | xmlWriter.WriteEndElement(); 33 | } 34 | } 35 | 36 | private void LoadLayout() 37 | { 38 | var path = Path.Combine(WorkspaceDirectory, Constants.LayoutFile); 39 | if(!File.Exists(path)) 40 | return; 41 | 42 | var settings = new XmlReaderSettings(); 43 | settings.IgnoreWhitespace = true; 44 | 45 | var serializer = new XmlSerializer(typeof(WindowLocation)); 46 | using (var xmlReader = XmlReader.Create(path, settings)) 47 | { 48 | xmlReader.ReadStartElement(); 49 | var windowLocation = (WindowLocation)serializer.Deserialize(xmlReader); 50 | shell.RestoreWindowLocation(windowLocation); 51 | 52 | shell.LoadLayout(xmlReader); 53 | } 54 | } 55 | 56 | [Browsable(false)] 57 | [XmlRootAttribute("WindowLocation", IsNullable = false)] 58 | public class WindowLocation 59 | { 60 | public double Top { get; set; } 61 | public double Left { get; set; } 62 | public double Height { get; set; } 63 | public double Width { get; set; } 64 | public string State { get; set; } 65 | public int Monitor { get; set; } 66 | } 67 | 68 | }//end class Workspace 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Src/CShell.Core/WorkspaceEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell 7 | { 8 | public class WorkspaceOpeningEventArgs : EventArgs 9 | { 10 | public WorkspaceOpeningEventArgs(string workspaceDirectory) 11 | { 12 | WorkspaceDirectory = workspaceDirectory; 13 | } 14 | public string WorkspaceDirectory { get; private set; } 15 | } 16 | 17 | public class WorkspaceOpenedEventArgs : EventArgs 18 | { 19 | public WorkspaceOpenedEventArgs(string workspaceDirectory) 20 | { 21 | WorkspaceDirectory = workspaceDirectory; 22 | } 23 | public string WorkspaceDirectory { get; private set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/CShell.Core/WorkspaceException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace CShell 7 | { 8 | public class WorkspaceException : Exception 9 | { 10 | public WorkspaceException() 11 | {} 12 | 13 | public WorkspaceException(string message) 14 | :base(message) 15 | { } 16 | 17 | public WorkspaceException(string message, Exception innerException) 18 | : base(message, innerException) 19 | { } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/CShell.Core/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Src/CShell.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Src/CShell.Hosting.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CShell.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("09c1b10b-c3f2-4e64-b6a5-6b36114914ea")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Hosting.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Src/CShell.Hosting.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/DefaultReferences.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace CShell.Hosting 6 | { 7 | public class DefaultReferences : IDefaultReferences 8 | { 9 | public DefaultReferences() 10 | { 11 | Assemblies = new List(); 12 | AssemblyPaths = new List(); 13 | Namespaces = new List(); 14 | } 15 | public List Assemblies { get; private set; } 16 | public List AssemblyPaths { get; private set; } 17 | public List Namespaces { get; private set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/FileSystem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CShell.Hosting 8 | { 9 | public class FileSystem : ScriptCs.FileSystem 10 | { 11 | public override string BinFolder 12 | { 13 | get { return Constants.BinFolder; } 14 | } 15 | 16 | public override string DllCacheFolder 17 | { 18 | get { return Constants.DllCacheFolder; } 19 | } 20 | 21 | public override string PackagesFile 22 | { 23 | get { return Constants.PackagesFile; } 24 | } 25 | 26 | public override string PackagesFolder 27 | { 28 | get { return Constants.PackagesFolder; } 29 | } 30 | 31 | public override string NugetFile 32 | { 33 | get { return Constants.NugetFile; } 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/ObjectSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using ScriptCs.Contracts; 7 | 8 | namespace CShell.Hosting 9 | { 10 | class ObjectSerializer : IObjectSerializer 11 | { 12 | public string Serialize(object value) 13 | { 14 | throw new NotImplementedException(); 15 | } 16 | } 17 | 18 | class MockConsole : IConsole 19 | { 20 | public void Clear() 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | 25 | public void Exit() 26 | { 27 | throw new NotImplementedException(); 28 | } 29 | 30 | public ConsoleColor ForegroundColor 31 | { 32 | get 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | set 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | } 41 | 42 | public string ReadLine() 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | 47 | public void ResetColor() 48 | { 49 | throw new NotImplementedException(); 50 | } 51 | 52 | public void Write(string value) 53 | { 54 | throw new NotImplementedException(); 55 | } 56 | 57 | public void WriteLine(string value) 58 | { 59 | throw new NotImplementedException(); 60 | } 61 | 62 | public void WriteLine() 63 | { 64 | throw new NotImplementedException(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/Package/NugetMachineWideSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NuGet; 4 | 5 | namespace CShell.Hosting.Package 6 | { 7 | internal class NugetMachineWideSettings : IMachineWideSettings 8 | { 9 | private readonly Lazy> _settings; 10 | 11 | public NugetMachineWideSettings() 12 | { 13 | var baseDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); 14 | _settings = new Lazy>(() => NuGet.Settings.LoadMachineWideSettings(new PhysicalFileSystem(baseDirectory))); 15 | } 16 | 17 | public IEnumerable Settings 18 | { 19 | get 20 | { 21 | return _settings.Value; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Src/CShell.Hosting/Package/PackageInstaller.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using ScriptCs.Contracts; 5 | 6 | namespace CShell.Hosting.Package 7 | { 8 | public class PackageInstaller : IPackageInstaller 9 | { 10 | private readonly IInstallationProvider _installer; 11 | private readonly ILog _logger; 12 | 13 | public PackageInstaller(IInstallationProvider installer, ILogProvider logProvider) 14 | { 15 | _installer = installer; 16 | _logger = logProvider.For(); 17 | } 18 | 19 | public void InstallPackages(IEnumerable packageIds, bool allowPreRelease = false) 20 | { 21 | if (packageIds == null) 22 | { 23 | throw new ArgumentNullException("packageIds"); 24 | } 25 | 26 | packageIds = packageIds.ToList(); 27 | 28 | if (!packageIds.Any()) 29 | { 30 | _logger.Info("Nothing to install."); 31 | return; 32 | } 33 | 34 | var exceptions = new List(); 35 | foreach (var packageId in packageIds) 36 | { 37 | if (_installer.IsInstalled(packageId, allowPreRelease)) 38 | { 39 | continue; 40 | } 41 | 42 | try 43 | { 44 | _installer.InstallPackage(packageId, allowPreRelease); 45 | } 46 | catch (Exception ex) 47 | { 48 | _logger.ErrorException(ex.Message, ex); 49 | exceptions.Add(ex); 50 | } 51 | } 52 | 53 | if (exceptions.Any()) 54 | { 55 | throw new AggregateException(exceptions); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Hosting")] 9 | [assembly: AssemblyDescription("A Simple C# Scripting IDE")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Arnova")] 12 | [assembly: AssemblyProduct("CShellCore")] 13 | [assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8f0f1b90-3409-42fc-b1ae-5d3fe9fc523b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.1.3.*")] 36 | [assembly: AssemblyFileVersion("0.1.3.*")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/ReplCommands/ClearCommand.cs: -------------------------------------------------------------------------------- 1 | using CShell.Framework.Services; 2 | using CShell.Hosting.ReplCommands; 3 | using ScriptCs.Contracts; 4 | 5 | namespace CShell.Hosting.ReplCommands 6 | { 7 | public class ClearCommand : IReplCommand 8 | { 9 | private readonly IReplOutput replOutput; 10 | 11 | public ClearCommand(IReplOutput replOutput) 12 | { 13 | this.replOutput = replOutput; 14 | } 15 | 16 | public string CommandName 17 | { 18 | get { return "clear"; } 19 | } 20 | 21 | public string Description 22 | { 23 | get { return "Clears all text from the REPL."; } 24 | } 25 | 26 | public object Execute(IRepl repl, object[] args) 27 | { 28 | replOutput.Clear(); 29 | return null; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Src/CShell.Hosting/ReplCommands/HelpCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CShell.Framework.Services; 7 | using ScriptCs.Contracts; 8 | 9 | namespace CShell.Hosting.ReplCommands 10 | { 11 | public class HelpCommand : IReplCommand 12 | { 13 | private readonly IReplOutput replOutput; 14 | 15 | public HelpCommand(IReplOutput replOutput) 16 | { 17 | this.replOutput = replOutput; 18 | } 19 | 20 | public string CommandName 21 | { 22 | get { return "help"; } 23 | } 24 | 25 | public string Description 26 | { 27 | get { return "Displays this help screen."; } 28 | } 29 | 30 | public object Execute(IRepl repl, object[] args) 31 | { 32 | replOutput.WriteLine("The following commands are available in the REPL:"); 33 | foreach (var command in repl.Commands.OrderBy(x => x.Key)) 34 | { 35 | replOutput.WriteLine(string.Format(":{0,-15}{1,10}", command.Key, command.Value.Description)); 36 | } 37 | return null; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/ReplCommands/ResetCommand.cs: -------------------------------------------------------------------------------- 1 | using ScriptCs.Contracts; 2 | 3 | namespace CShell.Hosting.ReplCommands 4 | { 5 | public class ResetCommand : IReplCommand 6 | { 7 | public string CommandName 8 | { 9 | get { return "reset"; } 10 | } 11 | 12 | public string Description 13 | { 14 | get { return "Resets the REPL environment and clears all text."; } 15 | } 16 | 17 | public object Execute(IRepl repl, object[] args) 18 | { 19 | repl.Reset(); 20 | return null; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Src/CShell.Hosting/ReplScriptExecutorFactory.cs: -------------------------------------------------------------------------------- 1 | using CShell.Framework.Services; 2 | using ScriptCs; 3 | 4 | namespace CShell.Hosting 5 | { 6 | public class ReplScriptExecutorFactory : IReplScriptExecutorFactory 7 | { 8 | private readonly IReplOutput replOutput; 9 | private readonly IDefaultReferences defaultReferences; 10 | private readonly ScriptServices scriptServices; 11 | 12 | public ReplScriptExecutorFactory(ScriptServices scriptServices, IReplOutput replOutput, IDefaultReferences defaultReferences) 13 | { 14 | this.scriptServices = scriptServices; 15 | this.replOutput = replOutput; 16 | this.defaultReferences = defaultReferences; 17 | } 18 | 19 | public IReplScriptExecutor Create(string workspaceDirectory) 20 | { 21 | scriptServices.FileSystem.CurrentDirectory = workspaceDirectory; 22 | scriptServices.InstallationProvider.Initialize(); 23 | 24 | var replExecutor = new ReplScriptExecutor( 25 | replOutput, 26 | scriptServices.ObjectSerializer, 27 | scriptServices.FileSystem, 28 | scriptServices.FilePreProcessor, 29 | scriptServices.Engine, 30 | scriptServices.LogProvider, 31 | scriptServices.ReplCommands, 32 | defaultReferences 33 | ); 34 | 35 | var assemblies = scriptServices.AssemblyResolver.GetAssemblyPaths(scriptServices.FileSystem.CurrentDirectory); 36 | var scriptPacks = scriptServices.ScriptPackResolver.GetPacks(); 37 | 38 | replExecutor.Initialize(assemblies, scriptPacks); 39 | replOutput.Initialize(replExecutor); 40 | 41 | return replExecutor; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/ReplScriptHost.cs: -------------------------------------------------------------------------------- 1 | using CShell.Framework.Services; 2 | using ScriptCs; 3 | using ScriptCs.Contracts; 4 | 5 | namespace CShell.Hosting 6 | { 7 | public class ReplScriptHost : ScriptHost 8 | { 9 | public ReplScriptHost(IScriptPackManager scriptPackManager, ScriptEnvironment environment) 10 | : base(scriptPackManager, environment) 11 | { 12 | } 13 | } 14 | 15 | public class ReplScriptHostFactory : IScriptHostFactory 16 | { 17 | public IScriptHost CreateScriptHost(IScriptPackManager scriptPackManager, string[] scriptArgs) 18 | { 19 | return new ReplScriptHost(scriptPackManager, new ScriptEnvironment(scriptArgs)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Src/CShell.Hosting/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/ChartSinkProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Framework.Services; 8 | 9 | namespace CShell.Sinks.Charting 10 | { 11 | [Export(typeof(ISinkProvider))] 12 | public class ChartSinkProvider : ISinkProvider 13 | { 14 | public bool Handles(Uri uri) 15 | { 16 | return uri.Scheme == "sink" && uri.Host == "cshell"; 17 | } 18 | 19 | /// 20 | /// Creates a CShell sink. 21 | /// 22 | /// The URI. 23 | /// If the URI was correct a sink, otherwise null. 0) 28 | { 29 | //the first part of the uri is the sink type 30 | var sinkType = pathParts[0].ToLower(); 31 | 32 | if (sinkType == "plot" || sinkType == "chart") 33 | { 34 | return new ChartSinkViewModel(uri); 35 | } 36 | 37 | } 38 | return null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/ChartSinkView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/ChartSinkView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace CShell.Sinks.Charting 6 | { 7 | /// 8 | /// Interaction logic for ChartSinkView.xaml 9 | /// 10 | public partial class ChartSinkView : UserControl 11 | { 12 | public ChartSinkView() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) 18 | { 19 | var vm = e.OldValue as ChartSinkViewModel; 20 | if(vm != null) 21 | { 22 | vm.PropertyChanged -= VmOnPropertyChanged; 23 | } 24 | vm = e.NewValue as ChartSinkViewModel; 25 | if(vm != null) 26 | { 27 | vm.PropertyChanged += VmOnPropertyChanged; 28 | FormHost.Child = vm.Chart; 29 | } 30 | } 31 | 32 | private void VmOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) 33 | { 34 | var vm = sender as ChartSinkViewModel; 35 | if (vm != null) 36 | { 37 | FormHost.Child = vm.Chart; 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/Module.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Framework; 8 | 9 | namespace CShell.Sinks.Charting 10 | { 11 | [Export(typeof(IModule))] 12 | public class Module : ModuleBase 13 | { 14 | [Import] 15 | public IDefaultReferences DefaultReferences { get; set; } 16 | 17 | public override void Configure() 18 | { 19 | if (DefaultReferences != null) 20 | { 21 | DefaultReferences.Assemblies.Add(typeof(ChartSink).Assembly); 22 | DefaultReferences.Namespaces.Add(typeof(ChartSink).Namespace); 23 | } 24 | } 25 | 26 | public override void Start() 27 | {} 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Sinks.Chart")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CShell.Sinks.Chart")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1937547e-a5ee-44c8-b917-97f9e32992d8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Chart/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/GridSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CShell.Framework; 7 | 8 | namespace CShell.Sinks.Grid 9 | { 10 | public static class GridSink 11 | { 12 | public const string GridSinkUri = "sink://cshell/grid/"; 13 | 14 | public static ISink GetGridSink(string sinkName) 15 | { 16 | return GetGridSink(sinkName, false); 17 | } 18 | 19 | public static ISink GetGridSink(string sinkName, bool suppressOpen) 20 | { 21 | var uri = new Uri(GridSinkUri + sinkName); 22 | return Shell.GetSink(uri, suppressOpen); 23 | } 24 | 25 | public static void DumpGrid(this object o, string sinkName = null) 26 | { 27 | var sink = GetGridSink(sinkName); 28 | sink.Dump(o); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/GridSinkProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Framework.Services; 8 | 9 | namespace CShell.Sinks.Grid 10 | { 11 | [Export(typeof(ISinkProvider))] 12 | public class GridSinkProvider : ISinkProvider 13 | { 14 | public bool Handles(Uri uri) 15 | { 16 | return uri.Scheme == "sink" && uri.Host == "cshell"; 17 | } 18 | 19 | /// 20 | /// Creates a CShell sink. 21 | /// 22 | /// The URI. 23 | /// If the URI was correct a sink, otherwise null. 24 | public Framework.ISink Create(Uri uri) 25 | { 26 | var pathParts = uri.AbsolutePath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); 27 | if (pathParts.Length > 0) 28 | { 29 | //the first part of the uri is the sink type 30 | var sinkType = pathParts[0].ToLower(); 31 | 32 | if (sinkType == "grid") 33 | { 34 | return new GridSinkViewModel(uri); 35 | } 36 | 37 | } 38 | return null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/GridSinkView.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 28 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/Module.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Framework; 8 | 9 | namespace CShell.Sinks.Grid 10 | { 11 | [Export(typeof(IModule))] 12 | public class Module : ModuleBase 13 | { 14 | [Import] 15 | public IDefaultReferences DefaultReferences { get; set; } 16 | 17 | public override void Configure() 18 | { 19 | if (DefaultReferences != null) 20 | { 21 | DefaultReferences.Assemblies.Add(typeof(GridSinkViewModel).Assembly); 22 | DefaultReferences.Namespaces.Add(typeof(GridSinkViewModel).Namespace); 23 | } 24 | } 25 | 26 | public override void Start() 27 | {} 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Sinks.Grid")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CShell.Sinks.Grid")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("789b2929-9c9d-478d-9ff0-76e68ab37aaf")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Grid/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/Module.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Framework; 8 | 9 | namespace CShell.Sinks.Xhtml 10 | { 11 | [Export(typeof(IModule))] 12 | public class Module : ModuleBase 13 | { 14 | [Import] 15 | public IDefaultReferences DefaultReferences { get; set; } 16 | 17 | public override void Configure() 18 | { 19 | if (DefaultReferences != null) 20 | { 21 | DefaultReferences.Assemblies.Add(typeof(XhtmlSinkViewModel).Assembly); 22 | DefaultReferences.Namespaces.Add(typeof(XhtmlSinkViewModel).Namespace); 23 | } 24 | } 25 | 26 | public override void Start() 27 | {} 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Sinks.Xhtml")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CShell.Sinks.Xhtml")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("855a9513-0074-47e0-a8f8-9e5a2f909747")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlDumper/BasicXhtmlRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Web.UI; 2 | 3 | namespace CShell.Sinks.Xhtml.XhtmlDumper 4 | { 5 | //todo: should be called GeneralXhtmlRenderer 6 | public sealed class BasicXhtmlRenderer : IXhtmlRenderer 7 | { 8 | public bool Render(object o, string description, int depth, XhtmlTextWriter writer) 9 | { 10 | writer.WriteLine(o); 11 | return true; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlDumper/IXhtmlRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Web.UI; 2 | 3 | namespace CShell.Sinks.Xhtml.XhtmlDumper 4 | { 5 | public interface IXhtmlRenderer 6 | { 7 | bool Render(object o, string description, int depth, XhtmlTextWriter writer); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CShell.Framework; 7 | 8 | namespace CShell.Sinks.Xhtml 9 | { 10 | public static class XhtmlSink 11 | { 12 | public const string XhtmlSinkUri = "sink://cshell/xhtml/"; 13 | 14 | public static ISink GetXhtmlSink(string sinkName) 15 | { 16 | return GetXhtmlSink(sinkName, false); 17 | } 18 | 19 | public static ISink GetXhtmlSink(string sinkName, bool suppressOpen) 20 | { 21 | var uri = new Uri(XhtmlSinkUri + sinkName); 22 | return Shell.GetSink(uri, suppressOpen); 23 | } 24 | 25 | public static void DumpXhtml(this object o, string sinkName = null) 26 | { 27 | var sink = GetXhtmlSink(sinkName); 28 | sink.Dump(o); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlSinkProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Framework.Services; 8 | 9 | namespace CShell.Sinks.Xhtml 10 | { 11 | [Export(typeof(ISinkProvider))] 12 | public class XhtmlSinkProvider : ISinkProvider 13 | { 14 | public bool Handles(Uri uri) 15 | { 16 | return uri.Scheme == "sink" && uri.Host == "cshell"; 17 | } 18 | 19 | /// 20 | /// Creates a CShell sink. 21 | /// The CShell sink URI is arranged like this: 22 | /// sink://cshell/SinkType/SinkName 23 | /// for example, following uri would create a XHTML window named "Hi" 24 | /// sink://cshell/xhtml/Hi 25 | /// 26 | /// The URI. 27 | /// If the URI was correct a sink, otherwise null. 0) 32 | { 33 | //the first part of the uri is the sink type 34 | var sinkType = pathParts[0].ToLower(); 35 | 36 | if (sinkType == "xhtml") 37 | { 38 | return new XhtmlSinkViewModel(uri); 39 | } 40 | 41 | } 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlSinkView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlSinkView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace CShell.Sinks.Xhtml 7 | { 8 | /// 9 | /// Interaction logic for XhtmlSinkView.xaml 10 | /// 11 | public partial class XhtmlSinkView : UserControl 12 | { 13 | public XhtmlSinkView() 14 | { 15 | InitializeComponent(); 16 | } 17 | 18 | private void webBrowser_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) 19 | { 20 | var vm = e.NewValue as XhtmlSinkViewModel; 21 | if (vm != null) 22 | { 23 | vm.PropertyChanged += VMOnPropertyChanged; 24 | if(!String.IsNullOrEmpty(vm.Text)) 25 | webBrowser.NavigateToString(vm.Text); 26 | } 27 | } 28 | 29 | private void VMOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) 30 | { 31 | if (propertyChangedEventArgs.PropertyName == "Text") 32 | { 33 | var vm = sender as XhtmlSinkViewModel; 34 | if (!String.IsNullOrEmpty(vm.Text)) 35 | webBrowser.NavigateToString(vm.Text); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/XhtmlSinkViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Text; 5 | using Caliburn.Micro; 6 | using CShell.Framework.Services; 7 | using CShell.Sinks.Xhtml.XhtmlDumper; 8 | 9 | namespace CShell.Sinks.Xhtml 10 | { 11 | public class XhtmlSinkViewModel : Framework.Sink 12 | { 13 | private StringBuilder stringBuilder; 14 | private StringWriter stringWriter; 15 | private XhtmlDumper.XhtmlDumper xhtmlDumper; 16 | 17 | private TextWriter linqPadWriter; 18 | 19 | public XhtmlSinkViewModel(Uri uri) 20 | { 21 | Uri = uri; 22 | DisplayName = GetTitle(uri, "Dump"); 23 | } 24 | 25 | public override PaneLocation PreferredLocation 26 | { 27 | get { return PaneLocation.Right; } 28 | } 29 | 30 | private string text = ""; 31 | public string Text 32 | { 33 | get { return text; } 34 | } 35 | 36 | public override void Dump(object o) 37 | { 38 | if (xhtmlDumper == null) 39 | { 40 | stringBuilder = new StringBuilder(); 41 | stringWriter = new StringWriter(stringBuilder); 42 | var renderers = IoC.GetAllInstances(typeof(IXhtmlRenderer)).Cast().ToList(); 43 | //add the basic rederer at the end 44 | renderers.Add(new BasicXhtmlRenderer()); 45 | xhtmlDumper = new XhtmlDumper.XhtmlDumper(stringWriter); 46 | } 47 | 48 | xhtmlDumper.WriteObject(o, null, 3); 49 | text = stringBuilder.ToString(); 50 | //append the closing HTML closing tags to the string 51 | text += Environment.NewLine + ""; 52 | 53 | NotifyOfPropertyChange(()=>Text); 54 | } 55 | 56 | public override void Clear() 57 | { 58 | if(linqPadWriter != null) 59 | linqPadWriter.Dispose(); 60 | linqPadWriter = null; 61 | 62 | text = String.Empty; 63 | NotifyOfPropertyChange(() => Text); 64 | } 65 | 66 | protected override void OnDeactivate(bool close) 67 | { 68 | Clear(); 69 | base.OnDeactivate(close); 70 | } 71 | 72 | public override bool Equals(object obj) 73 | { 74 | var other = obj as XhtmlSinkViewModel; 75 | return other != null && Uri == other.Uri; 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Src/CShell.Sinks.Xhtml/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/CShell.Tests/CommandQueueTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using CShell.Modules.Repl.Controls; 4 | using NUnit.Framework; 5 | 6 | namespace CShell.Tests 7 | { 8 | public class CommandQueueTest 9 | { 10 | [Test] 11 | public void AddItemToQueue_Limit1_ExpectAdded() 12 | { 13 | var queue = new CommandQueue(1); 14 | const string expected = "Test string"; 15 | 16 | queue.Add(expected); 17 | 18 | List actual = queue.Contents().ToList(); 19 | 20 | Assert.AreEqual(expected, actual[0]); 21 | } 22 | 23 | [Test] 24 | public void AddMultipleItemsToQueue_Limit1_ExpectLimitAdhered() 25 | { 26 | const int expectedQueueLength = 1; 27 | 28 | var queue = new CommandQueue(expectedQueueLength); 29 | 30 | queue.Add("Test String 1"); 31 | queue.Add("Test String 2"); 32 | 33 | int actualQueueLength = queue.Contents().Count(); 34 | 35 | Assert.AreEqual(expectedQueueLength,actualQueueLength); 36 | } 37 | 38 | [Test] 39 | public void AddMultipleItemsToQueue_Limit1_ExpectLastElementKept() 40 | { 41 | const string expectedElementKept = "Test String 2"; 42 | 43 | var queue = new CommandQueue(1); 44 | 45 | queue.Add("Test String 1"); 46 | queue.Add("Test String 2"); 47 | 48 | string actualElementKept = queue.Contents().Single(); 49 | 50 | Assert.AreEqual(expectedElementKept, actualElementKept); 51 | } 52 | 53 | [Test] 54 | //[TestCase("Test String 1", -1] We don't test String 1 as it should've been removed from queue 55 | [TestCase("Test String 2", 0)] 56 | [TestCase("Test String 3", 1)] 57 | [TestCase("Test String 4", 2)] 58 | public void AddMultipleItemsToQueue_Limit3_ExpectLastElementKept(string actual, int expectedQueuePosition) 59 | { 60 | var queue = new CommandQueue(3); 61 | 62 | queue.Add("Test String 1"); 63 | queue.Add("Test String 2"); 64 | queue.Add("Test String 3"); 65 | queue.Add("Test String 4"); 66 | 67 | string[] actualElementKept = queue.Contents().ToArray(); 68 | 69 | Assert.AreEqual(actual, actualElementKept[expectedQueuePosition]); 70 | 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Src/CShell.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CShell.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CShell.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7b3353b4-bf81-4446-8c8e-f8f64cba7cdf")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Src/CShell.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Src/CShell.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | False 3 | True 4 | False 5 | True 6 | License 7 | CShell, A Simple C# Scripting IDE 8 | Copyright (C) $CREATED_YEAR$ Arnova Asset Management Ltd., Lukas Buhler 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------------- /Src/CShell/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Src/CShell/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Linq; 5 | using System.Windows; 6 | 7 | namespace CShell 8 | { 9 | /// 10 | /// Interaction logic for App.xaml 11 | /// 12 | public partial class App : Application 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/CShell/Default/Default.cshell: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using CShell; 6 | 7 | public class CShellFile : ICShellFile 8 | { 9 | public void OnOpened(Workspace workspace) 10 | { 11 | workspace.Load(workspace.CShellFileName + CShell.Constants.WorkspaceFileExtension, true); 12 | Shell.TryOpen("Scratchpad.csx"); 13 | Shell.TryOpen("Tutorial.csx"); 14 | } 15 | 16 | public void OnClosing(Workspace workspace) 17 | { 18 | workspace.Save(workspace.CShellFileName + CShell.Constants.WorkspaceFileExtension, true); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/CShell/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Icon.ico -------------------------------------------------------------------------------- /Src/CShell/Modules/Editors/Controls/CodeCompletionTextEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using CShell.Completion; 8 | using CShell.Framework.Services; 9 | 10 | namespace CShell.Modules.Editors.Controls 11 | { 12 | public class CodeCompletionTextEditor : CodeTextEditor 13 | { 14 | public IReplScriptExecutor ReplExecutor { get; set; } 15 | 16 | protected override string[] GetNamespaces() 17 | { 18 | if (ReplExecutor != null) 19 | { 20 | var fileExtension = Path.GetExtension(FileName); 21 | if (fileExtension != null && fileExtension.ToLower() == ".csx") 22 | { 23 | return ReplExecutor.Namespaces.ToArray(); 24 | } 25 | } 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Editors/EditorProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.IO; 5 | using CShell.Framework; 6 | using CShell.Framework.Services; 7 | using CShell.Modules.Editors.ViewModels; 8 | 9 | namespace CShell.Modules.Editors 10 | { 11 | [Export(typeof(IDocumentProvider))] 12 | public class EditorProvider : IDocumentProvider 13 | { 14 | private readonly List extensions = new List 15 | { 16 | ".cshell", 17 | ".cs", 18 | ".csx", 19 | ".txt", 20 | ".cmd", 21 | ".xml", 22 | ".config", 23 | }; 24 | 25 | [Import] 26 | public CShell.Workspace Workspace { get; set; } 27 | 28 | public bool Handles(Uri uri) 29 | { 30 | var extension = Path.GetExtension(uri.AbsolutePath); 31 | return uri.Scheme == "file" && extensions.Contains(extension); 32 | } 33 | 34 | public IDocument Create(Uri uri) 35 | { 36 | var editor = new EditorViewModel(Workspace); 37 | editor.Open(uri); 38 | return editor; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Src/CShell/Modules/Editors/Views/EditorView.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Editors/Views/EditorView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Windows.Controls; 7 | using System.Windows.Input; 8 | using CShell.Framework.Services; 9 | using CShell.Modules.Editors.ViewModels; 10 | using ICSharpCode.AvalonEdit.CodeCompletion; 11 | using ICSharpCode.AvalonEdit.Document; 12 | 13 | namespace CShell.Modules.Editors.Views 14 | { 15 | /// 16 | /// Interaction logic for EditorView.xaml 17 | /// 18 | public partial class EditorView : UserControl 19 | { 20 | public EditorView() 21 | { 22 | InitializeComponent(); 23 | } 24 | 25 | #region Commend / Uncomment 26 | public void Comment() 27 | { 28 | var document = textEditor.Document; 29 | var start = document.GetLineByOffset(textEditor.SelectionStart); 30 | var end = document.GetLineByOffset(textEditor.SelectionStart + textEditor.SelectionLength); 31 | using (document.RunUpdate()) 32 | { 33 | for (DocumentLine line = start; line!=null && line.LineNumber <= end.LineNumber; line = line.NextLine) 34 | { 35 | if(!IsLineCommented(line)) 36 | document.Insert(line.Offset, "//"); 37 | } 38 | } 39 | } 40 | 41 | public void Uncomment() 42 | { 43 | var document = textEditor.Document; 44 | var start = document.GetLineByOffset(textEditor.SelectionStart); 45 | var end = document.GetLineByOffset(textEditor.SelectionStart + textEditor.SelectionLength); 46 | using (document.RunUpdate()) 47 | { 48 | for (DocumentLine line = start; line != null && line.LineNumber <= end.LineNumber; line = line.NextLine) 49 | { 50 | if (IsLineCommented(line)) 51 | document.Remove(line.Offset, 2); 52 | } 53 | } 54 | } 55 | 56 | private bool IsLineCommented(DocumentLine line) 57 | { 58 | var lineText = textEditor.Document.GetText(line.Offset, line.Length); 59 | var trimmed = lineText.Trim(); 60 | return trimmed.IndexOf("//",0).Equals(0); 61 | } 62 | #endregion 63 | }//end class 64 | } 65 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Help/Module.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Input; 7 | using CShell.Framework; 8 | using CShell.Framework.Menus; 9 | using CShell.Framework.Results; 10 | using CShell.Modules.Help.ViewModels; 11 | using Caliburn.Micro; 12 | 13 | namespace CShell.Modules.Help 14 | { 15 | [Export(typeof (IModule))] 16 | public class Module : ModuleBase 17 | { 18 | public Module() 19 | { 20 | Order = 6; 21 | } 22 | 23 | public override void Start() 24 | { 25 | //populate the menu 26 | MainMenu.First(item => item.Name == "Help") 27 | .Add( 28 | new MenuItem("View Help", ViewHelp).WithGlobalShortcut(ModifierKeys.Control, Key.F1), 29 | MenuItemBase.Separator, 30 | new MenuItem("About CShell", About) 31 | ); 32 | } 33 | 34 | public IEnumerable ViewHelp() 35 | { 36 | System.Diagnostics.Process.Start(Constants.CShellHelp); 37 | yield break; 38 | } 39 | 40 | public IEnumerable About() 41 | { 42 | yield return Show.Dialog(); 43 | } 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Help/ViewModels/AboutViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using Caliburn.Micro; 8 | 9 | namespace CShell.Modules.Help.ViewModels 10 | { 11 | [Export] 12 | public class AboutViewModel : Screen 13 | { 14 | public AboutViewModel() 15 | { 16 | DisplayName = "About CShell"; 17 | } 18 | 19 | public string Version 20 | { 21 | get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } 22 | } 23 | 24 | public string AboutText 25 | { 26 | get 27 | { 28 | var txt = ""; 29 | txt += "CShell, A Simple C# Scripting IDE" + Environment.NewLine; 30 | txt+="Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler" + Environment.NewLine; 31 | txt+="" + Environment.NewLine; 32 | txt += "This program is free software: you can redistribute it and/or modify "; 33 | txt += "it under the terms of the GNU General Public License as published by "; 34 | txt += "the Free Software Foundation, either version 3 of the License, or "; 35 | txt+="(at your option) any later version." + Environment.NewLine; 36 | txt+="" + Environment.NewLine; 37 | txt += "This program is distributed in the hope that it will be useful, "; 38 | txt += "but WITHOUT ANY WARRANTY; without even the implied warranty of "; 39 | txt += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "; 40 | txt+="GNU General Public License for more details." + Environment.NewLine; 41 | txt += "" + Environment.NewLine; 42 | txt += "You should have received a copy of the GNU General Public License "; 43 | txt += "along with this program. If not, see: "; 44 | txt+="http://www.gnu.org/licenses/." + Environment.NewLine; 45 | return txt; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Help/Views/AboutView.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Help/Views/AboutView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace CShell.Modules.Help.Views 4 | { 5 | /// 6 | /// Interaction logic for AboutView.xaml 7 | /// 8 | public partial class AboutView : UserControl 9 | { 10 | public AboutView() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Controls/CSRepl.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Controls/CSReplTextEditor.cs: -------------------------------------------------------------------------------- 1 | using CShell.Completion; 2 | using ICSharpCode.NRefactory.Editor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace CShell.Modules.Repl.Controls 9 | { 10 | public class CSReplTextEditor : CodeTextEditor 11 | { 12 | public CSRepl Repl { get; set; } 13 | 14 | protected override IDocument GetCompletionDocument(out int offset) 15 | { 16 | return Repl.GetCompletionDocument(out offset); 17 | } 18 | 19 | protected override string[] GetNamespaces() 20 | { 21 | return Repl.ReplExecutor.Namespaces.ToArray(); 22 | } 23 | 24 | protected override IDictionary GetAdditionalCompletions() 25 | { 26 | if (Repl.ReplExecutor.Commands != null && Repl.ReplExecutor.Commands.Count > 0) 27 | { 28 | return Repl.ReplExecutor.Commands.ToDictionary(kv => ":"+kv.Key, kv=>kv.Value.Description); 29 | } 30 | return null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Controls/CommandHistory.cs: -------------------------------------------------------------------------------- 1 | using CShell.Properties; 2 | 3 | namespace CShell.Modules.Repl.Controls 4 | { 5 | internal class CommandHistory 6 | { 7 | private int currentPosn; 8 | private string lastCommand; 9 | private readonly CommandQueue commandHistory = new CommandQueue(Settings.Default.REPLBuffer); 10 | 11 | internal void Add(string command) 12 | { 13 | if(string.IsNullOrWhiteSpace(command)) 14 | return; 15 | 16 | if (command != lastCommand) 17 | { 18 | commandHistory.Add(command); 19 | lastCommand = command; 20 | currentPosn = commandHistory.Count; 21 | } 22 | else 23 | { 24 | currentPosn++; 25 | } 26 | } 27 | 28 | internal bool DoesPreviousCommandExist() 29 | { 30 | return currentPosn > 0; 31 | } 32 | 33 | internal bool DoesNextCommandExist() 34 | { 35 | return currentPosn < commandHistory.Count; 36 | } 37 | 38 | internal string GetPreviousCommand() 39 | { 40 | lastCommand = commandHistory[--currentPosn]; 41 | return lastCommand; 42 | } 43 | 44 | internal string GetNextCommand() 45 | { 46 | if (currentPosn == commandHistory.Count - 1) 47 | { 48 | currentPosn++; 49 | return ""; 50 | } 51 | else 52 | { 53 | lastCommand = (string)commandHistory[++currentPosn]; 54 | return LastCommand; 55 | } 56 | } 57 | 58 | internal string LastCommand 59 | { 60 | get { return lastCommand; } 61 | } 62 | 63 | internal string[] GetCommandHistory() 64 | { 65 | return commandHistory.ToArray(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Controls/CommandQueue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using System.Collections.Generic; 3 | 4 | namespace CShell.Modules.Repl.Controls 5 | { 6 | public class CommandQueue 7 | { 8 | private readonly int _limit; 9 | readonly ConcurrentQueue _queue = new ConcurrentQueue(); 10 | 11 | public int Count 12 | { 13 | get { return _queue.Count; } 14 | } 15 | 16 | public T this[int i] 17 | { 18 | get { return _queue.ToArray()[i]; } 19 | } 20 | 21 | public T[] ToArray() 22 | { 23 | return _queue.ToArray(); 24 | } 25 | 26 | public CommandQueue(int limit) 27 | { 28 | _limit = limit; 29 | } 30 | 31 | public void Add(T item) 32 | { 33 | _queue.Enqueue(item); 34 | 35 | lock (this) //ensure threads don't step on each other 36 | { 37 | T overflow; 38 | while (_queue.Count > _limit && _queue.TryDequeue(out overflow)) ; 39 | } 40 | 41 | } 42 | 43 | public IEnumerable Contents() 44 | { 45 | return _queue; 46 | } 47 | 48 | 49 | } 50 | } -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Controls/ConsoleStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Caliburn.Micro; 9 | 10 | namespace CShell.Modules.Repl.Controls 11 | { 12 | internal class ConsoleStream : Stream 13 | { 14 | private readonly TextType textType; 15 | readonly Action callback; 16 | 17 | public ConsoleStream(TextType textType, Action cb) 18 | { 19 | this.textType = textType; 20 | callback = cb; 21 | } 22 | 23 | public override bool CanRead { get { return false; } } 24 | public override bool CanSeek { get { return false; } } 25 | public override bool CanWrite { get { return true; } } 26 | 27 | 28 | public override long Length { get { return 0; } } 29 | public override long Position { get { return 0; } set { } } 30 | public override void Flush() { } 31 | public override int Read([In, Out] byte[] buffer, int offset, int count) { return -1; } 32 | 33 | public override long Seek(long offset, SeekOrigin origin) { return 0; } 34 | 35 | public override void SetLength(long value) { } 36 | 37 | public override void Write(byte[] buffer, int offset, int count) 38 | { 39 | Execute.OnUIThread(() => callback(Encoding.UTF8.GetString(buffer, offset, count), textType)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Controls/OffsetColorizer.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | using ICSharpCode.AvalonEdit.Document; 3 | using ICSharpCode.AvalonEdit.Rendering; 4 | 5 | namespace CShell.Modules.Repl.Controls 6 | { 7 | public class OffsetColorizer : DocumentColorizingTransformer 8 | { 9 | public OffsetColorizer() 10 | { 11 | Brush = Brushes.Navy; 12 | } 13 | 14 | public OffsetColorizer(Brush brush) 15 | { 16 | Brush = brush; 17 | } 18 | 19 | public OffsetColorizer(Color color) 20 | { 21 | Brush = new SolidColorBrush(color); 22 | } 23 | 24 | public int StartOffset { get; set; } 25 | public int EndOffset { get; set; } 26 | public Brush Brush { get; set; } 27 | 28 | protected override void ColorizeLine(DocumentLine line) 29 | { 30 | if (line.Length == 0) 31 | return; 32 | 33 | if (line.Offset < StartOffset || line.Offset > EndOffset) 34 | return; 35 | 36 | int start = line.Offset > StartOffset ? line.Offset : StartOffset; 37 | int end = EndOffset > line.EndOffset ? line.EndOffset : EndOffset; 38 | 39 | ChangeLinePart(start, end, element => element.TextRunProperties.SetForegroundBrush(Brush)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Module.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using System.Linq; 4 | using CShell.Framework; 5 | using CShell.Framework.Menus; 6 | using CShell.Framework.Results; 7 | using CShell.Framework.Services; 8 | using CShell.Modules.Repl.ViewModels; 9 | using Caliburn.Micro; 10 | 11 | namespace CShell.Modules.Repl 12 | { 13 | [Export(typeof(IModule))] 14 | public class Module : ModuleBase 15 | { 16 | public Module() 17 | { 18 | Order = 2; 19 | } 20 | 21 | public override void Start() 22 | { 23 | MainMenu.All.First(x => x.Name == "View") 24 | .Add( 25 | //new MenuItem("Output", OpenOutput).WithIcon("Resources/Icons/Output.png"), 26 | new MenuItem("C# Interactive", OpenRepl).WithIcon("Resources/Icons/Output.png")); 27 | 28 | var replViewModel = IoC.Get(); 29 | Shell.ShowTool(replViewModel); 30 | } 31 | 32 | private IEnumerable OpenOutput() 33 | { 34 | yield return Show.Tool(); 35 | } 36 | 37 | private IEnumerable OpenRepl() 38 | { 39 | yield return Show.Tool(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Views/IOutputView.cs: -------------------------------------------------------------------------------- 1 | namespace CShell.Modules.Repl.Views 2 | { 3 | public interface IOutputView 4 | { 5 | void ScrollToEnd(); 6 | } 7 | } -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Views/IReplView.cs: -------------------------------------------------------------------------------- 1 | using CShell.Framework.Services; 2 | using CShell.Modules.Repl.Controls; 3 | 4 | namespace CShell.Modules.Repl.Views 5 | { 6 | public interface IReplView 7 | { 8 | IReplOutput GetReplOutput(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Views/OutputView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 20 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Views/OutputView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace CShell.Modules.Repl.Views 4 | { 5 | /// 6 | /// Interaction logic for OutputView.xaml 7 | /// 8 | public partial class OutputView : UserControl, IOutputView 9 | { 10 | public OutputView() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | public void ScrollToEnd() 16 | { 17 | outputText.ScrollToEnd(); 18 | } 19 | 20 | public void SetText(string text) 21 | { 22 | outputText.Text = text; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Views/ReplView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Repl/Views/ReplView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using CShell.Framework.Services; 3 | using CShell.Modules.Repl.Controls; 4 | 5 | namespace CShell.Modules.Repl.Views 6 | { 7 | /// 8 | /// Interaction logic for ReplView.xaml 9 | /// 10 | public partial class ReplView : UserControl, IReplView 11 | { 12 | public ReplView() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | public IReplOutput GetReplOutput() 18 | { 19 | return repl; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Shell/ViewModels/MainMenuViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using CShell.Framework.Menus; 4 | using CShell.Framework.Results; 5 | using CShell.Framework.Services; 6 | using Caliburn.Micro; 7 | using Microsoft.Win32; 8 | 9 | namespace CShell.Modules.Shell.ViewModels 10 | { 11 | [Export(typeof(IMenu))] 12 | public class MainMenuViewModel : MenuModel 13 | { 14 | [Import] 15 | private IShell _shell; 16 | 17 | public MainMenuViewModel() 18 | { 19 | Add( 20 | new MenuItem("_File"), 21 | new MenuItem("_Edit"), 22 | new MenuItem("_View"), 23 | new MenuItem("_Workspace"), 24 | new MenuItem("Ev_aluate"), 25 | new MenuItem("_Help")); 26 | } 27 | 28 | private IEnumerable OpenFile() 29 | { 30 | var dialog = new OpenFileDialog(); 31 | yield return Show.Dialog(dialog); 32 | yield return Show.Document(dialog.FileName); 33 | } 34 | 35 | private IEnumerable Exit() 36 | { 37 | _shell.Close(); 38 | yield break; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Src/CShell/Modules/Shell/ViewModels/StatusBarViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Composition; 3 | using CShell.Framework.Services; 4 | using Caliburn.Micro; 5 | using Execute = CShell.Framework.Services.Execute; 6 | 7 | namespace CShell.Modules.Shell.ViewModels 8 | { 9 | [Export(typeof(IStatusBar))] 10 | public class StatusBarViewModel : PropertyChangedBase, IStatusBar 11 | { 12 | private readonly object syncRoot = new object(); 13 | private const string DefaultMessage = "Ready"; 14 | 15 | private string message; 16 | public string Message 17 | { 18 | get { lock(syncRoot) return message; } 19 | } 20 | 21 | public void UpdateMessage() 22 | { 23 | UpdateMessage(DefaultMessage); 24 | } 25 | 26 | public void UpdateMessage(string message) 27 | { 28 | lock (syncRoot) 29 | { 30 | this.message = message; 31 | } 32 | Execute.OnUIThread(()=>NotifyOfPropertyChange(() => Message)); 33 | } 34 | 35 | private int progress = 0; 36 | public int Progress 37 | { 38 | get { lock (syncRoot) return progress; } 39 | } 40 | 41 | private bool showingProgress; 42 | public bool ShowingProgress 43 | { 44 | get { lock (syncRoot) return showingProgress; } 45 | } 46 | 47 | public bool IndeterminateProgress 48 | { 49 | get { lock (syncRoot) return progress <= 0; } 50 | } 51 | 52 | public void UpdateProgress(bool running) 53 | { 54 | lock (syncRoot) 55 | { 56 | showingProgress = running; 57 | if (!running) 58 | progress = 0; 59 | } 60 | NotifyOfPropertyChange(() => Progress); 61 | NotifyOfPropertyChange(() => ShowingProgress); 62 | NotifyOfPropertyChange(() => IndeterminateProgress); 63 | } 64 | 65 | public void UpdateProgress(int progress) 66 | { 67 | var prog = progress; 68 | if (progress < 0) 69 | prog = 0; 70 | else if (progress > 100) 71 | prog = 100; 72 | 73 | lock (syncRoot) 74 | { 75 | showingProgress = true; 76 | this.progress = prog; 77 | } 78 | NotifyOfPropertyChange(() => Progress); 79 | NotifyOfPropertyChange(() => ShowingProgress); 80 | NotifyOfPropertyChange(() => IndeterminateProgress); 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Src/CShell/Modules/Shell/ViewModels/ToolBarViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using CShell.Framework.Menus; 3 | using CShell.Framework.Services; 4 | 5 | namespace CShell.Modules.Shell.ViewModels 6 | { 7 | [Export(typeof(IToolBar))] 8 | public class ToolBarViewModel : ToolBarModel 9 | { 10 | [Import] 11 | private IShell _shell; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Shell/Views/IShellView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Xceed.Wpf.AvalonDock; 6 | 7 | namespace CShell.Modules.Shell.Views 8 | { 9 | public interface IShellView 10 | { 11 | DockingManager DockingManager { get;} 12 | 13 | CShell.Workspace.WindowLocation GetWindowLocation(); 14 | void RestoreWindowLocation(CShell.Workspace.WindowLocation windowLocation); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Controls/EditableTextBlock.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Results/AddFilesResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using CShell.Framework.Results; 7 | using Microsoft.Win32; 8 | 9 | namespace CShell.Modules.Workspace.Results 10 | { 11 | public class AddFilesResult : ResultBase 12 | { 13 | private readonly IEnumerable files; 14 | 15 | public AddFilesResult(string file) 16 | { 17 | this.files = new string[] {file}; 18 | } 19 | 20 | public AddFilesResult(IEnumerable files) 21 | { 22 | this.files = files; 23 | } 24 | 25 | public override void Execute(Caliburn.Micro.CoroutineExecutionContext context) 26 | { 27 | foreach (var file in files) 28 | { 29 | if(!File.Exists(file)) 30 | { 31 | CShell.Workspace.CreateEmptyFile(file); 32 | } 33 | } 34 | OnCompleted(null); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Results/AddFolderResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using CShell.Framework.Results; 7 | using CShell.Modules.Workspace.ViewModels; 8 | 9 | namespace CShell.Modules.Workspace.Results 10 | { 11 | public class AddFolderResult : ResultBase 12 | { 13 | private readonly string folder; 14 | 15 | public AddFolderResult(string folder) 16 | { 17 | this.folder = folder; 18 | } 19 | 20 | public override void Execute(Caliburn.Micro.CoroutineExecutionContext context) 21 | {} 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Results/CopyReferencesResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using CShell.Framework; 10 | using CShell.Framework.Results; 11 | using CShell.Framework.Services; 12 | using Microsoft.Win32; 13 | 14 | namespace CShell.Modules.Workspace.Results 15 | { 16 | public class CopyReferencesResult : ResultBase 17 | { 18 | private readonly IEnumerable assemblyPaths; 19 | 20 | [Import] 21 | public IShell Shell { get; set; } 22 | 23 | [Import] 24 | public CShell.Workspace Workspace { get; set; } 25 | 26 | public CopyReferencesResult(string file) 27 | { 28 | this.assemblyPaths = new[] { file }; 29 | } 30 | 31 | public CopyReferencesResult(IEnumerable files) 32 | { 33 | this.assemblyPaths = files; 34 | } 35 | 36 | public override void Execute(Caliburn.Micro.CoroutineExecutionContext context) 37 | { 38 | try 39 | { 40 | var binDir = Path.Combine(Workspace.WorkspaceDirectory, Constants.BinFolder); 41 | if (!Directory.Exists(binDir)) 42 | Directory.CreateDirectory(binDir); 43 | var copiedReferences = new List(); 44 | foreach (var assemblyPath in assemblyPaths) 45 | { 46 | if (File.Exists(assemblyPath)) 47 | { 48 | var destFileName = Path.Combine(binDir, Path.GetFileName(assemblyPath)); 49 | File.Copy(assemblyPath, destFileName, true); 50 | copiedReferences.Add(destFileName); 51 | } 52 | } 53 | 54 | //make sure they are available for code completion 55 | Workspace.ReplExecutor.AddReferences(copiedReferences.ToArray()); 56 | 57 | OnCompleted(null); 58 | } 59 | catch (Exception ex) 60 | { 61 | OnCompleted(ex); 62 | } 63 | } 64 | 65 | 66 | 67 | }//end class 68 | } 69 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/ViewModels/AssemblyPackagesViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Caliburn.Micro; 7 | 8 | namespace CShell.Modules.Workspace.ViewModels 9 | { 10 | public class AssemblyPackagesViewModel : Screen 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/ViewModels/FilePackagesViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using Caliburn.Micro; 9 | using CShell.Framework.Results; 10 | 11 | namespace CShell.Modules.Workspace.ViewModels 12 | { 13 | public class FilePackagesViewModel : FileViewModel 14 | { 15 | public FilePackagesViewModel(string filePath) : base(filePath) 16 | { 17 | } 18 | 19 | public FilePackagesViewModel(FileInfo info) : base(info) 20 | { 21 | } 22 | 23 | public IEnumerable MangePackages() 24 | { 25 | var windowSettings = new Dictionary { { "SizeToContent", SizeToContent.Manual }, { "Width", 500.0 }, { "Height", 500.0 } }; 26 | var dialog = new AssemblyPackagesViewModel(); 27 | yield return Show.Dialog(dialog, windowSettings); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/ViewModels/FolderBinViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Caliburn.Micro; 8 | using CShell.Framework.Results; 9 | using CShell.Modules.Workspace.Results; 10 | using Microsoft.Win32; 11 | 12 | namespace CShell.Modules.Workspace.ViewModels 13 | { 14 | public class FolderBinViewModel : FolderViewModel 15 | { 16 | protected FolderBinViewModel(string path, CShell.Workspace workspace) : base(path, workspace) 17 | { 18 | } 19 | 20 | public FolderBinViewModel(DirectoryInfo info, CShell.Workspace workspace) : base(info, workspace) 21 | { 22 | } 23 | 24 | public override Uri IconSource 25 | { 26 | get 27 | { 28 | if (IsExpanded) 29 | return new Uri("pack://application:,,,/CShell;component/Resources/Icons/ReferenceFolder.Open.png"); 30 | else 31 | return new Uri("pack://application:,,,/CShell;component/Resources/Icons/ReferenceFolder.Closed.png"); 32 | } 33 | } 34 | 35 | public IEnumerable CopyReferences() 36 | { 37 | var dialog = new OpenFileDialog(); 38 | dialog.Filter = CShell.Constants.AssemblyFileFilter; 39 | dialog.Multiselect = true; 40 | yield return Show.Dialog(dialog); 41 | if (dialog.FileNames != null && dialog.FileNames.Length > 0) 42 | { 43 | yield return new CopyReferencesResult(dialog.FileNames); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/ViewModels/FolderPackagesViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using Caliburn.Micro; 9 | using CShell.Framework.Results; 10 | using Microsoft.Win32; 11 | 12 | namespace CShell.Modules.Workspace.ViewModels 13 | { 14 | public class FolderPackagesViewModel : FolderViewModel 15 | { 16 | protected FolderPackagesViewModel(string path, CShell.Workspace workspace) : base(path, workspace) 17 | { 18 | } 19 | 20 | public FolderPackagesViewModel(DirectoryInfo info, CShell.Workspace workspace) 21 | : base(info, workspace) 22 | { 23 | } 24 | 25 | public override Uri IconSource 26 | { 27 | get 28 | { 29 | if (IsExpanded) 30 | return new Uri("pack://application:,,,/CShell;component/Resources/Icons/ReferenceFolder.Open.png"); 31 | else 32 | return new Uri("pack://application:,,,/CShell;component/Resources/Icons/ReferenceFolder.Closed.png"); 33 | } 34 | } 35 | 36 | public IEnumerable MangePackages() 37 | { 38 | var windowSettings = new Dictionary { { "SizeToContent", SizeToContent.Manual }, { "Width", 500.0 }, { "Height", 500.0 } }; 39 | var dialog = new AssemblyPackagesViewModel(); 40 | yield return Show.Dialog(dialog, windowSettings); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Views/AssemblyPackagesView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Views/AssemblyPackagesView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace CShell.Modules.Workspace.Views 17 | { 18 | /// 19 | /// Interaction logic for AssemblyPackagesView.xaml 20 | /// 21 | public partial class AssemblyPackagesView : UserControl 22 | { 23 | public AssemblyPackagesView() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Views/RootFolderSettingsView.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Views/RootFolderSettingsView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace CShell.Modules.Workspace.Views 16 | { 17 | /// 18 | /// Interaction logic for RootFolderSettingsView.xaml 19 | /// 20 | public partial class RootFolderSettingsView : UserControl 21 | { 22 | public RootFolderSettingsView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/CShell/Modules/Workspace/Views/WorkspaceView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace CShell.Modules.Workspace.Views 4 | { 5 | /// 6 | /// Interaction logic for WorkspaceView.xaml 7 | /// 8 | public partial class WorkspaceView : UserControl 9 | { 10 | public WorkspaceView() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | /// 16 | /// Hack to access the parents control DataContext, due to the ContextMenus separate DataContext. 17 | /// 18 | /// The source of the event. 19 | /// The instance containing the event data. 20 | private void ContextMenu_Opened(object sender, System.Windows.RoutedEventArgs e) 21 | { 22 | var contextMenu = sender as ContextMenu; 23 | if (contextMenu != null) 24 | { 25 | ////the first time set the tag to the TS VM. 26 | //if (contextMenu.Tag == null) 27 | // contextMenu.Tag = contextMenu.DataContext; 28 | ////try selecting the item of the contect menu 29 | //var vm = DataContext as TimeSeriesExplorerViewModel; 30 | //var itemVM = contextMenu.Tag as ITimeSeriesDisplay; 31 | //if (vm != null && itemVM != null) 32 | //{ 33 | // vm.SelectedItem = itemVM; 34 | //} 35 | //contextMenu.DataContext = DataContext; 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/CShell/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("CShell")] 11 | [assembly: AssemblyDescription("A Simple C# Scripting IDE")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("Arnova")] 14 | [assembly: AssemblyProduct("CShell")] 15 | [assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2015")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("0.1.3.*")] 55 | [assembly: AssemblyFileVersion("0.1.3.*")] 56 | -------------------------------------------------------------------------------- /Src/CShell/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | True 10 | 11 | 12 | True 13 | 14 | 15 | 3000 16 | 17 | 18 | -------------------------------------------------------------------------------- /Src/CShell/Resources/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/ClearOutputWindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/ClearOutputWindow.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/FileBrowser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/FileBrowser.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Folder.Closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Folder.Closed.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Folder.Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Folder.Open.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.Assembly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.Assembly.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.CSFile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.CSFile.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.CommentRegion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.CommentRegion.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.CopyIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.CopyIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.CutIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.CutIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.DeleteIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.DeleteIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.FindIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.FindIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.Indent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.Indent.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.MiscFiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.MiscFiles.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.PasteIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.PasteIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.Property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.Property.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.RedoIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.RedoIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.Reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.Reference.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.ReferenceModule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.ReferenceModule.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.RunAllIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.RunAllIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.RunProgramIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.RunProgramIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.SaveAllIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.SaveAllIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.SaveIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.SaveIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.TextFileIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.TextFileIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.UndoIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.UndoIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Icons.16x16.XMLFileIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Icons.16x16.XMLFileIcon.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Open.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Output.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/ReferenceFolder.Closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/ReferenceFolder.Closed.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/ReferenceFolder.Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/ReferenceFolder.Open.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/Toolbar.Refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/Toolbar.Refresh.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/page_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/page_go.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Icons/page_white_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/Resources/Icons/page_white_go.png -------------------------------------------------------------------------------- /Src/CShell/Resources/Menu.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Src/CShell/Resources/Styles.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 34 | 35 | -------------------------------------------------------------------------------- /Src/CShell/SplashScreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/CShell/SplashScreen.png -------------------------------------------------------------------------------- /Src/CShell/Templates/Empty.cshell: -------------------------------------------------------------------------------- 1 | public class CShellFile : ICShellFile 2 | { 3 | public void OnOpened(Workspace workspace) 4 | { 5 | workspace.Load(workspace.CShellFileName + CShell.Constants.WorkspaceFileExtension, true); 6 | } 7 | 8 | public void OnClosing(Workspace workspace) 9 | { 10 | workspace.Save(workspace.CShellFileName + CShell.Constants.WorkspaceFileExtension, true); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Src/CShell/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Src/NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/SetupProject/LicenseAgreement.rtf.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukebuehler/CShell/a02a0414ed8fb42bbacb8ba72542bcdcaac233e9/Src/SetupProject/LicenseAgreement.rtf.docx --------------------------------------------------------------------------------