Exemplo n.º 1
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.Instance.LaunchBrowser("https://guides.github.com/features/mastering-markdown/");
            };
            footerRow.AddChild(link, 0);
        }
Exemplo n.º 2
0
        public CheckForUpdatesPage()
            : base("Close".Localize())
        {
            this.WindowTitle = this.HeaderText = "Check for Update".Localize();
            this.Padding     = 0;
            this.AnchorAll();

            // Clear padding so UpdateControlView toolbar appears like toolbar
            contentRow.Padding = 0;

            // Update Status Widget
            contentRow.AddChild(
                new UpdateControlView(theme));

            var contentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
                Padding = 8
            };

            contentRow.AddChild(contentPanel);

            var currentBuildInfo = new TextWidget("Current Build".Localize() + $" : {VersionInfo.Instance.BuildVersion}")
            {
                HAnchor   = HAnchor.Stretch,
                Margin    = new BorderDouble(left: 5, bottom: 15, top: 20),
                TextColor = theme.TextColor
            };

            contentPanel.AddChild(currentBuildInfo);

            var currentFeedAndDropDownContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
            {
                VAnchor = VAnchor.Fit,
                HAnchor = HAnchor.Stretch,
            };

            contentPanel.AddChild(currentFeedAndDropDownContainer);

            var feedLabel = new TextWidget("Update Channel".Localize(), pointSize: 12)
            {
                TextColor = theme.TextColor,
                VAnchor   = VAnchor.Center,
                Margin    = new BorderDouble(left: 5)
            };

            currentFeedAndDropDownContainer.AddChild(feedLabel);

            FlowLayoutWidget additionalInfoContainer = null;

            var whatsThisLink = new LinkLabel("What's this?".Localize(), theme)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(left: 6),
            };

            whatsThisLink.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    if (!additionalInfoContainer.Visible)
                    {
                        additionalInfoContainer.Visible = true;
                    }
                    else
                    {
                        additionalInfoContainer.Visible = false;
                    }
                });
            };
            currentFeedAndDropDownContainer.AddChild(whatsThisLink);

            currentFeedAndDropDownContainer.AddChild(new HorizontalSpacer());


            var acceptableUpdateFeedTypeValues = new List <string>()
            {
                "release", "pre-release", "development"
            };

            string currentUpdateFeedType = UserSettings.Instance.get(UserSettingsKey.UpdateFeedType);

            if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1)
            {
                UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, "release");
            }

            var releaseOptionsDropList = new MHDropDownList("Development", theme, maxHeight: 200 * GuiWidget.DeviceScale)
            {
                HAnchor = HAnchor.Fit,
            };

            releaseOptionsDropList.AddItem("Stable".Localize(), "release");
            releaseOptionsDropList.AddItem("Beta".Localize(), "pre-release");
            releaseOptionsDropList.AddItem("Alpha".Localize(), "development");
            releaseOptionsDropList.SelectedValue     = currentUpdateFeedType;
            releaseOptionsDropList.SelectionChanged += (s, e) =>
            {
                string releaseCode = releaseOptionsDropList.SelectedValue;
                if (releaseCode != UserSettings.Instance.get(UserSettingsKey.UpdateFeedType))
                {
                    UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, releaseCode);
                }

                UpdateControlData.Instance.CheckForUpdate();
            };
            currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList);

            additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                BackgroundColor = theme.MinimalShade,
                HAnchor         = HAnchor.Stretch,
                Padding         = new BorderDouble(left: 6, top: 6),
                Visible         = false
            };
            additionalInfoContainer.AddChild(
                new WrappedTextWidget("Changing your update channel will change the version of MatterControl that you receive when updating".Localize() + ":")
            {
                TextColor = theme.TextColor,
                Margin    = new BorderDouble(bottom: 20)
            });

            additionalInfoContainer.AddChild(
                new WrappedTextWidget("Stable: The current release version of MatterControl (recommended)".Localize())
            {
                TextColor = theme.TextColor,
                Margin    = new BorderDouble(bottom: 10)
            });

            additionalInfoContainer.AddChild(
                new WrappedTextWidget("Beta: The release candidate version of MatterControl".Localize())
            {
                TextColor = theme.TextColor,
                Margin    = new BorderDouble(bottom: 10)
            });

            additionalInfoContainer.AddChild(
                new WrappedTextWidget("Alpha: The in development version of MatterControl".Localize())
            {
                TextColor = theme.TextColor,
                Margin    = new BorderDouble(bottom: 10)
            });
            contentPanel.AddChild(additionalInfoContainer);
        }
Exemplo n.º 3
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).SetToColor(theme.TextColor);

            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);
        }