public void Show() { var win = new StickyWindow((r) => Persist.Put <PersistRect>("LexError", r), () => Persist.Get <PersistRect>("LexError", new PersistRect(100, 100, 500, 300))) { Title = "Compiler Error", }; var dock = new DockPanel(); win.Content = dock; TabControl tabbie = new TabControl() { TabStripPlacement = Dock.Bottom }; Label Lab; dock.Children.Add(Lab = new Label() { Content = Message }); DockPanel.SetDock(Lab, Dock.Top); dock.Children.Add(tabbie); bool firstFocus = true; if (CompilerList != null) { var dialog = new LexReadDialog(CompilerList, new FontFamily("Lucida Console"), 10); MakeDialogItem(tabbie, ref firstFocus, dialog, "Compiler"); } if (Source != null) { var dialog = new LexReadDialog(Source, Index, new FontFamily("Lucida Console"), 10); MakeDialogItem(tabbie, ref firstFocus, dialog, "Source"); } win.ShowDialog(); }
public static void Show(TypeParser parser) { REPL repl = new REPL(parser); REPLRenderingPanel replPanel = new REPLRenderingPanel(repl.DisplayData, repl.Command, new FontFamily("Lucida Console"), 10); repl.ReplPanel = replPanel; var win = new StickyWindow((r) => Persist.Put <PersistRect>("REPL", r), () => Persist.Get <PersistRect>("REPL", new PersistRect(150, 150, 500, 400))) { Title = "C# REPL by KamimuCode", Content = new ScrollerPanel() { Content = new CursorPanel() { Content = replPanel } } }; replPanel.Focus(); win.ShowDialog(); }
public static void Main() { LexToken.ShowError = (msg, theList) => { new LexErrorDialog() { Message = msg, CompilerList = theList, }.Show(); }; TypeParser parser = new TypeParser(Assembly.GetExecutingAssembly(), new List <string>() { "System", "System.Collections.Generic", "System.Linq", "System.Text", "System.Windows", "System.Windows.Shapes", "System.Windows.Controls", "System.Windows.Media", "System.IO", "System.Reflection", "Kamimu" } ); TypeParser.DefaultParser = parser; Directory.CreateDirectory(@"C:\KamimuCodeTemp"); Persist.ReadFromFile(@"C:\KamimuCodeTemp\CsharpEvalConfiguration.xml"); try { { var s = ""; Func <int, string> fn = MakeMethod <Func <int, string> > .Compile(parser, LexListGet(@" string Test (int howMany) { string s = '' ; for ( int i = howMany ; i > 0 ; i -- ) s = s + i.ToString() + `~` ; return s ; }")); bool error = false; if (fn(0) != "") { error = true; } if (fn(1) != "1~") { error = true; } if (fn(2) != "2~1~") { error = true; } if (fn(3) != "3~2~1~") { error = true; } if (fn(-1) != "") { error = true; } if (error) { MessageBox.Show("There was an error", "Test Make with dialog"); } else { MessageBox.Show("Ran OK", "Test Make with dialog"); } } } catch (Exception ex) { MessageBox.Show("There was a compilation or execution error.", "Test Make with dialog"); } Persist.WriteToFile(); }
public static void Main() { LexToken.ShowError = (msg, theList) => { new LexErrorDialog() { Message = msg, CompilerList = theList, }.Show(); }; TypeParser parser = new TypeParser(Assembly.GetExecutingAssembly(), new List <string>() { "System", "System.Collections.Generic", "System.Linq", "System.Text", "System.Windows", "System.Windows.Shapes", "System.Windows.Controls", "System.Windows.Media", "System.IO", "System.Reflection", "Kamimu" } ); TypeParser.DefaultParser = parser; Directory.CreateDirectory(@"C:\KamimuCodeTemp"); Persist.ReadFromFile(@"C:\KamimuCodeTemp\CsharpEvalConfiguration.xml"); try { { Func <TestClass, int> getLength; Action <TestClass, int[]> setArray; Action <TestClass> actInit; MakeClass mc = new MakeClass(parser, LexList.Get(@" partial class TestClass { public int[] LocalInt ; public void SetArray ( int[] input ) { LocalInt = input ; } public int GetLength () { return LocalInt.Length ; } }")). GetFunc <TestClass, int>("GetLength", out getLength). GetAction <TestClass, int[]>("SetArray", out setArray). GetAction <TestClass>("FieldsInitialiser", out actInit); TestClass tc = new TestClass(); actInit(tc); int[] thearray = new int[300]; setArray(tc, thearray); if (getLength(tc) != thearray.Length) { MessageBox.Show("There was an error", "Test class with dialog"); } else { MessageBox.Show("Ran OK", "Test class with dialog"); } } } catch (Exception ex) { MessageBox.Show("There was a compilation or execution error.", "Test class with dialog"); } Persist.WriteToFile(); }