Beispiel #1
0
 public static void EnsureStarted()
 {
     if (_singelton == null)
     {
         _singelton = new EmbeddedHttpServer();
     }
 }
Beispiel #2
0
 public void RegisterCSharpServices(Guid id, IRequestHandler handler)
 {
     _handlers.Add(handler);
     EmbeddedHttpServer.AddHandler(handler);
     if (_isInitialized && !_isDisposed)
     {
         _monaco.registerCSharpsServices(id);
     }
     else
     {
         _afterInits.Add(() => _monaco.registerCSharpsServices(id));
     }
 }
Beispiel #3
0
        public MonacoDiffEditor()
        {
            EmbeddedHttpServer.EnsureStarted();

            var sitePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MonacoWpf", "Site");

            _isInitialized = false;
            _browser       = new WebBrowser();
            Content        = _browser;
            _monaco        = new MonacoIntegration(
                browser: _browser,
                onValueChanged: value => { },
                log: (s, m) => { },
                onInitDone: () => { }
                );
            _browser.ObjectForScripting = _monaco;
            _browser.Navigated         += async(o, e) =>
            {
                await Task.Delay(3000);

                _isInitialized = true;
            };
            _browser.Navigate(EmbeddedHttpServer.DiffUri);
        }
Beispiel #4
0
        public MonacoEditor()
        {
            EmbeddedHttpServer.EnsureStarted();

            var sitePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MonacoWpf", "Site");

            _isInitialized = false;
            _browser       = new WebBrowser();
            var tb = new TextBlock
            {
                Text = "Loading Editor...",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };

            _monaco = new MonacoIntegration(
                browser: _browser,
                onValueChanged: value => Value = value,
                getValue: () => Value,
                getLang: () => _lang,
                log: (s, m) => {
            },
                onInitDone: () =>
            {
                if (_isDisposed)
                {
                    return;
                }

                _isInitialized = true;
                foreach (var a in _afterInits)
                {
                    a();
                }
                UpdateValue();
                var e = OnEditorInitialized;
                if (e != null)
                {
                    e.Invoke(this, new EventArgs());
                }
                _browser.Visibility = Visibility.Visible;
                tb.Visibility       = Visibility.Collapsed;
            });
            _browser.ObjectForScripting = _monaco;

            this.Loaded += (o, e) =>
            {
            };
            this.Unloaded += (o, e) =>
            {
                _isDisposed = true;
                _browser.Dispose();
            };


            _browser.Visibility = Visibility.Collapsed;
            Content             = new Grid
            {
                Children =
                {
                    tb,
                    _browser
                }
            };

            _browser.Navigate(EmbeddedHttpServer.EditorUri);
        }
Beispiel #5
0
 public void RemoveCSharpServices(Guid id, IRequestHandler handler)
 {
     _handlers.Remove(handler);
     EmbeddedHttpServer.RemoveHandler(handler);
 }