Ejemplo n.º 1
0
        protected override void ComposeTree(TreeComposer composer)
        {
            switch (this.Engine.State)
            {
            case ExecutionState.Paused:
            {
                Actions.Action(composer, "nextline", EditorResources.Actions_NextLine, () =>
                    {
                        this.Engine.Continue(pauseAtNextLine: true);
                        return(Task.CompletedTask);
                    });

                Actions.Action(composer, "continue", EditorResources.Actions_Continue, () =>
                    {
                        this.Engine.Continue(pauseAtNextLine: false);
                        return(JSInterop.Monaco.RemoveDecorations());
                    });

                break;
            }

            case ExecutionState.Running:
            {
                Actions.Action(composer, "pause", EditorResources.Actions_Pause, () =>
                    {
                        this.Engine.Pause();
                        return(Task.CompletedTask);
                    });

                break;
            }
            }
        }
Ejemplo n.º 2
0
 internal void ComposeTree(TreeComposer composer)
 {
     foreach (var shape in this.shapes.Values)
     {
         shape.ComposeTree(composer);
     }
 }
Ejemplo n.º 3
0
 public static void FontAwesome(TreeComposer composer, string iconName)
 {
     composer.Element(name: "font-awesome-icon", attributes: new Dictionary <string, string>
     {
         { "class", $"fas fa-{iconName}" }
     });
 }
Ejemplo n.º 4
0
 internal static void Inject(TreeComposer composer, AsyncEngine engine)
 {
     composer.Inject <DebugPageExeuctionActions>(new Dictionary <string, object>
     {
         { nameof(DebugPageExeuctionActions.Engine), engine }
     });
 }
Ejemplo n.º 5
0
 internal static void Inject(TreeComposer composer, Library library)
 {
     composer.Inject <LibraryBody>(new Dictionary <string, object>
     {
         { nameof(LibraryBody.Library), library }
     });
 }
Ejemplo n.º 6
0
 internal static void Inject(TreeComposer composer, LibrariesCollection libraries)
 {
     composer.Inject <GraphicsDisplay>(new Dictionary <string, object>
     {
         { nameof(GraphicsDisplay.Libraries), libraries }
     });
 }
Ejemplo n.º 7
0
 internal static void Inject(TreeComposer composer, AsyncEngine engine)
 {
     composer.Inject <MemoryExplorer>(new Dictionary <string, object>
     {
         { nameof(MemoryExplorer.Engine), engine }
     });
 }
Ejemplo n.º 8
0
 protected override void ComposeBody(TreeComposer composer)
 {
     composer.Element("run-page", body: () =>
     {
         EngineDisplay.Inject(composer, this.engine);
     });
 }
Ejemplo n.º 9
0
        private void ComposeHeader(TreeComposer composer)
        {
            composer.Element("header-area", body: () =>
            {
                composer.Element(
                    name: "logo-area",
                    events: new TreeComposer.Events
                {
                    OnClick = args => this.isExpanded = !this.isExpanded
                },
                    body: () =>
                {
                    composer.Element("logo");
                });

                composer.Element("empty-scroll-area");

                if (this.isExpanded)
                {
                    composer.Element("title-area", body: () => composer.Text(EditorResources.MemoryExplorer_Title));
                    composer.Element(
                        name: "minimize-button",
                        events: new TreeComposer.Events
                    {
                        OnClick = args => this.isExpanded = false
                    },
                        body: () =>
                    {
                        composer.Element("angle-left");
                    });
                }
            });
        }
Ejemplo n.º 10
0
 internal void ComposeTree(TreeComposer composer)
 {
     foreach (var control in this.controls.Values)
     {
         control.ComposeTree(this, composer);
     }
 }
Ejemplo n.º 11
0
 protected override void ComposeTree(TreeComposer composer)
 {
     composer.Inject <Router>(new Dictionary <string, object>
     {
         { "AppAssembly", RuntimeHelpers.TypeCheck(typeof(App).Assembly) }
     });
 }
Ejemplo n.º 12
0
        public override void ComposeTree(TreeComposer composer)
        {
            var attributes = new Dictionary <string, string>
            {
                { "x", this.X.ToString(CultureInfo.CurrentCulture) },
                { "y", this.Y.ToString(CultureInfo.CurrentCulture) },
                { "dy", this.Styles.FontSize.ToString(CultureInfo.CurrentCulture) }
            };

            if (this.Width.HasValue)
            {
                attributes.Add("textLength", this.Width.Value.ToString(CultureInfo.CurrentCulture));
            }

            composer.Element(
                name: "text",
                styles: new Dictionary <string, string>
            {
                { "fill", this.Styles.BrushColor },
                { "font-weight", this.Styles.FontBold ? "bold" : "normal" },
                { "font-style", this.Styles.FontItalic ? "italic" : "normal" },
                { "font-family", $@"""{this.Styles.FontName}""" },
                { "font-size", $"{this.Styles.FontSize}px" },
                { "pointer-events", "none" }
            },
                attributes: attributes,
                body: () => composer.Text(this.Text));
        }
Ejemplo n.º 13
0
 internal static void Inject(TreeComposer composer, AsyncEngine engine)
 {
     composer.Inject <EngineDisplay>(new Dictionary <string, object>
     {
         { nameof(EngineDisplay.Engine), engine }
     });
 }
Ejemplo n.º 14
0
 protected override void ComposeTree(TreeComposer composer)
 {
     composer.Element("editor-container", body: () =>
     {
         composer.Element("editor", capture: element => this.editorElement = element);
     });
 }
Ejemplo n.º 15
0
 public static void Inject(TreeComposer composer, bool isReadOnly)
 {
     composer.Inject <MonacoEditor>(new Dictionary <string, object>
     {
         { nameof(MonacoEditor.IsReadOnly), isReadOnly },
     });
 }
Ejemplo n.º 16
0
        protected override void ComposeTree(TreeComposer composer)
        {
            if (!CompilationStore.Compilation.Diagnostics.Any())
            {
                return;
            }

            composer.Element("errors-space", body: () =>
            {
                composer.Element(
                    name: "title-row",
                    events: new TreeComposer.Events
                {
                    OnClick = args => this.areErrorsExpanded = !this.areErrorsExpanded
                },
                    body: () =>
                {
                    composer.Element("icon");

                    composer.Element("errors-count", body: () =>
                    {
                        composer.Text(string.Format(CultureInfo.CurrentCulture, EditorResources.Errors_Count, CompilationStore.Compilation.Diagnostics.Count));
                    });

                    composer.Element(this.areErrorsExpanded ? "caret-opened" : "caret-closed");
                });

                if (!this.areErrorsExpanded)
                {
                    return;
                }

                composer.Element("header-line", body: () =>
                {
                    composer.Element("line-number", body: () => composer.Text(EditorResources.Errors_Line));
                    composer.Element("description", body: () => composer.Text(EditorResources.Errors_Description));
                });

                composer.Element("errors-list", body: () =>
                {
                    foreach (var error in CompilationStore.Compilation.Diagnostics.OrderBy(d => d.Range.Start.Line))
                    {
                        var range = error.Range.ToMonacoRange();

                        composer.Element(
                            name: "error-line",
                            events: new TreeComposer.Events
                        {
                            OnClickAsync = args => JSInterop.Monaco.SelectRange(range)
                        },
                            body: () =>
                        {
                            composer.Element("line-number", body: () => composer.Text(range.startLineNumber.ToString(CultureInfo.CurrentCulture)));
                            composer.Element("description", body: () => composer.Text(error.ToDisplayString()));
                        });
                    }
                });
            });
        }
Ejemplo n.º 17
0
 public static void Row(TreeComposer composer, Action left = null, Action right = null)
 {
     composer.Element("actions-row", body: () =>
     {
         composer.Element("left-actions", body: left);
         composer.Element("right-actions", body: right);
     });
 }
Ejemplo n.º 18
0
 protected override void ComposeLeftActions(TreeComposer composer)
 {
     Actions.Action(composer, "back", EditorResources.Actions_Back, () =>
     {
         NavigationStore.NagivateTo(NavigationStore.PageId.Edit);
         return(Task.CompletedTask);
     });
 }
Ejemplo n.º 19
0
        internal void ComposeTree(TreeComposer composer)
        {
            foreach (var line in this.lines)
            {
                line.ComposeTree(composer);
            }

            this.turtle.ComposeTree(composer);
        }
Ejemplo n.º 20
0
        protected override void ComposeTree(TreeComposer composer)
        {
            composer.Element(
                name: "text-display",
                capture: element => this.textDisplayRef = element,
                styles: new Dictionary <string, string>
            {
                { "background-color", this.backgroundColor }
            },
                attributes: new Dictionary <string, string>
            {
                { "tabindex", "0" },     // required to receive focus
            },
                events: new TreeComposer.Events
            {
                OnKeyDownAsync = args => this.AcceptInput(args.Key)
            },
                body: () =>
            {
                if (!string.IsNullOrEmpty(this.Title))
                {
                    composer.Element(
                        name: "title",
                        body: () => composer.Text(this.Title));
                }
                foreach (var chunk in this.outputChunks)
                {
                    composer.Element(
                        name: "span",
                        body: () => composer.Text(chunk.Text),
                        styles: new Dictionary <string, string>
                    {
                        { "color", chunk.HexColor }
                    });

                    if (chunk.AppendNewLine)
                    {
                        composer.Element("br");
                    }
                }

                composer.Element("input-field", capture: element => this.inputFieldRef = element, body: () =>
                {
                    if (this.mode != AcceptedInputMode.None)
                    {
                        composer.Element("span", body: () => composer.Text(this.inputBuffer));
                        composer.Element(name: "span", body: () =>
                        {
                            composer.Element("cursor", body: () =>
                            {
                                composer.Markup("&#x2588;");
                            });
                        });
                    }
                });
            });
        }
Ejemplo n.º 21
0
        protected override void ComposeTree(TreeComposer composer)
        {
            if (!this.IsVisible)
            {
                return;
            }

            composer.Element(
                name: "graphics-display",
                attributes: new Dictionary <string, string>
            {
                { "tabindex", "0" },     // required to receive focus
            },
                styles: new Dictionary <string, string>
            {
                { "cursor", this.IsMouseVisible ? "initial" : "none" }
            },
                body: () =>
            {
                if (!string.IsNullOrEmpty(this.Title))
                {
                    composer.Element(
                        name: "title",
                        body: () => composer.Text(this.Title));
                }
                composer.Element(
                    name: "svg",
                    capture: element => this.RenderArea = element,
                    attributes: new Dictionary <string, string>
                {
                    { "height", "100%" },
                    { "width", "100%" },
                },
                    events: new TreeComposer.Events
                {
                    OnMouseDown = args => GraphicsDisplayStore.NotifyMouseDown(args.ClientX, args.ClientY, GetMouseButton(args.Button)),
                    OnMouseUp   = args => GraphicsDisplayStore.NotifyMouseUp(args.ClientX, args.ClientY, GetMouseButton(args.Button)),
                    OnMouseMove = args => GraphicsDisplayStore.NotifyMouseMove(args.ClientX, args.ClientY),
                },
                    body: () =>
                {
                    if (!this.Libraries.IsDefault())
                    {
                        this.Libraries.ImageList.EmbedImages(composer);
                        this.Libraries.GraphicsWindow.ComposeTree(composer);
                        this.Libraries.Shapes.ComposeTree(composer);
                        this.Libraries.Turtle.ComposeTree(composer);
                    }
                });

                if (!this.Libraries.IsDefault())
                {
                    this.Libraries.Controls.ComposeTree(composer);
                }
            });
        }
Ejemplo n.º 22
0
 internal static void Inject(TreeComposer composer, bool isSelected, Library library, Method method, Action onHeaderClick)
 {
     composer.Inject <LibraryMethod>(new Dictionary <string, object>
     {
         { nameof(LibraryMethod.IsSelected), isSelected },
         { nameof(LibraryMethod.Library), library },
         { nameof(LibraryMethod.Method), method },
         { nameof(LibraryMethod.OnHeaderClick), onHeaderClick }
     });
 }
Ejemplo n.º 23
0
 public override void ComposeTree(ControlsLibrary library, TreeComposer composer)
 {
     composer.Element(
         name: "button",
         body: () => composer.Text(this.Caption),
         events: new TreeComposer.Events
     {
         OnClick = args => library.NotifyButtonClicked(this.Name)
     },
         styles: this.Styles);
 }
 public override void ComposeTree(TreeComposer composer)
 {
     composer.Element(
         name: "image",
         attributes: new Dictionary <string, string>
     {
         { "href", this.Name },
         { "x", this.X.ToString(CultureInfo.CurrentCulture) },
         { "y", this.Y.ToString(CultureInfo.CurrentCulture) },
         { "transform", $"scale({this.ScaleX}, {this.ScaleY})" }
     });
 }
 public override void ComposeTree(TreeComposer composer)
 {
     composer.Element(
         name: "image",
         attributes: new Dictionary <string, string>
     {
         { "href", $"Turtle.svg" },
         /* width and height attributes required on Firefox */
         { "width", Width.ToString(CultureInfo.CurrentCulture) },
         { "height", Height.ToString(CultureInfo.CurrentCulture) }
     });
 }
Ejemplo n.º 26
0
        public static void DisabledAction(TreeComposer composer, string name, string title, string message)
        {
            composer.Element("disabled-action-container", body: () =>
            {
                composer.Element("action", body: () =>
                {
                    composer.Element("icon-" + name);
                    composer.Text(title);
                });

                composer.Element("disabled-message", body: () => composer.Text(message));
            });
        }
Ejemplo n.º 27
0
 public static void Action(TreeComposer composer, string name, string title, Func <Task> onClick)
 {
     composer.Element(
         name: "action",
         events: new TreeComposer.Events
     {
         OnClickAsync = args => onClick()
     },
         body: () =>
     {
         composer.Element("icon-" + name);
         composer.Text(title);
     });
 }
Ejemplo n.º 28
0
        private void ComposeCallStack(TreeComposer composer)
        {
            composer.Element("call-stack-member", body: () =>
            {
                composer.Element("member-title-area", body: () =>
                {
                    composer.Element("logo-area", body: () => composer.Element("logo"));
                    composer.Element("title-text", body: () => composer.Text(EditorResources.MemoryExplorer_CallStack));
                });

                composer.Element("member-table-header", body: () =>
                {
                    composer.Element("left-text", body: () => composer.Text(EditorResources.MemoryExplorer_Line));
                    composer.Element("right-text", body: () => composer.Text(EditorResources.MemoryExplorer_Module));
                });

                this.ComposeOnlyIfNotRunning(composer, showEvenIfTerminated: false, body: () =>
                {
                    composer.Element("call-stack", body: () =>
                    {
                        composer.Element("blue-box");
                        composer.Element("container-box", body: () =>
                        {
                            bool firstFrame = true;
                            foreach (var frame in this.Engine.GetSnapshot().ExecutionStack.Reverse())
                            {
                                string name;
                                if (firstFrame)
                                {
                                    firstFrame = false;
                                    name       = "stack-frame-highlighted";
                                }
                                else
                                {
                                    name = "stack-frame";
                                }

                                composer.Element(name, body: () =>
                                {
                                    var line = frame.CurrentSourceLine + 1; // Monaco editor is one-based
                                    composer.Element("line-cell", body: () => composer.Text(line.ToString(CultureInfo.CurrentCulture)));
                                    composer.Element("module-name-cell", body: () => composer.Text(frame.Module.Name));
                                });
                            }
                        });
                    });
                });
            });
        }
Ejemplo n.º 29
0
 public override void ComposeTree(TreeComposer composer)
 {
     composer.Element(
         name: "polygon",
         styles: new Dictionary <string, string>
     {
         { "fill", this.Styles.BrushColor },
         { "stroke", this.Styles.PenColor },
         { "stroke-width", $"{this.Styles.PenWidth}px" },
     },
         attributes: new Dictionary <string, string>
     {
         { "points", string.Join(",", this.X1, this.Y1, this.X2, this.Y2, this.X3, this.Y3) }
     });
 }
Ejemplo n.º 30
0
 protected override void ComposeLeftActions(TreeComposer composer)
 {
     Actions.Action(composer, "new", EditorResources.Actions_New, onClick: () => JSInterop.Monaco.ClearEditor(EditorResources.Actions_ClearEverythingConfirmation));
     Actions.Separator(composer);
     Actions.Action(composer, "save", EditorResources.Actions_Save, onClick: JSInterop.Monaco.SaveToFile);
     Actions.Action(composer, "open", EditorResources.Actions_Open, onClick: () => JSInterop.Monaco.OpenFile(EditorResources.Actions_ClearEverythingConfirmation));
     Actions.DisabledAction(composer, "import", EditorResources.Actions_Import, message: EditorResources.Actions_DisabledMessage_ComingSoon);
     Actions.DisabledAction(composer, "publish", EditorResources.Actions_Publish, message: EditorResources.Actions_DisabledMessage_ComingSoon);
     Actions.Separator(composer);
     Actions.Action(composer, "cut", EditorResources.Actions_Cut, onClick: JSInterop.Monaco.Cut);
     Actions.Action(composer, "copy", EditorResources.Actions_Copy, onClick: JSInterop.Monaco.Copy);
     Actions.Action(composer, "paste", EditorResources.Actions_Paste, onClick: JSInterop.Monaco.Paste);
     Actions.Separator(composer);
     Actions.Action(composer, "undo", EditorResources.Actions_Undo, onClick: JSInterop.Monaco.Undo);
     Actions.Action(composer, "redo", EditorResources.Actions_Redo, onClick: JSInterop.Monaco.Redo);
 }