Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Integrated Help system in a WPF Application

, 20 Jun 2013
Quick guideline to understand a workflow of screen without reading long and boring(!!) documentation guide.
integratedhelpinwpf-noexe.zip
IntegratedHelpInWPF
IntegratedHelpInWPF
AttachProperties
bin
Debug
DynamicHelpReference
IntegratedHelpInWPF.vshost.exe.manifest
Commands
DynamicHelpReference
IntegratedHelpInWPF.csproj.user
Languages
Popup
Properties
Settings.settings
Resources
integratedhelpinwpf.zip
IntegratedHelpInWPF.exe
IntegratedHelpInWPF.vshost.exe
IntegratedHelpInWPF.vshost.exe.manifest
Release
IntegratedHelpInWPF.csproj.user
obj
Debug
Resources
TempPE
Settings.settings
IntegratedHelpInWPF_Revised_-noexe.zip
IntegratedHelpInWPF.vshost.exe.manifest
Converter
IntegratedHelpInWPF.csproj.user
DetailsHelpView.baml
DynamicHelpView.baml
IntegratedHelpInWPF.g.resources
IntegratedHelpInWPF.Properties.Resources.resources
IntegratedHelpInWPF_MarkupCompile.lref
MainWindow.baml
CommonResource.baml
WishlistView.baml
Settings.settings
IntegratedHelpInWPF.v11.suo
IntegratedHelpInWPF_Revised_.zip
Assembly
System.Windows.Interactivity.dll
IntegratedHelpInWPF.exe
IntegratedHelpInWPF.pdb
IntegratedHelpInWPF.vshost.exe
IntegratedHelpInWPF.vshost.exe.manifest
System.Windows.Interactivity.dll
IntegratedHelpInWPF.csproj.user
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
DetailsHelpView.baml
DynamicHelpView.baml
IntegratedHelpInWPF.csproj.GenerateResource.Cache
IntegratedHelpInWPF.csprojResolveAssemblyReference.cache
IntegratedHelpInWPF.exe
IntegratedHelpInWPF.g.resources
IntegratedHelpInWPF.pdb
IntegratedHelpInWPF.Properties.Resources.resources
IntegratedHelpInWPF_MarkupCompile.cache
IntegratedHelpInWPF_MarkupCompile.i.cache
IntegratedHelpInWPF_MarkupCompile.lref
MainWindow.baml
CommonResource.baml
Properties.Resources.Designer.cs.dll
WishlistView.baml
Settings.settings
IntegratedHelpInWPF.v11.suo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Microsoft.Win32;

namespace IntegratedHelpInWPF
{
    public static class Utility
    {
        public static DependencyObject GetParentObject(this DependencyObject child)
        {
            if (child == null) return null;

            //handle content elements separately
            var contentElement = child as ContentElement;
            if (contentElement != null)
            {
                DependencyObject parent = ContentOperations.GetParent(contentElement);
                if (parent != null) return parent;

                var fce = contentElement as FrameworkContentElement;
                return fce != null ? fce.Parent : null;
            }

            //also try searching for parent in framework elements (such as DockPanel, etc)
            var frameworkElement = child as FrameworkElement;
            if (frameworkElement != null)
            {
                DependencyObject parent = frameworkElement.Parent;
                if (parent != null) return parent;
            }

            //if it's not a ContentElement/FrameworkElement, rely on VisualTreeHelper
            return VisualTreeHelper.GetParent(child);
        }

        public static bool CheckParent(this DependencyObject child, DependencyObject parentToCheck)
        {
            if (child.Equals(parentToCheck))
                return true;
            //get parent item
            DependencyObject parentObject = GetParentObject(child);

            //we've reached the end of the tree
            if (parentObject == null)
                return false;
            //use recursion to proceed with next level
            return CheckParent(parentObject, parentToCheck);
        }

        /// <summary>
        /// method for retrieving the users default web browser
        /// </summary>
        /// <returns></returns>
        public static string GetSystemDefaultBrowser()
        {
            string name = string.Empty;
            RegistryKey regKey = null;

            try
            {
                //set the registry key we want to open
                regKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);

                //get rid of the enclosing quotes
                name = regKey.GetValue(null).ToString().ToLower().Replace("" + (char)34, "");

                //check to see if the value ends with .exe (this way we can remove any command line arguments)
                if (!name.EndsWith("exe"))
                    //get rid of all command line arguments (anything after the .exe must go)
                    name = name.Substring(0, name.LastIndexOf(".exe") + 4);

            }
            finally
            {
                //check and see if the key is still open, if so
                //then close it
                if (regKey != null)
                    regKey.Close();
            }
            //return the value
            return name;
        }
    }


}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Morshed Anwar
Team Leader Adaptive Enterprise Limited (www.ael-bd.com)
Bangladesh Bangladesh
No Biography provided

| Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 20 Jun 2013
Article Copyright 2012 by Morshed Anwar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid