1) Added Hover Link, ChromiumVersion, CefVersion, CefSharpVersion, ProcessInfo in Status Bar. 2) Added Back, Forward, Print and View source buttons and Addressbar. (#36)
Add Primary Navigation/Address Bar and Status bar
This commit is contained in:
		
				
					committed by
					
						
						Alex Maitland
					
				
			
			
				
	
			
			
			
						parent
						
							75ccd029e0
						
					
				
				
					commit
					63d6b44f35
				
			@@ -1,9 +1,10 @@
 | 
				
			|||||||
<Application x:Class="CefSharp.MinimalExample.Wpf.App"
 | 
					<Application x:Class="CefSharp.MinimalExample.Wpf.App"
 | 
				
			||||||
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
					             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
             xmlns:binding="clr-namespace:CefSharp.MinimalExample.Wpf.Binding"
 | 
					             xmlns:converter="clr-namespace:CefSharp.MinimalExample.Wpf.Converter"
 | 
				
			||||||
             StartupUri="MainWindow.xaml">
 | 
					             StartupUri="MainWindow.xaml">
 | 
				
			||||||
    <Application.Resources>
 | 
					    <Application.Resources>
 | 
				
			||||||
        <binding:TitleConverter x:Key="TitleConverter"/>
 | 
					        <converter:TitleConverter x:Key="TitleConverter"/>
 | 
				
			||||||
 | 
					        <converter:EnvironmentConverter x:Key="EnvironmentConverter" />
 | 
				
			||||||
    </Application.Resources>
 | 
					    </Application.Resources>
 | 
				
			||||||
</Application>
 | 
					</Application>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										34
									
								
								CefSharp.MinimalExample.Wpf/Behaviours/HoverLinkBehaviour.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								CefSharp.MinimalExample.Wpf/Behaviours/HoverLinkBehaviour.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					using CefSharp.Wpf;
 | 
				
			||||||
 | 
					using System.Windows;
 | 
				
			||||||
 | 
					using System.Windows.Interactivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace CefSharp.MinimalExample.Wpf.Behaviours
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public class HoverLinkBehaviour : Behavior<ChromiumWebBrowser>
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Using a DependencyProperty as the backing store for HoverLink.  This enables animation, styling, binding, etc...
 | 
				
			||||||
 | 
					        public static readonly DependencyProperty HoverLinkProperty = DependencyProperty.Register("HoverLink", typeof(string), typeof(HoverLinkBehaviour), new PropertyMetadata(string.Empty));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string HoverLink
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get { return (string)GetValue(HoverLinkProperty); }
 | 
				
			||||||
 | 
					            set { SetValue(HoverLinkProperty, value); }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override void OnAttached()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            AssociatedObject.StatusMessage += OnStatusMessageChanged;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        protected override void OnDetaching()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            AssociatedObject.StatusMessage -= OnStatusMessageChanged;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        private void OnStatusMessageChanged(object sender, StatusMessageEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var dp = sender as ChromiumWebBrowser;
 | 
				
			||||||
 | 
					            dp.Dispatcher.Invoke(() => HoverLink = e.Value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -67,8 +67,16 @@
 | 
				
			|||||||
    <ApplicationManifest>app.manifest</ApplicationManifest>
 | 
					    <ApplicationManifest>app.manifest</ApplicationManifest>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
					    <Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
 | 
				
			||||||
 | 
					      <HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
 | 
				
			||||||
 | 
					      <Private>True</Private>
 | 
				
			||||||
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="System" />
 | 
					    <Reference Include="System" />
 | 
				
			||||||
    <Reference Include="System.Data" />
 | 
					    <Reference Include="System.Data" />
 | 
				
			||||||
 | 
					    <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
 | 
				
			||||||
 | 
					      <HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
 | 
				
			||||||
 | 
					      <Private>True</Private>
 | 
				
			||||||
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="System.Xml" />
 | 
					    <Reference Include="System.Xml" />
 | 
				
			||||||
    <Reference Include="Microsoft.CSharp" />
 | 
					    <Reference Include="Microsoft.CSharp" />
 | 
				
			||||||
    <Reference Include="System.Core" />
 | 
					    <Reference Include="System.Core" />
 | 
				
			||||||
@@ -94,7 +102,9 @@
 | 
				
			|||||||
      <DependentUpon>App.xaml</DependentUpon>
 | 
					      <DependentUpon>App.xaml</DependentUpon>
 | 
				
			||||||
      <SubType>Code</SubType>
 | 
					      <SubType>Code</SubType>
 | 
				
			||||||
    </Compile>
 | 
					    </Compile>
 | 
				
			||||||
    <Compile Include="Binding\TitleConverter.cs" />
 | 
					    <Compile Include="Behaviours\HoverLinkBehaviour.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Converter\EnvironmentConverter.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Converter\TitleConverter.cs" />
 | 
				
			||||||
    <Compile Include="MainWindow.xaml.cs">
 | 
					    <Compile Include="MainWindow.xaml.cs">
 | 
				
			||||||
      <DependentUpon>MainWindow.xaml</DependentUpon>
 | 
					      <DependentUpon>MainWindow.xaml</DependentUpon>
 | 
				
			||||||
      <SubType>Code</SubType>
 | 
					      <SubType>Code</SubType>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Globalization;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace CefSharp.MinimalExample.Wpf.Converter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    class EnvironmentConverter : System.Windows.Data.IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return Environment.Is64BitProcess ? "x64" : "x86";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return System.Windows.Data.Binding.DoNothing;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
using System.Globalization;
 | 
					using System.Globalization;
 | 
				
			||||||
using System.Windows.Data;
 | 
					using System.Windows.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace CefSharp.MinimalExample.Wpf.Binding
 | 
					namespace CefSharp.MinimalExample.Wpf.Converter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class TitleConverter : IValueConverter
 | 
					    public class TitleConverter : IValueConverter
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -2,25 +2,81 @@
 | 
				
			|||||||
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
					        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
				
			||||||
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
					        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
				
			||||||
        xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
 | 
					        xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
 | 
				
			||||||
 | 
					        xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core"
 | 
				
			||||||
 | 
					        xmlns:behaviours="clr-namespace:CefSharp.MinimalExample.Wpf.Behaviours"
 | 
				
			||||||
 | 
					        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
 | 
				
			||||||
        Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}"
 | 
					        Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}"
 | 
				
			||||||
        WindowState="Maximized">
 | 
					        WindowState="Maximized">
 | 
				
			||||||
 | 
					    <Window.Resources>
 | 
				
			||||||
 | 
					        <cef:Cef x:Key="Cef" />
 | 
				
			||||||
 | 
					    </Window.Resources>
 | 
				
			||||||
    <Grid>
 | 
					    <Grid>
 | 
				
			||||||
        <Grid.RowDefinitions>
 | 
					        <Grid.RowDefinitions>
 | 
				
			||||||
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
            <RowDefinition />
 | 
					            <RowDefinition />
 | 
				
			||||||
            <RowDefinition Height="Auto" />
 | 
					            <RowDefinition Height="Auto" />
 | 
				
			||||||
        </Grid.RowDefinitions>
 | 
					        </Grid.RowDefinitions>
 | 
				
			||||||
        <wpf:ChromiumWebBrowser Grid.Row="0"
 | 
					        <Grid>
 | 
				
			||||||
                                x:Name="Browser"
 | 
					            <Grid.Resources>
 | 
				
			||||||
                                Address="http://www.google.com" />
 | 
					                <Style TargetType="{x:Type Button}">
 | 
				
			||||||
        <StatusBar Grid.Row="1">
 | 
					                    <Setter Property="Margin" Value="2,5" />
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					                <Style TargetType="{x:Type TextBox}">
 | 
				
			||||||
 | 
					                    <Setter Property="Margin" Value="2,5" />
 | 
				
			||||||
 | 
					                </Style>
 | 
				
			||||||
 | 
					            </Grid.Resources>
 | 
				
			||||||
 | 
					            <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                <ColumnDefinition />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					            </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					            <Button Content="Back" Command="{Binding WebBrowser.BackCommand, ElementName=Browser}" Width="50"/>
 | 
				
			||||||
 | 
					            <Button Content="Forward" Command="{Binding WebBrowser.ForwardCommand, ElementName=Browser}" Grid.Column="1" Width="60"/>
 | 
				
			||||||
 | 
					            <TextBox x:Name="txtBoxAddress" Text="{Binding Address, ElementName=Browser, FallbackValue=www.google.com}" Grid.Column="2" FontSize="12" BorderBrush="Gray" BorderThickness="1" />
 | 
				
			||||||
 | 
					            <Button Content="Print..." Command="{Binding WebBrowser.PrintCommand, ElementName=Browser}" Grid.Column="3" Width="50" />
 | 
				
			||||||
 | 
					            <Button Content="View source" Command="{Binding WebBrowser.ViewSourceCommand, ElementName=Browser}" Grid.Column="4" Width="75" />
 | 
				
			||||||
 | 
					        </Grid>
 | 
				
			||||||
 | 
					        <Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1">
 | 
				
			||||||
 | 
					            <wpf:ChromiumWebBrowser x:Name="Browser"
 | 
				
			||||||
 | 
					                                    Address="{Binding Text, ElementName=txtBoxAddress}">
 | 
				
			||||||
 | 
					                <i:Interaction.Behaviors>
 | 
				
			||||||
 | 
					                    <behaviours:HoverLinkBehaviour x:Name="HoverLinkBehaviour"/>
 | 
				
			||||||
 | 
					                </i:Interaction.Behaviors>
 | 
				
			||||||
 | 
					            </wpf:ChromiumWebBrowser>
 | 
				
			||||||
 | 
					        </Border>
 | 
				
			||||||
 | 
					        <StatusBar Grid.Row="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
 | 
				
			||||||
 | 
					            <StatusBar.ItemsPanel>
 | 
				
			||||||
 | 
					                <ItemsPanelTemplate>
 | 
				
			||||||
 | 
					                    <Grid>
 | 
				
			||||||
 | 
					                        <Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                            <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                            <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                            <ColumnDefinition Width="*" />
 | 
				
			||||||
 | 
					                            <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                            <ColumnDefinition Width="Auto" />
 | 
				
			||||||
 | 
					                        </Grid.ColumnDefinitions>
 | 
				
			||||||
 | 
					                    </Grid>
 | 
				
			||||||
 | 
					                </ItemsPanelTemplate>
 | 
				
			||||||
 | 
					            </StatusBar.ItemsPanel>
 | 
				
			||||||
 | 
					            <StatusBarItem>
 | 
				
			||||||
                <ProgressBar HorizontalAlignment="Right"
 | 
					                <ProgressBar HorizontalAlignment="Right"
 | 
				
			||||||
                             IsIndeterminate="{Binding IsLoading, ElementName=Browser}"
 | 
					                             IsIndeterminate="{Binding IsLoading, ElementName=Browser}"
 | 
				
			||||||
                             Width="100"
 | 
					                             Width="100"
 | 
				
			||||||
                             Height="16"
 | 
					                             Height="16"
 | 
				
			||||||
                             Margin="3" />
 | 
					                             Margin="3" />
 | 
				
			||||||
            <Separator />
 | 
					            </StatusBarItem>
 | 
				
			||||||
            <!-- TODO: Could show hover link URL here -->
 | 
					            <Separator Grid.Column="1" />
 | 
				
			||||||
            <TextBlock Text="{Binding Address, ElementName=Browser}"/>
 | 
					            <StatusBarItem Grid.Column="2">
 | 
				
			||||||
 | 
					                <TextBlock Text="{Binding HoverLink, ElementName=HoverLinkBehaviour}" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
 | 
				
			||||||
 | 
					            </StatusBarItem>
 | 
				
			||||||
 | 
					            <Separator Grid.Column="3" />
 | 
				
			||||||
 | 
					            <StatusBarItem Grid.Column="4">
 | 
				
			||||||
 | 
					                <TextBlock HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="3" VerticalAlignment="Center">
 | 
				
			||||||
 | 
					                Chromium: <Run Text="{Binding ChromiumVersion, Source={StaticResource Cef}, Mode=OneTime}" />, CEF: <Run Text="{Binding CefVersion, Source={StaticResource Cef}, Mode=OneTime}" />, CefSharp: <Run Text="{Binding CefSharpVersion, Source={StaticResource Cef}, Mode=OneTime}"/>, Environment: <Run Text="{Binding Converter={StaticResource EnvironmentConverter}, Mode=OneTime}"/>
 | 
				
			||||||
 | 
					                </TextBlock>
 | 
				
			||||||
 | 
					            </StatusBarItem>
 | 
				
			||||||
        </StatusBar>
 | 
					        </StatusBar>
 | 
				
			||||||
    </Grid>
 | 
					    </Grid>
 | 
				
			||||||
</Window>
 | 
					</Window>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,4 +4,5 @@
 | 
				
			|||||||
  <package id="cef.redist.x86" version="3.2883.1552" targetFramework="net452" />
 | 
					  <package id="cef.redist.x86" version="3.2883.1552" targetFramework="net452" />
 | 
				
			||||||
  <package id="CefSharp.Common" version="55.0.0" targetFramework="net452" />
 | 
					  <package id="CefSharp.Common" version="55.0.0" targetFramework="net452" />
 | 
				
			||||||
  <package id="CefSharp.Wpf" version="55.0.0" targetFramework="net452" />
 | 
					  <package id="CefSharp.Wpf" version="55.0.0" targetFramework="net452" />
 | 
				
			||||||
 | 
					  <package id="System.Windows.Interactivity.WPF" version="2.0.20525" targetFramework="net452" />
 | 
				
			||||||
</packages>
 | 
					</packages>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user