public SettingsWindow()
        {
            InitializeComponent();

            // Set up version info.
            if (string.IsNullOrWhiteSpace(_runtimeVersion))
            {
                var runtimeTypeInfo = typeof(ArcGISRuntimeEnvironment).GetTypeInfo();
                var rtVersion       = FileVersionInfo.GetVersionInfo(runtimeTypeInfo.Assembly.Location);
                _runtimeVersion = rtVersion.FileVersion;
            }
            VersionTextField.Text = _runtimeVersion;

            // Set up license info.
            string markdownPath   = Path.Combine(App.ResourcePath, "Resources", "licenses.md");
            string cssPath        = Path.Combine(App.ResourcePath, "Resources", "github-markdown.css");
            string licenseContent = File.ReadAllText(markdownPath);

            licenseContent = _markdownRenderer.Parse(licenseContent);
            string htmlString = "<!doctype html><head><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + licenseContent + "</body>";

            LicenseView.NavigateToString(htmlString);

            // Set up offline data.
            OfflineDataSamples = SampleManager.Current.AllSamples.Where(m => m.OfflineDataItems?.Any() ?? false).ToList();

            SampleDataListView.ItemsSource = OfflineDataSamples;
        }
        public SamplePage()
        {
            InitializeComponent();

            HideStatusBar();

            // Get selected sample and set that as the DataContext.
            DataContext = SampleManager.Current.SelectedSample;

            // Load and show the sample.
            SampleContainer.Content = SampleManager.Current.SampleToControl(SampleManager.Current.SelectedSample);

            // Default to the live sample view.
            LiveSample.IsChecked = true;

            string folderPath    = SampleManager.Current.SelectedSample.Path;
            string cssPath       = "ms-appx-web:///Resources\\github-markdown.css";
            string basePath      = $"ms-appx-web:///{folderPath.Substring(folderPath.LastIndexOf("Samples"))}";
            string readmePath    = System.IO.Path.Combine(folderPath, "Readme.md");
            string readmeContent = System.IO.File.ReadAllText(readmePath);

            readmeContent = _markdownRenderer.Parse(readmeContent);
            readmeContent = readmeContent.Replace("src='", "src=\"").Replace(".jpg'", ".jpg\"").Replace("src=\"", $"src=\"{basePath}\\");
            string htmlString = "<!doctype html><head><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + readmeContent + "</body>";

            DescriptionView.NavigateToString(htmlString);
            SourceCodeContainer.LoadSourceCode();
        }
Пример #3
0
        /// <summary>
        /// Display help tab.
        /// </summary>
        /// <returns>Help tab view</returns>
        public async Task <ActionResult> Index()
        {
            string helpTabText = await this.configurationProvider.GetSavedEntityDetailAsync(ConfigurationEntityTypes.HelpTabText);

            var marked      = new MarkedNet.Marked();
            var helpTabHtml = marked.Parse(helpTabText);

            return(this.View(nameof(this.Index), helpTabHtml));
        }
Пример #4
0
        public void SetSample(SampleInfo sample)
        {
            DataContext = sample;

            string folderPath    = sample.Path;
            string readmePath    = System.IO.Path.Combine(folderPath, "Readme.md");
            string readmeContent = System.IO.File.ReadAllText(readmePath);
            string cssPath       = folderPath.Substring(0, folderPath.LastIndexOf("Samples")) + "Resources\\github-markdown.css";

            readmeContent = _markdownRenderer.Parse(readmeContent);

            string htmlString = "<!doctype html><head><base href=\"" + readmePath + "\"><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + readmeContent + "</body>";

            DescriptionView.NavigateToString(htmlString);
        }
Пример #5
0
        public SamplePage(ContentPage sample, SampleInfo sampleInfo) : this()
        {
            // Set the sample variable.
            _sample = sample;

            // Update the binding context - this is important for the description tab.
            BindingContext = sampleInfo;

            // Update the content - this displays the sample.
            SampleContentPage.Content = sample.Content;

            // Because the sample control isn't navigated to (its content is displayed directly),
            //    navigation won't work from within the sample until the parent is manually set.
            sample.Parent = this;

            // Set the title. If the sample control didn't
            // define the title, use the name from the sample metadata.
            if (!String.IsNullOrWhiteSpace(sample.Title))
            {
                Title = sample.Title;
            }
            else
            {
                Title = sampleInfo.SampleName;
            }

            // Set up the description page.
            try
            {
                string folderPath = sampleInfo.Path;
                string baseUrl    = "";
                string readmePath = "";
                string basePath   = "";
#if WINDOWS_UWP
                baseUrl    = "ms-appx-web:///";
                basePath   = $"{baseUrl}{folderPath.Substring(folderPath.LastIndexOf("Samples"))}";
                readmePath = System.IO.Path.Combine(folderPath, "readme.md");
#elif XAMARIN_ANDROID
                baseUrl    = "file:///android_asset";
                basePath   = baseUrl + folderPath;
                readmePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + folderPath, "readme.md");
#elif __IOS__
                baseUrl    = Foundation.NSBundle.MainBundle.BundlePath;
                basePath   = folderPath;
                readmePath = System.IO.Path.Combine(folderPath, "readme.md");
#endif
                string cssPath = $"{baseUrl}/github-markdown.css";

                string readmeContent = System.IO.File.ReadAllText(readmePath);
                readmeContent = _markdownRenderer.Parse(readmeContent);

                // Fix paths for images.
                readmeContent = readmeContent.Replace("src='", "src=\"").Replace(".jpg'", ".jpg\"").Replace("src=\"", $"src=\"{basePath}/");

                string htmlString = $"<!doctype html><head><link rel=\"stylesheet\" href=\"{cssPath}\" /></head><body class=\"markdown-body\">{readmeContent}</body>";
                DescriptionView.Source = new HtmlWebViewSource()
                {
                    Html    = htmlString,
                    BaseUrl = basePath
                };
                DescriptionView.Navigating += Webview_Navigating;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
        public SettingsWindow()
        {
            this.InitializeComponent();

            // Set up version info and About section.
            try
            {
                if (string.IsNullOrWhiteSpace(_runtimeVersion))
                {
                    var rtVersion = FileVersionInfo.GetVersionInfo(Path.Combine(Windows.ApplicationModel.Package.Current.Installed­Location.Path, "RuntimeCoreNet.dll"));
                    _runtimeVersion = rtVersion.FileVersion;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                _runtimeVersion = "Couldn't find ArcGIS Runtime version.";
            }

            // Set up markdown tabs.
            string cssPath = "";

            if (Application.Current.RequestedTheme != ApplicationTheme.Dark)
            {
                cssPath = "Resources/github-markdown.css";
            }
            else
            {
                cssPath = "Resources/github-markdown-dark.css";
            }

            string aboutPath = "Resources\\about.md";
            string aboutHTML = "<!doctype html><head><link rel=\"stylesheet\" href=\"ms-appx-web:///" + cssPath + "\" /></head><body class=\"markdown-body\">" + _markdownRenderer.Parse(File.ReadAllText(aboutPath)) + _runtimeVersion + "</body>";

            AboutBlock.NavigateToString(aboutHTML);

            string licensePath = "Resources\\licenses.md";
            string licenseHTML = "<!doctype html><head><link rel=\"stylesheet\" href=\"ms-appx-web:///" + cssPath + "\" /></head><body class=\"markdown-body\">" + _markdownRenderer.Parse(File.ReadAllText(licensePath)) + "</body>";

            LicensesBlock.NavigateToString(licenseHTML);

            // Set up offline data.
            OfflineDataSamples             = SampleManager.Current.AllSamples.Where(m => m.OfflineDataItems?.Any() ?? false).ToList();
            SampleDataListView.ItemsSource = OfflineDataSamples;
            _cancellationTokenSource       = new CancellationTokenSource();
        }
Пример #7
0
        private void Initialize()
        {
            // Get the ArcGIS Runtime version number.
            string versionNumber = string.Empty;

            try
            {
#if XAMARIN_ANDROID
                versionNumber = typeof(ArcGISRuntimeEnvironment).GetTypeInfo().Assembly.GetName().Version.ToString(2);
#else
                var runtimeTypeInfo = typeof(ArcGISRuntimeEnvironment).GetTypeInfo();
                versionNumber = FileVersionInfo.GetVersionInfo(runtimeTypeInfo.Assembly.Location).FileVersion;
#endif
            }
            // Precise version number cant be used while running in release mode.
            catch (Exception)
            {
                versionNumber = "100.11.0";
            }


            // Set up offline data.
            OfflineDataSamples          = SampleManager.Current.AllSamples.Where(m => m.OfflineDataItems?.Any() ?? false).ToList();
            OfflineDataView.ItemsSource = OfflineDataSamples;
            _cancellationTokenSource    = new CancellationTokenSource();

            // Get the contents of the markdown files for the "About" and "Licenses" pages.
            var    assembly      = Assembly.GetExecutingAssembly();
            string aboutString   = new StreamReader(assembly.GetManifestResourceStream("ArcGISRuntime.Resources.SettingsPage.about.md")).ReadToEnd();
            string licenseString = new StreamReader(assembly.GetManifestResourceStream("ArcGISRuntime.Resources.SettingsPage.licenses.md")).ReadToEnd();

            // The location of the github markdown css is platform dependent.
            string baseUrl = string.Empty;
#if WINDOWS_UWP
            baseUrl = "ms-appx-web:///";
#elif XAMARIN_ANDROID
            baseUrl = "file:///android_asset";
#elif __IOS__
            baseUrl = Foundation.NSBundle.MainBundle.BundlePath;

            // Need to set the viewport on iOS to scale page correctly.
            string viewportHTML = "<meta name=\"viewport\" content=\"width=" +
                                  Application.Current.MainPage.Width +
                                  ", shrink-to-fit=YES\">";
#endif
            string cssPath   = $"{baseUrl}/github-markdown.css";
            string htmlStart = $"<!doctype html><head><link rel=\"stylesheet\" href=\"{cssPath}\" />";

            // Load the HTML for the about and license pages.
            string licenseHTML = htmlStart +
#if __IOS__
                                 viewportHTML +
#endif
                                 $"</head><body class=\"markdown-body\">{_markdownRenderer.Parse(licenseString)}</body>";
            LicensePage.Source = new HtmlWebViewSource()
            {
                Html = licenseHTML
            };

            string aboutHTML = htmlStart +
#if __IOS__
                               viewportHTML +
#endif
                               $"</head><body class=\"markdown-body\">{_markdownRenderer.Parse(aboutString)}{versionNumber}</body>";
            AboutPage.Source = new HtmlWebViewSource()
            {
                Html = aboutHTML
            };

            // Add an event handler for hyperlinks in the web views.
            AboutPage.Navigating   += HyperlinkClicked;
            LicensePage.Navigating += HyperlinkClicked;
        }