Skip to content

Commit 683c307

Browse files
945162: How to hide form field based on user in PdfViewer WPF control
1 parent 517cf32 commit 683c307

17 files changed

+896
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="User_BasedFormFieldVisibility.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:User_BasedFormFieldVisibility"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace User_BasedFormFieldVisibility
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
Binary file not shown.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Collections.ObjectModel;
3+
using System.IO;
4+
using System.Windows;
5+
using System.Windows.Resources;
6+
7+
namespace User_BasedFormFieldVisibility
8+
{
9+
public class EsigningPdfFormsViewModel
10+
{
11+
private Stream m_documentStream;
12+
public EsigningPdfFormsViewModel()
13+
{
14+
this.Employees = new ObservableCollection<Employee>();
15+
string andrewFilePath = "../../Data/profile1.png";
16+
string anneFilePath = "../../Data/profile2.png";
17+
18+
Employees.Add(new Employee
19+
{
20+
Name = "Andrew Fuller",
21+
ProfilePicture = GetFileStream("profile1.png"),
22+
23+
BorderColor = true,
24+
25+
});
26+
Employees.Add(new Employee
27+
{
28+
Name = "Anne Dodsworth",
29+
ProfilePicture = GetFileStream("profile2.png"),
30+
31+
BorderColor = false,
32+
33+
});
34+
}
35+
36+
/// <summary>
37+
/// Gets or sets the document path.
38+
/// </summary>
39+
public Stream DocumentStream
40+
{
41+
get
42+
{
43+
return m_documentStream;
44+
}
45+
set
46+
{
47+
m_documentStream = value;
48+
}
49+
}
50+
/// <summary>
51+
/// Gets or sets the collection of Employees.
52+
/// </summary>
53+
public ObservableCollection<Employee> Employees { get; set; }
54+
private Stream GetFileStream(string filePath)
55+
{
56+
Uri uriResource = new Uri("/User-BasedFormFieldVisibility;component/Data/" + filePath, UriKind.Relative);
57+
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(uriResource);
58+
return streamResourceInfo.Stream;
59+
}
60+
}
61+
/// <summary>
62+
/// Class to represent the details of the Employees
63+
/// </summary>
64+
public class Employee
65+
{
66+
public string Name { get; set; }
67+
public Stream ProfilePicture { get; set; }
68+
public string Mail { get; set; }
69+
public bool BorderColor { get; set; }
70+
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<Window xmlns:cc="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF" x:Class="User_BasedFormFieldVisibility.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:User_BasedFormFieldVisibility" xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
7+
mc:Ignorable="d"
8+
Title="MainWindow" Height="450" Width="800">
9+
<Window.DataContext>
10+
<local:EsigningPdfFormsViewModel/>
11+
</Window.DataContext>
12+
<Grid>
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="50" />
15+
<RowDefinition Height="*" />
16+
</Grid.RowDefinitions>
17+
<DockPanel>
18+
<Grid>
19+
<Grid.DataContext>
20+
<local:EsigningPdfFormsViewModel/>
21+
</Grid.DataContext>
22+
<Grid.ColumnDefinitions>
23+
<ColumnDefinition Width="6*" />
24+
<ColumnDefinition Width="2*" />
25+
</Grid.ColumnDefinitions>
26+
<syncfusion:ComboBoxAdv x:Name="comboBox" Grid.Row="0" Grid.Column="0" Height="38" Width="220" Margin="10,5,0,5" HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding Employees}" SelectedIndex="0" SelectionChanged="ComboBoxAdv_SelectionChanged">
27+
<syncfusion:ComboBoxAdv.ItemTemplate>
28+
<DataTemplate>
29+
<Grid>
30+
<Grid.ColumnDefinitions>
31+
<ColumnDefinition Width="45"/>
32+
<ColumnDefinition Width="*"/>
33+
</Grid.ColumnDefinitions>
34+
<Border BorderBrush="White" BorderThickness="1" Background="Transparent" Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center">
35+
<Border.CornerRadius>
36+
<CornerRadius TopLeft="16" TopRight="16" BottomLeft="16" BottomRight="16"/>
37+
</Border.CornerRadius>
38+
<Image Source="{Binding ProfilePicture}" Stretch="Fill" Width="30" Height="30" />
39+
</Border>
40+
<Grid Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" >
41+
<Grid.RowDefinitions>
42+
<RowDefinition Height="*"></RowDefinition>
43+
<RowDefinition Height="*"></RowDefinition>
44+
</Grid.RowDefinitions>
45+
<TextBlock Text="{Binding Name}" FontSize="13" Grid.Row="0"/>
46+
<TextBlock Text="{Binding Mail}" FontSize="11" Grid.Row="1"/>
47+
</Grid>
48+
</Grid>
49+
</DataTemplate>
50+
</syncfusion:ComboBoxAdv.ItemTemplate>
51+
</syncfusion:ComboBoxAdv>
52+
<syncfusion:ButtonAdv x:Name="buttonAdv" Label="Finish Signing" IconHeight="0" IconWidth="0" Grid.Column="1" Margin="0,0,10,0" Width="150" Height="40" BorderThickness="3" CornerRadius="5" HorizontalAlignment="Right" VerticalAlignment="Center" Click="button_Click" />
53+
</Grid>
54+
</DockPanel>
55+
<cc:PdfViewerControl
56+
x:Name="pdfviewer"
57+
Grid.Row="1"
58+
Margin="8,0,8,8"
59+
AllowDrop="True"
60+
BorderThickness="1"
61+
WarnBeforeClose="False"
62+
ItemSource="{Binding DocumentStream}"
63+
ShowToolbar="False"
64+
DocumentLoaded ="pdfviewer_DocumentLoaded"
65+
ZoomMode="FitPage">
66+
</cc:PdfViewerControl>
67+
</Grid>
68+
</Window>

0 commit comments

Comments
 (0)