Ejemplo n.º 1
0
        /// <summary>
        /// Selects the package.
        /// </summary>
        /// <param name="guidancePackage">The guidance package.</param>
        private void SelectPackage(GuidancePackage guidancePackage)
        {
            int index = 0;

            foreach (object item in this.cbGuidancePackages.Items)
            {
                GuidancePackageEntry entry = item as GuidancePackageEntry;
                if (entry != null)
                {
                    if (entry.GuidancePackage == guidancePackage)
                    {
                        cbGuidancePackages.SelectedIndex = index;
                        break;
                    }
                }
                index++;
            }
            selectedGuidancePackage = guidancePackage;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the specified uri and return the combined base path when possible.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <returns></returns>
        private string ParseUri(string uri)
        {
            GuidancePackageEntry packageItem = cbGuidancePackages.SelectedItem as GuidancePackageEntry;

            if (packageItem == null)
            {
                return(uri);
            }

            string basePath             = packageItem.GuidancePackage.BasePath;
            string helpRelativeLocation = uri;

            Uri    baselocation = null;
            string helpLocation = string.Empty;

            if (Uri.TryCreate(helpRelativeLocation, UriKind.RelativeOrAbsolute, out baselocation))
            {
                if (baselocation != null)
                {
                    if (baselocation.IsAbsoluteUri)
                    {
                        if (baselocation.IsFile)
                        {
                            helpLocation = baselocation.LocalPath;
                        }
                        else
                        {
                            helpLocation = baselocation.AbsoluteUri;
                        }
                    }
                    else
                    {
                        helpLocation = Path.Combine(basePath, helpRelativeLocation);
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Resources.Navigator_CannotGetHelpResource, helpLocation));
            }
            return(helpLocation);
        }