Skip to content

Commit 7d87e53

Browse files
authored
Merge pull request #4 from SyncfusionExamples/PdfViewer-AI
Smart Summarization sample for the WPF PdfViewer
2 parents 261f0ff + 4f6ef84 commit 7d87e53

12 files changed

+713
-0
lines changed

Smart_Summarize/AIResultChatBox.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
using Syncfusion.Windows.Shared;
4+
5+
namespace Smart_Summarize
6+
{
7+
internal class AIResultChatBox : Border
8+
{
9+
static AIResultChatBox()
10+
{
11+
DefaultStyleKeyProperty.OverrideMetadata(typeof(AIResultChatBox), new FrameworkPropertyMetadata(typeof(AIResultChatBox)));
12+
}
13+
14+
15+
public void ApplyStyle()
16+
{
17+
this.HorizontalAlignment = HorizontalAlignment.Left;
18+
this.MaxWidth = 300;
19+
this.CornerRadius = new CornerRadius(5);
20+
this.BorderThickness = new Thickness(2);
21+
this.Margin = new Thickness(10);
22+
this.SetResourceReference(Button.BackgroundProperty, "SecondaryBackground");
23+
this.SetResourceReference(Button.ForegroundProperty, "SecondaryForeground");
24+
}
25+
}
26+
}

Smart_Summarize/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="Smart_Summarize.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:Smart_Summarize"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

Smart_Summarize/App.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace Smart_Summarize
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
14+
}

Smart_Summarize/AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

Smart_Summarize/ChatTextBlock.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
4+
namespace Smart_Summarize
5+
{
6+
internal class ChatTextBlock : TextBlock
7+
{
8+
static ChatTextBlock()
9+
{
10+
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChatTextBlock), new FrameworkPropertyMetadata(typeof(ChatTextBlock)));
11+
}
12+
13+
public void ApplyStyle()
14+
{
15+
this.MaxWidth = 300;
16+
this.TextWrapping = TextWrapping.Wrap;
17+
this.Margin = new Thickness(5);
18+
this.FontSize = 12;
19+
}
20+
}
21+
}
217 KB
Binary file not shown.

Smart_Summarize/MainWindow.xaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Window x:Class="Smart_Summarize.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:Smart_Summarize"
7+
xmlns:PdfViewer="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
8+
xmlns:Notification="clr-namespace:Syncfusion.Windows.Controls.Notification;assembly=Syncfusion.SfBusyIndicator.WPF"
9+
xmlns:syncfusionskin ="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
10+
mc:Ignorable="d"
11+
Title="MainWindow" Height="450" Width="800" WindowState="Maximized"
12+
syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManagerExtension ThemeName=Windows11Light}">
13+
<Grid>
14+
<Grid.ColumnDefinitions>
15+
<ColumnDefinition Width="7*"/>
16+
<ColumnDefinition Width="auto"/>
17+
</Grid.ColumnDefinitions>
18+
<PdfViewer:PdfViewerControl x:Name="pdfViewer" Grid.Column="0" Loaded="pdfViewer_Loaded" DocumentLoaded="pdfViewer_DocumentLoaded"/>
19+
<Grid x:Name="summarizeGrid" Grid.Column="1" Visibility="Collapsed">
20+
<Grid.RowDefinitions>
21+
<RowDefinition Height="41"/>
22+
<RowDefinition/>
23+
</Grid.RowDefinitions>
24+
<Grid.ColumnDefinitions>
25+
<ColumnDefinition Width="2"/>
26+
<ColumnDefinition/>
27+
</Grid.ColumnDefinitions>
28+
<Border x:Name="seperator" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderThickness="1,0,0,0"/>
29+
<Label x:Name="aI_Title" Grid.Row="0" Grid.Column="1" FontSize="14" Padding="6,12,0,0" Content="AI Assist" Width="350" HorizontalAlignment="Left"/>
30+
<Grid x:Name="chatGrid" Grid.Row="1" Grid.Column="1">
31+
<Grid.RowDefinitions>
32+
<RowDefinition/>
33+
<RowDefinition Height="Auto"/>
34+
</Grid.RowDefinitions>
35+
<ScrollViewer Grid.Row="0" x:Name="ChatViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" >
36+
<StackPanel x:Name="chatStack" Orientation="Vertical" >
37+
</StackPanel>
38+
</ScrollViewer>
39+
<StackPanel x:Name="inputStack" Grid.Row="1" Orientation="Horizontal">
40+
<Grid>
41+
<TextBox x:Name="inputText" Width="340" Padding="0,10,35,10" MinHeight="40" VerticalContentAlignment="Top" AcceptsReturn="True" MaxHeight="90" Margin="5,10" TextWrapping="Wrap" GotFocus="inputText_GotFocus" LostFocus="inputText_LostFocus"/>
42+
<Button x:Name="sendButton" Margin="5,10,6,15" Height="25" Width="25" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="sendButton_Click">
43+
<Button.Content>
44+
<Path Data="M0.175518 0.119595C0.324511 -0.00749701 0.533985 -0.0359071 0.711447 0.0469087L15.7114 7.04691C15.8875 7.12906 16 7.30574 16 7.5C16 7.69426 15.8875 7.87094 15.7114 7.95309L0.711447 14.9531C0.533985 15.0359 0.324511 15.0075 0.175518 14.8804C0.0265241 14.7533 -0.0345577 14.5509 0.0192423 14.3626L1.98 7.5L0.0192423 0.637361C-0.0345577 0.449061 0.0265241 0.246686 0.175518 0.119595ZM2.87716 8L1.28191 13.5833L14.3177 7.5L1.28191 1.41666L2.87716 7H9.5C9.77615 7 10 7.22386 10 7.5C10 7.77614 9.77615 8 9.5 8H2.87716Z"
45+
Height="14" Width="16" Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"/>
46+
</Button.Content>
47+
</Button>
48+
</Grid>
49+
</StackPanel>
50+
</Grid>
51+
<Canvas x:Name="loadingCanvas" Grid.Row="1" Grid.Column="1" Background="White" Opacity="0.5" Visibility="Collapsed"/>
52+
<Notification:SfBusyIndicator x:Name="loadingIndicator" Grid.Row="1" Grid.Column="1" Visibility="Collapsed" IsBusy="True" AnimationType="DotCircle" ViewboxHeight="75" ViewboxWidth="150"/>
53+
</Grid>
54+
</Grid>
55+
</Window>

0 commit comments

Comments
 (0)