コード例 #1
0
        public HelpPage(string guideKey = null)
            : base("Close".Localize())
        {
            WindowSize = new Vector2(940, 700);

            this.guideKey         = guideKey;
            this.WindowTitle      = "MatterControl " + "Help".Localize();
            this.HeaderText       = "How to succeed with MatterControl".Localize();
            this.ChildBorderColor = theme.GetBorderColor(75);

            var tabControl = new SimpleTabs(theme, new GuiWidget())
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            tabControl.TabBar.BackgroundColor = theme.TabBarBackground;

            contentRow.AddChild(tabControl);
            contentRow.Padding = 0;

            // add the mouse commands
            var mouseControls = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Fit | HAnchor.Center,
                Padding = theme.DefaultContainerPadding
            };

            var mouseTab = new ToolTab("Mouse".Localize(), tabControl, mouseControls, theme, hasClose: false)
            {
                // this can be used to navigate to this tab on construction
                Name = "Mouse Tab"
            };

            tabControl.AddTab(mouseTab);

            var mouseKeys = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mouseControls.AddChild(mouseKeys);

            var mouseActions = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                Border      = new BorderDouble(1, 0, 0, 0),
                BorderColor = this.ChildBorderColor
            };

            mouseControls.AddChild(mouseActions);

            var mouseKeyActions = new List <(string key, string action)>(new(string, string)[]
コード例 #2
0
        public SurfacedEditorPage(IObject3D selectedItem)
        {
            this.WindowTitle = "MatterControl - " + "Editor Selector".Localize();
            this.HeaderText  = "Surfaced Editor".Localize();

            var tabControl = new SimpleTabs(theme, new GuiWidget())
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
            };

            tabControl.TabBar.BackgroundColor = theme.TabBarBackground;
            tabControl.TabBar.Padding         = 0;

            contentRow.AddChild(tabControl);
            contentRow.Padding = 0;

            var editContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Stretch,
                Padding         = theme.DefaultContainerPadding,
                BackgroundColor = theme.ActiveTabColor
            };

            editWidget = new MHTextEditWidget("", multiLine: true)
            {
                HAnchor = HAnchor.Stretch,
                Name    = this.Name
            };
            editWidget.DrawFromHintedCache();

            editContainer.AddChild(editWidget);

            // add the tree view
            var treeView = new TreeView(theme)
            {
                Margin = new BorderDouble(left: 18),
            };

            treeView.AfterSelect += (s, e) =>
            {
                if (treeView.SelectedNode.Tag is IObject3D contextNode)
                {
                    editWidget.Text = "$." + string.Join(".", contextNode.AncestorsAndSelf().TakeWhile(o => !(o is ComponentObject3D)).Select(o => $"Children<{o.GetType().Name.ToString()}>").Reverse().ToArray());
                }
            };
            treeView.ScrollArea.ChildAdded += (s, e) =>
            {
                if (e is GuiWidgetEventArgs childEventArgs &&
                    childEventArgs.Child is TreeNode treeNode)
                {
                    treeNode.AlwaysExpandable = true;
                }
            };

            treeView.Click += (s, e) =>
            {
                if (treeView.IsDoubleClick(e))
                {
                    Console.WriteLine();
                }
            };

            treeView.ScrollArea.CloseAllChildren();

            var rootNode = Object3DTreeBuilder.BuildTree(selectedItem, theme);

            treeView.AddChild(rootNode);
            rootNode.TreeView = treeView;

            editContainer.AddChild(treeView);
            var dummyWidget = new GuiWidget()
            {
                BackgroundColor = Color.Red
            };

            var editTab = new ToolTab("Edit".Localize(), tabControl, editContainer, theme, hasClose: false)
            {
                Name = "Edit Tab"
            };

            tabControl.AddTab(editTab);

            var previewTab = new ToolTab("Preview".Localize(), tabControl, dummyWidget, theme, hasClose: false)
            {
                Name = "Preview Tab"
            };

            tabControl.AddTab(previewTab);

            tabControl.ActiveTabChanged += (s, e) =>
            {
                if (tabControl.SelectedTabIndex == 1)
                {
                    // dummyWidget.Markdown = editWidget.Text;
                }
            };

            tabControl.SelectedTabIndex = 0;

            var saveButton = theme.CreateDialogButton("Save".Localize());

            saveButton.Click += (s, e) =>
            {
                this.ValueChanged?.Invoke(this, null);

                this.DialogWindow.CloseOnIdle();
            };
            this.AddPageAction(saveButton);
        }
コード例 #3
0
ファイル: Tabs.cs プロジェクト: connectblocks/MatterControl
        public SimpleTab(string tabLabel, SimpleTabs parentTabControl, GuiWidget tabContent, ThemeConfig theme, string tabImageUrl = null, bool hasClose = true, double pointSize = 12, ImageBuffer iconImage = null)
        {
            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit | VAnchor.Bottom;
            this.Padding = 0;
            this.Margin  = 0;
            this.theme   = theme;

            this.TabContent       = tabContent;
            this.parentTabControl = parentTabControl;

            if (iconImage != null)
            {
                tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, iconImage, pointSize);
            }
            else
            {
                tabPill = new TabPill(tabLabel, ActiveTheme.Instance.PrimaryTextColor, tabImageUrl, pointSize);
            }
            tabPill.Margin = (hasClose) ? new BorderDouble(right: 16) : 0;

            this.AddChild(tabPill);

            if (hasClose)
            {
                var closeButton = theme.CreateSmallResetButton();
                closeButton.HAnchor     = HAnchor.Right;
                closeButton.Margin      = new BorderDouble(right: 7, top: 1);
                closeButton.Name        = "Close Tab Button";
                closeButton.ToolTipText = "Close".Localize();
                closeButton.Click      += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        if (TabContent is PrinterTabPage printerTab &&
                            printerTab.printer.Connection.PrinterIsPrinting)
                        {
                            StyledMessageBox.ShowMessageBox(
                                (bool response) =>
                            {
                                if (response)
                                {
                                    UiThread.RunOnIdle(() =>
                                    {
                                        this.parentTabControl.RemoveTab(this);
                                        this.CloseClicked?.Invoke(this, null);
                                    });
                                }
                            },
                                "Cancel the current print?".Localize(),
                                "Cancel Print?".Localize(),
                                StyledMessageBox.MessageType.YES_NO,
                                "Cancel Print".Localize(),
                                "Continue Printing".Localize());
                        }
                        else                         // need to handle asking about saving a
                        {
                            UiThread.RunOnIdle(() =>
                            {
                                this.parentTabControl.RemoveTab(this);
                                this.CloseClicked?.Invoke(this, null);
                            });
                        }
                    });
コード例 #4
0
        public MarkdownEditPage(UIField uiField)
        {
            this.WindowTitle = "MatterControl - " + "Markdown Edit".Localize();
            this.HeaderText  = "Edit Page".Localize() + ":";

            var tabControl = new SimpleTabs(theme, new GuiWidget())
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
            };

            tabControl.TabBar.BackgroundColor = theme.TabBarBackground;
            tabControl.TabBar.Padding         = 0;

            contentRow.AddChild(tabControl);
            contentRow.Padding = 0;

            var editContainer = new GuiWidget()
            {
                HAnchor         = HAnchor.Stretch,
                VAnchor         = VAnchor.Stretch,
                Padding         = theme.DefaultContainerPadding,
                BackgroundColor = theme.BackgroundColor
            };

            editWidget = new MHTextEditWidget("", theme, multiLine: true, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono))
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
                Name    = this.Name
            };
            editWidget.DrawFromHintedCache();
            editWidget.ActualTextEditWidget.VAnchor = VAnchor.Stretch;

            editContainer.AddChild(editWidget);

            markdownWidget = new MarkdownWidget(theme, true)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
                Margin  = 0,
                Padding = 0,
            };

            var previewTab = new ToolTab("Preview", "Preview".Localize(), tabControl, markdownWidget, theme, hasClose: false)
            {
                Name = "Preview Tab"
            };

            tabControl.AddTab(previewTab);

            var editTab = new ToolTab("Edit", "Edit".Localize(), tabControl, editContainer, theme, hasClose: false)
            {
                Name = "Edit Tab"
            };

            tabControl.AddTab(editTab);

            tabControl.ActiveTabChanged += (s, e) =>
            {
                if (tabControl.SelectedTabIndex == 1)
                {
                    markdownWidget.Markdown = editWidget.Text;
                }
            };

            tabControl.SelectedTabIndex = 0;

            var saveButton = theme.CreateDialogButton("Save".Localize());

            saveButton.Click += (s, e) =>
            {
                uiField.SetValue(
                    editWidget.Text.Replace("\n", "\\n"),
                    userInitiated: true);

                this.DialogWindow.CloseOnIdle();
            };
            this.AddPageAction(saveButton);

            var link = new LinkLabel("Markdown Help", theme)
            {
                Margin  = new BorderDouble(right: 20),
                VAnchor = VAnchor.Center
            };

            link.Click += (s, e) =>
            {
                ApplicationController.Instance.LaunchBrowser("https://guides.github.com/features/mastering-markdown/");
            };
            footerRow.AddChild(link, 0);
        }