├── bin
└── Mono.CSharp.dll
├── src
├── 201308_ilnum_button_play_small.png
├── 201308_ilnum_button_download_braun_small.png
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── FormExtended
│ ├── ILCSTextArea.cs
│ ├── ILShellControl.cs
│ ├── ILCSTextArea.Designer.cs
│ ├── ILShellControl.Designer.cs
│ ├── ILForm.resx
│ ├── ILCSTextArea.resx
│ ├── ILShellControl.resx
│ ├── ILForm.Designer.cs
│ └── ILForm.cs
├── License.txt
├── SharedControls
│ ├── IILShellControl.cs
│ ├── IILCompletionEntry.cs
│ ├── IILCompletionFormProvider.cs
│ ├── IILPanelForm.cs
│ ├── ILCompletionTextEntry.cs
│ ├── IILShell.cs
│ ├── ILCommandEnteredEventArgs.cs
│ ├── ILCompletionRequestEventArgs.cs
│ ├── IILUserInterfaceControls.cs
│ ├── ILCommandHistory.cs
│ ├── ILShellBaseClass.cs
│ └── ILView.cs
├── FormSimple
│ ├── ILShell.Designer.cs
│ ├── ILShellForm.Designer.cs
│ ├── ILShellForm.cs
│ ├── ILMainFormSimple.cs
│ ├── ILShellForm.resx
│ ├── ILShell.resx
│ ├── ILMainFormSimple.Designer.cs
│ ├── ILMainFormSimple.resx
│ └── ILShell.cs
├── Program.cs
└── ILView.csproj
├── .gitattributes
├── .gitignore
└── Readme.md
/bin/Mono.CSharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilnumerics-dp/ILView/HEAD/bin/Mono.CSharp.dll
--------------------------------------------------------------------------------
/src/201308_ilnum_button_play_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilnumerics-dp/ILView/HEAD/src/201308_ilnum_button_play_small.png
--------------------------------------------------------------------------------
/src/201308_ilnum_button_download_braun_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilnumerics-dp/ILView/HEAD/src/201308_ilnum_button_download_braun_small.png
--------------------------------------------------------------------------------
/src/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/FormExtended/ILCSTextArea.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using WeifenLuo.WinFormsUI.Docking;
10 |
11 | namespace ILNumerics {
12 | public partial class ILCSTextArea : DockContent {
13 | public ILCSTextArea() {
14 | InitializeComponent();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/src/License.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013, ILNumerics KG
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/src/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18047
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ILNumerics.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/SharedControls/IILShellControl.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | namespace ILNumerics.ILView {
15 | public interface IILShellControl : IILShell {
16 | bool Visible { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/SharedControls/IILCompletionEntry.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Windows.Forms;
18 |
19 | namespace ILNumerics.ILView {
20 | public interface IILCompletionEntry {
21 |
22 | void Draw(ListViewItem itemTarget);
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/SharedControls/IILCompletionFormProvider.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Windows.Forms;
18 |
19 | namespace ILNumerics.ILView {
20 | public interface IILCompletionFormProvider {
21 | // todo: abstract away listbox! replace with interface
22 | ListBox GetCompletionForm();
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/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("ILView")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ILView")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
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("7531cf8a-a2cc-42cc-99c0-0b1e632a8f64")]
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/FormSimple/ILShell.Designer.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | namespace ILNumerics.ILView {
3 | partial class ILShell {
4 | ///
5 | /// Required designer variable.
6 | ///
7 | private System.ComponentModel.IContainer components = null;
8 |
9 | ///
10 | /// Clean up any resources being used.
11 | ///
12 | /// true if managed resources should be disposed; otherwise, false.
13 | protected override void Dispose(bool disposing) {
14 | if (disposing && (components != null)) {
15 | components.Dispose();
16 | }
17 | base.Dispose(disposing);
18 | }
19 |
20 | #region Windows Form Designer generated code
21 |
22 | ///
23 | /// Required method for Designer support - do not modify
24 | /// the contents of this method with the code editor.
25 | ///
26 | private void InitializeComponent() {
27 | this.SuspendLayout();
28 | //
29 | // ILShell
30 | //
31 | this.Dock = System.Windows.Forms.DockStyle.Fill;
32 | this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
33 | this.Size = new System.Drawing.Size(286, 20);
34 | this.ResumeLayout(false);
35 |
36 | }
37 |
38 | #endregion
39 |
40 |
41 | }
42 | }
--------------------------------------------------------------------------------
/src/SharedControls/IILPanelForm.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using ILNumerics;
18 | using ILNumerics.Drawing;
19 |
20 | namespace ILNumerics.ILView {
21 | public interface IILPanelForm {
22 | ILPanel Panel { get; }
23 | string Text { get; set; }
24 |
25 | event EventHandler Closed;
26 | event EventHandler Load;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/SharedControls/ILCompletionTextEntry.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace ILNumerics.ILView {
19 | public class ILCompletionTextEntry : IILCompletionEntry {
20 |
21 | public string Text { get; set; }
22 |
23 | public void Draw(System.Windows.Forms.ListViewItem itemTarget) {
24 | itemTarget.SubItems[0].Text = Text;
25 | }
26 |
27 | public override string ToString() {
28 | return Text;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/SharedControls/IILShell.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace ILNumerics.ILView {
19 | public interface IILShell {
20 | event EventHandler CommandEntered;
21 | event EventHandler CompletionRequested;
22 | //event EventHandler CompletionsHide;
23 | void WriteCommand(string text);
24 | void WriteError(string text);
25 | void WriteText(string text);
26 | void Init(object host);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/SharedControls/ILCommandEnteredEventArgs.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace ILNumerics {
19 |
20 | public class ILCommandEnteredEventArgs : EventArgs {
21 | ///
22 | /// The command text which has been entered into the shell. This may consist out of multiple lines.
23 | ///
24 | public string Command { get; internal set; }
25 |
26 | public ILCommandEnteredEventArgs(string command) {
27 | Command = command;
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/SharedControls/ILCompletionRequestEventArgs.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Drawing;
15 | using System.Collections.Generic;
16 | using System.Linq;
17 | using System.Text;
18 |
19 | namespace ILNumerics.ILView {
20 | public class ILCompletionRequestEventArgs : EventArgs {
21 |
22 | public string Expression;
23 | public IEnumerable CompletionResult;
24 | public string Prefix = "";
25 | public bool Success = false;
26 | public Point Location { get; set; }
27 |
28 | public ILCompletionRequestEventArgs(string expression, Point location) {
29 | Expression = expression;
30 | Location = location;
31 | CompletionResult = null;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/FormExtended/ILShellControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using WeifenLuo.WinFormsUI.Docking;
10 |
11 | namespace ILNumerics.ILView {
12 | public partial class ILShellControl : DockContent, IILShellControl {
13 |
14 | #region attributes
15 |
16 | #endregion
17 |
18 | #region event handlers
19 | public event EventHandler CommandEntered;
20 | protected void OnCommandEntered(string expression) {
21 | if (CommandEntered != null) {
22 | CommandEntered(this, new ILCommandEnteredEventArgs(expression));
23 | }
24 | }
25 | protected void OnCommandEntered(ILCommandEnteredEventArgs args) {
26 | if (CommandEntered != null) {
27 | CommandEntered(this, args);
28 | }
29 | }
30 | #endregion
31 |
32 | #region constructors
33 |
34 | public ILShellControl() {
35 | InitializeComponent();
36 | }
37 | #endregion
38 |
39 | #region public interface
40 | public void WriteText(string text) {
41 | ilShell1.WriteText(text);
42 | }
43 | public void WriteCommand(string text) {
44 | ilShell1.WriteCommand(text);
45 |
46 | }
47 | public void WriteError(string text) {
48 | ilShell1.WriteError(text);
49 | }
50 | public void Init(object host) {
51 |
52 | }
53 | #endregion
54 |
55 | #region private helpers
56 | private void ilShell1_CommandEntered(object sender, ILCommandEnteredEventArgs e) {
57 | OnCommandEntered(e);
58 | }
59 | #endregion
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/SharedControls/IILUserInterfaceControls.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace ILNumerics.ILView {
19 |
20 | public class SourceChangedEventArgs : EventArgs {
21 | public string Source;
22 | }
23 | public class ShellVisibleChangedEventArgs : EventArgs {
24 | public bool Visible;
25 | }
26 |
27 | public interface IILUserInterfaceControls {
28 |
29 | event EventHandler ShellVisibleChanged;
30 | event EventHandler ExportSVG;
31 | event EventHandler ExportPNG;
32 | event EventHandler SourceChanged;
33 |
34 | // todo: add more UI control abstractions here if needed ....
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/FormExtended/ILCSTextArea.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ILNumerics {
2 | partial class ILCSTextArea {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Windows Form Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | this.textEditorControl1 = new ICSharpCode.TextEditor.TextEditorControl();
27 | this.SuspendLayout();
28 | //
29 | // textEditorControl1
30 | //
31 | this.textEditorControl1.Dock = System.Windows.Forms.DockStyle.Fill;
32 | this.textEditorControl1.IsReadOnly = false;
33 | this.textEditorControl1.Location = new System.Drawing.Point(0, 0);
34 | this.textEditorControl1.Name = "textEditorControl1";
35 | this.textEditorControl1.Size = new System.Drawing.Size(284, 261);
36 | this.textEditorControl1.TabIndex = 0;
37 | this.textEditorControl1.Text = "textEditorControl1";
38 | //
39 | // ILCSTextArea
40 | //
41 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
42 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
43 | this.ClientSize = new System.Drawing.Size(284, 261);
44 | this.Controls.Add(this.textEditorControl1);
45 | this.Name = "ILCSTextArea";
46 | this.Text = "ILCSTextArea";
47 | this.ResumeLayout(false);
48 |
49 | }
50 |
51 | #endregion
52 |
53 | private ICSharpCode.TextEditor.TextEditorControl textEditorControl1;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/SharedControls/ILCommandHistory.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 |
18 | namespace ILNumerics {
19 | class ILCommandHistory {
20 |
21 | #region attributes
22 |
23 | #endregion
24 |
25 | #region properties
26 | List Commands { get; set; }
27 | #endregion
28 |
29 | #region constructor
30 | public ILCommandHistory() {
31 | Commands = new List();
32 | }
33 | #endregion
34 |
35 | #region public interface
36 | public void Add(string command) {
37 | command = command.Trim();
38 | // only compare with latest command, prevent duplicates
39 | if (Commands.Count == 0 || Commands[Commands.Count - 1] != command) {
40 | Commands.Add(command);
41 | }
42 | }
43 | public string this[int index] {
44 | get {
45 | if (index >= 0 && index < Commands.Count) {
46 | return Commands[index];
47 | }
48 | return string.Empty;
49 | }
50 | }
51 | public int Count {
52 | get { return Commands.Count; }
53 | }
54 | public string LastCommand {
55 | get { return this[Count - 1]; }
56 | }
57 | #endregion
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/FormExtended/ILShellControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ILNumerics.ILView {
2 | partial class ILShellControl {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Component Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | this.ilShell1 = new ILNumerics.ILShell();
27 | this.SuspendLayout();
28 | //
29 | // ilShell1
30 | //
31 | this.ilShell1.BackColor = System.Drawing.Color.Black;
32 | this.ilShell1.Dock = System.Windows.Forms.DockStyle.Fill;
33 | this.ilShell1.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
34 | this.ilShell1.ForeColor = System.Drawing.SystemColors.Menu;
35 | this.ilShell1.Location = new System.Drawing.Point(0, 0);
36 | this.ilShell1.Name = "ilShell1";
37 | this.ilShell1.Size = new System.Drawing.Size(284, 261);
38 | this.ilShell1.TabIndex = 0;
39 | this.ilShell1.CommandEntered += new System.EventHandler(this.ilShell1_CommandEntered);
40 | //
41 | // ILShellControl
42 | //
43 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
44 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
45 | this.ClientSize = new System.Drawing.Size(284, 261);
46 | this.Controls.Add(this.ilShell1);
47 | this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
48 | this.Name = "ILShellControl";
49 | this.ResumeLayout(false);
50 |
51 | }
52 |
53 | #endregion
54 |
55 | private ILShell ilShell1;
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18047
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ILNumerics.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ILNumerics.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/FormSimple/ILShellForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ILNumerics.ILView {
2 | partial class ILShellForm {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Windows Form Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | this.listBox1 = new System.Windows.Forms.ListBox();
27 | this.ilShell1 = new ILNumerics.ILView.ILShell();
28 | this.SuspendLayout();
29 | //
30 | // listBox1
31 | //
32 | this.listBox1.Font = new System.Drawing.Font("Courier New", 10F);
33 | this.listBox1.FormattingEnabled = true;
34 | this.listBox1.ItemHeight = 16;
35 | this.listBox1.Location = new System.Drawing.Point(361, 176);
36 | this.listBox1.Name = "listBox1";
37 | this.listBox1.Size = new System.Drawing.Size(120, 84);
38 | this.listBox1.TabIndex = 1;
39 | this.listBox1.Visible = false;
40 | //
41 | // ilShell1
42 | //
43 | this.ilShell1.Dock = System.Windows.Forms.DockStyle.Fill;
44 | this.ilShell1.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
45 | this.ilShell1.Location = new System.Drawing.Point(0, 0);
46 | this.ilShell1.Name = "ilShell1";
47 | this.ilShell1.Size = new System.Drawing.Size(584, 361);
48 | this.ilShell1.TabIndex = 0;
49 | this.ilShell1.WordWrap = false;
50 | //
51 | // ILShellForm
52 | //
53 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
54 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
55 | this.ClientSize = new System.Drawing.Size(584, 361);
56 | this.ControlBox = false;
57 | this.Controls.Add(this.listBox1);
58 | this.Controls.Add(this.ilShell1);
59 | this.Name = "ILShellForm";
60 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
61 | this.Text = "C# Interactive Console";
62 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ILShellForm_FormClosing);
63 | this.Load += new System.EventHandler(this.ILShellForm_Load);
64 | this.ResumeLayout(false);
65 |
66 | }
67 |
68 | #endregion
69 |
70 | private ILShell ilShell1;
71 | private System.Windows.Forms.ListBox listBox1;
72 | }
73 | }
--------------------------------------------------------------------------------
/src/FormSimple/ILShellForm.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.ComponentModel;
16 | using System.Data;
17 | using System.Drawing;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Forms;
21 |
22 | namespace ILNumerics.ILView {
23 | public partial class ILShellForm : Form, IILShellControl, IILCompletionFormProvider {
24 |
25 | public ILShellForm() {
26 | InitializeComponent();
27 | ilShell1.CommandEntered += (s,arg) => {
28 | if (CommandEntered != null) {
29 | CommandEntered(s, arg);
30 | }
31 | };
32 | }
33 |
34 | private void ILShellForm_Load(object sender, EventArgs e) {
35 | //ilCompletionsForm1.Visible = false;
36 | ilShell1.CompletionRequested += (s, args) => {
37 | OnCompletionRequested(args);
38 | };
39 | }
40 |
41 | public event EventHandler CommandEntered;
42 | public event EventHandler CompletionRequested;
43 | protected void OnCompletionRequested(ILCompletionRequestEventArgs args) {
44 | if (CompletionRequested != null) {
45 | CompletionRequested(this, args);
46 | }
47 | }
48 | public void WriteCommand(string text) {
49 | ilShell1.WriteCommand(text);
50 | }
51 |
52 | public void WriteError(string text) {
53 | ilShell1.WriteError(text);
54 | }
55 |
56 | public void WriteText(string text) {
57 | ilShell1.WriteText(text);
58 | }
59 |
60 | public void Init(object host) {
61 | // nothing to do here. More advanced IDE forms might have something... (docking setup a.t.l)
62 | }
63 |
64 | private void ILShellForm_FormClosing(object sender, FormClosingEventArgs e) {
65 | e.Cancel = true;
66 | Visible = false;
67 | }
68 |
69 |
70 | protected override void OnKeyDown(KeyEventArgs e) {
71 | if (listBox1.Visible) {
72 | int a = 1;
73 | } else {
74 | base.OnKeyDown(e);
75 | }
76 | }
77 |
78 | public ListBox GetCompletionForm() {
79 | return listBox1;
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 |
131 | # NuGet Packages Directory
132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133 | #packages/
134 |
135 | # Windows Azure Build Output
136 | csx
137 | *.build.csdef
138 |
139 | # Windows Store app package directory
140 | AppPackages/
141 |
142 | # Others
143 | sql/
144 | *.Cache
145 | ClientBin/
146 | [Ss]tyle[Cc]op.*
147 | ~$*
148 | *~
149 | *.dbmdl
150 | *.[Pp]ublish.xml
151 | *.pfx
152 | *.publishsettings
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | App_Data/*.mdf
166 | App_Data/*.ldf
167 |
168 | #############
169 | ## Windows detritus
170 | #############
171 |
172 | # Windows image file caches
173 | Thumbs.db
174 | ehthumbs.db
175 |
176 | # Folder config file
177 | Desktop.ini
178 |
179 | # Recycle Bin used on file shares
180 | $RECYCLE.BIN/
181 |
182 | # Mac crap
183 | .DS_Store
184 |
185 |
186 | #############
187 | ## Python
188 | #############
189 |
190 | *.py[co]
191 |
192 | # Packages
193 | *.egg
194 | *.egg-info
195 | dist/
196 | build/
197 | eggs/
198 | parts/
199 | var/
200 | sdist/
201 | develop-eggs/
202 | .installed.cfg
203 |
204 | # Installer logs
205 | pip-log.txt
206 |
207 | # Unit test / coverage reports
208 | .coverage
209 | .tox
210 |
211 | #Translations
212 | *.mo
213 |
214 | #Mr Developer
215 | .mr.developer.cfg
216 |
--------------------------------------------------------------------------------
/src/FormSimple/ILMainFormSimple.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 |
14 | using System;
15 | using System.Collections.Generic;
16 | using System.ComponentModel;
17 | using System.Data;
18 | using System.Drawing;
19 | using System.Linq;
20 | using System.Text;
21 | using System.Windows.Forms;
22 | using ILNumerics;
23 | using ILNumerics.Drawing;
24 | using ILNumerics.Drawing.Plotting;
25 |
26 | namespace ILNumerics.ILView {
27 | public partial class ILMainFormSimple : Form, IILPanelForm, IILUserInterfaceControls {
28 |
29 | ILPanel panel1;
30 |
31 | public event EventHandler ShellVisibleChanged;
32 |
33 | public event EventHandler ExportSVG;
34 |
35 | public event EventHandler ExportPNG;
36 |
37 | public event EventHandler SourceChanged;
38 | protected void OnSourceChanged(string source) {
39 | if (SourceChanged != null) {
40 | SourceChanged(this, new SourceChangedEventArgs() { Source = source });
41 | }
42 | }
43 |
44 | ///
45 | /// Provides access to the ILNumerics panel
46 | ///
47 | public ILPanel Panel {
48 | get { return panel1; }
49 | }
50 |
51 | public ILMainFormSimple() {
52 | InitializeComponent();
53 |
54 | // setup source combo box
55 | // fill couple of interesting sources
56 | toolStripCmbSource.Items.Add("id0b426");
57 | toolStripCmbSource.Items.Add("if920ce");
58 | toolStripCmbSource.Items.Add("id8c59a");
59 | toolStripCmbSource.Items.Add("icd3109");
60 | toolStripCmbSource.Items.Add("i3748c4");
61 | toolStripCmbSource.Items.Add("ib5b26c");
62 | toolStripCmbSource.Items.Add("i8951b3");
63 | toolStripCmbSource.Items.Add("i794c2c");
64 | toolStripCmbSource.Items.Add("i461339");
65 | toolStripCmbSource.Items.Add("i9b1f80");
66 | toolStripCmbSource.Items.Add("ia3fcd0");
67 | toolStripCmbSource.Items.Add("i57d081");
68 | toolStripCmbSource.Items.Add("i77c8ac");
69 | toolStripCmbSource.Items.Add("i9481ea");
70 | toolStripCmbSource.Items.Add("i5a1dc1");
71 | toolStripCmbSource.Items.Add("i24bd56");
72 | toolStripCmbSource.Items.Add("i1a27e2");
73 | toolStripCmbSource.Items.Add("example");
74 |
75 | panel1 = new ILPanel();
76 | Controls.Add(panel1);
77 | // wire up UI controls
78 | this.toolStripCmbSource.KeyDown += (s, arg) => {
79 | if (arg.KeyCode == Keys.Enter) {
80 | OnSourceChanged(this.toolStripCmbSource.Text);
81 | }
82 | };
83 |
84 | this.toolStripBtnConsoleVisible.Click += (s, arg) => {
85 | if (this.ShellVisibleChanged != null) {
86 | this.ShellVisibleChanged(this, new ShellVisibleChangedEventArgs() { Visible = this.toolStripBtnConsoleVisible.Checked });
87 | };
88 | };
89 |
90 | Show();
91 | }
92 |
93 | private void toolStripButton1_Click(object sender, EventArgs e) {
94 | OnSourceChanged(this.toolStripCmbSource.Text);
95 | }
96 |
97 | private void toolStripCmbSource_TextChanged(object sender, EventArgs e) {
98 | OnSourceChanged(this.toolStripCmbSource.Text);
99 | }
100 |
101 | private void toolStripButtonSVG_Click(object sender, EventArgs e) {
102 | if (ExportSVG != null)
103 | ExportSVG(this, EventArgs.Empty);
104 | }
105 |
106 | private void toolStripButtonPNG_Click(object sender, EventArgs e) {
107 | if (ExportPNG != null)
108 | ExportPNG(this, EventArgs.Empty);
109 | }
110 |
111 |
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/SharedControls/ILShellBaseClass.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using ILNumerics.Drawing;
14 | using System;
15 | using System.Collections.Generic;
16 | using System.Linq;
17 | using System.Text;
18 |
19 | namespace ILNumerics.ILView {
20 | ///
21 | /// This class provides the static class context for all expressions / classes in the interactive shell. Extend this class with new commands available in the shell!
22 | ///
23 | public class ILShellBaseClass : ILMath {
24 |
25 | public static string help {
26 | get {
27 | return @"
28 | ILNumerics Interactive C# Shell
29 | Version: " + version + ", Date: " + DateTime.Now.ToString() + @"
30 | __________________________________________________________
31 | Help overview:
32 |
33 | General shell handling. Enter expressions at the command prompt.
34 | Evaluate by pressing 'Enter'. Text output is displayed immediately:
35 | > 1 + 2 [Enter]
36 | 3
37 |
38 | Common variable declaration rules apply. All static functions from
39 | ILNumerics.ILMath are directly accessible:
40 | > ILArray A = rand(3,2);
41 |
42 | Variables are retained between command invocations:
43 | > (A + 3) * 2
44 | [3,2]
45 | 7,25088 7,02224
46 | 7,17780 7,03576
47 | 6,06555 7,97830
48 |
49 | If an object of type ILNumerics.Drawing.ILScene is returned by an
50 | expression, it replaces the current scene in the panel of the main window:
51 | > new ILScene { Camera = { new ILSphere() } }
52 | (... replaces existing visual with new scene)
53 |
54 | The panel is accessed by 'Panel':
55 | > Panel.BackColor = Color.Gray;
56 | > Panel.Scene.First().Color = Color.White;
57 | (... colors the background and the fill of the shphere )
58 |
59 | The shell accepts all valid C# constructs. Lambda expressions are compiled on
60 | the fly:
61 | > Func cubic = d => d * d * d;
62 | > cubic(3)
63 | 27
64 |
65 | Multiple lines are spanned with [Shift]+[Enter]:
66 | > class myPoints : ILPoints {
67 | public myPoints() {
68 | Positions = ILMath.tosingle(ILMath.rand(3,100));
69 | Color = System.Drawing.Color.Red;
70 | }
71 | }
72 | Panel.Scene.Camera.Add(new myPoints())
73 | (... adds 100 random red points to the current scene)
74 |
75 | Misc:
76 | ____________________________________________________________
77 | * Errors are reported in red with line and column number and description.
78 | * History of commands: [CURSOR UP] and [CURSOR DOWN]
79 | * version - displays versions: [OS]/[ILView]/[ILNumerics]
80 | * loadscene(source) - loads a scene and replaces existing scene
81 | valid sources: ILC# code: loadscene(""if920ce"")
82 | * help - displays this help text
83 |
84 | Read the full documentation on ILNumerics at:
85 | http://ilnumerics.net/docu.html
86 | ";
87 | }
88 | }
89 |
90 | private static string getVersion() {
91 | try {
92 | var versionString = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
93 |
94 | return versionString;
95 | } catch (Exception exc) { //todo: be more specific here!
96 | return "(unknown)";
97 | }
98 | }
99 | ///
100 | /// The panel currently selected as target for interactive scene drawing
101 | ///
102 | public static ILPanel Panel { get; set; }
103 |
104 | public static ILView View { get; set; }
105 |
106 | public static string version {
107 | get {
108 | try {
109 | var ilviewVers = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
110 | var ilnumerics = typeof(ILMath).Assembly.GetName().Version.ToString();
111 |
112 | var ret = String.Format("ILView: {0} - ILNumerics: {1} - OS: {2}", ilviewVers, ilnumerics, Environment.OSVersion.VersionString);
113 | return ret;
114 | } catch (Exception exc) { //todo: be more specific here!
115 | return "(unknown)";
116 | }
117 | }
118 | }
119 | ///
120 | /// Load a new scene from ILC#, URI to C# source code or by C# code
121 | ///
122 | /// source to create scene from
123 | public static void loadscene(string source) {
124 | if (View != null) {
125 | View.LoadSzene(source);
126 | }
127 | }
128 |
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/src/FormExtended/ILForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FormSimple/ILShellForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FormExtended/ILCSTextArea.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FormExtended/ILShellControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FormSimple/ILShell.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | False
122 |
123 |
--------------------------------------------------------------------------------
/src/Program.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Diagnostics;
16 | using System.Drawing;
17 | using System.Linq;
18 | using System.Text;
19 | using System.Threading.Tasks;
20 | using System.Windows.Forms;
21 | using ILNumerics;
22 | using ILNumerics.Drawing;
23 | using ILNumerics.Drawing.Plotting;
24 | using Mono;
25 | using Mono.CSharp;
26 |
27 | namespace ILNumerics.ILView {
28 |
29 | class Program {
30 | private static string ilc_instanceRegexp = @"_i([a-z0-9]{2})([a-z0-9$]+)\.exe";
31 | private static string ErrorlogName = "ILNumerics_Errorlog.txt";
32 | private static string[] s_commandLineArgs;
33 | public static string ExeName {
34 | get {
35 | try {
36 | return (new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
37 | } catch (System.Security.SecurityException) {
38 | return String.Empty;
39 | }
40 | }
41 | }
42 |
43 | [STAThread]
44 | static void Main(string[] args) {
45 | s_commandLineArgs = args;
46 | try {
47 | initializeLogging();
48 | Application.EnableVisualStyles();
49 | Application.SetCompatibleTextRenderingDefault(false);
50 |
51 | // for now, we create the most simple version of IILPanelForm and IILShellControl and instantiate the ILView with them
52 | var mainForm = new ILMainFormSimple();
53 | ILView view = new ILView(mainForm, new ILShellForm(), mainForm);
54 | view_Load(view, EventArgs.Empty);
55 | Application.Run(view);
56 | } catch (Exception exc) {
57 | System.Diagnostics.Trace.Flush();
58 | var dlgRes = MessageBox.Show(@"ILView has encountered an error and will be closed now.
59 |
60 | Please help us improve ILView! Information about the error can be sent to us
61 | automatically after this window was closed. The information will consist out
62 | of the contents of the file '" + ErrorlogName + @"' which records trace messages
63 | generated by ILView during run. If you do not wish to have ILView sent the information,
64 | click on [Cancel] now. Please sent the file '" + ErrorlogName + @"' by email to
65 | info@ilnumerics.net than. This enables us to look into the problem and provide
66 | fixes for it.
67 |
68 | Otherwise click [OK] to sent the content of the file now. We apologize any inconvenience!", "Hoops! There is something broken! :/", MessageBoxButtons.OKCancel);
69 | if (dlgRes == DialogResult.OK) {
70 | string log = "(empty)";
71 | if (System.IO.File.Exists(ErrorlogName)) {
72 | log = System.IO.File.ReadAllText(ErrorlogName);
73 | }
74 |
75 | }
76 | }
77 | }
78 |
79 | static void view_Load(object sender, EventArgs e) {
80 | string url;
81 | string exePath;
82 | ILView view = sender as ILView;
83 | // from command parameters ?
84 |
85 | #if DEBUG
86 | // s_commandLineArgs = new string[] { @"var scene = new ILScene() {
87 | // Camera = {
88 | // new ILSphere()
89 | // }
90 | //};
91 | //scene;"
92 | // };
93 | #endif
94 |
95 | if (s_commandLineArgs != null && s_commandLineArgs.Length > 0 && !String.IsNullOrEmpty(s_commandLineArgs[0])) {
96 | try {
97 | string expression = s_commandLineArgs[0];
98 | // evaluate expression
99 | Console.WriteLine("Evaluating Expression from Command Line Input: ");
100 | Console.WriteLine(expression);
101 | view.Source = expression;
102 | return;
103 | } catch (Exception exc) {
104 | Trace.WriteLine(exc.ToString());
105 | MessageBox.Show(exc.ToString());
106 | }
107 | }
108 | // from exe name ?
109 | try {
110 | if (!String.IsNullOrEmpty(ExeName) && urlFromExeName(ExeName, out url)) {
111 | view.Source = url;
112 | return;
113 | }
114 | } catch (System.Security.SecurityException exc) { }
115 | view.Source = "example"; // shows the common example
116 | }
117 |
118 | private static void initializeLogging() {
119 | Trace.Listeners.Add(new ConsoleTraceListener());
120 | // register new trace listener
121 | if (System.IO.File.Exists(ErrorlogName)) System.IO.File.Delete(ErrorlogName);
122 | Trace.Listeners.Add(new TextWriterTraceListener(ErrorlogName, "ILNumerics"));
123 | AppDomain.CurrentDomain.ProcessExit += (s, arg) => { Trace.Close(); };
124 | Trace.WriteLine("Starting Trace at " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString());
125 | Trace.WriteLine("======================================================");
126 | Trace.WriteLine("");
127 | }
128 |
129 | private static bool urlFromExeName(string exename, out string url) {
130 | #if DEBUG
131 | //exename = "ilviewer_ibad83e.exe";
132 | #endif
133 | System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"_i([a-z0-9]{2})([a-z0-9$]+).exe");
134 | var matches = reg.Match(exename);
135 | url = "";
136 | if (matches.Success && matches.Groups != null && matches.Groups.Count > 2) {
137 | url = String.Format(ILView.ilc_requestURL, matches.Groups[1].Value, matches.Groups[2]);
138 | return true;
139 | }
140 | return false;
141 | }
142 |
143 | }
144 |
145 | }
146 |
--------------------------------------------------------------------------------
/src/FormExtended/ILForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ILNumerics.ILView {
2 | partial class ILForm {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Windows Form Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | WeifenLuo.WinFormsUI.Docking.DockPanelSkin dockPanelSkin1 = new WeifenLuo.WinFormsUI.Docking.DockPanelSkin();
27 | WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin autoHideStripSkin1 = new WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin();
28 | WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
29 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient1 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
30 | WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin dockPaneStripSkin1 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin();
31 | WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient dockPaneStripGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient();
32 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient2 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
33 | WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient2 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
34 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient3 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
35 | WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient();
36 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient4 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
37 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient5 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
38 | WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient3 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
39 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient6 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
40 | WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient7 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
41 | this.dockPanel1 = new WeifenLuo.WinFormsUI.Docking.DockPanel();
42 | this.SuspendLayout();
43 | //
44 | // dockPanel1
45 | //
46 | this.dockPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
47 | this.dockPanel1.Location = new System.Drawing.Point(0, 0);
48 | this.dockPanel1.Name = "dockPanel1";
49 | this.dockPanel1.Size = new System.Drawing.Size(730, 371);
50 | dockPanelGradient1.EndColor = System.Drawing.SystemColors.ControlLight;
51 | dockPanelGradient1.StartColor = System.Drawing.SystemColors.ControlLight;
52 | autoHideStripSkin1.DockStripGradient = dockPanelGradient1;
53 | tabGradient1.EndColor = System.Drawing.SystemColors.Control;
54 | tabGradient1.StartColor = System.Drawing.SystemColors.Control;
55 | tabGradient1.TextColor = System.Drawing.SystemColors.ControlDarkDark;
56 | autoHideStripSkin1.TabGradient = tabGradient1;
57 | autoHideStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F);
58 | dockPanelSkin1.AutoHideStripSkin = autoHideStripSkin1;
59 | tabGradient2.EndColor = System.Drawing.SystemColors.ControlLightLight;
60 | tabGradient2.StartColor = System.Drawing.SystemColors.ControlLightLight;
61 | tabGradient2.TextColor = System.Drawing.SystemColors.ControlText;
62 | dockPaneStripGradient1.ActiveTabGradient = tabGradient2;
63 | dockPanelGradient2.EndColor = System.Drawing.SystemColors.Control;
64 | dockPanelGradient2.StartColor = System.Drawing.SystemColors.Control;
65 | dockPaneStripGradient1.DockStripGradient = dockPanelGradient2;
66 | tabGradient3.EndColor = System.Drawing.SystemColors.ControlLight;
67 | tabGradient3.StartColor = System.Drawing.SystemColors.ControlLight;
68 | tabGradient3.TextColor = System.Drawing.SystemColors.ControlText;
69 | dockPaneStripGradient1.InactiveTabGradient = tabGradient3;
70 | dockPaneStripSkin1.DocumentGradient = dockPaneStripGradient1;
71 | dockPaneStripSkin1.TextFont = new System.Drawing.Font("Segoe UI", 9F);
72 | tabGradient4.EndColor = System.Drawing.SystemColors.ActiveCaption;
73 | tabGradient4.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
74 | tabGradient4.StartColor = System.Drawing.SystemColors.GradientActiveCaption;
75 | tabGradient4.TextColor = System.Drawing.SystemColors.ActiveCaptionText;
76 | dockPaneStripToolWindowGradient1.ActiveCaptionGradient = tabGradient4;
77 | tabGradient5.EndColor = System.Drawing.SystemColors.Control;
78 | tabGradient5.StartColor = System.Drawing.SystemColors.Control;
79 | tabGradient5.TextColor = System.Drawing.SystemColors.ControlText;
80 | dockPaneStripToolWindowGradient1.ActiveTabGradient = tabGradient5;
81 | dockPanelGradient3.EndColor = System.Drawing.SystemColors.ControlLight;
82 | dockPanelGradient3.StartColor = System.Drawing.SystemColors.ControlLight;
83 | dockPaneStripToolWindowGradient1.DockStripGradient = dockPanelGradient3;
84 | tabGradient6.EndColor = System.Drawing.SystemColors.InactiveCaption;
85 | tabGradient6.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
86 | tabGradient6.StartColor = System.Drawing.SystemColors.GradientInactiveCaption;
87 | tabGradient6.TextColor = System.Drawing.SystemColors.InactiveCaptionText;
88 | dockPaneStripToolWindowGradient1.InactiveCaptionGradient = tabGradient6;
89 | tabGradient7.EndColor = System.Drawing.Color.Transparent;
90 | tabGradient7.StartColor = System.Drawing.Color.Transparent;
91 | tabGradient7.TextColor = System.Drawing.SystemColors.ControlDarkDark;
92 | dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7;
93 | dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1;
94 | dockPanelSkin1.DockPaneStripSkin = dockPaneStripSkin1;
95 | this.dockPanel1.Skin = dockPanelSkin1;
96 | this.dockPanel1.TabIndex = 3;
97 | //
98 | // ILForm
99 | //
100 | this.ClientSize = new System.Drawing.Size(730, 371);
101 | this.Controls.Add(this.dockPanel1);
102 | this.IsMdiContainer = true;
103 | this.Name = "ILForm";
104 | this.ResumeLayout(false);
105 |
106 | }
107 |
108 | #endregion
109 |
110 | private WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel1;
111 |
112 |
113 |
114 |
115 |
116 | }
117 | }
--------------------------------------------------------------------------------
/src/FormSimple/ILMainFormSimple.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ILNumerics.ILView {
2 | partial class ILMainFormSimple {
3 | ///
4 | /// Required designer variable.
5 | ///
6 | private System.ComponentModel.IContainer components = null;
7 |
8 | ///
9 | /// Clean up any resources being used.
10 | ///
11 | /// true if managed resources should be disposed; otherwise, false.
12 | protected override void Dispose(bool disposing) {
13 | if (disposing && (components != null)) {
14 | components.Dispose();
15 | }
16 | base.Dispose(disposing);
17 | }
18 |
19 | #region Windows Form Designer generated code
20 |
21 | ///
22 | /// Required method for Designer support - do not modify
23 | /// the contents of this method with the code editor.
24 | ///
25 | private void InitializeComponent() {
26 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ILMainFormSimple));
27 | this.toolStrip1 = new System.Windows.Forms.ToolStrip();
28 | this.toolStripCmbSource = new System.Windows.Forms.ToolStripComboBox();
29 | this.toolStripBtnLoad = new System.Windows.Forms.ToolStripButton();
30 | this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
31 | this.toolStripBtnConsoleVisible = new System.Windows.Forms.ToolStripButton();
32 | this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
33 | this.toolStripButtonSVG = new System.Windows.Forms.ToolStripButton();
34 | this.toolStripButtonPNG = new System.Windows.Forms.ToolStripButton();
35 | this.toolStrip1.SuspendLayout();
36 | this.SuspendLayout();
37 | //
38 | // toolStrip1
39 | //
40 | this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
41 | this.toolStripCmbSource,
42 | this.toolStripBtnLoad,
43 | this.toolStripSeparator1,
44 | this.toolStripBtnConsoleVisible,
45 | this.toolStripSeparator2,
46 | this.toolStripButtonSVG,
47 | this.toolStripButtonPNG});
48 | this.toolStrip1.Location = new System.Drawing.Point(0, 0);
49 | this.toolStrip1.Name = "toolStrip1";
50 | this.toolStrip1.Size = new System.Drawing.Size(786, 25);
51 | this.toolStrip1.TabIndex = 0;
52 | this.toolStrip1.Text = "toolStrip1";
53 | //
54 | // toolStripCmbSource
55 | //
56 | this.toolStripCmbSource.Name = "toolStripCmbSource";
57 | this.toolStripCmbSource.Size = new System.Drawing.Size(121, 25);
58 | this.toolStripCmbSource.Text = "(enter example source URI or ILC# here or select from list...)";
59 | this.toolStripCmbSource.ToolTipText = "enter example source URI or ILC# here or select from list...";
60 | this.toolStripCmbSource.TextChanged += new System.EventHandler(this.toolStripCmbSource_TextChanged);
61 | //
62 | // toolStripBtnLoad
63 | //
64 | this.toolStripBtnLoad.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
65 | this.toolStripBtnLoad.Image = ((System.Drawing.Image)(resources.GetObject("toolStripBtnLoad.Image")));
66 | this.toolStripBtnLoad.ImageTransparentColor = System.Drawing.Color.Magenta;
67 | this.toolStripBtnLoad.Name = "toolStripBtnLoad";
68 | this.toolStripBtnLoad.Size = new System.Drawing.Size(23, 22);
69 | this.toolStripBtnLoad.Text = "toolStripButton1";
70 | this.toolStripBtnLoad.ToolTipText = "Reload scene from ILC# or URI";
71 | this.toolStripBtnLoad.Click += new System.EventHandler(this.toolStripButton1_Click);
72 | //
73 | // toolStripSeparator1
74 | //
75 | this.toolStripSeparator1.Name = "toolStripSeparator1";
76 | this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
77 | //
78 | // toolStripBtnConsoleVisible
79 | //
80 | this.toolStripBtnConsoleVisible.CheckOnClick = true;
81 | this.toolStripBtnConsoleVisible.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
82 | this.toolStripBtnConsoleVisible.Image = ((System.Drawing.Image)(resources.GetObject("toolStripBtnConsoleVisible.Image")));
83 | this.toolStripBtnConsoleVisible.ImageTransparentColor = System.Drawing.Color.Magenta;
84 | this.toolStripBtnConsoleVisible.Name = "toolStripBtnConsoleVisible";
85 | this.toolStripBtnConsoleVisible.Size = new System.Drawing.Size(72, 22);
86 | this.toolStripBtnConsoleVisible.Text = "C# Console";
87 | this.toolStripBtnConsoleVisible.ToolTipText = "Toogles vsibility for the C# interactive shell window";
88 | //
89 | // toolStripSeparator2
90 | //
91 | this.toolStripSeparator2.Name = "toolStripSeparator2";
92 | this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
93 | //
94 | // toolStripButtonSVG
95 | //
96 | this.toolStripButtonSVG.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSVG.Image")));
97 | this.toolStripButtonSVG.ImageTransparentColor = System.Drawing.Color.Magenta;
98 | this.toolStripButtonSVG.Name = "toolStripButtonSVG";
99 | this.toolStripButtonSVG.Size = new System.Drawing.Size(48, 22);
100 | this.toolStripButtonSVG.Text = "SVG";
101 | this.toolStripButtonSVG.ToolTipText = "Export current scene as SVG";
102 | this.toolStripButtonSVG.Click += new System.EventHandler(this.toolStripButtonSVG_Click);
103 | //
104 | // toolStripButtonPNG
105 | //
106 | this.toolStripButtonPNG.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonPNG.Image")));
107 | this.toolStripButtonPNG.ImageTransparentColor = System.Drawing.Color.Magenta;
108 | this.toolStripButtonPNG.Name = "toolStripButtonPNG";
109 | this.toolStripButtonPNG.Size = new System.Drawing.Size(51, 22);
110 | this.toolStripButtonPNG.Text = "PNG";
111 | this.toolStripButtonPNG.ToolTipText = "Export current scene as PNG";
112 | this.toolStripButtonPNG.Click += new System.EventHandler(this.toolStripButtonPNG_Click);
113 | //
114 | // ILMainFormSimple
115 | //
116 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
117 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
118 | this.ClientSize = new System.Drawing.Size(786, 415);
119 | this.Controls.Add(this.toolStrip1);
120 | this.Name = "ILMainFormSimple";
121 | this.Text = "ILNumerics Example Viewer";
122 | this.toolStrip1.ResumeLayout(false);
123 | this.toolStrip1.PerformLayout();
124 | this.ResumeLayout(false);
125 | this.PerformLayout();
126 |
127 | }
128 |
129 | #endregion
130 |
131 | private System.Windows.Forms.ToolStrip toolStrip1;
132 | private System.Windows.Forms.ToolStripComboBox toolStripCmbSource;
133 | private System.Windows.Forms.ToolStripButton toolStripBtnLoad;
134 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
135 | private System.Windows.Forms.ToolStripButton toolStripButtonSVG;
136 | private System.Windows.Forms.ToolStripButton toolStripButtonPNG;
137 | private System.Windows.Forms.ToolStripButton toolStripBtnConsoleVisible;
138 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
139 |
140 |
141 | }
142 | }
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # ILView
2 |
3 | Interactive REPL and lightweight 3D Viewer for Scientists and Programmers.
4 | Watch an introductory video here: [http://www.youtube.com/watch?v=RTfLAdVWReI#at=32](http://www.youtube.com/watch?v=RTfLAdVWReI#at=32)
5 |
6 | ## Overview
7 |
8 | This is the official repository for ILView - an interactive viewer for 3D scenes and plottings created with [ILNumerics](http://ilnumerics.net). This repository targets
9 | potential developers for ILView. If you want to try out ILView directly, fetch it from here: . On Windows, you may start the
10 | exe directly out of the zip package. On Linux, you may have to install monodevelop, extract the package and start ILView via: `mono ILView_i18fb66.exe`.
11 |
12 |
13 | ILView allows the visualization of arbitrary 3D scenes in a small and lightweight .NET application. Scenes can be fetched
14 | from arbitrary URIs, provided as ILC# (permalinks from the official ILNumerics project site) or interactively defined.
15 |
16 | ILView comes with a C# interactive console (C# REPL). It can be used to modify 3D scenes interactively. Furthermore, it is handy as a general
17 | computing REPL for the evaluation of arbitrary computational expressions.
18 |
19 | ILView is the default viewer for all interactive [web code components](http://ilnumerics.net/ilnumerics-interactive-web-component.html)
20 | on the official ILNumerics website.
21 |
22 | This project is intended as community project. We (the maintainer of ILNumerics) will keep pushing updates to it.
23 | But we do explicitly encourage you to collaborate and to support the project. We are open for pull requests and general ideas for
24 | enhancements and new features.
25 |
26 | ## Supported Platforms
27 |
28 | ILView is a .NET application. It runs on all supporting platforms for .NET CLR 4.0 or mono. We have tried to keep the GUI as simple as
29 | possible, in order to minimize platform specific issues. The initial state of the GUI does not use any fancy docking windows or the like.
30 | It runs unmmodified on all major Windows and Linux distributions without further dependencies.
31 |
32 | ## Dependencies
33 |
34 | - **ILNumerics** provides the computational base and the scene graph implementation. It is provided as Open Source project (GPL3) on .
35 | - **OpenTK** provides OpenGL bindings. [OpenTK](http://opentk.com) is part of the ILNumerics distribution.
36 | - **Mono.CSharp** is a C# compiler and interactive evaluator made available by the [mono](http://www.mono-project.com/Main_Page) team. It
37 | is used to realize the C# REPL in ILView. The official repository is found on github here . Mono CSharp is found under mcs\class\Mono.CSharp.
38 | A modified prebuilt assembly is provided in the bin directory of ILView for convenience and easier reference.
39 | - On Linux we recommend to install **monodevelop**. It brings all needed .NET libraries (mostly winforms and GDI).
40 |
41 | ## Binaries
42 |
43 | We do currently not provide precompiled binaries of ILView. In order to create an executable, clone the repository and build ILView. Another way to
44 | get a prebuilt executable is to visit a web code component at the ILNumerics website. The output type EXE provides a single prebuilt
45 | executable file, having all dependencies merged into.
46 |
47 | ## Building ILView
48 |
49 | Build is straightforward:
50 |
51 | - Clone the repository
52 | - Open ILView.csproj in Visual Studio (or your favorite IDE)
53 | - Add a reference to Mono.CSharp (build Mono.CSharp on your own or take the DLL from the bin/ folder in the repos root)
54 | - Add a reference to ILNumerics by using NuGet:
55 |
56 | Install-Package ILNumerics
57 |
58 | - Build
59 |
60 | ## Notes
61 |
62 | Installing ILNumerics via NuGet will also install ILNumerics.Native. This package contains the Intel MKL binaries for 32 and 64 bit and is
63 | needed, in order to make the **full** ILNumerics feature set available on the REPL. Especially, functions like fft(), svd() and pinv() depend
64 | on ILNumerics.Native.
65 |
66 | However, in order to run interactive 3D graphics only, ILNumerics.Native is not needed. So, in case you are after a minimal deployment size,
67 | you may remove the ILNumerics.Native package. Keep in mind, all attempts to call any of the functions which depend on LAPACK or FFT will cause
68 | ILView to crash at runtime then! In a future version, ILView should try to load needed binaries automatically from the official nuget repositories.
69 |
70 | ## License
71 |
72 | ILView is provided under the MIT/X11 license.
73 |
74 | # Getting Started
75 |
76 | ILView is a simple application which consists out of several windows. At application startup, a console is started (src/Program.cs)
77 | which starts the main application window (src/FormSimple/ILMainFormSimple.cs). The main window contains a single ILPanel and some toolbar
78 | buttons. It is used to display the current scene. The scene reacts on mouse input as common for interactive ILNumerics scene drivers.
79 | A dropdown allows to fetch further preconfigured examples from the ILNumerics website and replace the current scene. Buttons are provided
80 | to allow to export the current state of the scene (including current camera settings) as SVG or PNG. Another toolbar button allows to toogle
81 | the visibility of the C# Interactive Console REPL.
82 |
83 | ## C# REPL Overview
84 |
85 | The C# Interactive Console (REPL) allows for the evaluation of arbitrary C# expressions on the fly. This means, in difference to writing
86 | regular C# programs - the REPL accepts individual valid expressions without the need to wrap them in a full class context. The
87 | expressions are entered by the user at the command line, wrapped automatically by the compiler and executed. The result is immediately
88 | returned and displayed on the command line as text output.
89 |
90 | > 1 + 3 [Enter]
91 | 4
92 | > ILArray A = ILMath.rand(5,4); [Enter]
93 | > A [Enter]
94 | [5,4]
95 | 0,62847 0,51569 0,32339 0,40215
96 | 0,48536 0,40263 0,51768 0,38973
97 | 0,79303 0,80743 0,93868 0,93390
98 | 0,57042 0,73974 0,13721 0,82855
99 | 0,47411 0,12583 0,40773 0,61560
100 |
101 | ## REPL Handling
102 |
103 | The evaluation is triggered when the `Enter` key is pressed. Multiple lines are spanned by pressing `Space` + `Enter` together. The `Up` key
104 | iteratively steps through the entries in the list of earlier expressions history. A (by now yet limited) set of code completions is
105 | provided automatically while entering expressions. Marking of text areas, copy and paste of text is working the regular way. The use of a
106 | trailing semicolon ';' is optional.
107 |
108 | The C# Interactive Console allows arbitrary modifications to the scene being displayed in the main window. It exposes the panel of the
109 | main window via the `Panel` property and may be used to alter any property of the panel, including the `Panel.Scene`:
110 |
111 | > Panel.BackColor = Color.DarkGray
112 | > Panel.Scene = new ILScene { Camera = { new ILSphere() } }
113 |
114 | Of course, all regular C# expressions are allowed, which reference any .NET type or namespace. By default, the following namespaces are
115 | included:
116 |
117 | using System;
118 | using System.Drawing;
119 | using System.Collections.Generic;
120 | using System.Linq;
121 | using ILNumerics;
122 | using ILNumerics.Drawing;
123 | using ILNumerics.Drawing.Plotting;
124 |
125 | More namespaces can be included at any point (and not necessarily at the beginning of the session) on the command line. Furthermore,
126 | all members of the `ILNumerics.ILMath` class are directly accessible, without the need to specify the `ILMath` class. All common rules
127 | for [writing functions and handling arrays in ILNumerics](http://ilnumerics.net/GeneralRules.html) apply:
128 |
129 | > ILArray A = rand(100,200) * 2 - 1;
130 | > // set diagonal to 1
131 | > A[r(0,101,end)] = 1;
132 | > // Some more fun with subarrays
133 | > A[A == 1] = A[A == 1] * 2;
134 | > // create a new surface scene
135 | > var scene = new ILScene { new ILPlotCube { new ILSurface(tosingle(A)) } }
136 | > // apply the scene to our panel
137 | > Panel.Scene = scene
138 | > // make the plot cube rotatable
139 | > Panel.Scene.First().TwoDMode = false
140 |
141 | 
142 |
143 | ## Default Scene Loading
144 |
145 | The console starter loads a default scene into the main window. Which scene is displayed, depends
146 | on the **name** of the executable: if an ILNumerics web code was found as part of the executable name, the corresponding scene is loaded
147 | from http://ilnumerics.net and displayed.
--------------------------------------------------------------------------------
/src/ILView.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9E7AE414-638D-4151-8D1C-136AD876C151}
8 | Exe
9 | Properties
10 | ILNumerics
11 | ILView
12 | 512
13 | 10.0.0
14 | 2.0
15 |
16 |
17 | x86
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x86
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 | true
37 | bin\x86\Debug\
38 | DEBUG;TRACE
39 | full
40 | x86
41 | prompt
42 | MinimumRecommendedRules.ruleset
43 | true
44 | 4
45 | false
46 |
47 |
48 | bin\x86\Release\
49 | TRACE
50 | true
51 | pdbonly
52 | AnyCPU
53 | prompt
54 | MinimumRecommendedRules.ruleset
55 | true
56 | 4
57 |
58 |
59 | true
60 | bin\x64\Debug\
61 | DEBUG;TRACE
62 | full
63 | x64
64 | prompt
65 | MinimumRecommendedRules.ruleset
66 | true
67 | 4
68 | false
69 |
70 |
71 | bin\x64\Release\
72 | TRACE
73 | true
74 | pdbonly
75 | x64
76 | prompt
77 | MinimumRecommendedRules.ruleset
78 | true
79 | 4
80 |
81 |
82 |
83 | False
84 | ..\..\packages\ILNumerics.3.3.2.0\lib\ILNumerics.dll
85 |
86 |
87 | ..\bin\Mono.CSharp.dll
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | Form
103 |
104 |
105 | ILMainFormSimple.cs
106 |
107 |
108 | Form
109 |
110 |
111 | ILShellForm.cs
112 |
113 |
114 |
115 |
116 |
117 |
118 | Component
119 |
120 |
121 | ILShell.cs
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | ILMainFormSimple.cs
131 |
132 |
133 | ILShell.cs
134 |
135 |
136 | ILShellForm.cs
137 |
138 |
139 | ResXFileCodeGenerator
140 | Resources.Designer.cs
141 | Designer
142 |
143 |
144 | True
145 | Resources.resx
146 | True
147 |
148 |
149 |
150 | SettingsSingleFileGenerator
151 | Settings.Designer.cs
152 |
153 |
154 | True
155 | Settings.settings
156 | True
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | PreserveNewest
172 |
173 |
174 | PreserveNewest
175 |
176 |
177 | PreserveNewest
178 |
179 |
180 | PreserveNewest
181 |
182 |
183 |
184 |
191 |
--------------------------------------------------------------------------------
/src/FormSimple/ILMainFormSimple.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 |
125 |
126 | iVBORw0KGgoAAAANSUhEUgAAAA4AAAAPCAYAAADUFP50AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
127 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAC/SURBVDhPlZMxCsJAEEW/mEZLsdcb6Bn0EB5AyBkEizFa
128 | i3cQKz2AHkGJxxBr02mhyQ/OkqDLsvvhMWH2vw0pAixwIRPkaCAoggfFnKR8HunWI5VoOGKJgZ468i+W
129 | vLnfYoWetiyxi18ET841Z0fbtbhEQ9kRzHhFSy3GRzQIbpxT7NEMEysOoW+8k5hEvmJG5uy29QMZt/gi
130 | G3a62q7FJgo+ZEf62rLkVxScyFBPHTGi4IoEY916RHCmGPh3AAWAwawKPdMMdQAAAABJRU5ErkJggg==
131 |
132 |
133 |
134 |
135 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
136 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
137 | YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
138 | 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
139 | bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
140 | VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
141 | c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
142 | Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
143 | mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
144 | kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
145 | TgDQASA1MVpwzwAAAABJRU5ErkJggg==
146 |
147 |
148 |
149 |
150 | iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
151 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHDSURBVDhPdVO/SxxBFB6T5t5bRcQUKcT/QBQC0UYSgkUi
152 | ik0MJLgzGxEray3TWwcM2qQI5rjyUFSwiwi3O2dyZ1CMhakNQf8Dfd/b2U1U/OAxN9/3zfsxN2tuwyeV
153 | 0czyV+/osIjM0drBex4MlrtoxF293tKuxOV9IUnrrTnqC0dytN9193jLe/9MtJUlPJ7G0RhW7EvN8f6P
154 | GROFo8aUouMTbytvwPm40p/N0DBW3Quf6+qrXn0wD0zT8ZM8I/1pOB6CEZBOank1rgXKQIcP/IHlVya1
155 | vKKHLX0JHgXmy3muB0oBH/g05k9GZvDYNC0tBF0h3CZ4rIFSwAdeOjiC6buakugFxDSuPJOEi/o3wWSp
156 | LdWXwEOHT/2Wf0llamFTVBbza4mL3JAH5sStQy8rWzo2WUKranK0DhFIHc//f9DHPBGkcmbh17B5Gox/
157 | i9YBuZBZ0c6bCU0G6sZtF51gbn1ZMtvvLIkGlBT8dPw4/NQiaDX30UZt2jxUwb/tfCSX9C0IFzLC5yym
158 | qcxFz6XaS0n6sazo+FS4MqnCz/d0i2EHhvtCEm8XL+4OrozpkKojMucyWpSKZ/pVWa7i0vRJljDmGkHu
159 | K5AD1wzmAAAAAElFTkSuQmCC
160 |
161 |
162 |
163 |
164 | iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
165 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHDSURBVDhPdVO/SxxBFB6T5t5bRcQUKcT/QBQC0UYSgkUi
166 | ik0MJLgzGxEray3TWwcM2qQI5rjyUFSwiwi3O2dyZ1CMhakNQf8Dfd/b2U1U/OAxN9/3zfsxN2tuwyeV
167 | 0czyV+/osIjM0drBex4MlrtoxF293tKuxOV9IUnrrTnqC0dytN9193jLe/9MtJUlPJ7G0RhW7EvN8f6P
168 | GROFo8aUouMTbytvwPm40p/N0DBW3Quf6+qrXn0wD0zT8ZM8I/1pOB6CEZBOank1rgXKQIcP/IHlVya1
169 | vKKHLX0JHgXmy3muB0oBH/g05k9GZvDYNC0tBF0h3CZ4rIFSwAdeOjiC6buakugFxDSuPJOEi/o3wWSp
170 | LdWXwEOHT/2Wf0llamFTVBbza4mL3JAH5sStQy8rWzo2WUKranK0DhFIHc//f9DHPBGkcmbh17B5Gox/
171 | i9YBuZBZ0c6bCU0G6sZtF51gbn1ZMtvvLIkGlBT8dPw4/NQiaDX30UZt2jxUwb/tfCSX9C0IFzLC5yym
172 | qcxFz6XaS0n6sazo+FS4MqnCz/d0i2EHhvtCEm8XL+4OrozpkKojMucyWpSKZ/pVWa7i0vRJljDmGkHu
173 | K5AD1wzmAAAAAElFTkSuQmCC
174 |
175 |
176 |
--------------------------------------------------------------------------------
/src/FormSimple/ILShell.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.ComponentModel;
16 | using System.Data;
17 | using System.Drawing;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Forms;
21 |
22 | namespace ILNumerics.ILView {
23 |
24 | public partial class ILShell : RichTextBox, IILShell {
25 |
26 | /* features to be supported:
27 | * + Entering commands over single & multiple lines (+)
28 | * + Copy & Paste commands (multiple lines) (+)
29 | * + Edit current command (+)
30 | * + Code completion (on '.' key, 'tab' key)
31 | * + Syntax highlighting
32 | * + Error reporting & highlighting
33 | * + Text result reporting (+)
34 | * + History (+)
35 | * + Custom commands (Compile, Scene, Example, Tutor, ... )
36 | */
37 |
38 | /* DISCLAIMER: This code is derived from and uses parts of the following projects:
39 | * + ShellControl - A console emulation control; By S. Senthil Kumar, 26 Feb 2005
40 | * http://www.codeproject.com/Articles/9621/ShellControl-A-console-emulation-control?msg=2063648
41 | * It has further been inspired by and copies major parts of the concept of:
42 | * + Mono.CSharp.GUI.Shell; Copyright (C) 2006-2008 Novell, Inc., (CSharpShell.cs)
43 | * Written by Aaron Bockover .
44 | * Miguel de Icaza (miguel@gnome.org).
45 | */
46 |
47 | #region attributes
48 | private static readonly string Prompt = "> ";
49 | private static readonly string InitMessage = @"ILNumerics C# Interactive Console
50 |
51 | " + ILShellBaseClass.version + @"
52 | Type 'help' for instructions!
53 | -------------------------------------------------------------------------------------
54 | ";
55 | private int m_cmdLineStart = 0;
56 | private ILCommandHistory m_history;
57 | private int m_curHistoryIdx;
58 | private StringBuilder m_sbuilder;
59 | #endregion
60 |
61 | #region event handlers
62 | public event EventHandler CommandEntered;
63 | protected void OnCommandEntered(string expression) {
64 | if (CommandEntered != null) {
65 | CommandEntered(this, new ILCommandEnteredEventArgs(expression));
66 | }
67 | }
68 | public event EventHandler CompletionRequested;
69 | protected void OnCompletionRequested(string expression, Point location) {
70 | if (CompletionRequested != null && !String.IsNullOrEmpty(expression)) {
71 | var args = new ILCompletionRequestEventArgs(expression, location);
72 | CompletionRequested(this, args);
73 | if (args.CompletionResult != null && args.CompletionResult.Count() > 0) {
74 | ShowCompletions(args);
75 | } else {
76 | HideCompletions();
77 | }
78 |
79 | }
80 | }
81 |
82 |
83 | #endregion
84 |
85 | #region constructors
86 | public ILShell() {
87 | InitializeComponent();
88 | Text = "";
89 | WordWrap = false;
90 | m_history = new ILCommandHistory();
91 | m_sbuilder = new StringBuilder();
92 | m_cmdLineStart = -1;
93 | WriteText(InitMessage);
94 | }
95 | #endregion
96 |
97 | #region public interface
98 | public void WriteText(string text) {
99 | // todo: styling
100 | base.AppendText(text);
101 | base.ScrollToCaret();
102 | }
103 | public void WriteCommand(string text) {
104 | if (InvokeRequired) {
105 | Invoke((Action)WriteCommand, text);
106 | } else {
107 | StartCommand();
108 | // todo: syntax highlighting
109 | AppendCommand(text);
110 | EndCommand();
111 | }
112 | }
113 | public void StartCommand() {
114 | // always starts new line
115 | // always writes prompt as first line start
116 | base.AppendText(Environment.NewLine + Prompt);
117 | m_cmdLineStart = CmdLineEnd;
118 | var oldStart = SelectionStart;
119 | SelectionStart = oldStart - Prompt.Length;
120 | SelectionLength = Prompt.Length;
121 | SelectionColor = Color.Black;
122 | SelectionLength = 0;
123 | SelectionStart = oldStart;
124 | }
125 | public void AppendCommand(string text) {
126 | // todo: syntax highlighting
127 | base.AppendText(text);
128 | }
129 | public void EndCommand() {
130 | if (m_cmdLineStart <= CmdLineEnd) {
131 | var cmd = CurrentCommand;
132 | m_cmdLineStart = -1;
133 | if (!String.IsNullOrEmpty(cmd)) {
134 | OnCommandEntered(cmd);
135 | m_history.Add(cmd);
136 | m_curHistoryIdx = m_history.Count - 1;
137 | }
138 | }
139 | HideCompletions();
140 | }
141 | public void WriteError(string text) {
142 | // todo: error styling
143 | AppendText(Environment.NewLine);
144 | text = text.TrimEnd('\r','\n',' ','\t');
145 | int start = SelectionStart;
146 | text = "Error: " + text;
147 | base.AppendText(text);
148 |
149 | SelectionStart = start;
150 | SelectionLength = text.Length;// - Environment.NewLine.Length;
151 | SelectionColor = Color.Red;
152 | HideCompletions();
153 | }
154 |
155 | public string CurrentCommand {
156 | get {
157 | if (m_cmdLineStart < 0) return string.Empty;
158 | m_sbuilder.Clear();
159 | m_sbuilder.Append(removePrompt(Lines[m_cmdLineStart]));
160 | for (int i = m_cmdLineStart + 1; i <= CmdLineEnd; i++) {
161 | m_sbuilder.Append(Environment.NewLine + Lines[i]);
162 | }
163 | return m_sbuilder.ToString();
164 | }
165 | }
166 | public override string Text {
167 | get { return base.Text; }
168 | set {
169 | if (!String.IsNullOrEmpty(value)) {
170 | // convert line endings to this platform new lines
171 | // (not very efficient ... )
172 | value = value.Replace("\r\n", "\n");
173 | var lines = value.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
174 | value = String.Join(Environment.NewLine, lines);
175 | base.Text = value;
176 | }
177 | }
178 | }
179 | public int CursorLinePosition {
180 | get {
181 | return GetLineFromCharIndex(SelectionStart);
182 | }
183 | }
184 | public int CursorColumnPosition {
185 | get {
186 | var firstIdx = GetFirstCharIndexFromLine(CursorLinePosition);
187 | return SelectionStart - firstIdx;
188 | }
189 | }
190 | public ListBox CompletionBox {
191 | get {
192 | if (Parent != null && Parent is IILCompletionFormProvider) {
193 | return (Parent as IILCompletionFormProvider).GetCompletionForm();
194 | }
195 | return null;
196 | }
197 | }
198 | #endregion
199 |
200 | #region private helpers
201 | private void HideCompletions() {
202 | var box = CompletionBox;
203 | if (box != null) {
204 | box.Visible = false;
205 | }
206 | }
207 |
208 | public void ShowCompletions(ILCompletionRequestEventArgs args) {
209 | var box = CompletionBox;
210 | if (box != null) {
211 | IEnumerable items = args.CompletionResult;
212 | Point location = args.Location;
213 | box.Items.Clear();
214 | foreach (var item in items) {
215 | box.Items.Add(args.Prefix + item.ToString());
216 | }
217 | box.Location = sizeAndPositionCompletionWindow(box, location);
218 | box.SelectedIndex = 0;
219 | box.MouseClick -= box_MouseClick;
220 | box.MouseClick += box_MouseClick;
221 | box.Show();
222 | Focus();
223 | }
224 | }
225 |
226 | void box_MouseClick(object sender, MouseEventArgs e) {
227 | ReplaceWord(CompletionBox.SelectedItem.ToString());
228 | HideCompletions();
229 | }
230 | private Point sizeAndPositionCompletionWindow(ListBox box, Point location) {
231 | // resize
232 | int numberRows = Math.Min(box.Items.Count, 8) + 1;
233 | box.Height = box.ItemHeight * numberRows;
234 |
235 | // optimal: right under the caret
236 | int x = location.X, y = location.Y + Font.Height;
237 | if (x + box.Width > ClientSize.Width) {
238 | x = ClientSize.Width - box.Width;
239 | }
240 | if (y + box.Height > ClientSize.Height) {
241 | y = location.Y - box.Height;
242 | }
243 | return new Point(x, y);
244 | }
245 | private string removePrompt(string p) {
246 | if (p.StartsWith(Prompt)) {
247 | return p.Substring(Prompt.Length);
248 | }
249 | return p;
250 | }
251 | private int CmdLineEnd { get { return Lines.Length - 1; } }
252 | protected override void OnKeyPress (KeyPressEventArgs e)
253 | {
254 | // regular keys -> ensure "in command state"
255 | if (m_cmdLineStart < 0) {
256 | StartCommand ();
257 | }
258 | if (e.KeyChar == (char)13) {
259 | e.Handled = true;
260 | }
261 | base.OnKeyPress(e);
262 | }
263 | protected override void OnTextChanged(EventArgs e) {
264 | base.OnTextChanged(e);
265 | // handle completions
266 | Point location = GetPositionFromCharIndex(SelectionStart);
267 | OnCompletionRequested(CurrentCommand, location);
268 | }
269 |
270 | protected override void OnKeyDown(KeyEventArgs e) {
271 | KeyDownHandler(e);
272 | base.OnKeyDown(e);
273 | }
274 |
275 | private void KeyDownHandler(KeyEventArgs e) {
276 | // handle backspace
277 | if (e.KeyCode == Keys.Back) { // || e.KeyCode == Keys.Delete)
278 | e.Handled = !handleBackKey();
279 | e.SuppressKeyPress = e.Handled;
280 | HideCompletions();
281 | return;
282 | }
283 | if (e.KeyCode == Keys.Escape) {
284 | HideCompletions();
285 | }
286 | // handle Shift + Enter (multiple command lines
287 | if (e.KeyCode == Keys.Enter) {
288 | if (e.Shift) {
289 | e.Handled = true;
290 | //e.SuppressKeyPress = true;
291 | AppendCommand(Environment.NewLine);
292 | return;
293 | } else {
294 | if (CompletionBox != null && CompletionBox.Visible == true) {
295 | ReplaceWord(CompletionBox.SelectedItem.ToString());
296 | HideCompletions();
297 | e.Handled = true;
298 | e.SuppressKeyPress = true;
299 | return;
300 | } else {
301 | e.Handled = true;
302 | //e.SuppressKeyPress = true;
303 | EndCommand();
304 | return;
305 | }
306 | }
307 | } else if (e.KeyCode == Keys.Tab && CompletionBox != null && CompletionBox.Visible == true) {
308 | ReplaceWord(CompletionBox.SelectedItem.ToString());
309 | HideCompletions();
310 | e.Handled = true;
311 | e.SuppressKeyPress = true;
312 | return;
313 | }
314 |
315 | // Prevent caret from moving before the prompt
316 | if (e.KeyCode == Keys.Left && IsCaretJustBeforePrompt()) {
317 | e.Handled = true;
318 | return;
319 | } else if (e.KeyCode == Keys.Down) {
320 | if (CompletionBox != null && CompletionBox.Visible) {
321 | if (CompletionBox.SelectedIndex < CompletionBox.Items.Count - 1) {
322 | CompletionBox.SelectedIndex++;
323 | }
324 | e.Handled = true;
325 | } else {
326 | HandleHistory(ref m_curHistoryIdx);
327 | m_curHistoryIdx++;
328 | e.Handled = true;
329 | }
330 | return;
331 | } else if (e.KeyCode == Keys.Up) {
332 | if (CompletionBox != null && CompletionBox.Visible) {
333 | if (CompletionBox.SelectedIndex > 0 && CompletionBox.Items.Count > 0) {
334 | CompletionBox.SelectedIndex--;
335 | }
336 | e.Handled = true;
337 | } else {
338 | HandleHistory(ref m_curHistoryIdx);
339 | m_curHistoryIdx--;
340 | e.Handled = true;
341 | }
342 | return;
343 | } else if (e.KeyCode == Keys.Right) {
344 | return;
345 | } else if (e.KeyCode == Keys.Home) {
346 | int currentLineIdx = m_cmdLineStart >= 0 ? m_cmdLineStart : GetLineFromCharIndex(SelectionStart);
347 | int startCmd = GetFirstCharIndexFromLine(currentLineIdx);
348 | if (Lines[currentLineIdx].StartsWith(Prompt))
349 | startCmd += Prompt.Length;
350 | //int endSelect = SelectionStart;
351 | SelectionStart = startCmd;
352 | //SelectionLength = endSelect - startCmd;
353 | e.Handled = true;
354 | return;
355 | } else if (e.Control) {
356 | if (e.KeyValue == 17) {
357 | // Control only
358 | e.Handled = true;
359 | return;
360 | } else if (e.KeyCode == Keys.C) {
361 | // copy should not move the carret
362 | return;
363 | }
364 | }
365 | // handle all common user input, including PASTE event (by keyboard only)
366 |
367 | // If the caret is anywhere else, set it back when a key is pressed.
368 | if (!IsCaretAtWritablePosition()) {
369 | MoveCaretToEndOfText();
370 | }
371 | }
372 |
373 | protected override bool IsInputKey(Keys keyData) {
374 | if (keyData == Keys.Tab || keyData == (Keys.Shift | Keys.Tab)) return true;
375 | return base.IsInputKey(keyData);
376 | }
377 | private void ReplaceWord(string word) {
378 | int start, end = start = SelectionStart;
379 | int cmdStart = GetCurrentCommandStartCharIdx();
380 | if (cmdStart < 0) return;
381 | string txt = Text;
382 | //if (start >= txt.Length) start = txt.Length - 1;
383 | while (start > cmdStart && (char.IsLetterOrDigit(txt[start-1]) || '_' == txt[start-1])) {
384 | start--;
385 | }
386 | SelectionStart = start;
387 | SelectionLength = end - start + 1;
388 | SelectedText = word;
389 |
390 | }
391 |
392 | private void HandleHistory (ref int p)
393 | {
394 | // simplyfied history variant: do not recognize partial texts manually entered by user
395 | if (m_history.Count == 0) return;
396 | if (p < 0)
397 | p = 0;
398 | if (p >= m_history.Count) {
399 | p = m_history.Count - 1;
400 | }
401 | // replace full command with history entry
402 | if (m_cmdLineStart < 0) StartCommand();
403 | int charIdxStart = GetCurrentCommandStartCharIdx();
404 | int charIdxEnd = Text.Length-1;
405 | if (charIdxEnd < charIdxStart) charIdxEnd = charIdxStart;
406 | base.SelectionStart = charIdxStart;
407 | base.SelectionLength = charIdxEnd - charIdxStart + 1;
408 | base.SelectedText = m_history[p];
409 | }
410 |
411 | int GetCurrentCommandStartCharIdx ()
412 | {
413 | if (m_cmdLineStart < 0)
414 | return 0;
415 | int startCharIdx = GetFirstCharIndexFromLine(m_cmdLineStart);
416 | return startCharIdx + Prompt.Length;
417 | }
418 |
419 | private bool handleBackKey() {
420 | var c = CursorColumnPosition;
421 | if (CursorLinePosition == m_cmdLineStart) {
422 | return c > Prompt.Length;
423 | } else {
424 | return true;
425 | }
426 | }
427 | // Overridden to protect against deletion of contents
428 | // cutting the text and deleting it from the context menu
429 | protected override void WndProc(ref Message m) {
430 | switch (m.Msg) {
431 | case 0x0302: //WM_PASTE
432 | case 0x0300: //WM_CUT
433 | case 0x000C: //WM_SETTEXT
434 | if (!IsCaretAtWritablePosition())
435 | MoveCaretToEndOfText();
436 | break;
437 | case 0x0303: //WM_CLEAR
438 | return;
439 | }
440 | base.WndProc(ref m);
441 | }
442 | private bool IsTerminatorKey(Keys key) {
443 | return key == Keys.Enter;
444 | }
445 | private bool IsTerminatorKey(char keyChar) {
446 | return ((int)keyChar) == 13;
447 | }
448 |
449 | private bool IsCaretJustBeforePrompt() {
450 | return IsCaretInCmd() &&
451 | (CursorColumnPosition == Prompt.Length && CursorLinePosition == m_cmdLineStart);
452 | }
453 |
454 | private void MoveCaretToEndOfText() {
455 | this.SelectionStart = this.TextLength;
456 | this.ScrollToCaret();
457 | }
458 | private bool IsCaretAtWritablePosition() {
459 | return IsCaretInCmd() && CursorColumnPosition >= Prompt.Length;
460 | }
461 | private bool IsCaretInCmd() {
462 | int clp = CursorLinePosition;
463 | if (clp > m_cmdLineStart)
464 | return true;
465 | else if (clp == m_cmdLineStart) {
466 | return CursorColumnPosition >= Prompt.Length;
467 | }
468 | return false;
469 | }
470 | private string GetCurrentLine() {
471 | int lineIdx = GetLineFromCharIndex(SelectionStart);
472 | if (lineIdx >= 0 && lineIdx < Lines.Length && Lines.Length > 0)
473 | return Lines[lineIdx];
474 | else
475 | return "";
476 | }
477 |
478 | protected void SyntaxHighlightCmd(int start, int length) {
479 | // todo
480 | }
481 | #endregion
482 |
483 | public void Init(object host) {
484 |
485 | }
486 | }
487 |
488 | }
489 |
--------------------------------------------------------------------------------
/src/FormExtended/ILForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using ILNumerics;
10 | using ILNumerics.Drawing;
11 | using ILNumerics.Drawing.Plotting;
12 | using System.Diagnostics;
13 | using WeifenLuo.WinFormsUI.Docking;
14 | using Mono.CSharp;
15 | using System.IO;
16 | using ICSharpCode.TextEditor.Document;
17 |
18 | namespace ILNumerics.ILView {
19 | partial class ILForm : Form {
20 |
21 | #region attributes
22 | private string m_source;
23 | public static string ilc_requestURL = @"http://ilnumerics.net/ilcf/{0}/{1}/in.txt";
24 | private static string defaultSourceTextBoxText = "(enter source URI/ ILC# here or choose from list ...)";
25 | private ILShellControl m_shell;
26 | private Action m_cleanUpExample;
27 | private Evaluator m_evaluator;
28 | private StringBuilder m_errorStream;
29 | #endregion
30 |
31 | #region properties
32 |
33 | public Evaluator Evaluator {
34 | get {
35 | if (m_evaluator == null)
36 | resetEvaluator();
37 | return m_evaluator;
38 | }
39 | }
40 | public StringBuilder ErrorStream {
41 | get {
42 | if (m_errorStream == null) {
43 | m_errorStream = new StringBuilder();
44 | }
45 | return m_errorStream;
46 | }
47 | }
48 |
49 |
50 | ///
51 | /// The source for the initial state of the viewer
52 | ///
53 | /// Allowed values are: a uri string, C# code with a valid szene definition, empty string.
54 | ///
55 | ///
56 | /// - URI: the uri is expected to reference a file location with a valid scene definition (C# code).
57 | /// - C# Code: a valid C# code snippet creating a ILScene. Valid snippets are syntactically correct and end
58 | /// with a statement, returning the scene object. One example of a valid C# code snippet which creates a simple
59 | /// scene with a sphere in 3D:
60 | ///
var scene = new ILScene { Camera = { new ILSphere() } };
61 | /// scene;
62 | /// Note that the following namespaces are automatically included, hence no using statements are necessary for classes in them:
63 | /// System; System.Drawing; System.Collections.Generic; System.Linq; ILNumerics; ILNumerics.Drawing; ILNumerics.Drawing.Plotting;
64 | ///
65 | /// - Empty String: the ILNumerics example will be created. This shows a scene with three subpplots
66 | /// with several static and dynamic features and plots.
67 | ///
68 | public string Source {
69 | get { return m_source; }
70 | set {
71 | m_source = value;
72 | LoadSzene(m_source);
73 | }
74 | }
75 | ///
76 | ///
77 | ///
78 | public ILPanel Panel {
79 | get {
80 | //var doc = dockPanel1.Documents.ElementAt(0) as ILMainContent;
81 | //if (doc != null)
82 | // return doc.Panel;
83 | return null;
84 | }
85 | }
86 | ///
87 | ///
88 | ///
89 | public ILShellControl Shell {
90 | get { return m_shell; }
91 | }
92 | #endregion
93 |
94 | #region constructors
95 | public ILForm() {
96 | InitializeComponent();
97 | // setup source combo box
98 | // fill couple of interesting sources
99 | cmbSources1.Items.Add("id0b426");
100 | cmbSources1.Items.Add("if920ce");
101 | cmbSources1.Items.Add("id8c59a");
102 | cmbSources1.Items.Add("icd3109");
103 | cmbSources1.Items.Add("i3748c4");
104 | cmbSources1.Items.Add("ib5b26c");
105 | cmbSources1.Items.Add("i8951b3");
106 | cmbSources1.Items.Add("i794c2c");
107 | cmbSources1.Items.Add("i461339");
108 | cmbSources1.Items.Add("i9b1f80");
109 | cmbSources1.Items.Add("ia3fcd0");
110 | cmbSources1.Items.Add("i57d081");
111 | cmbSources1.Items.Add("i77c8ac");
112 | cmbSources1.Items.Add("i9481ea");
113 | cmbSources1.Items.Add("i5a1dc1");
114 | cmbSources1.Items.Add("i24bd56");
115 | cmbSources1.Items.Add("example");
116 |
117 | ILMain mainContent = new ILMainContent();
118 | mainContent.Show(dockPanel1, dockState: DockState.Document);
119 | m_shell = new ILShellControl();
120 | Shell.Show(dockPanel1, dockState: DockState.DockTopAutoHide);
121 | Shell.CommandEntered += shell_Evaluate;
122 | Shell.Text = "C# Interactive Console";
123 |
124 | //Panel.Driver = RendererTypes.GDI;
125 |
126 | }
127 |
128 | void shell_Evaluate(object sender, ILCommandEnteredEventArgs e) {
129 | Evaluate(e.Command);
130 | }
131 | #endregion
132 | private void resetEvaluator() {
133 | m_errorStream = new StringBuilder();
134 | //StreamReader sr =
135 | TextWriter tw = new StringWriter(m_errorStream);
136 | var ctx = new Mono.CSharp.CompilerContext(
137 | new Mono.CSharp.CompilerSettings() {
138 | AssemblyReferences = new List() {
139 | typeof(ILMath).Assembly.FullName,
140 | typeof(System.Drawing.PointF).Assembly.FullName,
141 | typeof(System.Linq.Queryable).Assembly.FullName
142 | },
143 | //Unsafe = true
144 | }, new StreamReportPrinter(tw));
145 |
146 | var eval = new Mono.CSharp.Evaluator(ctx);
147 | // reset line colors (thread safe)
148 | ILNumerics.Drawing.Plotting.ILLinePlot.NextColors = new ILColorEnumerator();
149 |
150 | string m_head = @"
151 | using System;
152 | using System.Drawing;
153 | using System.Collections.Generic;
154 | using System.Linq;
155 | using ILNumerics;
156 | using ILNumerics.Drawing;
157 | using ILNumerics.Drawing.Plotting;";
158 |
159 | eval.Run(m_head);
160 | m_evaluator = eval;
161 | }
162 |
163 | #region public interface
164 | public void Evaluate(string expression) {
165 | try {
166 | object result;
167 | bool result_set;
168 | ErrorStream.Clear();
169 | string ret = this.Evaluator.Evaluate(expression, out result, out result_set);
170 | if (result_set) {
171 | if (result is ILScene) {
172 | Panel.Scene = (result as ILScene);
173 | } else {
174 | m_shell.WriteText(Environment.NewLine);
175 | m_shell.WriteText(result.ToString());
176 | }
177 | } else if (ErrorStream.Length > 0) {
178 | m_shell.WriteError(ErrorStream.ToString());
179 | }
180 | Panel.Configure();
181 | Panel.Refresh();
182 | } catch (Exception exc) {
183 | m_shell.WriteError(exc.ToString());
184 | }
185 | }
186 |
187 | public static bool URLFromILCode(string ilcode, out string url) {
188 | url = "";
189 | // match whole words only
190 | System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^i([a-z0-9]{2})([a-z0-9$]+)$");
191 | var matches = reg.Match(ilcode);
192 | url = "";
193 | if (matches.Success && matches.Groups != null && matches.Groups.Count > 2) {
194 | url = String.Format(ilc_requestURL, matches.Groups[1].Value, matches.Groups[2]);
195 | return true;
196 | }
197 | return false;
198 | }
199 |
200 | public void LoadSzene(string source) {
201 | Uri uri;
202 | string expression = "";
203 | // is ilc code?
204 | string url = "";
205 | if (URLFromILCode(source, out url)) {
206 | source = url;
207 | }
208 | // ... for example
209 | try {
210 | if (source.ToLower() == "example") {
211 | Trace.WriteLine("Showing ILNumerics Example ...");
212 | SetExampleScene(Panel);
213 | Panel.Configure();
214 | // show selected driver and framerate in forms title bar
215 | Panel.EndRenderFrame -= registerShowFrameInfo;
216 | Panel.EndRenderFrame += registerShowFrameInfo;
217 | // we have a dynamic scene, start the clockx
218 | Panel.Clock.Running = true;
219 | cmbSources1.Text = defaultSourceTextBoxText;
220 | return;
221 | }
222 | } catch (Exception exc) {
223 | Trace.WriteLine("Failure:");
224 | Trace.WriteLine(exc.ToString());
225 | }
226 |
227 | #region is URI?
228 | try {
229 | uri = new Uri(source);
230 | if (uri.IsFile) {
231 | Trace.WriteLine("Loading example instance from: " + uri.AbsolutePath);
232 | expression = System.IO.File.ReadAllText(uri.AbsolutePath);
233 | } else {
234 | Trace.WriteLine("Fetching example instance from: " + uri);
235 | var web = new System.Net.WebClient();
236 | expression = web.DownloadString(uri);
237 | }
238 | } catch (ArgumentNullException) {
239 | expression = source;
240 | } catch (UriFormatException) {
241 | expression = source;
242 | } catch (System.Net.WebException wexc) {
243 | MessageBox.Show(wexc.ToString());
244 | }
245 | #endregion
246 |
247 | #region is C# Code?
248 | try {
249 | Trace.WriteLine("Evaluating Expression: ");
250 | Trace.WriteLine(expression);
251 | if (m_cleanUpExample != null) {
252 | m_cleanUpExample();
253 | m_cleanUpExample = null;
254 | }
255 |
256 | //Evaluate(expression);
257 | if (!string.IsNullOrEmpty(source) && source != expression) {
258 | cmbSources1.Text = source;
259 | } else {
260 | cmbSources1.Text = defaultSourceTextBoxText;
261 | }
262 | Shell.WriteCommand(expression);
263 | return;
264 | } catch (Exception exc) {
265 | Trace.WriteLine("Failure: ");
266 | Trace.WriteLine(exc.ToString());
267 | }
268 | #endregion
269 | }
270 | #endregion
271 |
272 | #region private helpers
273 |
274 | private void registerShowFrameInfo(object sender, ILRenderEventArgs args) {
275 | string txt = "ILView Example --- Driver: " + Panel.Driver.ToString();
276 | if (Panel.Driver == RendererTypes.OpenGL && Settings.OpenGL31_FIX_GL_CLIPVERTEX) {
277 | txt += " (Fix)";
278 | }
279 | txt += " FPS: " + Panel.FPS.ToString();
280 | if (Text != txt) {
281 | Text = txt; // show in title + log
282 | System.Diagnostics.Trace.WriteLine("Render Frame:" + Text);
283 | }
284 | }
285 |
286 | private void SetExampleScene(ILPanel panel) {
287 | ILScene scene = new ILScene();
288 | try {
289 | ILLabel.DefaultFont = new System.Drawing.Font("Helvetica", 8);
290 | //ilPanel1.Driver = RendererTypes.GDI;
291 |
292 | #region upper left plot
293 | // prepare some data
294 | ILArray P = 1,
295 | x = ILMath.linspace(-2, 2, 40),
296 | y = ILMath.linspace(2, -2, 40);
297 |
298 | ILArray F = ILMath.meshgrid(x, y, P);
299 | // a simple RBF
300 | ILArray Z = ILMath.exp(-(1.2f * F * F + P * P));
301 | // surface expects a single matrix
302 | Z[":;:;2"] = F; Z[":;:;1"] = P;
303 |
304 | // add a plot cube
305 | var pc = scene.Add(new ILPlotCube {
306 | // shrink viewport to upper left quadrant
307 | ScreenRect = new RectangleF(0.05f, 0, 0.4f, 0.5f),
308 | // 3D rotation
309 | TwoDMode = false,
310 | Children = {
311 | // add surface
312 | new ILSurface(Z) {
313 | // disable mouse hover marking
314 | Fill = { Markable = false },
315 | Wireframe = { Markable = false },
316 | // make it shiny
317 | UseLighting = true,
318 | Children = { new ILColorbar() }
319 | },
320 | //ILLinePlot.CreateXPlots(Z["1:10;:;0"], markers: new List() {
321 | // MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.Circle, MarkerStyle.Cross, MarkerStyle.Plus, MarkerStyle.TriangleDown }),
322 | //new ILLegend("hi","n","ku","zs","le", "blalblalblalblalb\\color{red} hier gehts rot")
323 | },
324 | Rotation = Matrix4.Rotation(new Vector3(1.1f, -0.4f, -0.69f), 1.3f)
325 | });
326 |
327 | #endregion
328 |
329 | #region top right plot
330 | // create a gear shape
331 | var gear = new ILGear(toothCount: 30, inR: 0.5f, outR: 0.9f) {
332 | Fill = { Markable = false, Color = Color.DarkGreen }
333 | };
334 | // group with right clipping plane
335 | var clipgroup = new ILGroup() {
336 | Clipping = new ILClipParams() {
337 | Plane0 = new Vector4(1, 0, 0, 0)
338 | },
339 | Children = {
340 | // a camera holding the (right) clipped gear
341 | new ILCamera() {
342 | // shrink viewport to upper top quadrant
343 | ScreenRect = new RectangleF(0.5f,0,0.5f,0.5f),
344 | // populate interactive changes back to the global scene
345 | IsGlobal = true,
346 | // adds the gear to the camera
347 | Children = { gear },
348 | Position = new Vector3(0,0,-15)
349 | }
350 | }
351 | };
352 | // setup the scene
353 | var gearGroup = scene.Add(new ILGroup {
354 | clipgroup, clipgroup // <- second time: group is cloned
355 | });
356 |
357 | gearGroup.First().Parent.Clipping = new ILClipParams() {
358 | Plane0 = new Vector4(-1, 0, 0, 0)
359 | };
360 | // make the left side transparent green
361 | gearGroup.First().Color = Color.FromArgb(100, Color.Green);
362 |
363 | // synchronize both cameras; source: left side
364 | gearGroup.First().PropertyChanged += (s, arg) => {
365 | gearGroup.Find().ElementAt(1).CopyFrom(s as ILCamera, false);
366 | };
367 | #endregion
368 |
369 | #region left bottom plot
370 | // start value
371 | int nrBalls = 10; bool addBalls = true;
372 | var balls = new ILPoints("balls") {
373 | Positions = ILMath.tosingle(ILMath.randn(3, nrBalls)),
374 | Colors = ILMath.tosingle(ILMath.rand(3, nrBalls)),
375 | Color = null,
376 | Markable = false
377 | };
378 | var leftBottomCam = scene.Add(new ILCamera {
379 | ScreenRect = new RectangleF(0, 0.5f, 0.5f, 0.5f),
380 | Projection = Projection.Perspective,
381 | Children = { balls }
382 | });
383 | // funny label
384 | string harmony = @"\color{red}H\color{blue}a\color{green}r\color{yellow}m\color{magenta}o\color{cyan}n\color{black}y\reset
385 | ";
386 | var ballsLabel = scene.Add(new ILLabel(tag: "harmony") {
387 | Text = harmony,
388 | Fringe = { Color = Color.FromArgb(240, 240, 240) },
389 | Position = new Vector3(-0.75f, -0.25f, 0)
390 | });
391 | long oldFPS = 1;
392 | PointF currentMousePos = new PointF();
393 | // setup the swarm. Start with a few balls, increase number
394 | // until framerate drops below 60 fps.
395 | ILArray velocity = ILMath.tosingle(ILMath.randn(3, nrBalls));
396 | EventHandler updateBallsRenderFrame = (s, arg) => {
397 | // transform viewport coords into 3d scene coords
398 | Vector3 mousePos = new Vector3(currentMousePos.X * 2 - 1,
399 | currentMousePos.Y * -2 + 1, 0);
400 | // framerate dropped? -> stop adding balls
401 | if (panel.FPS < oldFPS && panel.FPS < 60) addBalls = false;
402 | oldFPS = panel.FPS;
403 | Computation.UpdateBalls(mousePos, balls, velocity, addBalls);
404 | // balls buffers have been changed -> must call configure() to publish
405 | balls.Configure();
406 | // update balls label
407 | ballsLabel.Text = harmony + "(" + balls.Positions.DataCount.ToString() + " balls)";
408 | };
409 |
410 | // saving the mouse position in MouseMove is easier for
411 | // transforming the coordinates into the viewport
412 | leftBottomCam.MouseMove += (s, arg) => {
413 | // save the mouse position
414 | currentMousePos = arg.LocationF;
415 | };
416 | panel.BeginRenderFrame += updateBallsRenderFrame;
417 | m_cleanUpExample = () => {
418 | leftBottomCam.MouseMove -= (s, arg) => {
419 | // save the mouse position
420 | currentMousePos = arg.LocationF;
421 | };
422 | panel.BeginRenderFrame -= updateBallsRenderFrame;
423 | };
424 | #endregion
425 |
426 | panel.Scene = scene;
427 |
428 | } catch (Exception exc) {
429 | System.Diagnostics.Trace.WriteLine("ILPanel_Load Error:");
430 | System.Diagnostics.Trace.WriteLine("====================");
431 | System.Diagnostics.Trace.WriteLine(exc.ToString());
432 | MessageBox.Show(exc.ToString());
433 | }
434 | }
435 |
436 | private class Computation : ILMath {
437 | public static void UpdateBalls(Vector3 center, ILPoints balls, ILOutArray velocity, bool addBalls) {
438 | using (ILScope.Enter()) {
439 | ILArray position = balls.Positions.Storage;
440 | ILArray colors = balls.Colors.Storage;
441 | if (addBalls) {
442 | // increase number of balls (this is very inefficient!)
443 | position[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
444 | colors[full, r(end + 1, end + 10)] = tosingle(rand(4, 10));
445 | velocity[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
446 | }
447 | ILArray d = array(center.X, center.Y, center.Z);
448 | ILArray off = position * 0.1f;
449 | ILArray dist = sqrt(sum(position * position));
450 | ILArray where = find(dist < 0.2f);
451 | velocity[full, where] = velocity[full, where]
452 | + tosingle(rand(3, where.Length)) * 0.2f;
453 | dist.a = position - d;
454 | off.a = off + dist * -0.02f / sqrt(sum(dist * dist));
455 | velocity.a = velocity * 0.95f - off;
456 | balls.Positions.Update(position + velocity * 0.12f);
457 | ILArray Zs = abs(position[end, full]);
458 |
459 | colors[end, full] = Zs / maxall(Zs) * 0.7f + 0.3f;
460 | balls.Colors.Update(colors);
461 | }
462 | }
463 | }
464 |
465 | private void textBox1_KeyDown(object sender, KeyEventArgs e) {
466 | if (e.KeyCode == Keys.Enter) {
467 | Source = cmbSources1.Text;
468 | }
469 | }
470 |
471 | private void button1_Click(object sender, EventArgs e) {
472 | try {
473 | Source = cmbSources1.Text;
474 | } catch (Exception exc) {
475 | Trace.WriteLine("Error selecting new scene: ");
476 | Trace.WriteLine(exc.ToString());
477 | MessageBox.Show(exc.ToString());
478 | }
479 | }
480 | #endregion
481 | }
482 | }
483 |
--------------------------------------------------------------------------------
/src/SharedControls/ILView.cs:
--------------------------------------------------------------------------------
1 | /* License: MIT/X11
2 |
3 | Copyright (c) 2013, ILNumerics KG
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | */
12 |
13 | using System;
14 | using System.Collections.Generic;
15 | using System.Linq;
16 | using System.Text;
17 | using Mono;
18 | using Mono.CSharp;
19 | using System.IO;
20 | using ILNumerics;
21 | using ILNumerics.Drawing;
22 | using ILNumerics.Drawing.Plotting;
23 | using System.Diagnostics;
24 | using System.Drawing;
25 | using System.Windows.Forms;
26 |
27 | namespace ILNumerics.ILView {
28 | ///
29 | /// Application Context base for ILView
30 | ///
31 | /// The main purpose of this class is to start an instance of ILView without statically linking to a concrete form class.
32 | /// ILView expects abstracted interfaces of IILPanelForm and IILShellControl. The design is prepared for plugging in more advanced custom forms later.
33 | ///
34 |
35 | public class ILView : ApplicationContext {
36 | #region attributes
37 | private string m_source;
38 | public static string ilc_requestURL = @"http://ilnumerics.net/ilcf/{0}/{1}/in.txt";
39 | private static string defaultSourceTextBoxText = "(enter source URI/ ILC# here or choose from list ...)";
40 | private IILShellControl m_shell;
41 | private IILPanelForm m_panel;
42 | private IILUserInterfaceControls m_controlsProv;
43 | private Action m_cleanUpExample;
44 | private Evaluator m_evaluator;
45 | private StringBuilder m_errorStream;
46 | private string m_lastExportPath = "";
47 | #endregion
48 |
49 | ///
50 | /// Fires, when the panel form was closed
51 | ///
52 | public event EventHandler Closed;
53 | ///
54 | /// Fires, when the panel form was loaded
55 | ///
56 | public event EventHandler Load;
57 |
58 | #region properties
59 |
60 | public Evaluator Evaluator {
61 | get {
62 | if (m_evaluator == null)
63 | resetEvaluator();
64 | return m_evaluator;
65 | }
66 | }
67 | public StringBuilder ErrorStream {
68 | get {
69 | if (m_errorStream == null) {
70 | m_errorStream = new StringBuilder();
71 | }
72 | return m_errorStream;
73 | }
74 | }
75 | ///
76 | /// Provides access to the C# Console window / control
77 | ///
78 | public IILShellControl Shell {
79 | get {
80 | return m_shell;
81 | }
82 | }
83 |
84 | ///
85 | /// The source for the initial state of the viewer
86 | ///
87 | /// Allowed values are: a uri string, C# code with a valid szene definition, empty string.
88 | ///
89 | ///
90 | /// - URI: the uri is expected to reference a file location with a valid scene definition (C# code).
91 | /// - C# Code: a valid C# code snippet creating a ILScene. Valid snippets are syntactically correct and end
92 | /// with a statement, returning the scene object. One example of a valid C# code snippet which creates a simple
93 | /// scene with a sphere in 3D:
94 | ///
var scene = new ILScene { Camera = { new ILSphere() } };
95 | /// scene;
96 | /// Note that the following namespaces are automatically included, hence no using statements are necessary for classes in them:
97 | /// System; System.Drawing; System.Collections.Generic; System.Linq; ILNumerics; ILNumerics.Drawing; ILNumerics.Drawing.Plotting;
98 | ///
99 | /// - Empty String: the ILNumerics example will be created. This shows a scene with three subpplots
100 | /// with several static and dynamic features and plots.
101 | ///
102 | public string Source {
103 | get { return m_source; }
104 | set {
105 | m_source = value;
106 | LoadSzene(m_source);
107 | }
108 | }
109 | ///
110 | ///
111 | ///
112 | public IILPanelForm PanelForm {
113 | get {
114 | return m_panel;
115 | }
116 | }
117 | public string Text {
118 | get { return PanelForm.Text; }
119 | set {
120 | PanelForm.Text = value;
121 | }
122 | }
123 | #endregion
124 |
125 | #region constructors
126 | public ILView(IILPanelForm panel, IILShellControl shell, IILUserInterfaceControls controlsProvider) {
127 | m_shell = shell;
128 | m_shell.CommandEntered += (s, arg) => {
129 | Evaluate(arg.Command);
130 | };
131 | m_shell.CompletionRequested += (s, arg) => {
132 | Completion(arg);
133 | };
134 |
135 | m_panel = panel;
136 | m_panel.Closed += (s, arg) => {
137 | ExitThread();
138 | };
139 | m_panel.Load += (s, arg) => {
140 | if (Load != null) {
141 | Load(s, arg);
142 | }
143 | };
144 | // TODO: this does obviously not work in a multi-window setup!
145 | ILShellBaseClass.Panel = m_panel.Panel;
146 | ILShellBaseClass.View = this;
147 |
148 | m_controlsProv = controlsProvider;
149 | m_controlsProv.ShellVisibleChanged += (s, arg) => {
150 | m_shell.Visible = arg.Visible;
151 | };
152 | m_controlsProv.SourceChanged += (s, arg) => {
153 | Source = arg.Source;
154 | };
155 | m_controlsProv.ExportPNG += m_controlsProv_ExportPNG;
156 | m_controlsProv.ExportSVG += m_controlsProv_ExportSVG;
157 | }
158 |
159 | private void Completion(ILCompletionRequestEventArgs arg) {
160 | string prefix;
161 | var completions = Evaluator.GetCompletions(arg.Expression, out prefix);
162 | arg.Success = completions != null && completions.Length > 0;
163 | if (arg.Success) {
164 | arg.Prefix = prefix;
165 | var result = new List();
166 | arg.CompletionResult = completions.Select(item => new ILCompletionTextEntry() { Text = item });
167 | }
168 | }
169 |
170 | void m_controlsProv_ExportSVG(object sender, EventArgs e) {
171 | SaveFileDialog svd = new SaveFileDialog() {
172 | AddExtension = true,
173 | CheckFileExists = false,
174 | CheckPathExists = true,
175 | DefaultExt = "svg",
176 | InitialDirectory = m_lastExportPath,
177 | OverwritePrompt = true,
178 | Title = "ILNumerics - Export SVG",
179 | Filter = "SVG File (*.svg)|*.svg|All Formats (*.*)|*.*"
180 | };
181 | svd.ShowDialog();
182 | if (!String.IsNullOrEmpty(svd.FileName)) {
183 | m_lastExportPath = Path.GetDirectoryName(svd.FileName);
184 | // export SVG
185 | using (FileStream fs = new FileStream(svd.FileName, FileMode.Create)) {
186 | var driver = new ILSVGDriver(fs, scene: PanelForm.Panel.GetCurrentScene(),
187 | width : PanelForm.Panel.Width, height: PanelForm.Panel.Height);
188 | driver.Render();
189 | }
190 | }
191 | }
192 |
193 | void m_controlsProv_ExportPNG(object sender, EventArgs e) {
194 | SaveFileDialog svd = new SaveFileDialog() {
195 | AddExtension = true,
196 | CheckFileExists = false,
197 | CheckPathExists = true,
198 | DefaultExt = "png",
199 | InitialDirectory = m_lastExportPath,
200 | OverwritePrompt = true,
201 | Title = "ILNumerics - Export PNG",
202 | Filter = "PNG File (*.png)|*.png|All Formats (*.*)|*.*"
203 | };
204 | svd.ShowDialog();
205 | if (!String.IsNullOrEmpty(svd.FileName)) {
206 | m_lastExportPath = Path.GetDirectoryName(svd.FileName);
207 | // export SVG
208 | using (FileStream fs = new FileStream(svd.FileName, FileMode.Create)) {
209 | var driver = new ILGDIDriver(scene: PanelForm.Panel.GetCurrentScene(),
210 | width: PanelForm.Panel.Width, height: PanelForm.Panel.Height);
211 | driver.Render();
212 | driver.BackBuffer.Bitmap.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
213 | }
214 | }
215 | }
216 |
217 | void shell_Evaluate(object sender, ILCommandEnteredEventArgs e) {
218 | Evaluate(e.Command);
219 | }
220 | #endregion
221 |
222 | private void resetEvaluator() {
223 | m_errorStream = new StringBuilder();
224 | //StreamReader sr =
225 | TextWriter tw = new StringWriter(m_errorStream);
226 | var ctx = new Mono.CSharp.CompilerContext(
227 | new Mono.CSharp.CompilerSettings() {
228 | AssemblyReferences = new List() {
229 | typeof(ILMath).Assembly.FullName,
230 | typeof(System.Drawing.PointF).Assembly.FullName,
231 | typeof(System.Linq.Queryable).Assembly.FullName
232 | },
233 |
234 | //Unsafe = true
235 | }, new StreamReportPrinter(tw));
236 |
237 | var eval = new Mono.CSharp.Evaluator(ctx);
238 | eval.InteractiveBaseClass = typeof(ILShellBaseClass);
239 |
240 | // reset line colors (thread safe)
241 | ILNumerics.Drawing.Plotting.ILLinePlot.NextColors = new ILColorEnumerator();
242 |
243 | string m_head = @"
244 | using System;
245 | using System.Drawing;
246 | using System.Collections.Generic;
247 | using System.Linq;
248 | using ILNumerics;
249 | using ILNumerics.Drawing;
250 | using ILNumerics.Drawing.Plotting;";
251 |
252 | eval.Run(m_head);
253 | m_evaluator = eval;
254 | }
255 |
256 | #region public interface
257 | public void Evaluate(string expression) {
258 | try {
259 | object result;
260 | bool result_set;
261 | ErrorStream.Clear();
262 | string ret = this.Evaluator.Evaluate(expression, out result, out result_set);
263 | if (result_set) {
264 | if (result is ILScene) {
265 | if (m_cleanUpExample != null) {
266 | m_cleanUpExample();
267 | m_cleanUpExample = null;
268 | }
269 | PanelForm.Panel.Scene = (result as ILScene);
270 | } else {
271 | m_shell.WriteText(Environment.NewLine);
272 | m_shell.WriteText(result.ToString());
273 | }
274 | } else if (ErrorStream.Length > 0) {
275 | m_shell.WriteError(ErrorStream.ToString());
276 | }
277 | PanelForm.Panel.Configure();
278 | PanelForm.Panel.Refresh();
279 | } catch (ArgumentException exc) {
280 | m_shell.WriteError(exc.Message.ToString());
281 | } catch (ILNumerics.Exceptions.ILArgumentException exc) {
282 | m_shell.WriteError(exc.Message.ToString());
283 | } catch (Exception exc) {
284 | m_shell.WriteError(exc.ToString());
285 | }
286 | }
287 |
288 | public static bool URLFromILCode(string ilcode, out string url) {
289 | url = "";
290 | // match whole words only
291 | System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^i([a-z0-9]{2})([a-z0-9$]+)$");
292 | var matches = reg.Match(ilcode);
293 | url = "";
294 | if (matches.Success && matches.Groups != null && matches.Groups.Count > 2) {
295 | url = String.Format(ilc_requestURL, matches.Groups[1].Value, matches.Groups[2]);
296 | return true;
297 | }
298 | return false;
299 | }
300 |
301 | public void LoadSzene(string source) {
302 | Uri uri;
303 | string expression = "";
304 | // is ilc code?
305 | string url = "";
306 | if (URLFromILCode(source, out url)) {
307 | source = url;
308 | }
309 | // ... for example
310 | try {
311 | if (source.ToLower() == "example") {
312 | Trace.WriteLine("Showing ILNumerics Example ...");
313 | SetExampleScene(PanelForm);
314 | PanelForm.Panel.Configure();
315 | // show selected driver and framerate in forms title bar
316 | PanelForm.Panel.EndRenderFrame -= registerShowFrameInfo;
317 | PanelForm.Panel.EndRenderFrame += registerShowFrameInfo;
318 | // we have a dynamic scene, start the clockx
319 | PanelForm.Panel.Clock.Running = true;
320 | //cmbSources1.Text = defaultSourceTextBoxText;
321 | return;
322 | }
323 | } catch (Exception exc) {
324 | Trace.WriteLine("Failure:");
325 | Trace.WriteLine(exc.ToString());
326 | }
327 |
328 | #region is URI?
329 | try {
330 | uri = new Uri(source);
331 | if (uri.IsFile) {
332 | Trace.WriteLine("Loading example instance from: " + uri.AbsolutePath);
333 | expression = System.IO.File.ReadAllText(uri.AbsolutePath);
334 | } else {
335 | Trace.WriteLine("Fetching example instance from: " + uri);
336 | var web = new System.Net.WebClient();
337 | expression = web.DownloadString(uri);
338 | }
339 | if (!expression.EndsWith("\n")) {
340 | expression += Environment.NewLine;
341 | }
342 | } catch (ArgumentNullException) {
343 | expression = source;
344 | } catch (UriFormatException) {
345 | expression = source;
346 | } catch (System.Net.WebException wexc) {
347 | MessageBox.Show(wexc.ToString());
348 | }
349 | #endregion
350 |
351 | #region is C# Code?
352 | try {
353 | Trace.WriteLine("Evaluating Expression: ");
354 | Trace.WriteLine(expression);
355 | if (m_cleanUpExample != null) {
356 | m_cleanUpExample();
357 | m_cleanUpExample = null;
358 | }
359 |
360 | //Evaluate(expression);
361 | if (!string.IsNullOrEmpty(source) && source != expression) {
362 | Text = source;
363 | } else {
364 | Text = defaultSourceTextBoxText;
365 | }
366 | Shell.WriteCommand(expression);
367 | return;
368 | } catch (Exception exc) {
369 | Trace.WriteLine("Failure: ");
370 | Trace.WriteLine(exc.ToString());
371 | }
372 | #endregion
373 | }
374 | #endregion
375 |
376 | #region private helpers
377 |
378 | private void registerShowFrameInfo(object sender, ILRenderEventArgs args) {
379 | string txt = "ILView Example --- Driver: " + PanelForm.Panel.Driver.ToString();
380 | if (PanelForm.Panel.Driver == RendererTypes.OpenGL && Settings.OpenGL31_FIX_GL_CLIPVERTEX) {
381 | txt += " (Fix)";
382 | }
383 | txt += " FPS: " + PanelForm.Panel.FPS.ToString();
384 | if (Text != txt) {
385 | Text = txt; // show in title + log
386 | System.Diagnostics.Trace.WriteLine("Render Frame:" + Text);
387 | }
388 | }
389 |
390 | private void SetExampleScene(IILPanelForm panel) {
391 | if (m_cleanUpExample != null) {
392 | m_cleanUpExample();
393 | m_cleanUpExample = null;
394 | }
395 | ILScene scene = new ILScene();
396 | try {
397 | ILLabel.DefaultFont = new System.Drawing.Font("Helvetica", 8);
398 | //ilPanel1.Driver = RendererTypes.GDI;
399 |
400 | #region upper left plot
401 | // prepare some data
402 | ILArray P = 1,
403 | x = ILMath.linspace(-2, 2, 40),
404 | y = ILMath.linspace(2, -2, 40);
405 |
406 | ILArray F = ILMath.meshgrid(x, y, P);
407 | // a simple RBF
408 | ILArray Z = ILMath.exp(-(1.2f * F * F + P * P));
409 | // surface expects a single matrix
410 | Z[":;:;2"] = F; Z[":;:;1"] = P;
411 |
412 | // add a plot cube
413 | var pc = scene.Add(new ILPlotCube {
414 | // shrink viewport to upper left quadrant
415 | ScreenRect = new RectangleF(0.05f, 0, 0.4f, 0.5f),
416 | // 3D rotation
417 | TwoDMode = false,
418 | Children = {
419 | // add surface
420 | new ILSurface(Z) {
421 | // disable mouse hover marking
422 | Fill = { Markable = false },
423 | Wireframe = { Markable = false },
424 | // make it shiny
425 | UseLighting = true,
426 | Children = { new ILColorbar() }
427 | },
428 | //ILLinePlot.CreateXPlots(Z["1:10;:;0"], markers: new List() {
429 | // MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.None,MarkerStyle.Circle, MarkerStyle.Cross, MarkerStyle.Plus, MarkerStyle.TriangleDown }),
430 | //new ILLegend("hi","n","ku","zs","le", "blalblalblalblalb\\color{red} hier gehts rot")
431 | },
432 | Rotation = Matrix4.Rotation(new Vector3(1.1f, -0.4f, -0.69f), 1.3f)
433 | });
434 |
435 | #endregion
436 |
437 | #region top right plot
438 | // create a gear shape
439 | var gear = new ILGear(toothCount: 30, inR: 0.5f, outR: 0.9f) {
440 | Fill = { Markable = false, Color = Color.DarkGreen }
441 | };
442 | // group with right clipping plane
443 | var clipgroup = new ILGroup() {
444 | Clipping = new ILClipParams() {
445 | Plane0 = new Vector4(1, 0, 0, 0)
446 | },
447 | Children = {
448 | // a camera holding the (right) clipped gear
449 | new ILCamera() {
450 | // shrink viewport to upper top quadrant
451 | ScreenRect = new RectangleF(0.5f,0,0.5f,0.5f),
452 | // populate interactive changes back to the global scene
453 | IsGlobal = true,
454 | // adds the gear to the camera
455 | Children = { gear },
456 | Position = new Vector3(0,0,-15)
457 | }
458 | }
459 | };
460 | // setup the scene
461 | var gearGroup = scene.Add(new ILGroup {
462 | clipgroup, clipgroup // <- second time: group is cloned
463 | });
464 |
465 | gearGroup.First().Parent.Clipping = new ILClipParams() {
466 | Plane0 = new Vector4(-1, 0, 0, 0)
467 | };
468 | // make the left side transparent green
469 | gearGroup.First().Color = Color.FromArgb(100, Color.Green);
470 |
471 | // synchronize both cameras; source: left side
472 | gearGroup.First().PropertyChanged += (s, arg) => {
473 | gearGroup.Find().ElementAt(1).CopyFrom(s as ILCamera, false);
474 | };
475 | #endregion
476 |
477 | #region left bottom plot
478 | // start value
479 | int nrBalls = 10; bool addBalls = true;
480 | var balls = new ILPoints("balls") {
481 | Positions = ILMath.tosingle(ILMath.randn(3, nrBalls)),
482 | Colors = ILMath.tosingle(ILMath.rand(3, nrBalls)),
483 | Color = null,
484 | Markable = false
485 | };
486 | var leftBottomCam = scene.Add(new ILCamera {
487 | ScreenRect = new RectangleF(0, 0.5f, 0.5f, 0.5f),
488 | Projection = Projection.Perspective,
489 | Children = { balls }
490 | });
491 | // funny label
492 | string harmony = @"\color{red}H\color{blue}a\color{green}r\color{yellow}m\color{magenta}o\color{cyan}n\color{black}y\reset
493 | ";
494 | var ballsLabel = scene.Add(new ILLabel(tag: "harmony") {
495 | Text = harmony,
496 | Fringe = { Color = Color.FromArgb(240, 240, 240) },
497 | Position = new Vector3(-0.75f, -0.25f, 0)
498 | });
499 | long oldFPS = 1;
500 | PointF currentMousePos = new PointF();
501 | // setup the swarm. Start with a few balls, increase number
502 | // until framerate drops below 60 fps.
503 | ILArray velocity = ILMath.tosingle(ILMath.randn(3, nrBalls));
504 | EventHandler updateBallsRenderFrame = (s, arg) => {
505 | // transform viewport coords into 3d scene coords
506 | Vector3 mousePos = new Vector3(currentMousePos.X * 2 - 1,
507 | currentMousePos.Y * -2 + 1, 0);
508 | // framerate dropped? -> stop adding balls
509 | if (panel.Panel.FPS < oldFPS && panel.Panel.FPS < 60) addBalls = false;
510 | oldFPS = panel.Panel.FPS;
511 | Computation.UpdateBalls(mousePos, balls, velocity, addBalls);
512 | // balls buffers have been changed -> must call configure() to publish
513 | balls.Configure();
514 | // update balls label
515 | ballsLabel.Text = harmony + "(" + balls.Positions.DataCount.ToString() + " balls)";
516 | };
517 |
518 | // saving the mouse position in MouseMove is easier for
519 | // transforming the coordinates into the viewport
520 | leftBottomCam.MouseMove += (s, arg) => {
521 | // save the mouse position
522 | currentMousePos = arg.LocationF;
523 | };
524 | panel.Panel.BeginRenderFrame += updateBallsRenderFrame;
525 | m_cleanUpExample = () => {
526 | leftBottomCam.MouseMove -= (s, arg) => {
527 | // save the mouse position
528 | currentMousePos = arg.LocationF;
529 | };
530 | panel.Panel.BeginRenderFrame -= updateBallsRenderFrame;
531 | };
532 | balls.Disposing += (s, arg) => {
533 | if (m_cleanUpExample != null) {
534 | m_cleanUpExample();
535 | m_cleanUpExample = null;
536 | }
537 | };
538 | #endregion
539 |
540 | panel.Panel.Scene = scene;
541 |
542 | } catch (Exception exc) {
543 | System.Diagnostics.Trace.WriteLine("ILPanel_Load Error:");
544 | System.Diagnostics.Trace.WriteLine("====================");
545 | System.Diagnostics.Trace.WriteLine(exc.ToString());
546 | System.Windows.Forms.MessageBox.Show(exc.ToString());
547 | }
548 | }
549 |
550 | private class Computation : ILMath {
551 | public static void UpdateBalls(Vector3 center, ILPoints balls, ILOutArray velocity, bool addBalls) {
552 | if (!balls.IsDisposed) { // <- this obviously is not threadsafe!! TODO
553 | using (ILScope.Enter()) {
554 | ILArray position = balls.Positions.Storage;
555 | ILArray colors = balls.Colors.Storage;
556 | if (addBalls) {
557 | // increase number of balls (this is very inefficient!)
558 | position[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
559 | colors[full, r(end + 1, end + 10)] = tosingle(rand(4, 10));
560 | velocity[full, r(end + 1, end + 10)] = tosingle(randn(3, 10));
561 | }
562 | ILArray d = array(center.X, center.Y, center.Z);
563 | ILArray off = position * 0.1f;
564 | ILArray dist = sqrt(sum(position * position));
565 | ILArray where = find(dist < 0.2f);
566 | velocity[full, where] = velocity[full, where]
567 | + tosingle(rand(3, where.Length)) * 0.2f;
568 | dist.a = position - d;
569 | off.a = off + dist * -0.02f / sqrt(sum(dist * dist));
570 | velocity.a = velocity * 0.95f - off;
571 | balls.Positions.Update(position + velocity * 0.12f);
572 | ILArray Zs = abs(position[end, full]);
573 |
574 | colors[end, full] = Zs / maxall(Zs) * 0.7f + 0.3f;
575 | balls.Colors.Update(colors);
576 | }
577 | }
578 | }
579 | }
580 |
581 | #endregion
582 |
583 | }
584 | }
585 |
--------------------------------------------------------------------------------