Skip to content
Closed
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
31 changes: 31 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34310.174
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomSearchToolbar", "CustomSearchToolbar\CustomSearchToolbar.csproj", "{BBA73B1E-E93D-461F-BB81-E01B79006E3A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-Xml|Any CPU = Release-Xml|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Release|Any CPU.Build.0 = Release|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Release|Any CPU.Deploy.0 = Release|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
{BBA73B1E-E93D-461F-BB81-E01B79006E3A}.Release-Xml|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E68A9110-FEBA-46B4-8E01-5F1B0008A776}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomSearchToolbar"
x:Class="CustomSearchToolbar.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace CustomSearchToolbar
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
}
15 changes: 15 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="CustomSearchToolbar.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomSearchToolbar"
Shell.FlyoutBehavior="Disabled"
Title="CustomSearchToolbar">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CustomSearchToolbar
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
84 changes: 84 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/CustomSearchToolbar.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>CustomSearchToolbar</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>CustomSearchToolbar</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.customsearchtoolbar</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<None Remove="zero_degree_rotated_document.pdf" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="zero_degree_rotated_document.pdf" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Syncfusion.Maui.PdfViewer" Version="100.2.276" />
<PackageReference Include="Syncfusion.Compression.NET" Version="*" />
<PackageReference Include="Syncfusion.Maui.Core" Version="*" />
<PackageReference Include="Syncfusion.Maui.SignaturePad" Version="*" />
<PackageReference Include="Syncfusion.Maui.DataSource" Version="*" />
<PackageReference Include="Syncfusion.Maui.GridCommon" Version="*" />
<PackageReference Include="Syncfusion.Maui.ListView" Version="*" />
<PackageReference Include="Syncfusion.Maui.PdfToImageConverter" Version="*" />
<PackageReference Include="Syncfusion.Pdf.NET" Version="*" />
<PackageReference Include="Syncfusion.Pdf.Imaging.NET" Version="*" />
<PackageReference Include="Syncfusion.Maui.PdfViewer" Version="*" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CustomSearchToolbar.MainPage"
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer">
<Grid RowDefinitions="45,*">
<syncfusion:SfPdfViewer Grid.Row="1" x:Name="PdfViewer"></syncfusion:SfPdfViewer>
<Grid Grid.Row="0" BackgroundColor="#FFF7F2FB">
<HorizontalStackLayout HorizontalOptions="Center">
<Entry Placeholder="Search text..." Background="White" ClearButtonVisibility="WhileEditing" x:Name="TextField" WidthRequest="280"></Entry>
<Button Text="&#xe715;" TextColor="#1C1B1F" FontSize="20" FontFamily="Maui Material Assets" Background="Transparent" x:Name="Search" Clicked="Search_Clicked"></Button>
<Button x:Name="Previous" Text="&#xe707;" FontSize="20" TextColor="#1C1B1F" FontFamily="Maui Material Assets" Background="Transparent" Clicked="Previous_Clicked"></Button>
<Button x:Name="Next" Text="&#xe706;" FontSize="20" TextColor="#1C1B1F" FontFamily="Maui Material Assets" Background="Transparent" Clicked="Next_Clicked"></Button>
<Label Margin="5,0" VerticalOptions="Center" TextColor="#1C1B1F" Text="Match case"></Label>
<CheckBox x:Name="MatchCase" IsChecked="False" CheckedChanged="Search_Clicked"></CheckBox>
<Button x:Name="ChangeHightlightColor" FontSize="20" Text="&#xe710;" FontFamily="Maui Material Assets" Background="Transparent" TextColor="#1C1B1F" Clicked="ChangeHightlightColor_Clicked"></Button>
<Button x:Name="Close" Text="&#xe70e;" FontSize="20" FontFamily="Maui Material Assets" Background="Transparent" TextColor="#1C1B1F" Clicked="Close_Clicked"></Button>
<Label Margin="5,0" VerticalOptions="Center" IsVisible="false" x:Name="MatchesCount" Text="Matches count: " Background="Transparent" TextColor="#1C1B1F"></Label>
<Label Margin="5,0" VerticalOptions="Center" IsVisible="false" x:Name="CurrentMatch" Text="Current Match: " Background="Transparent" TextColor="#1C1B1F"></Label>
</HorizontalStackLayout>
</Grid>
</Grid>

</ContentPage>
86 changes: 86 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using Syncfusion.Maui.PdfViewer;
using System.Reflection;

namespace CustomSearchToolbar
{
public partial class MainPage : ContentPage
{
Stream? m_pdfDocumentStream;
TextSearchResult? SearchResult;
public MainPage()
{
InitializeComponent();

// Load PDF document from resources
m_pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("CustomSearchToolbar.zero_degree_rotated_document.pdf");
PdfViewer.LoadDocument(m_pdfDocumentStream);
}

//Event handler for the search button click, initiates a text search in a PDF viewer.
private async void Search_Clicked(object sender, EventArgs e)
{
// Set search options based on user preferences.
TextSearchOptions options = SetSearchOptions();

// Perform an asynchronous text search in the PDF viewer.
SearchResult = await PdfViewer.SearchTextAsync(TextField.Text, options);

if(SearchResult != null)
{
// Display an alert message based on the outcome.
if (SearchResult.TotalMatchesCount == 0)
await DisplayAlert("No Match Found!", "Sorry, no matches found. Please try different keywords", "Cancel");
else
{
// Update UI to show the total matches count and the current match index.
MatchesCount.IsVisible = true;
MatchesCount.Text = "Matches count: " + SearchResult.TotalMatchesCount.ToString();
CurrentMatch.IsVisible = true;
CurrentMatch.Text = "Current Match: " + SearchResult.CurrentMatchIndex.ToString();
}
}
}

// Set search options based on user preferences.
private TextSearchOptions SetSearchOptions()
{
TextSearchOptions options = new TextSearchOptions();
options = TextSearchOptions.None;
if (MatchCase.IsChecked)
options = TextSearchOptions.CaseSensitive;
return options;
}

// Moves to the previous match in the search results.
private void Previous_Clicked(object sender, EventArgs e)
{
SearchResult?.GoToPreviousMatch();
CurrentMatch.IsVisible = true;
CurrentMatch.Text = "Current Match: " + SearchResult?.CurrentMatchIndex.ToString();
}

//Moves to the next match in the search results.
private void Next_Clicked(object sender, EventArgs e)
{
SearchResult?.GoToNextMatch();
CurrentMatch.IsVisible = true;
CurrentMatch.Text = "Current Match: " + SearchResult?.CurrentMatchIndex.ToString();
}

//Changes settings of the highlight colors for the current and other matches in the PDF viewer.
private void ChangeHightlightColor_Clicked(object sender, EventArgs e)
{
PdfViewer.TextSearchSettings.CurrentMatchHighlightColor = Color.FromRgba("#8F00FF43");
PdfViewer.TextSearchSettings.OtherMatchesHighlightColor = Color.FromRgba("#00FF0043");
}

//Clears the search results and updates UI elements after closing the search.
private void Close_Clicked(object sender, EventArgs e)
{
SearchResult?.Clear();
MatchesCount.Text = "Matches count: " + SearchResult?.TotalMatchesCount.ToString();
CurrentMatch.Text = "Current Match: " + SearchResult?.CurrentMatchIndex.ToString();
}
}

}
26 changes: 26 additions & 0 deletions CustomSearchToolbar/CustomSearchToolbar/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Syncfusion.Maui.Core.Hosting;
using Microsoft.Extensions.Logging;

namespace CustomSearchToolbar
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

#if DEBUG
builder.Logging.AddDebug();
#endif
builder.ConfigureSyncfusionCore();
return builder.Build();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace CustomSearchToolbar
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Android.App;
using Android.Runtime;

namespace CustomSearchToolbar
{
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Foundation;

namespace CustomSearchToolbar
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
<dict>
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
<key>com.apple.security.app-sandbox</key>
<true/>
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

Loading