Exemple #1
0
        public AboutPage()
            : base("Close".Localize())
        {
            this.WindowTitle = "About".Localize() + " " + ApplicationController.Instance.ProductName;
            this.MinimumSize = new Vector2(480 * GuiWidget.DeviceScale, 520 * GuiWidget.DeviceScale);
            this.WindowSize  = new Vector2(500 * GuiWidget.DeviceScale, 550 * GuiWidget.DeviceScale);

            contentRow.BackgroundColor = Color.Transparent;

            headerRow.Visible = false;

            var altHeadingRow = new GuiWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Absolute,
                Height  = 100,
            };

            contentRow.AddChild(altHeadingRow);

            var productInfo = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Center | HAnchor.Fit,
                VAnchor = VAnchor.Center | VAnchor.Fit
            };

            var productTitle = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Center | HAnchor.Fit
            };

            productTitle.AddChild(new TextWidget("MatterControl".Localize(), textColor: theme.TextColor, pointSize: 20)
            {
                Margin = new BorderDouble(right: 3)
            });
            productTitle.AddChild(new TextWidget("TM".Localize(), textColor: theme.TextColor, pointSize: 7)
            {
                VAnchor = VAnchor.Top
            });

            altHeadingRow.AddChild(productInfo);
            productInfo.AddChild(productTitle);

            var spinnerPanel = new GuiWidget()
            {
                HAnchor = HAnchor.Absolute | HAnchor.Left,
                VAnchor = VAnchor.Absolute,
                Height  = 100,
                Width   = 100,
            };

            altHeadingRow.AddChild(spinnerPanel);
            var accentColor = theme.PrimaryAccentColor;

            var spinner = new LogoSpinner(spinnerPanel, 4, 0.2, 0, rotateX: 0);

            productInfo.AddChild(
                new TextWidget("Version".Localize() + " " + VersionInfo.Instance.BuildVersion, textColor: theme.TextColor, pointSize: theme.DefaultFontSize)
            {
                HAnchor = HAnchor.Center
            });

            productInfo.AddChild(
                new TextWidget("Developed By".Localize() + ": " + "MatterHackers", textColor: theme.TextColor, pointSize: theme.DefaultFontSize)
            {
                HAnchor = HAnchor.Center
            });

            contentRow.AddChild(
                new WrappedTextWidget(
                    "MatterControl is made possible by the team at MatterHackers and other open source software".Localize() + ":",
                    pointSize: theme.DefaultFontSize,
                    textColor: theme.TextColor)
            {
                Margin = new BorderDouble(0, 15)
            });

            var licensePanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit,
                Margin  = new BorderDouble(bottom: 15)
            };

            var data = JsonConvert.DeserializeObject <List <LibraryLicense> >(StaticData.Instance.ReadAllText(Path.Combine("License", "license.json")));

            var linkIcon = StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16, theme.InvertIcons);

            SectionWidget section = null;

            foreach (var item in data.OrderBy(i => i.Name))
            {
                var linkButton = new IconButton(linkIcon, theme);
                linkButton.Click += (s, e) => UiThread.RunOnIdle(() =>
                {
                    ApplicationController.LaunchBrowser(item.Url);
                });

                section = new SectionWidget(item.Title ?? item.Name, new LazyLicenseText(item.Name, theme), theme, linkButton, expanded: false)
                {
                    HAnchor = HAnchor.Stretch
                };
                licensePanel.AddChild(section);
            }

            // Apply a bottom border to the last time for balance
            if (section != null)
            {
                section.Border = section.Border.Clone(bottom: 1);
            }

            var scrollable = new ScrollableWidget(autoScroll: true)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
                Margin  = new BorderDouble(bottom: 10),
            };

            scrollable.ScrollArea.HAnchor = HAnchor.Stretch;
            scrollable.AddChild(licensePanel);
            contentRow.AddChild(scrollable);

            contentRow.AddChild(
                new TextWidget("Copyright © 2019 MatterHackers, Inc.", textColor: theme.TextColor, pointSize: theme.DefaultFontSize)
            {
                HAnchor = HAnchor.Center,
            });

            var siteLink = new LinkLabel("www.matterhackers.com", theme)
            {
                HAnchor   = HAnchor.Center,
                TextColor = theme.TextColor
            };

            siteLink.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                ApplicationController.LaunchBrowser("http://www.matterhackers.com");
            });
            contentRow.AddChild(siteLink);
        }
        private static PopupMenu CreatePopupMenu()
        {
            var menuTheme = ApplicationController.Instance.MenuTheme;

            var popupMenu = new PopupMenu(menuTheme)
            {
                MinimumSize = new Vector2(300, 0)
            };

            var linkIcon = StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16, menuTheme.InvertIcons);

            PopupMenu.MenuItem menuItem;

            menuItem        = popupMenu.CreateMenuItem("Help".Localize(), StaticData.Instance.LoadIcon("help_page.png", 16, 16, menuTheme.InvertIcons));
            menuItem.Click += (s, e) => ApplicationController.Instance.ShowApplicationHelp("Docs");

            menuItem        = popupMenu.CreateMenuItem("Interface Tour".Localize(), StaticData.Instance.LoadIcon("tour.png", 16, 16, menuTheme.InvertIcons));
            menuItem.Click += (s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    DialogWindow.Show <Tour.WelcomePage>();
                });
            };

            if (Application.EnableNetworkTraffic)
            {
                popupMenu.CreateSeparator();

                menuItem        = popupMenu.CreateMenuItem("Check For Update".Localize(), StaticData.Instance.LoadIcon("update.png", 16, 16, menuTheme.InvertIcons));
                menuItem.Click += (s, e) => UiThread.RunOnIdle(() =>
                {
                    UpdateControlData.Instance.CheckForUpdate();
                    DialogWindow.Show <CheckForUpdatesPage>();
                });
            }

            popupMenu.CreateSeparator();

            menuItem        = popupMenu.CreateMenuItem("Settings".Localize(), StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16, menuTheme.InvertIcons));
            menuItem.Click += (s, e) => DialogWindow.Show <ApplicationSettingsPage>();
            menuItem.Name   = "Settings MenuItem";

            popupMenu.CreateSeparator();

            ImageBuffer indicatorIcon = null;

            if (IntPtr.Size == 8)
            {
                indicatorIcon = StaticData.Instance.LoadIcon("x64.png", 16, 16, menuTheme.InvertIcons);
            }

            popupMenu.CreateSubMenu("Community".Localize(), menuTheme, (modifyMenu) =>
            {
                menuItem        = modifyMenu.CreateMenuItem("Forums".Localize(), linkIcon);
                menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://forums.matterhackers.com/category/20/mattercontrol");

                menuItem        = modifyMenu.CreateMenuItem("Guides and Articles".Localize(), linkIcon);
                menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/topic/mattercontrol");

                menuItem        = modifyMenu.CreateMenuItem("Support".Localize(), linkIcon);
                menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/mattercontrol/support");

                menuItem        = modifyMenu.CreateMenuItem("Release Notes".Localize(), linkIcon);
                menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/mattercontrol/support/release-notes");

                modifyMenu.CreateSeparator();

                menuItem        = modifyMenu.CreateMenuItem("Report a Bug".Localize(), StaticData.Instance.LoadIcon("feedback.png", 16, 16, menuTheme.InvertIcons));
                menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://github.com/MatterHackers/MatterControl/issues");
            }, StaticData.Instance.LoadIcon("feedback.png", 16, 16, menuTheme.InvertIcons));

            popupMenu.CreateSeparator();

            var imageBuffer = new ImageBuffer(18, 18);

            // x64 indicator icon
            if (IntPtr.Size == 8)
            {
                var graphics = imageBuffer.NewGraphics2D();
                graphics.Clear(menuTheme.BackgroundColor);
                graphics.Rectangle(imageBuffer.GetBoundingRect(), menuTheme.PrimaryAccentColor);
                graphics.DrawString("64", imageBuffer.Width / 2, imageBuffer.Height / 2, 8, Agg.Font.Justification.Center, Agg.Font.Baseline.BoundsCenter, color: menuTheme.PrimaryAccentColor);
            }

            menuItem        = popupMenu.CreateMenuItem("About".Localize() + " MatterControl", imageBuffer);
            menuItem.Click += (s, e) => ApplicationController.Instance.ShowAboutPage();
            return(popupMenu);
        }
Exemple #3
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 == 0)
                {
                    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.LaunchBrowser("https://guides.github.com/features/mastering-markdown/");
            };
            footerRow.AddChild(link, 0);
        }