public MainWindow()
        {
            InitializeComponent();
            CompilerUtils.DeleteFilesByWildcards("Test*.exe");

            ViewModel.Window = this;


            TextEditor.Text = ViewModel.SourceCode;
            TextEditor.TextArea.TextEntering       += textEditor_TextArea_TextEntering;
            TextEditor.TextArea.TextEntered        += textEditor_TextArea_TextEntered;
            TextEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(TextEditor.Options);
            foldingStrategy = new BraceFoldingStrategy();

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();

            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick    += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();


            if (foldingManager == null)
            {
                foldingManager = FoldingManager.Install(TextEditor.TextArea);
            }
            foldingStrategy.UpdateFoldings(foldingManager, TextEditor.Document);

            // Dynamic syntax highlighting for Intermediate Representation
            var rules = IL.SyntaxHighlighting.MainRuleSet.Rules;

            var highlightingRule = new HighlightingRule();

            highlightingRule.Color = new HighlightingColor()
            {
                Foreground = new CustomizedBrush(Color.Green),
                FontWeight = FontWeight.FromOpenTypeWeight(130)
            };

            var wordList = ILOperatorKeywords;
            var regex    = String.Format(@"\b({0})\b", String.Join("|", wordList));

            highlightingRule.Regex = new Regex(regex);

            rules.Add(highlightingRule);

            highlightingRule       = new HighlightingRule();
            highlightingRule.Color = new HighlightingColor()
            {
                Foreground = new CustomizedBrush(Color.Red)
            };

            wordList = ILKeywords;
            regex    = String.Format(@"\b({0})\b", String.Join("|", wordList));
            highlightingRule.Regex = new Regex(regex);

            rules.Add(highlightingRule);


            TextEditor.Text = VisualCompilerConstants.InitialCode;
        }
Beispiel #2
0
        public override void WindowControllerDidLoadNib(NSWindowController windowController)
        {
            base.WindowControllerDidLoadNib(windowController);

            // Add code to here after the controller has loaded the document window

//			NSView view = new NSView ();
//			var scrollView = new NSScrollView ();
//			var clipView = new NSClipView ();
//
//			var textView = new NSTextView ();
//			clipView.AddSubview (textView);
//
//			scrollView.AddSubview (clipView);
//
//			view.AddSubview (scrollView);
//
//			windowController.Window.ContentView.AddSubview (view);

            //Xcode assistant editor aint working, so I'm resorting to finding views manually

            /*var textViews = windowController.Window.ContentView.FindViews<NSTextView> ();
             * var count = 0;
             *
             * //foreach(var view in textViews)
             * //{
             * //	view.InsertText (new NSString("View: " + count++));
             * //}//0: cshapr
             * //1: output
             * //2:Intermediate
             * //3://CPP
             *
             * CSharpTextBox = textViews [0];
             * ConsoleTextBox = textViews [1];
             * IntermediateTextBox = textViews [2];
             * CPPTextBox = textViews [3];
             */

            windowController.Window.Title = "Visual Compiler Mac";

            CppFileList.UsesDataSource = true;

            MainWindowViewModel.TempDir = Path.Combine(Path.GetTempPath(), "CsNative");

            if (!Directory.Exists(MainWindowViewModel.TempDir))
            {
                Directory.CreateDirectory(MainWindowViewModel.TempDir);
            }


            //            Dispatcher.Invoke(() => Console.SetOut(new ControlWriter(Errors)));

            CompilerUtils.DeleteFilesByWildcards("Test*.exe", MainWindowViewModel.TempDir);


            CSharpTextEditor.TextStorage.TextStorageDidProcessEditing += (object sender, EventArgs e) => {
                ViewModel.SourceCode = CSharpTextEditor.Value;
            };

            CPPTextEditor.TextStorage.TextStorageDidProcessEditing += (object sender, EventArgs e) => {
                ViewModel.OutputCode = CPPTextEditor.Value;
            };

            CSharpTextEditor.Value = VisualCompilerConstants.InitialCode;


            CPPRunButton.Activated += RunCPPButton_Click;

            OpenFileButton.Activated += OpenFile;

            CppFileList.Activated += SelectedFile;

            CSharpRunButton.Activated += RunCSharpButton_Click;

            TestButton.Activated += TestButton_Click;

            RunAllTests.Activated += RunAllTests_Click;
        }