Skip to content

945162: How to hide form field based on user in PdfViewer WPF control #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions FormFields/User-BasedFormFieldVisibility/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions FormFields/User-BasedFormFieldVisibility/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="User_BasedFormFieldVisibility.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:User_BasedFormFieldVisibility"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions FormFields/User-BasedFormFieldVisibility/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace User_BasedFormFieldVisibility
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;
using System.Windows.Resources;

namespace User_BasedFormFieldVisibility
{
public class EsigningPdfFormsViewModel
{
private Stream m_documentStream;
public EsigningPdfFormsViewModel()
{
this.Employees = new ObservableCollection<Employee>();
string andrewFilePath = "../../Data/profile1.png";
string anneFilePath = "../../Data/profile2.png";

Employees.Add(new Employee
{
Name = "Andrew Fuller",
ProfilePicture = GetFileStream("profile1.png"),
Mail = "[email protected]",
BorderColor = true,

});
Employees.Add(new Employee
{
Name = "Anne Dodsworth",
ProfilePicture = GetFileStream("profile2.png"),
Mail = "[email protected]",
BorderColor = false,

});
}

/// <summary>
/// Gets or sets the document path.
/// </summary>
public Stream DocumentStream
{
get
{
return m_documentStream;
}
set
{
m_documentStream = value;
}
}
/// <summary>
/// Gets or sets the collection of Employees.
/// </summary>
public ObservableCollection<Employee> Employees { get; set; }
private Stream GetFileStream(string filePath)
{
Uri uriResource = new Uri("/User-BasedFormFieldVisibility;component/Data/" + filePath, UriKind.Relative);
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(uriResource);
return streamResourceInfo.Stream;
}
}
/// <summary>
/// Class to represent the details of the Employees
/// </summary>
public class Employee
{
public string Name { get; set; }
public Stream ProfilePicture { get; set; }
public string Mail { get; set; }
public bool BorderColor { get; set; }

}
}
68 changes: 68 additions & 0 deletions FormFields/User-BasedFormFieldVisibility/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<Window xmlns:cc="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF" x:Class="User_BasedFormFieldVisibility.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:User_BasedFormFieldVisibility" xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:EsigningPdfFormsViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DockPanel>
<Grid>
<Grid.DataContext>
<local:EsigningPdfFormsViewModel/>
</Grid.DataContext>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<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">
<syncfusion:ComboBoxAdv.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border BorderBrush="White" BorderThickness="1" Background="Transparent" Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center">
<Border.CornerRadius>
<CornerRadius TopLeft="16" TopRight="16" BottomLeft="16" BottomRight="16"/>
</Border.CornerRadius>
<Image Source="{Binding ProfilePicture}" Stretch="Fill" Width="30" Height="30" />
</Border>
<Grid Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" >
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Name}" FontSize="13" Grid.Row="0"/>
<TextBlock Text="{Binding Mail}" FontSize="11" Grid.Row="1"/>
</Grid>
</Grid>
</DataTemplate>
</syncfusion:ComboBoxAdv.ItemTemplate>
</syncfusion:ComboBoxAdv>
<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" />
</Grid>
</DockPanel>
<cc:PdfViewerControl
x:Name="pdfviewer"
Grid.Row="1"
Margin="8,0,8,8"
AllowDrop="True"
BorderThickness="1"
WarnBeforeClose="False"
ItemSource="{Binding DocumentStream}"
ShowToolbar="False"
DocumentLoaded ="pdfviewer_DocumentLoaded"
ZoomMode="FitPage">
</cc:PdfViewerControl>
</Grid>
</Window>
Loading