mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
709645a195
Left over from when the built in wasn't working (it still only works partially) due to https://github.com/cefsharp/CefSharp/issues/1767 Improve comments and add links to make clearer
444 lines
21 KiB
XML
444 lines
21 KiB
XML
<UserControl x:Class="CefSharp.Wpf.Example.Views.BrowserTabView"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
|
|
xmlns:local="clr-namespace:CefSharp.Wpf.Example.ViewModels"
|
|
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
|
mc:Ignorable="d"
|
|
d:DesignWidth="640"
|
|
d:DesignHeight="480"
|
|
d:DataContext="{d:DesignInstance local:BrowserTabViewModel}">
|
|
<UserControl.Resources>
|
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
|
<ObjectDataProvider x:Key="BitmapScalingModeEnum" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
|
|
<ObjectDataProvider.MethodParameters>
|
|
<x:Type TypeName="BitmapScalingMode"/>
|
|
</ObjectDataProvider.MethodParameters>
|
|
</ObjectDataProvider>
|
|
</UserControl.Resources>
|
|
<Grid>
|
|
<DockPanel>
|
|
<DockPanel VerticalAlignment="Top"
|
|
DockPanel.Dock="Top">
|
|
<Button Height="23"
|
|
Width="75"
|
|
Command="{Binding HomeCommand}">Home</Button>
|
|
<Button Height="23"
|
|
Width="75"
|
|
Command="{Binding WebBrowser.BackCommand}">Back</Button>
|
|
<Button Height="23"
|
|
Width="75"
|
|
Command="{Binding WebBrowser.ForwardCommand}">Forward</Button>
|
|
<Button Height="23"
|
|
Width="75"
|
|
Command="{Binding WebBrowser.ReloadCommand}">Reload</Button>
|
|
<Button Height="23"
|
|
Name="goStopButton"
|
|
Width="75"
|
|
DockPanel.Dock="Right"
|
|
Command="{Binding GoCommand}">Go</Button>
|
|
<TextBox Height="23"
|
|
Text="{Binding AddressEditable, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
|
GotKeyboardFocus="OnTextBoxGotKeyboardFocus"
|
|
GotMouseCapture="OnTextBoxGotMouseCapture">
|
|
<TextBox.InputBindings>
|
|
<KeyBinding Key="Enter"
|
|
Command="{Binding GoCommand}" />
|
|
</TextBox.InputBindings>
|
|
</TextBox>
|
|
</DockPanel>
|
|
<StackPanel DockPanel.Dock="Right"
|
|
Margin="6,3"
|
|
Visibility="{Binding ShowSidebar, Converter={StaticResource BooleanToVisibilityConverter}}">
|
|
<GroupBox Header="Tweak WPF Rendering">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
<Label Grid.Row="0"
|
|
Grid.Column="0"
|
|
Content="Angle:" />
|
|
<Slider Grid.Row="0"
|
|
Grid.Column="1"
|
|
Name="angleSlider"
|
|
Minimum="-180"
|
|
Maximum="180" />
|
|
<Label Grid.Row="1"
|
|
Grid.Column="0"
|
|
Content="Watermark Opacity:" />
|
|
<Slider Grid.Row="1"
|
|
Grid.Column="1"
|
|
Name="opacitySlider"
|
|
Minimum="0"
|
|
Maximum="1"
|
|
TickFrequency="0.01"
|
|
Value="0.95" />
|
|
<Label Grid.Row="2"
|
|
Grid.Column="0"
|
|
Content="Bitmap Scaling Mode:" />
|
|
<ComboBox Grid.Row="2"
|
|
Grid.Column="1"
|
|
Name="scalingModeComboBox"
|
|
ItemsSource="{Binding Source={StaticResource BitmapScalingModeEnum}}"
|
|
SelectedIndex="1"/>
|
|
</Grid>
|
|
</GroupBox>
|
|
<GroupBox Header="Execute Javascript (asynchronously)">
|
|
<Grid Width="300">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="75" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<TextBox x:Name="ExecuteJavascriptTextBox"
|
|
Grid.Row="0"
|
|
AcceptsReturn="True"
|
|
Margin="6"
|
|
Text="$('#modify-me').text('See how easy that was?')">
|
|
<TextBox.InputBindings>
|
|
<KeyBinding Key="Enter"
|
|
Modifiers="Control"
|
|
Command="{Binding ExecuteJavaScriptCommand}"
|
|
CommandParameter="{Binding Text, RelativeSource={RelativeSource AncestorType=TextBox}}" />
|
|
</TextBox.InputBindings>
|
|
</TextBox>
|
|
<Button Grid.Row="1"
|
|
HorizontalAlignment="Left"
|
|
Margin="6,0,6,6"
|
|
Padding="5,2"
|
|
Content="Run"
|
|
Command="{Binding ExecuteJavaScriptCommand}"
|
|
CommandParameter="{Binding Text, ElementName=ExecuteJavascriptTextBox}" />
|
|
</Grid>
|
|
</GroupBox>
|
|
<GroupBox Header="Execute Javascript">
|
|
<Grid Width="300">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="75" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<TextBox x:Name="EvaluateJavascriptTextBox"
|
|
Grid.Row="0"
|
|
Margin="6"
|
|
AcceptsReturn="True"
|
|
Text="bound.subObject.simpleProperty = (bound.myProperty++).toString();">
|
|
<TextBox.InputBindings>
|
|
<KeyBinding Key="Enter"
|
|
Modifiers="Control"
|
|
Command="{Binding EvaluateJavaScriptCommand}"
|
|
CommandParameter="{Binding Text, RelativeSource={RelativeSource AncestorType=TextBox}}" />
|
|
</TextBox.InputBindings>
|
|
</TextBox>
|
|
<Button Grid.Row="1"
|
|
HorizontalAlignment="Left"
|
|
Margin="6,0"
|
|
Padding="5,2"
|
|
Content="Run"
|
|
Command="{Binding EvaluateJavaScriptCommand}"
|
|
CommandParameter="{Binding Text, ElementName=EvaluateJavascriptTextBox}" />
|
|
<TextBlock Grid.Row="2"
|
|
Margin="6">Result:</TextBlock>
|
|
</Grid>
|
|
</GroupBox>
|
|
<GroupBox Header="Tests">
|
|
<Button HorizontalAlignment="Left"
|
|
Margin="6,0"
|
|
Padding="5,2"
|
|
Command="{Binding JavascriptBindingStressTest}"
|
|
Content="Javascript Binding Stress Test"/>
|
|
</GroupBox>
|
|
</StackPanel>
|
|
<StackPanel
|
|
Margin="6,3"
|
|
DockPanel.Dock="Right"
|
|
Visibility="{Binding ShowDownloadInfo, Converter={StaticResource BooleanToVisibilityConverter}}"
|
|
>
|
|
<GroupBox Header="Download info">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto" />
|
|
<ColumnDefinition Width="*" MinWidth="50" />
|
|
</Grid.ColumnDefinitions>
|
|
<Label
|
|
Grid.Row="0"
|
|
Grid.Column="0"
|
|
Content="Last action:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="0"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding LastDownloadAction}"
|
|
/>
|
|
<Label
|
|
Grid.Row="1"
|
|
Grid.Column="0"
|
|
Content="IsInProgress:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="1"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.IsInProgress}"
|
|
/>
|
|
<Label
|
|
Grid.Row="2"
|
|
Grid.Column="0"
|
|
Content="IsComplete:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="2"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.IsComplete}"
|
|
/>
|
|
<Label
|
|
Grid.Row="3"
|
|
Grid.Column="0"
|
|
Content="IsCancelled:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="3"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.IsCancelled}"
|
|
/>
|
|
<Label
|
|
Grid.Row="4"
|
|
Grid.Column="0"
|
|
Content="CurrentSpeed:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="4"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.CurrentSpeed}"
|
|
/>
|
|
<Label
|
|
Grid.Row="5"
|
|
Grid.Column="0"
|
|
Content="PercentComplete:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="5"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.PercentComplete}"
|
|
/>
|
|
<Label
|
|
Grid.Row="6"
|
|
Grid.Column="0"
|
|
Content="TotalBytes:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="6"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.TotalBytes}"
|
|
/>
|
|
<Label
|
|
Grid.Row="7"
|
|
Grid.Column="0"
|
|
Content="ReceivedBytes:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="7"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.ReceivedBytes}"
|
|
/>
|
|
<Label
|
|
Grid.Row="8"
|
|
Grid.Column="0"
|
|
Content="StartTime:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="8"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.StartTime}"
|
|
/>
|
|
<Label
|
|
Grid.Row="9"
|
|
Grid.Column="0"
|
|
Content="EndTime:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="9"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.EndTime}"
|
|
/>
|
|
<Label
|
|
Grid.Row="10"
|
|
Grid.Column="0"
|
|
Content="FullPath:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="10"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.FullPath}"
|
|
/>
|
|
<Label
|
|
Grid.Row="11"
|
|
Grid.Column="0"
|
|
Content="Id:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="11"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.Id}"
|
|
/>
|
|
<Label
|
|
Grid.Row="12"
|
|
Grid.Column="0"
|
|
Content="Url:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="12"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.Url}"
|
|
/>
|
|
<Label
|
|
Grid.Row="13"
|
|
Grid.Column="0"
|
|
Content="OriginalUrl:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="13"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.OriginalUrl}"
|
|
/>
|
|
<Label
|
|
Grid.Row="14"
|
|
Grid.Column="0"
|
|
Content="SuggestedFileName:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="14"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.SuggestedFileName}"
|
|
/>
|
|
<Label
|
|
Grid.Row="15"
|
|
Grid.Column="0"
|
|
Content="ContentDisposition:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="15"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.ContentDisposition}"
|
|
/>
|
|
<Label
|
|
Grid.Row="16"
|
|
Grid.Column="0"
|
|
Content="MimeType:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="16"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.MimeType}"
|
|
/>
|
|
<Label
|
|
Grid.Row="17"
|
|
Grid.Column="0"
|
|
Content="IsValid:"
|
|
/>
|
|
<TextBox
|
|
Grid.Row="17"
|
|
Grid.Column="1"
|
|
IsReadOnly="True"
|
|
Text="{Binding DownloadItem.IsValid}"
|
|
/>
|
|
</Grid>
|
|
</GroupBox>
|
|
</StackPanel>
|
|
<StatusBar DockPanel.Dock="Bottom">
|
|
<ProgressBar HorizontalAlignment="Right"
|
|
IsIndeterminate="{Binding WebBrowser.IsLoading}"
|
|
Width="100"
|
|
Height="16"
|
|
Margin="3" />
|
|
<TextBlock Text="{Binding StatusMessage}" />
|
|
<Separator />
|
|
<TextBlock Text="{Binding OutputMessage}" />
|
|
</StatusBar>
|
|
<Grid Background="#FFF0F0F0">
|
|
<Rectangle>
|
|
<Rectangle.Fill>
|
|
<VisualBrush TileMode="Tile"
|
|
Viewport="0,0,500,90"
|
|
ViewportUnits="Absolute"
|
|
Opacity="0.05">
|
|
<VisualBrush.Visual>
|
|
<StackPanel>
|
|
<TextBlock Margin="6,12"
|
|
FontWeight="Bold">CefSharp Rocks!</TextBlock>
|
|
</StackPanel>
|
|
</VisualBrush.Visual>
|
|
<VisualBrush.Transform>
|
|
<RotateTransform Angle="-22.5" />
|
|
</VisualBrush.Transform>
|
|
</VisualBrush>
|
|
</Rectangle.Fill>
|
|
</Rectangle>
|
|
|
|
<cefSharp:ChromiumWebBrowser x:Name="browser"
|
|
Opacity="{Binding ElementName=opacitySlider, Path=Value}"
|
|
Address="{Binding Address, Mode=TwoWay}"
|
|
Title="{Binding Title, Mode=OneWayToSource}"
|
|
AllowDrop="True"
|
|
WebBrowser="{Binding WebBrowser, Mode=OneWayToSource}"
|
|
RenderOptions.BitmapScalingMode="{Binding ElementName=scalingModeComboBox, Path=SelectedItem}">
|
|
<!-- Just an example of how you may override the BrowserSettings. Disabled by default since it looks so
|
|
incredibly ugly... -->
|
|
<!--<cefSharp:ChromiumWebBrowser.BrowserSettings>
|
|
<CefSharp:BrowserSettings MinimumFontSize="36" />
|
|
</cefSharp:ChromiumWebBrowser.BrowserSettings>-->
|
|
<FrameworkElement.LayoutTransform>
|
|
<TransformGroup>
|
|
<RotateTransform Angle="{Binding Value, ElementName=angleSlider}" />
|
|
</TransformGroup>
|
|
</FrameworkElement.LayoutTransform>
|
|
</cefSharp:ChromiumWebBrowser>
|
|
</Grid>
|
|
</DockPanel>
|
|
</Grid>
|
|
</UserControl>
|