Exemple #1
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);
        }
Exemple #2
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);
        }