v22.1.34
|
@ -0,0 +1,19 @@
|
|||
Any raw assets you want to be deployed with your application can be placed in
|
||||
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||
|
||||
These files will be deployed with you package and will be accessible using Android's
|
||||
AssetManager, like this:
|
||||
|
||||
public class ReadAsset : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
InputStream input = Assets.Open ("my_asset.txt");
|
||||
}
|
||||
}
|
||||
|
||||
Additionally, some Android functions will automatically load asset files:
|
||||
|
||||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
|
@ -0,0 +1,37 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content.PM;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Android.OS;
|
||||
|
||||
namespace SampleBrowser.DocIO.Droid
|
||||
{
|
||||
[Activity(Label = "SampleBrowser DocIO", MainLauncher = false, Icon = "@drawable/AppIcon", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||
{
|
||||
internal static MainActivity MainPageActivity;
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
TabLayoutResource = Resource.Layout.Tabbar;
|
||||
ToolbarResource = Resource.Layout.Toolbar;
|
||||
|
||||
base.OnCreate(bundle);
|
||||
MainPageActivity = this;
|
||||
|
||||
global::Xamarin.Forms.Forms.Init(this, bundle);
|
||||
Core.Droid.CoreSampleBrowser.Init(Resources, this);
|
||||
LoadApplication(new App());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.syncfusion.samplebrowser.docio">
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<application android:label="DocIO Sample">
|
||||
<provider android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,41 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.App;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SampleBrowser.DocIO.Droid")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Syncfusion Inc.")]
|
||||
[assembly: AssemblyProduct("SampleBrowser.DocIO.Droid")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2001-2023 Syncfusion Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly:Preserve]
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
// Add some common permissions, these can be removed if not needed
|
||||
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
|
||||
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/sliding_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabGravity="fill"
|
||||
app:tabMode="fixed" />
|
|
@ -0,0 +1,9 @@
|
|||
<android.support.v7.widget.Toolbar
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<resources>
|
||||
|
||||
<style name="MainTheme" parent="MainTheme.Base">
|
||||
</style>
|
||||
<!-- Base theme applied no matter what API -->
|
||||
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
|
||||
<item name="windowNoTitle">true</item>
|
||||
<!--We will be using the toolbar so no need to show ActionBar-->
|
||||
<item name="windowActionBar">false</item>
|
||||
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
|
||||
<!-- colorPrimary is used for the default action bar background -->
|
||||
<item name="colorPrimary">#2196F3</item>
|
||||
<!-- colorPrimaryDark is used for the status bar -->
|
||||
<item name="colorPrimaryDark">#1976D2</item>
|
||||
<!-- colorAccent is used as the default value for colorControlActivated
|
||||
which is used to tint widgets -->
|
||||
<item name="colorAccent">#FF4081</item>
|
||||
<!-- You can also set colorControlNormal, colorControlActivated
|
||||
colorControlHighlight and colorSwitchThumbNormal. -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
|
||||
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
|
||||
</style>
|
||||
|
||||
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
|
||||
<item name="colorAccent">#FF4081</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
</paths>
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DEC3BC88-6A26-4282-BF1B-0D5989F58CB1}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>SampleBrowser.DocIO.Droid</RootNamespace>
|
||||
<AssemblyName>SampleBrowser.DocIO.Android</AssemblyName>
|
||||
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
|
||||
<AndroidApplication>True</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidManagedSymbols>true</AndroidManagedSymbols>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Resources\Resource.Designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SaveAndroid.cs" />
|
||||
<Compile Include="SplashScreenActivity.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Assets\AboutAssets.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Tabbar.axml" />
|
||||
<AndroidResource Include="Resources\layout\Toolbar.axml" />
|
||||
<AndroidResource Include="Resources\values\styles.xml" />
|
||||
<AndroidResource Include="Resources\xml\provider_paths.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SampleBrowser.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.DataSource" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.GridCommon" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.SfListView" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Buttons" Version="22.1.34" />
|
||||
<Reference Include="Mono.Android.Export" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
|
||||
<PackageReference Include="Xamarin.AndroidX.AppCompat">
|
||||
<Version>1.2.6</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DocIO\SampleBrowser.DocIO.csproj">
|
||||
<Project>{EB5CBDB6-C051-446B-BDDF-A00B0F1829D1}</Project>
|
||||
<Name>SampleBrowser.DocIO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\SaveAndroid.cs">
|
||||
<Link>DocIO\SaveAndroid.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,116 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using System.IO;
|
||||
using Android.Content;
|
||||
using Java.IO;
|
||||
using Xamarin.Forms;
|
||||
using System.Threading.Tasks;
|
||||
using SampleBrowser.DocIO.Droid;
|
||||
using SampleBrowser.Core;
|
||||
using AndroidX.Core.Content;
|
||||
|
||||
[assembly: Dependency(typeof(SaveAndroid))]
|
||||
[assembly: Dependency(typeof(MailService))]
|
||||
namespace SampleBrowser.DocIO.Droid
|
||||
{
|
||||
class SaveAndroid : ISave
|
||||
{
|
||||
public void Save(string fileName, String contentType, MemoryStream stream)
|
||||
{
|
||||
string exception = string.Empty;
|
||||
string root = null;
|
||||
if (Android.OS.Environment.IsExternalStorageEmulated)
|
||||
{
|
||||
root = Android.App.Application.Context.GetExternalFilesDir(Android.OS.Environment.DirectoryDownloads).AbsolutePath;
|
||||
}
|
||||
else
|
||||
root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
|
||||
Java.IO.File myDir = new Java.IO.File(root + "/Syncfusion");
|
||||
myDir.Mkdir();
|
||||
|
||||
Java.IO.File file = new Java.IO.File(myDir, fileName);
|
||||
|
||||
if (file.Exists()) file.Delete();
|
||||
|
||||
try
|
||||
{
|
||||
FileOutputStream outs = new FileOutputStream(file);
|
||||
outs.Write(stream.ToArray());
|
||||
|
||||
outs.Flush();
|
||||
outs.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
exception = e.ToString();
|
||||
}
|
||||
if (file.Exists() && contentType != "application/html")
|
||||
{
|
||||
Android.Net.Uri path = Android.Net.Uri.FromFile(file);
|
||||
string extension = Android.Webkit.MimeTypeMap.GetFileExtensionFromUrl(Android.Net.Uri.FromFile(file).ToString());
|
||||
string mimeType = Android.Webkit.MimeTypeMap.Singleton.GetMimeTypeFromExtension(extension);
|
||||
Intent intent = new Intent(Intent.ActionView);
|
||||
intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);
|
||||
path = FileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".provider", file);
|
||||
intent.SetDataAndType(path, mimeType);
|
||||
intent.AddFlags(ActivityFlags.GrantReadUriPermission);
|
||||
Android.App.Application.Context.StartActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MailService : IMailService
|
||||
{
|
||||
public MailService()
|
||||
{
|
||||
}
|
||||
public void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream filestream)
|
||||
{
|
||||
string exception = string.Empty;
|
||||
string root = null;
|
||||
if (Android.OS.Environment.IsExternalStorageEmulated)
|
||||
{
|
||||
root = Android.OS.Environment.ExternalStorageDirectory.ToString();
|
||||
}
|
||||
else
|
||||
root = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
|
||||
|
||||
Java.IO.File myDir = new Java.IO.File(root + "/Syncfusion");
|
||||
myDir.Mkdir();
|
||||
|
||||
Java.IO.File file = new Java.IO.File(myDir, fileName);
|
||||
|
||||
if (file.Exists()) file.Delete();
|
||||
|
||||
try
|
||||
{
|
||||
FileOutputStream outs = new FileOutputStream(file);
|
||||
outs.Write(filestream.ToArray());
|
||||
|
||||
outs.Flush();
|
||||
outs.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
exception = e.ToString();
|
||||
}
|
||||
|
||||
Intent email = new Intent(Android.Content.Intent.ActionSend);
|
||||
var uri = Android.Net.Uri.Parse("file:///" + file.AbsolutePath);
|
||||
|
||||
//file.SetReadable(true, true);
|
||||
email.PutExtra(Android.Content.Intent.ExtraSubject, subject);
|
||||
email.PutExtra(Intent.ExtraStream, uri);
|
||||
email.SetType("application/pdf");
|
||||
|
||||
//MainActivity.MainPageActivity.StartActivity(email);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using Android.App;
|
||||
|
||||
namespace SampleBrowser.DocIO.Droid
|
||||
{
|
||||
[Activity(Theme = "@style/Theme.Splash",
|
||||
MainLauncher = true,
|
||||
NoHistory = true, Icon = "@drawable/AppIcon")]
|
||||
public class SplashScreenActivity : SampleBrowser.Core.Android.SplashScreenActivity
|
||||
{
|
||||
protected override Type GetMainActivityType()
|
||||
{
|
||||
return typeof(MainActivity);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<Application
|
||||
x:Class="SampleBrowser.DocIO.UWP.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:SampleBrowser.DocIO.UWP"
|
||||
RequestedTheme="Light">
|
||||
</Application>
|
|
@ -0,0 +1,121 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace SampleBrowser.DocIO.UWP
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
List<Assembly> assembliesToInclude = new List<Assembly>();
|
||||
assembliesToInclude.Add(typeof(GettingStartedDocIO).GetTypeInfo().Assembly);
|
||||
assembliesToInclude.Add(typeof(Core.UWP.CoreSampleBrowser).GetTypeInfo().Assembly);
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.SfListView.XForms.UWP")));
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.GridCommon.Portable")));
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.DataSource.Portable")));
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.Core.XForms")));
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.Compression.Portable")));
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.DocIO.Portable")));
|
||||
assembliesToInclude.Add(Assembly.Load(new AssemblyName("Syncfusion.OfficeChart.Portable")));
|
||||
|
||||
Xamarin.Forms.Forms.Init(e, assembliesToInclude);
|
||||
|
||||
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
Xamarin.Forms.Forms.Init(e);
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<forms:WindowsPage
|
||||
x:Class="SampleBrowser.DocIO.UWP.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:forms="using:Xamarin.Forms.Platform.UWP"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:SampleBrowser.DocIO.UWP"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
</Grid>
|
||||
</forms:WindowsPage>
|
|
@ -0,0 +1,34 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace SampleBrowser.DocIO.UWP
|
||||
{
|
||||
public sealed partial class MainPage
|
||||
{
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
LoadApplication(new SampleBrowser.DocIO.App());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
||||
<Identity Name="ec0cc741-fd3e-485c-81be-68815c480690" Publisher="CN=MathanKumarVaradhara" Version="1.0.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="ec0cc741-fd3e-485c-81be-68815c480690" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>DocIO Sample</DisplayName>
|
||||
<PublisherDisplayName>Syncfusion</PublisherDisplayName>
|
||||
<Logo>SampleBrowser.Core.UWP\Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="SampleBrowser.DocIO.UWP.App">
|
||||
<uap:VisualElements DisplayName="DocIO Sample" Square150x150Logo="SampleBrowser.Core.UWP\Assets\Square150x150Logo.png" Square44x44Logo="SampleBrowser.Core.UWP\Assets\Square44x44Logo.png" Description="SampleBrowser.DocIO.UWP" BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="SampleBrowser.Core.UWP\Assets\Wide310x150Logo.png">
|
||||
</uap:DefaultTile>
|
||||
<uap:SplashScreen Image="SampleBrowser.Core.UWP\Assets\SplashScreen.png" BackgroundColor="blue" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
|
@ -0,0 +1,36 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SampleBrowser.DocIO.UWP")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Syncfusion Inc.")]
|
||||
[assembly: AssemblyProduct("SampleBrowser.DocIO.UWP")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2001-2023 Syncfusion Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
|
@ -0,0 +1,31 @@
|
|||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at http://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Seralize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|
|
@ -0,0 +1,144 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{C6469FB2-9CF4-453E-9ADF-0ACBC386A113}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SampleBrowser.DocIO.UWP</RootNamespace>
|
||||
<AssemblyName>SampleBrowser.DocIO.UWP</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>SampleBrowser.DocIO.UWP_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<PackageCertificateThumbprint>4250A46D064FF3F0BD071955236D0EB603B745B3</PackageCertificateThumbprint>
|
||||
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="SampleBrowser.DocIO.UWP_TemporaryKey.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SaveWindows.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.0.15" />
|
||||
<PackageReference Include="SampleBrowser.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.DataSource" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.GridCommon" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.SfListView" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Buttons" Version="22.1.34" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DocIO\SampleBrowser.DocIO.csproj">
|
||||
<Project>{EB5CBDB6-C051-446B-BDDF-A00B0F1829D1}</Project>
|
||||
<Name>SampleBrowser.DocIO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\SaveWindows.cs" >
|
||||
<Link>DocIO\SaveWindows.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,124 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
using SampleBrowser;
|
||||
using SampleBrowser.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using SampleBrowser.DocIO.UWP;
|
||||
using Xamarin.Forms.Platform.UWP;
|
||||
using Windows.ApplicationModel.Email;
|
||||
|
||||
[assembly: Dependency(typeof(SaveWindows))]
|
||||
[assembly: Dependency(typeof(MailService))]
|
||||
namespace SampleBrowser.DocIO.UWP
|
||||
{
|
||||
class SaveWindows: ISaveWindowsPhone
|
||||
{
|
||||
|
||||
public async Task Save(string filename, string contentType, MemoryStream stream)
|
||||
{
|
||||
if (Device.Idiom != TargetIdiom.Desktop)
|
||||
{
|
||||
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
|
||||
StorageFile outFile = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
|
||||
using (Stream outStream = await outFile.OpenStreamForWriteAsync())
|
||||
{
|
||||
outStream.Write(stream.ToArray(), 0, (int)stream.Length);
|
||||
}
|
||||
if (contentType != "application/html")
|
||||
await Windows.System.Launcher.LaunchFileAsync(outFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
StorageFile storageFile = null;
|
||||
FileSavePicker savePicker = new FileSavePicker();
|
||||
savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
|
||||
savePicker.SuggestedFileName = filename;
|
||||
switch (contentType)
|
||||
{
|
||||
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
||||
savePicker.FileTypeChoices.Add("PowerPoint Presentation", new List<string>() { ".pptx", });
|
||||
break;
|
||||
case "application/msexcel":
|
||||
savePicker.FileTypeChoices.Add("Excel Files", new List<string>() { ".xlsx", });
|
||||
break;
|
||||
case "application/msword":
|
||||
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
|
||||
break;
|
||||
case "application/pdf":
|
||||
savePicker.FileTypeChoices.Add("Adobe PDF Document", new List<string>() { ".pdf" });
|
||||
break;
|
||||
case "application/html":
|
||||
savePicker.FileTypeChoices.Add("HTML Files", new List<string>() { ".html" });
|
||||
break;
|
||||
}
|
||||
storageFile = await savePicker.PickSaveFileAsync();
|
||||
|
||||
if (storageFile != null)
|
||||
{
|
||||
using (Stream outStream = await storageFile.OpenStreamForWriteAsync())
|
||||
{
|
||||
if (outStream.CanSeek)
|
||||
outStream.SetLength(0);
|
||||
outStream.Write(stream.ToArray(), 0, (int)stream.Length);
|
||||
outStream.Flush();
|
||||
outStream.Dispose();
|
||||
}
|
||||
}
|
||||
stream.Flush();
|
||||
stream.Dispose();
|
||||
if (storageFile != null)
|
||||
await Windows.System.Launcher.LaunchFileAsync(storageFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class SfImageRenderer : ImageRenderer
|
||||
{
|
||||
public SfImageRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
this.Element.PropertyChanged -= OnElementPropertyChanged;
|
||||
base.Dispose(false);
|
||||
}
|
||||
}
|
||||
public class MailService : IMailService
|
||||
{
|
||||
public async void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream documentStream)
|
||||
{
|
||||
var emailMessage = new EmailMessage
|
||||
{
|
||||
Subject = subject,
|
||||
Body = messagebody
|
||||
};
|
||||
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
|
||||
|
||||
StorageFile outFile = await local.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
|
||||
|
||||
using (Stream outStream = await outFile.OpenStreamForWriteAsync())
|
||||
{
|
||||
outStream.Write(documentStream.ToArray(), 0, (int)documentStream.Length);
|
||||
}
|
||||
emailMessage.Attachments.Add(new EmailAttachment(fileName, outFile));
|
||||
|
||||
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace SampleBrowser.DocIO.iOS
|
||||
{
|
||||
// The UIApplicationDelegate for the application. This class is responsible for launching the
|
||||
// User Interface of the application, as well as listening (and optionally responding) to
|
||||
// application events from iOS.
|
||||
[Register("AppDelegate")]
|
||||
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
|
||||
{
|
||||
//
|
||||
// This method is invoked when the application has loaded and is ready to run. In this
|
||||
// method you should instantiate the window, load the UI into it and then make the window
|
||||
// visible.
|
||||
//
|
||||
// You have 17 seconds to return from this method, or iOS will terminate your application.
|
||||
//
|
||||
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
||||
{
|
||||
global::Xamarin.Forms.Forms.Init();
|
||||
Syncfusion.ListView.XForms.iOS.SfListViewRenderer.Init();
|
||||
Syncfusion.XForms.iOS.Buttons.SfRadioButtonRenderer.Init();
|
||||
SampleBrowser.Core.iOS.CoreSampleBrowser.Init(UIScreen.MainScreen.Bounds, app.StatusBarFrame.Size.Height);
|
||||
LoadApplication(new App());
|
||||
|
||||
|
||||
return base.FinishedLaunching(app, options);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"filename": "icon_29x29.png",
|
||||
"size": "29x29",
|
||||
"scale": "1x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "icon_58x58.png",
|
||||
"size": "29x29",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "icon_87x87.png",
|
||||
"size": "29x29",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "icon_80x80.png",
|
||||
"size": "40x40",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-60@2x.png",
|
||||
"size": "40x40",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"size": "57x57",
|
||||
"scale": "1x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"size": "57x57",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-60@2x.png",
|
||||
"size": "60x60",
|
||||
"scale": "2x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "Icon-60@3x.png",
|
||||
"size": "60x60",
|
||||
"scale": "3x",
|
||||
"idiom": "iphone"
|
||||
},
|
||||
{
|
||||
"filename": "icon_29x29.png",
|
||||
"size": "29x29",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon_58x58.png",
|
||||
"size": "29x29",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "40x40",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "50x50",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "50x50",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "83.5x83.5",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "72x72",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"size": "72x72",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon_76x76.png",
|
||||
"size": "76x76",
|
||||
"scale": "1x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"filename": "icon_152x152.png",
|
||||
"size": "76x76",
|
||||
"scale": "2x",
|
||||
"idiom": "ipad"
|
||||
},
|
||||
{
|
||||
"role": "notificationCenter",
|
||||
"size": "24x24",
|
||||
"subtype": "38mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "notificationCenter",
|
||||
"size": "27.5x27.5",
|
||||
"subtype": "42mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "companionSettings",
|
||||
"filename": "icon_58x58.png",
|
||||
"size": "29x29",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "companionSettings",
|
||||
"filename": "icon_87x87.png",
|
||||
"size": "29x29",
|
||||
"scale": "3x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "appLauncher",
|
||||
"filename": "icon_80x80.png",
|
||||
"size": "40x40",
|
||||
"subtype": "38mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "longLook",
|
||||
"size": "44x44",
|
||||
"subtype": "42mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "quickLook",
|
||||
"size": "86x86",
|
||||
"subtype": "38mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"role": "quickLook",
|
||||
"size": "98x98",
|
||||
"subtype": "42mm",
|
||||
"scale": "2x",
|
||||
"idiom": "watch"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "16x16",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "32x32",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "128x128",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "256x256",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"size": "512x512",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 5.6 KiB |
После Ширина: | Высота: | Размер: 8.8 KiB |
После Ширина: | Высота: | Размер: 7.2 KiB |
После Ширина: | Высота: | Размер: 1.9 KiB |
После Ширина: | Высота: | Размер: 3.0 KiB |
После Ширина: | Высота: | Размер: 3.8 KiB |
После Ширина: | Высота: | Размер: 6.0 KiB |
После Ширина: | Высота: | Размер: 7.0 KiB |
|
@ -0,0 +1,7 @@
|
|||
<?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">
|
||||
<dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?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">
|
||||
<dict>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>10.2</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.syncfusion.samplebrowser.docio</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>DocIO Sample</string>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="25"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="26"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3" userLabel="UIImageView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="Launch.png" translatesAutoresizingMaskIntoConstraints="NO" id="9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="1024" height="1366"/>
|
||||
<accessibility key="accessibilityConfiguration">
|
||||
<accessibilityTraits key="traits" image="YES" adjustable="YES"/>
|
||||
</accessibility>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.043137254901960784" green="0.396078431372549" blue="0.87450980392156863" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="9" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="5Pp-ad-0e9"/>
|
||||
<constraint firstItem="9" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="Qh3-BI-SYx"/>
|
||||
<constraint firstItem="9" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="Vw3-WQ-V0s"/>
|
||||
<constraint firstItem="9" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="bOh-ga-Mqn"/>
|
||||
<constraint firstItem="9" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="rKd-8B-Xi9"/>
|
||||
<constraint firstItem="9" firstAttribute="bottom" secondItem="26" secondAttribute="top" id="rdg-Zc-hcq"/>
|
||||
<constraint firstItem="26" firstAttribute="top" secondItem="9" secondAttribute="bottom" id="vdm-Ck-t1F"/>
|
||||
<constraint firstAttribute="trailing" secondItem="9" secondAttribute="trailing" id="vmn-ia-DmA"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="52" y="374.6627"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="icon_512x512.png" width="512" height="512"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -0,0 +1,22 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using UIKit;
|
||||
|
||||
namespace SampleBrowser.DocIO.iOS
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main(args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using QuickLook;
|
||||
|
||||
namespace SampleBrowser.DocIO.iOS
|
||||
{
|
||||
public class PreviewControllerDS : QLPreviewControllerDataSource
|
||||
{
|
||||
private QLPreviewItem _item;
|
||||
|
||||
public PreviewControllerDS(QLPreviewItem item)
|
||||
{
|
||||
_item = item;
|
||||
}
|
||||
|
||||
public override nint PreviewItemCount (QLPreviewController controller)
|
||||
{
|
||||
return (nint)1;
|
||||
}
|
||||
|
||||
public override IQLPreviewItem GetPreviewItem (QLPreviewController controller, nint index)
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SampleBrowser.DocIO.iOS")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Syncfusion Inc.")]
|
||||
[assembly: AssemblyProduct("SampleBrowser.DocIO.iOS")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2001-2023 Syncfusion Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly:Preserve]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,68 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using QuickLook;
|
||||
using Foundation;
|
||||
using System.IO;
|
||||
|
||||
namespace SampleBrowser.DocIO.iOS
|
||||
{
|
||||
public class QLPreviewItemFileSystem : QLPreviewItem
|
||||
{
|
||||
string _fileName, _filePath;
|
||||
|
||||
public QLPreviewItemFileSystem(string fileName, string filePath)
|
||||
{
|
||||
_fileName = fileName;
|
||||
_filePath = filePath;
|
||||
}
|
||||
|
||||
public override string ItemTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileName;
|
||||
}
|
||||
}
|
||||
public override NSUrl ItemUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
return NSUrl.FromFilename(_filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class QLPreviewItemBundle : QLPreviewItem
|
||||
{
|
||||
string _fileName, _filePath;
|
||||
public QLPreviewItemBundle(string fileName, string filePath)
|
||||
{
|
||||
_fileName = fileName;
|
||||
_filePath = filePath;
|
||||
}
|
||||
|
||||
public override string ItemTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fileName;
|
||||
}
|
||||
}
|
||||
public override NSUrl ItemUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var documents = NSBundle.MainBundle.BundlePath;
|
||||
var lib = Path.Combine(documents, _filePath);
|
||||
var url = NSUrl.FromFilename(lib);
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
После Ширина: | Высота: | Размер: 2.8 KiB |
После Ширина: | Высота: | Размер: 5.1 KiB |
После Ширина: | Высота: | Размер: 8.2 KiB |
После Ширина: | Высота: | Размер: 1.0 MiB |
|
@ -0,0 +1,177 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F4D99EF7-F197-428F-92DE-7482DBAD7476}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>SampleBrowser.DocIO.iOS</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>SampleBrowser.DocIO.iOS</AssemblyName>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchArch>x86_64</MtouchArch>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<BuildIpa>True</BuildIpa>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>False</ConsolePause>
|
||||
<MtouchArch>ARM64</MtouchArch>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="QLPreviewItemFileSystem.cs" />
|
||||
<Compile Include="SaveIOS.cs" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" >
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
<None Include="Entitlements.plist" />
|
||||
<None Include="Info.plist" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PreviewControllerDS.cs" />
|
||||
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\DocIO.png" />
|
||||
<BundleResource Include="Resources\DocIO%402x.png" />
|
||||
<BundleResource Include="Resources\DocIO%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="iTunesArtwork" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\icon_512x512.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon-60%402x.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon_87x87.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon_80x80.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon_76x76.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon_29x29.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon_58x58.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\icon_152x152.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Icon-60%403x.png">
|
||||
<Visible>false</Visible>
|
||||
</ImageAsset>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SampleBrowser.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.DataSource" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.GridCommon" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.SfListView" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Buttons" Version="22.1.34" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DocIO\SampleBrowser.DocIO.csproj">
|
||||
<Project>{EB5CBDB6-C051-446B-BDDF-A00B0F1829D1}</Project>
|
||||
<Name>SampleBrowser.DocIO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\QLPreviewItemFileSystem.cs">
|
||||
<Link>DocIO\QLPreviewItemFileSystem.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\SaveIOS.cs">
|
||||
<Link>DocIO\SaveIOS.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\PreviewControllerDS.cs">
|
||||
<Link>DocIO\PreviewControllerDS.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="$(MSBuildThisFileDirectory)\Resources\DocIO.png" >
|
||||
<Link>Resources\DocIO.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="$(MSBuildThisFileDirectory)\Resources\DocIO%402x.png" >
|
||||
<Link>Resources\DocIO%402x.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="$(MSBuildThisFileDirectory)\Resources\DocIO%403x.png" >
|
||||
<Link>Resources\DocIO%403x.png</Link>
|
||||
</BundleResource>
|
||||
<BundleResource Include="$(MSBuildThisFileDirectory)\Resources\icon_512x512.png" >
|
||||
<Link>Resources\icon_512x512.png</Link>
|
||||
</BundleResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,143 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using QuickLook;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using SampleBrowser.DocIO.iOS;
|
||||
using MessageUI;
|
||||
|
||||
[assembly: Dependency(typeof(SaveIOS))]
|
||||
[assembly: Dependency(typeof(MailService))]
|
||||
namespace SampleBrowser.DocIO.iOS
|
||||
{
|
||||
class SaveIOS: ISave
|
||||
{
|
||||
public void Save(string filename, string contentType, MemoryStream stream)
|
||||
{
|
||||
string exception = string.Empty;
|
||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
string filePath = Path.Combine(path, filename);
|
||||
try
|
||||
{
|
||||
FileStream fileStream = File.Open(filePath, FileMode.Create);
|
||||
stream.Position = 0;
|
||||
stream.CopyTo(fileStream);
|
||||
fileStream.Flush();
|
||||
fileStream.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
exception = e.ToString();
|
||||
}
|
||||
if (contentType == "application/html" || exception != string.Empty)
|
||||
return;
|
||||
UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
|
||||
while (currentController.PresentedViewController != null)
|
||||
currentController = currentController.PresentedViewController;
|
||||
UIView currentView = currentController.View;
|
||||
|
||||
QLPreviewController qlPreview = new QLPreviewController();
|
||||
QLPreviewItem item = new QLPreviewItemBundle(filename, filePath);
|
||||
qlPreview.DataSource = new PreviewControllerDS(item);
|
||||
|
||||
//UIViewController uiView = currentView as UIViewController;
|
||||
|
||||
currentController.PresentViewController((UIViewController)qlPreview, true, (Action)null);
|
||||
}
|
||||
}
|
||||
public class MailService : IMailService
|
||||
{
|
||||
public MailService()
|
||||
{
|
||||
}
|
||||
|
||||
public void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream stream)
|
||||
{
|
||||
if (MFMailComposeViewController.CanSendMail)
|
||||
{
|
||||
|
||||
var mailer = new MFMailComposeViewController();
|
||||
|
||||
mailer.SetMessageBody(messagebody ?? string.Empty, false);
|
||||
mailer.SetSubject(subject ?? subject);
|
||||
mailer.Finished += (s, e) => ((MFMailComposeViewController)s).DismissViewController(true, () => { });
|
||||
|
||||
|
||||
string exception = string.Empty;
|
||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
string filePath = Path.Combine(path, fileName);
|
||||
try
|
||||
{
|
||||
FileStream fileStream = File.Open(filePath, FileMode.Create);
|
||||
stream.Position = 0;
|
||||
stream.CopyTo(fileStream);
|
||||
fileStream.Flush();
|
||||
fileStream.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
exception = e.ToString();
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
mailer.AddAttachmentData(NSData.FromFile(filePath), GetMimeType(fileName), Path.GetFileName(fileName));
|
||||
|
||||
|
||||
|
||||
UIViewController vc = UIApplication.SharedApplication.KeyWindow.RootViewController;
|
||||
while (vc.PresentedViewController != null)
|
||||
{
|
||||
vc = vc.PresentedViewController;
|
||||
}
|
||||
vc.PresentViewController(mailer, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetMimeType(string filename)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(filename.ToLowerInvariant());
|
||||
|
||||
switch (extension)
|
||||
{
|
||||
case "png":
|
||||
return "image/png";
|
||||
case "doc":
|
||||
return "application/msword";
|
||||
case "pdf":
|
||||
return "application/pdf";
|
||||
case "jpeg":
|
||||
case "jpg":
|
||||
return "image/jpeg";
|
||||
case "zip":
|
||||
case "docx":
|
||||
case "xlsx":
|
||||
case "pptx":
|
||||
return "application/zip";
|
||||
case "htm":
|
||||
case "html":
|
||||
return "text/html";
|
||||
}
|
||||
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 1.0 MiB |
После Ширина: | Высота: | Размер: 20 KiB |
|
@ -0,0 +1,38 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
public class App : Application
|
||||
{
|
||||
public static bool isUWP;
|
||||
public App()
|
||||
{
|
||||
var page = SampleBrowser.Core.SampleBrowser.GetMainPage("DocIO", "SampleBrowser.DocIO");
|
||||
MainPage = page;
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
// Handle when your app starts
|
||||
}
|
||||
|
||||
protected override void OnSleep()
|
||||
{
|
||||
// Handle when your app sleeps
|
||||
}
|
||||
|
||||
protected override void OnResume()
|
||||
{
|
||||
// Handle when your app resumes
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public interface ISave
|
||||
{
|
||||
void Save(string filename, string contentType, MemoryStream stream);
|
||||
}
|
||||
public interface ISaveWindowsPhone
|
||||
{
|
||||
Task Save(string filename, string contentType, MemoryStream stream);
|
||||
}
|
||||
|
||||
public interface IAndroidVersionDependencyService
|
||||
{
|
||||
int GetAndroidVersion();
|
||||
}
|
||||
public interface IMailService
|
||||
{
|
||||
void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream documentStream);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms.Xaml;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SampleBrowser.DocIO")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Syncfusion Inc.")]
|
||||
[assembly: AssemblyProduct("SampleBrowser.DocIO")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2001-2023 Syncfusion Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
[assembly:Preserve]
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,58 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageId>SampleBrowser.DocIO</PackageId>
|
||||
<Configurations>Debug;Release;Release-xml</Configurations>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
|
||||
<RootNamespace>SampleBrowser.DocIO</RootNamespace>
|
||||
<AssemblyName>SampleBrowser.DocIO</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SampleBrowser.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Compression" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Core" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.OfficeChart" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.DataSource" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.DocIO" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.DocIORenderer" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.SkiaSharpHelper" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.PDF" Version="22.1.34" />
|
||||
<PackageReference Include="SkiaSharp" version="2.88.2" />
|
||||
<PackageReference Include="SkiaSharp.HarfBuzz" version="2.88.2" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.GridCommon" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.SfListView" Version="22.1.34" />
|
||||
<PackageReference Include="Syncfusion.Xamarin.Buttons" Version="22.1.34" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Samples\Templates\BkmkDocumentPart_Template.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\Bookmark_Template.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\ContentControlTemplate.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\EmployeesReportDemo.doc" />
|
||||
<EmbeddedResource Include="Samples\Templates\SampleImage.png" />
|
||||
<EmbeddedResource Include="Samples\Templates\Template.doc" />
|
||||
<EmbeddedResource Include="Samples\Templates\Template_Letter.doc" />
|
||||
<EmbeddedResource Include="Samples\Templates\Security Settings.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\TrackChangesTemplate.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\WordtoHTML.doc" />
|
||||
<EmbeddedResource Include="Samples\Templates\WordtoPDF.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\MarkdownToWord.md" />
|
||||
<EmbeddedResource Include="Samples\Templates\CreateEquation.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\Excel_Template.xlsx" />
|
||||
<EmbeddedResource Include="Samples\Templates\Letter Formatting.docx" />
|
||||
<EmbeddedResource Include="Samples\Templates\Employees.xml" />
|
||||
<EmbeddedResource Include="Samples\Templates\Mountain-200.jpg" />
|
||||
<EmbeddedResource Include="Samples\Templates\Mountain-300.jpg" />
|
||||
<EmbeddedResource Include="Samples\Templates\Northwind.png" />
|
||||
<EmbeddedResource Include="Samples\Templates\Products.xml" />
|
||||
<EmbeddedResource Include="Samples\Templates\Road-550-W.jpg" />
|
||||
<EmbeddedResource Include="Samples\Templates\AdventureCycle.jpg" />
|
||||
<EmbeddedResource Include="SamplesList\SamplesList.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="App.cs">
|
||||
<DependentUpon>*.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,260 @@
|
|||
<Project>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\SamplesList\SamplesList.xml">
|
||||
<Link>Samples\DocIO\SamplesList\SamplesList.xml</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\BkmkDocumentPart_Template.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\BkmkDocumentPart_Template.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Bookmark_Template.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\Bookmark_Template.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\TrackChangesTemplate.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\TrackChangesTemplate.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Security Settings.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\Security Settings.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\ContentControlTemplate.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\ContentControlTemplate.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Excel_Template.xlsx">
|
||||
<Link>Samples\DocIO\Samples\Templates\Excel_Template.xlsx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Letter Formatting.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\Letter Formatting.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Employees.xml">
|
||||
<Link>Samples\DocIO\Samples\Templates\Employees.xml</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Mountain-200.jpg">
|
||||
<Link>Samples\DocIO\Samples\Templates\Mountain-200.jpg</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Mountain-300.jpg">
|
||||
<Link>Samples\DocIO\Samples\Templates\Mountain-300.jpg</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Northwind.png">
|
||||
<Link>Samples\DocIO\Samples\Templates\Northwind.png</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Products.xml">
|
||||
<Link>Samples\DocIO\Samples\Templates\Products.xml</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Road-550-W.jpg">
|
||||
<Link>Samples\DocIO\Samples\Templates\Road-550-W.jpg</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\AdventureCycle.jpg">
|
||||
<Link>Samples\DocIO\Samples\Templates\AdventureCycle.jpg</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\WordtoHTML.doc">
|
||||
<Link>Samples\DocIO\Samples\Templates\WordtoHTML.doc</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\WordtoPDF.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\WordtoPDF.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\CreateEquation.docx">
|
||||
<Link>Samples\DocIO\Samples\Templates\CreateEquation.docx</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\EmployeesReportDemo.doc">
|
||||
<Link>Samples\DocIO\Samples\Templates\EmployeesReportDemo.doc</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\SampleImage.png">
|
||||
<Link>Samples\DocIO\Samples\Templates\SampleImage.png</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Template.doc">
|
||||
<Link>Samples\DocIO\Samples\Templates\Template.doc</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\Template_Letter.doc">
|
||||
<Link>Samples\DocIO\Samples\Templates\Template_Letter.doc</Link>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\Templates\MarkdownToWord.md">
|
||||
<Link>Samples\DocIO\Samples\Templates\MarkdownToWord.md</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\BookmarkNavigation\BookmarkNavigation.xaml">
|
||||
<Link>Samples\DocIO\Samples\BookmarkNavigation\BookmarkNavigation.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\TableOfContents\TableOfContents.xaml">
|
||||
<Link>Samples\DocIO\Samples\TableOfContents\TableOfContents.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\EncryptAndDecrypt\EncryptAndDecrypt.xaml">
|
||||
<Link>Samples\DocIO\Samples\EncryptAndDecrypt\EncryptAndDecrypt.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\TrackChanges\TrackChanges.xaml">
|
||||
<Link>Samples\DocIO\Samples\TrackChanges\TrackChanges.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\BuiltInStyle\BuiltInStyle.xaml">
|
||||
<Link>Samples\DocIO\Samples\BuiltInStyle\BuiltInStyle.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\CustomStyle\CustomStyle.xaml">
|
||||
<Link>Samples\DocIO\Samples\CustomStyle\CustomStyle.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\DocIO_BarChart\DocIO_BarChart.xaml">
|
||||
<Link>Samples\DocIO\Samples\DocIO_BarChart\DocIO_BarChart.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\GroupShapes\GroupShapes.xaml">
|
||||
<Link>Samples\DocIO\Samples\GroupShapes\GroupShapes.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\DocIO_PieChart\DocIO_PieChart.xaml">
|
||||
<Link>Samples\DocIO\Samples\DocIO_PieChart\DocIO_PieChart.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\FormFillingAndProtection\FormFillingAndProtection.xaml">
|
||||
<Link>Samples\DocIO\Samples\FormFillingAndProtection\FormFillingAndProtection.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\GettingStartedDocIO\GettingStarted.xaml">
|
||||
<Link>Samples\DocIO\Samples\GettingStartedDocIO\GettingStarted.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\MailMerge\MailMerge.xaml">
|
||||
<Link>Samples\DocIO\Samples\MailMerge\MailMerge.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\EmployeeList_MailMerge\EmployeeList_MailMerge.xaml">
|
||||
<Link>Samples\DocIO\Samples\EmployeeList_MailMergee\EmployeeList_MailMerge.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\NestedMailMerge\NestedMailMerge.xaml">
|
||||
<Link>Samples\DocIO\Samples\NestedMailMerge\NestedMailMerge.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\WordToHTML\WordToHTML.xaml">
|
||||
<Link>Samples\DocIO\Samples\WordToHTML\WordToHTML.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\WordToPDF\WordToPDF.xaml">
|
||||
<Link>Samples\DocIO\Samples\WordToPDF\WordToPDF.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\XMLMapping\XMLMapping.xaml">
|
||||
<Link>Samples\DocIO\Samples\XMLMapping\XMLMapping.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\CreateEquation\CreateEquation.xaml">
|
||||
<Link>Samples\DocIO\Samples\CreateEquation\CreateEquation.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\FormatTable\FormatTable.xaml">
|
||||
<Link>Samples\DocIO\Samples\FormatTable\FormatTable.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)\Samples\MarkdownToWord\MarkdownToWord.xaml">
|
||||
<Link>Samples\DocIO\Samples\MarkdownToWord\MarkdownToWord.xaml</Link>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\BookmarkNavigation\BookmarkNavigation.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\BookmarkNavigation\BookmarkNavigation.xaml.cs</Link>
|
||||
<DependentUpon>BookmarkNavigation.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\TableOfContents\TableOfContents.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\TableOfContents\TableOfContents.xaml.cs</Link>
|
||||
<DependentUpon>TableOfContents.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\EncryptAndDecrypt\EncryptAndDecrypt.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\EncryptAndDecrypt\EncryptAndDecrypt.xaml.cs</Link>
|
||||
<DependentUpon>EncryptAndDecrypt.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\TrackChanges\TrackChanges.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\TrackChanges\TrackChanges.xaml.cs</Link>
|
||||
<DependentUpon>TrackChanges.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\BuiltInStyle\BuiltInStyle.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\BuiltInStyle\BuiltInStyle.xaml.cs</Link>
|
||||
<DependentUpon>BuiltInStyle.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\GroupShapes\GroupShapes.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\GroupShapes\GroupShapes.xaml.cs</Link>
|
||||
<DependentUpon>GroupShapes.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\CustomStyle\CustomStyle.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\CustomStyle\CustomStyle.xaml.cs</Link>
|
||||
<DependentUpon>CustomStyle.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\DocIO_BarChart\DocIO_BarChart.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\DocIO_BarChart\DocIO_BarChart.xaml.cs</Link>
|
||||
<DependentUpon>DocIO_BarChart.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\DocIO_PieChart\DocIO_PieChart.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\DocIO_PieChart\DocIO_PieChart.xaml.cs</Link>
|
||||
<DependentUpon>DocIO_PieChart.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\FormFillingAndProtection\FormFillingAndProtection.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\FormFillingAndProtection\FormFillingAndProtection.xaml.cs</Link>
|
||||
<DependentUpon>FormFillingAndProtection.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\GettingStartedDocIO\GettingStarted.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\GettingStartedDocIO\GettingStarted.xaml.cs</Link>
|
||||
<DependentUpon>GettingStarted.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\MailMerge\MailMerge.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\MailMerge\MailMerge.xaml.cs</Link>
|
||||
<DependentUpon>MailMerge.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\EmployeeList_MailMerge\EmployeeList_MailMerge.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\EmployeeList_MailMerge\EmployeeList_MailMerge.xaml.cs</Link>
|
||||
<DependentUpon>EmployeeList_MailMerge.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\NestedMailMerge\NestedMailMerge.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\NestedMailMerge\NestedMailMerge.xaml.cs</Link>
|
||||
<DependentUpon>NestedMailMerge.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\WordToHTML\WordToHTML.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\WordToHTML\WordToHTML.xaml.cs</Link>
|
||||
<DependentUpon>WordToHTML.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\WordToPDF\WordToPDF.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\WordToPDF\WordToPDF.xaml.cs</Link>
|
||||
<DependentUpon>WordToPDF.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\XMLMapping\XMLMapping.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\XMLMapping\XMLMapping.xaml.cs</Link>
|
||||
<DependentUpon>XMLMapping.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\CreateEquation\CreateEquation.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\CreateEquation\CreateEquation.xaml.cs</Link>
|
||||
<DependentUpon>CreateEquation.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\FormatTable\FormatTable.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\FormatTable\FormatTable.xaml.cs</Link>
|
||||
<DependentUpon>FormatTable.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\Samples\MarkdownToWord\MarkdownToWord.xaml.cs">
|
||||
<Link>Samples\DocIO\Samples\MarkdownToWord\MarkdownToWord.xaml.cs</Link>
|
||||
<DependentUpon>MarkdownToWord.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)\ISave.cs">
|
||||
<Link>Samples\DocIO\ISave.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,29 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using SampleBrowser.Core;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
public class SamplePages : SampleView
|
||||
{
|
||||
public SamplePages()
|
||||
{
|
||||
Content = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { Text = "Hello ContentPage" }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.BookmarkNavigation">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to insert, retrieve, replace and delete the contents of a specified bookmark using BookmarkNavigator functionality of DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
<Label></Label>
|
||||
<Button Grid.Row="2" Grid.Column="0" WidthRequest="180" x:Name="btnGenerate1" Clicked ="OnButtonClicked1" Text ="View Template " HorizontalOptions="Start" VerticalOptions="Start"/>
|
||||
<Button Grid.Row="3" Grid.Column="0" WidthRequest="180" x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Start" VerticalOptions="Start"/>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,261 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class BookmarkNavigation : SampleView
|
||||
{
|
||||
public BookmarkNavigation()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
this.btnGenerate1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate1.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
//if (!SampleBrowser.DocIO.App.isUWP)
|
||||
//{
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
//}
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked1(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(BookmarkNavigation).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "Bookmark_Template.docx");
|
||||
MemoryStream stream = new MemoryStream();
|
||||
inputStream.CopyTo(stream);
|
||||
inputStream.Dispose();
|
||||
stream.Position = 0;
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("Bookmark_Template.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("Bookmark_Template.docx", "application/msword", stream);
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(BookmarkNavigation).GetTypeInfo().Assembly;
|
||||
// Creating a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
//Adds section with one empty paragraph to the Word document
|
||||
document.EnsureMinimal();
|
||||
//sets the page margins
|
||||
document.LastSection.PageSetup.Margins.All = 72f;
|
||||
//Appends bookmark to the paragraph
|
||||
document.LastParagraph.AppendBookmarkStart("NorthwindDatabase");
|
||||
document.LastParagraph.AppendText("Northwind database with relational data");
|
||||
document.LastParagraph.AppendBookmarkEnd("NorthwindDatabase");
|
||||
// Open an existing template document with single section.
|
||||
WordDocument nwdInformation = new WordDocument();
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "Bookmark_Template.docx");
|
||||
// Open an existing template document.
|
||||
nwdInformation.Open(inputStream, FormatType.Docx);
|
||||
inputStream.Dispose();
|
||||
// Open an existing template document with multiple section.
|
||||
WordDocument templateDocument = new WordDocument();
|
||||
inputStream = assembly.GetManifestResourceStream(rootPath + "BkmkDocumentPart_Template.docx");
|
||||
// Open an existing template document.
|
||||
templateDocument.Open(inputStream, FormatType.Docx);
|
||||
inputStream.Dispose();
|
||||
// Creating a bookmark navigator. Which help us to navigate through the
|
||||
// bookmarks in the template document.
|
||||
BookmarksNavigator bk = new BookmarksNavigator(templateDocument);
|
||||
// Move to the NorthWind bookmark in template document
|
||||
bk.MoveToBookmark("NorthWind");
|
||||
//Gets the bookmark content as WordDocumentPart
|
||||
WordDocumentPart documentPart = bk.GetContent();
|
||||
// Creating a bookmark navigator. Which help us to navigate through the
|
||||
// bookmarks in the Northwind information document.
|
||||
bk = new BookmarksNavigator(nwdInformation);
|
||||
// Move to the information bookmark
|
||||
bk.MoveToBookmark("Information");
|
||||
// Get the content of information bookmark.
|
||||
TextBodyPart bodyPart = bk.GetBookmarkContent();
|
||||
// Creating a bookmark navigator. Which help us to navigate through the
|
||||
// bookmarks in the destination document.
|
||||
bk = new BookmarksNavigator(document);
|
||||
// Move to the NorthWind database in the destination document
|
||||
bk.MoveToBookmark("NorthwindDatabase");
|
||||
//Replace the bookmark content using word document parts
|
||||
bk.ReplaceContent(documentPart);
|
||||
// Move to the Northwind_Information in the destination document
|
||||
bk.MoveToBookmark("Northwind_Information");
|
||||
// Replacing content of Northwind_Information bookmark.
|
||||
bk.ReplaceBookmarkContent(bodyPart);
|
||||
#region Bookmark selection for table
|
||||
// Creating a bookmark navigator. Which help us to navigate through the
|
||||
// bookmarks in the Northwind information document.
|
||||
bk = new BookmarksNavigator(nwdInformation);
|
||||
bk.MoveToBookmark("SuppliersTable");
|
||||
//Sets the column index where the bookmark starts within the table
|
||||
bk.CurrentBookmark.FirstColumn = 1;
|
||||
//Sets the column index where the bookmark ends within the table
|
||||
bk.CurrentBookmark.LastColumn = 5;
|
||||
// Get the content of suppliers table bookmark.
|
||||
bodyPart = bk.GetBookmarkContent();
|
||||
// Creating a bookmark navigator. Which help us to navigate through the
|
||||
// bookmarks in the destination document.
|
||||
bk = new BookmarksNavigator(document);
|
||||
bk.MoveToBookmark("Table");
|
||||
bk.ReplaceBookmarkContent(bodyPart);
|
||||
#endregion
|
||||
// Move to the text bookmark
|
||||
bk.MoveToBookmark("Text");
|
||||
//Deletes the bookmark content
|
||||
bk.DeleteBookmarkContent(true);
|
||||
// Inserting text inside the bookmark. This will preserve the source formatting
|
||||
bk.InsertText("Northwind Database contains the following table:");
|
||||
#region tableinsertion
|
||||
WTable tbl = new WTable(document);
|
||||
tbl.TableFormat.Borders.BorderType = BorderStyle.None;
|
||||
tbl.TableFormat.IsAutoResized = true;
|
||||
tbl.ResetCells(8, 2);
|
||||
IWParagraph paragraph;
|
||||
tbl.Rows[0].IsHeader = true;
|
||||
paragraph = tbl[0, 0].AddParagraph();
|
||||
paragraph.AppendText("Suppliers");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[0, 1].AddParagraph();
|
||||
paragraph.AppendText("1");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[1, 0].AddParagraph();
|
||||
paragraph.AppendText("Customers");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[1, 1].AddParagraph();
|
||||
paragraph.AppendText("1");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[2, 0].AddParagraph();
|
||||
paragraph.AppendText("Employees");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[2, 1].AddParagraph();
|
||||
paragraph.AppendText("3");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[3, 0].AddParagraph();
|
||||
paragraph.AppendText("Products");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[3, 1].AddParagraph();
|
||||
paragraph.AppendText("1");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[4, 0].AddParagraph();
|
||||
paragraph.AppendText("Inventory");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[4, 1].AddParagraph();
|
||||
paragraph.AppendText("2");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[5, 0].AddParagraph();
|
||||
paragraph.AppendText("Shippers");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[5, 1].AddParagraph();
|
||||
paragraph.AppendText("1");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[6, 0].AddParagraph();
|
||||
paragraph.AppendText("PO Transactions");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[6, 1].AddParagraph();
|
||||
paragraph.AppendText("3");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[7, 0].AddParagraph();
|
||||
paragraph.AppendText("Sales Transactions");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
paragraph = tbl[7, 1].AddParagraph();
|
||||
paragraph.AppendText("7");
|
||||
paragraph.BreakCharacterFormat.FontName = "Calibri";
|
||||
paragraph.BreakCharacterFormat.FontSize = 10;
|
||||
|
||||
|
||||
bk.InsertTable(tbl);
|
||||
#endregion
|
||||
bk.MoveToBookmark("Image");
|
||||
bk.DeleteBookmarkContent(true);
|
||||
// Inserting image to the bookmark.
|
||||
IWPicture pic = bk.InsertParagraphItem(ParagraphItemType.Picture) as WPicture;
|
||||
inputStream = assembly.GetManifestResourceStream(rootPath + "Northwind.png");
|
||||
pic.LoadImage(inputStream);
|
||||
inputStream.Dispose();
|
||||
pic.WidthScale = 50f; // It reduce the image size because it don't fit
|
||||
pic.HeightScale = 75f; // in document page.
|
||||
|
||||
|
||||
#region Saving Document
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("BookMarkNavigation.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("BookMarkNavigation.docx", "application/msword", stream);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.BuiltInStyle">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to format the Word document contents with the built-in styles."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,252 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class BuiltInStyle : SampleView
|
||||
{
|
||||
public BuiltInStyle()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
//if (!SampleBrowser.DocIO.App.isUWP)
|
||||
//{
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
//}
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
// Creating a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
|
||||
|
||||
WSection section = document.AddSection() as WSection;
|
||||
//Set Margin of the section
|
||||
section.PageSetup.Margins.All = 72;
|
||||
WParagraph para = section.AddParagraph() as WParagraph;
|
||||
section.AddColumn(100, 100);
|
||||
section.AddColumn(100, 100);
|
||||
section.MakeColumnsEqual();
|
||||
|
||||
#region Built-in styles
|
||||
# region List Style
|
||||
|
||||
//List
|
||||
//para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("This para is written with style List").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.List);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
//List5 style
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style List5").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.List5);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
# endregion
|
||||
|
||||
# region ListNumber Style
|
||||
|
||||
//List Number style
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style ListNumber").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ListNumber);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
//List Number5 style
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style ListNumber5").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ListNumber5);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
# endregion
|
||||
|
||||
# region TOA Heading Style
|
||||
|
||||
//TOA Heading
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style TOA Heading").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ToaHeading);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
# endregion
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
section.BreakCode = SectionBreakCode.NewColumn;
|
||||
|
||||
# region ListBullet Style
|
||||
//ListBullet
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style ListBullet").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ListBullet);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
//ListBullet5
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style ListBullet5").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ListBullet5);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
# endregion
|
||||
|
||||
# region List Continue Style
|
||||
|
||||
//ListContinue
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style ListContinue").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ListContinue);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
//ListContinue5
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style ListContinue5").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.ListContinue5);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
# endregion
|
||||
|
||||
# region HTMLSample Style
|
||||
|
||||
//HtmlSample
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("\nThis para is written with style HtmlSample").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.HtmlSample);
|
||||
para.AppendText("Google Chrome\n");
|
||||
para.AppendText("Mozilla Firefox\n");
|
||||
para.AppendText("Internet Explorer");
|
||||
|
||||
# endregion
|
||||
|
||||
section = document.AddSection() as WSection;
|
||||
section.BreakCode = SectionBreakCode.NoBreak;
|
||||
|
||||
# region Document Map Style
|
||||
|
||||
//Docuemnt Map
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.AppendText("This para is written with style DocumentMap\n").CharacterFormat.UnderlineStyle = Syncfusion.Drawing.UnderlineStyle.Double;
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.DocumentMap);
|
||||
IWTextRange textrange = para.AppendText("Google Chrome\n");
|
||||
textrange.CharacterFormat.TextBackgroundColor = Syncfusion.Drawing.Color.Red;
|
||||
textrange = para.AppendText("Mozilla Firefox\n");
|
||||
textrange.CharacterFormat.TextBackgroundColor = Syncfusion.Drawing.Color.Red;
|
||||
textrange = para.AppendText("Internet Explorer");
|
||||
textrange.CharacterFormat.TextBackgroundColor = Syncfusion.Drawing.Color.Red;
|
||||
|
||||
#endregion
|
||||
|
||||
# region Heading Styles
|
||||
//Heading Styles
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading1);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading2);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading3);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading4);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading5);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading6);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading7);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading8);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
para = section.AddParagraph() as WParagraph;
|
||||
para.ApplyStyle(BuiltinStyle.Heading9);
|
||||
para.AppendText("Hello World. This para is written with style " + para.StyleName.ToString());
|
||||
|
||||
# endregion
|
||||
|
||||
#endregion Built-in styles
|
||||
|
||||
#region Saving Document
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("WordDocument_BuiltInStyles.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("WordDocument_BuiltInStyles.docx", "application/msword", stream);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns:SfRadio="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.CreateEquation">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to create a Word document with mathematical equations using Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label FontSize="Medium" Text="Save As:" Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="Start" VerticalTextAlignment="Center"/>
|
||||
<SfRadio:SfRadioGroup Grid.Column="1" Grid.Row="0" HeightRequest="30" Orientation="Horizontal">
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="docxButton" Text="DOCX"/>
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="pdfButton" Text="PDF"/>
|
||||
</SfRadio:SfRadioGroup>
|
||||
<Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,678 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
using Syncfusion.Office;
|
||||
using Syncfusion.DocIORenderer;
|
||||
using Syncfusion.Pdf;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class CreateEquation : SampleView
|
||||
{
|
||||
public CreateEquation()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.docxButton.IsChecked = true;
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
// if (!SampleBrowser.DocIO.App.isUWP)
|
||||
// {
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
// {
|
||||
this.Content_1.FontSize = 13.5;
|
||||
// }
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(CreateEquation).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "CreateEquation.docx");
|
||||
|
||||
// Loads the stream into Word Document.
|
||||
WordDocument document = new WordDocument(inputStream, Syncfusion.DocIO.FormatType.Automatic);
|
||||
//Gets the last section in the document
|
||||
WSection section = document.LastSection;
|
||||
//Sets page margins
|
||||
document.LastSection.PageSetup.Margins.All = 72;
|
||||
//Adds new paragraph to the section
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
|
||||
//Appends text to paragraph
|
||||
IWTextRange textRange = paragraph.AppendText("Mathematical equations");
|
||||
textRange.CharacterFormat.FontSize = 28;
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
paragraph.ParagraphFormat.AfterSpacing = 12;
|
||||
|
||||
#region Sum to the power of n
|
||||
//Adds new paragraph to the section
|
||||
paragraph = AddParagraph(section, "This is an expansion of the sum (1+X) to the power of n.");
|
||||
//Creates an equation with sum to the power of N
|
||||
CreateSumToThePowerOfN(paragraph);
|
||||
#endregion
|
||||
|
||||
#region Fourier series
|
||||
//Adds new paragraph to the section
|
||||
paragraph = AddParagraph(section, "This is a Fourier series for the function of period 2L");
|
||||
//Creates a Fourier series equation
|
||||
CreateFourierseries(paragraph);
|
||||
#endregion
|
||||
|
||||
#region Triple scalar product
|
||||
//Adds new paragraph to the section
|
||||
paragraph = AddParagraph(section, "This is an expansion of triple scalar product");
|
||||
//Creates a triple scalar product equation
|
||||
CreateTripleScalarProduct(paragraph);
|
||||
#endregion
|
||||
|
||||
#region Gamma function
|
||||
//Adds new paragraph to the section
|
||||
paragraph = AddParagraph(section, "This is an expansion of gamma function");
|
||||
//Creates a gamma function equation
|
||||
CreateGammaFunction(paragraph);
|
||||
#endregion
|
||||
|
||||
#region Vector relation
|
||||
//Adds new paragraph to the section
|
||||
paragraph = AddParagraph(section, "This is an expansion of vector relation ");
|
||||
//Creates a vector relation equation
|
||||
CreateVectorRelation(paragraph);
|
||||
#endregion
|
||||
|
||||
string filename = "";
|
||||
string contenttype = "";
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
if (this.pdfButton.IsChecked != null && (bool)this.pdfButton.IsChecked)
|
||||
{
|
||||
filename = "CreateEquation.pdf";
|
||||
contenttype = "application/pdf";
|
||||
DocIORenderer renderer = new DocIORenderer();
|
||||
PdfDocument pdfDoc = renderer.ConvertToPDF(document);
|
||||
pdfDoc.Save(outputStream);
|
||||
pdfDoc.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = "CreateEquation.docx";
|
||||
contenttype = "application/msword";
|
||||
document.Save(outputStream, FormatType.Docx);
|
||||
}
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save(filename, contenttype, outputStream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save(filename, contenttype, outputStream);
|
||||
}
|
||||
#region Helper Methods
|
||||
/// <summary>
|
||||
/// Adds new paragraph into the section
|
||||
/// </summary>
|
||||
/// <param name="section">Represents a section in Word document</param>
|
||||
/// <param name="text">Represents a text to append in paragraph</param>
|
||||
/// <returns>Returns a paragraph to add equation</returns>
|
||||
private IWParagraph AddParagraph(IWSection section, string text)
|
||||
{
|
||||
//Adds new paragraph to the section
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
//Adds new paragraph to add text
|
||||
paragraph = section.AddParagraph();
|
||||
//Appends text to paragraph
|
||||
paragraph.AppendText(text);
|
||||
paragraph.ParagraphFormat.AfterSpacing = 12;
|
||||
paragraph.ParagraphFormat.BeforeSpacing = 12;
|
||||
//Adds new paragraph to add equation
|
||||
paragraph = section.AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 12;
|
||||
return paragraph;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an expansion of triple scalar product
|
||||
/// </summary>
|
||||
/// <param name="paragraph">Represents a paragraph to add MathML element</param>
|
||||
private void CreateTripleScalarProduct(IWParagraph paragraph)
|
||||
{
|
||||
WordDocument document = paragraph.Document;
|
||||
//Creates a MathML element
|
||||
WMath math = paragraph.AppendMath();
|
||||
//Adds an office math
|
||||
IOfficeMath officeMath = math.MathParagraph.Maths.Add();
|
||||
|
||||
#region Math text
|
||||
//Unicode value of middle dot
|
||||
string middleDot = "\u00B7";
|
||||
string multiplicationSign = "\u00D7";
|
||||
string text = "A" + middleDot + "B" + multiplicationSign + "C";
|
||||
//Adds a math item
|
||||
IOfficeMathRunElement officeMathParaItem = AddMathText(document, officeMath, text);
|
||||
//Sets style for math text
|
||||
officeMathParaItem.MathFormat.Style = MathStyleType.Bold;
|
||||
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, officeMath, "=");
|
||||
//Sets style for math text
|
||||
officeMathParaItem.MathFormat.Style = MathStyleType.Bold;
|
||||
|
||||
//Adds math text
|
||||
text = "A" + multiplicationSign + "B" + middleDot + "C";
|
||||
officeMathParaItem = AddMathText(document, officeMath, text);
|
||||
//Sets style for math text
|
||||
officeMathParaItem.MathFormat.Style = MathStyleType.Bold;
|
||||
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, officeMath, "=");
|
||||
#endregion
|
||||
|
||||
#region Delimiter
|
||||
//Adds a delimiter
|
||||
IOfficeMathDelimiter mathDelimiter = officeMath.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Sets begin character for delimiter
|
||||
mathDelimiter.BeginCharacter = "|";
|
||||
//Sets end character for delimiter
|
||||
mathDelimiter.EndCharacter = "|";
|
||||
//Apply formats for delimiter
|
||||
mathDelimiter.ControlProperties = new WCharacterFormat(document);
|
||||
(mathDelimiter.ControlProperties as WCharacterFormat).Italic = true;
|
||||
|
||||
//Adds arguments for delimiter
|
||||
officeMath = mathDelimiter.Equation.Add() as IOfficeMath;
|
||||
|
||||
#region Matrix
|
||||
//Add matrix into delimiter
|
||||
IOfficeMathMatrix mathMatrix = officeMath.Functions.Add(MathFunctionType.Matrix) as IOfficeMathMatrix;
|
||||
//Add columns in matrix
|
||||
mathMatrix.Columns.Add();
|
||||
mathMatrix.Columns.Add();
|
||||
mathMatrix.Columns.Add();
|
||||
|
||||
#region First row
|
||||
//Adds a new row
|
||||
IOfficeMathMatrixRow mathMatrixRow = mathMatrix.Rows.Add();
|
||||
///Add values to row
|
||||
AddMatrixRowValues(document, mathMatrixRow, "A");
|
||||
#endregion
|
||||
|
||||
#region Second row
|
||||
//Adds a new row
|
||||
mathMatrixRow = mathMatrix.Rows.Add();
|
||||
///Add values to row
|
||||
AddMatrixRowValues(document, mathMatrixRow, "B");
|
||||
#endregion
|
||||
|
||||
#region Third row
|
||||
//Adds a new row
|
||||
mathMatrixRow = mathMatrix.Rows.Add();
|
||||
///Add values to row
|
||||
AddMatrixRowValues(document, mathMatrixRow, "C");
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an expansion of vector relation
|
||||
/// </summary>
|
||||
/// <param name="paragraph">Represents a paragraph to add MathML element</param>
|
||||
private void CreateVectorRelation(IWParagraph paragraph)
|
||||
{
|
||||
WordDocument document = paragraph.Document;
|
||||
//Creates a MathML element
|
||||
WMath math = paragraph.AppendMath();
|
||||
|
||||
IOfficeMath officeMath = math.MathParagraph.Maths.Add();
|
||||
//Adds an accent equation
|
||||
AddMathAccent(document, officeMath, 8407, "A");
|
||||
|
||||
//Adds a math text
|
||||
string middleDot = "\u00B7";
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
IOfficeMathRunElement officeMathParaItem = AddMathText(document, officeMath, middleDot);
|
||||
|
||||
//Adds an accent equation
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
AddMathAccent(document, officeMath, 8407, "B");
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
string multiplicationSign = "\u00D7";
|
||||
officeMathParaItem = AddMathText(document, officeMath, multiplicationSign);
|
||||
|
||||
//Adds an accent equation
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
AddMathAccent(document, officeMath, 8407, "C");
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
officeMathParaItem = AddMathText(document, officeMath, "=");
|
||||
|
||||
//Adds an accent equation
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
AddMathAccent(document, officeMath, 8407, "A");
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
officeMathParaItem = AddMathText(document, officeMath, multiplicationSign);
|
||||
|
||||
//Adds an accent equation
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
AddMathAccent(document, officeMath, 8407, "B");
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
officeMathParaItem = AddMathText(document, officeMath, middleDot);
|
||||
|
||||
//Adds an accent equation
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
AddMathAccent(document, officeMath, 8407, "C");
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts short value to string
|
||||
/// </summary>
|
||||
/// <param name="value">Represents a short value</param>
|
||||
private static string ConvertShortToString(short value)
|
||||
{
|
||||
char chrValue = Convert.ToChar(value);
|
||||
string strValue = Convert.ToString(chrValue);
|
||||
return strValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an equation with sum to the power of N
|
||||
/// </summary>
|
||||
/// <param name="paragraph">Represents a paragraph to add MathML element</param>
|
||||
private void CreateSumToThePowerOfN(IWParagraph paragraph)
|
||||
{
|
||||
WordDocument document = paragraph.Document;
|
||||
//Creates a new MathML element
|
||||
WMath math = paragraph.AppendMath();
|
||||
|
||||
IOfficeMath officeMath = math.MathParagraph.Maths.Add();
|
||||
//Adds a math script element
|
||||
IOfficeMathScript mathScript = AddMathScript(officeMath, MathScriptType.Superscript);
|
||||
|
||||
#region Delimiter equation
|
||||
//Adds a delimiter
|
||||
IOfficeMathDelimiter mathDelimiter = mathScript.Equation.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Adds an office math in the delimiter
|
||||
officeMath = mathDelimiter.Equation.Add() as IOfficeMath;
|
||||
//Adds a math text
|
||||
IOfficeMathRunElement mathParaItem = AddMathText(document, officeMath, "1+x");
|
||||
//Adds a math text
|
||||
mathParaItem = AddMathText(document, mathScript.Script, "n");
|
||||
#endregion
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add(1);
|
||||
mathParaItem = AddMathText(document, officeMath, "=1+");
|
||||
|
||||
#region Fraction equation
|
||||
//Adds a math fraction
|
||||
IOfficeMathFraction mathFraction = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction;
|
||||
//Adds a numerator text
|
||||
AddMathText(document, mathFraction.Numerator, "nx");
|
||||
//Adds a denominator text
|
||||
AddMathText(document, mathFraction.Denominator, "1!");
|
||||
#endregion
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
mathParaItem = AddMathText(document, officeMath, "+");
|
||||
|
||||
#region Fraction equation
|
||||
//Adds a math fraction
|
||||
mathFraction = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction;
|
||||
|
||||
#region Numerator
|
||||
//Adds a numerator text
|
||||
AddMathText(document, mathFraction.Numerator, "n");
|
||||
|
||||
//Adds a delimiter
|
||||
mathDelimiter = mathFraction.Numerator.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Adds a math text for delimiter
|
||||
officeMath = mathDelimiter.Equation.Add() as IOfficeMath;
|
||||
AddMathText(document, officeMath, "n-1");
|
||||
|
||||
//Adds a math script
|
||||
mathScript = mathFraction.Numerator.Functions.Add(MathFunctionType.SubSuperscript) as IOfficeMathScript;
|
||||
//Adds a math text for Superscript
|
||||
AddMathText(document, mathScript.Equation, "x");
|
||||
AddMathText(document, mathScript.Script, "2");
|
||||
#endregion
|
||||
|
||||
#region Denominator
|
||||
//Adds a math text for denominator
|
||||
AddMathText(document, mathFraction.Denominator, "2!");
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
AddMathText(document, officeMath, "+...");
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates an expansion of Gamma function
|
||||
/// </summary>
|
||||
/// <param name="paragraph">Represents a paragraph to add MathML element</param>
|
||||
private void CreateGammaFunction(IWParagraph paragraph)
|
||||
{
|
||||
WordDocument document = paragraph.Document;
|
||||
//Creates a new MathML element
|
||||
WMath math = paragraph.AppendMath();
|
||||
|
||||
//Adds a math text
|
||||
IOfficeMath officeMath = math.MathParagraph.Maths.Add();
|
||||
//Unicode value of capital gamma
|
||||
string capitalGamma = "\u0393";
|
||||
IOfficeMathRunElement officeMathParaItem = AddMathText(document, officeMath, capitalGamma);
|
||||
//Sets MathML style format for the text
|
||||
officeMathParaItem.MathFormat.Style = MathStyleType.Regular;
|
||||
|
||||
//Adds a delimiter equation
|
||||
IOfficeMathDelimiter mathDelimiter = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Adds a equation to the delimiter
|
||||
officeMath = mathDelimiter.Equation.Add();
|
||||
//Adds a math text
|
||||
officeMathParaItem = AddMathText(document, officeMath, "z");
|
||||
|
||||
//Adds a math text
|
||||
officeMath = math.MathParagraph.Maths.Add();
|
||||
officeMathParaItem = AddMathText(document, officeMath, "=");
|
||||
|
||||
//Adds an n array element
|
||||
IOfficeMathNArray mathNAry = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.NArray) as IOfficeMathNArray;
|
||||
//Adds a math text
|
||||
AddMathText(document, mathNAry.Subscript, "0");
|
||||
|
||||
//Adds a math text
|
||||
string infinitySymbol = "\u221E";
|
||||
AddMathText(document, mathNAry.Superscript, infinitySymbol);
|
||||
|
||||
//Adds a math superscript
|
||||
IOfficeMathScript mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript);
|
||||
//Adds a math text for Superscript
|
||||
AddMathText(document, mathScript.Equation, "t");
|
||||
AddMathText(document, mathScript.Script, "z-1");
|
||||
//Adds a Superscript
|
||||
mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript);
|
||||
|
||||
AddMathText(document, mathScript.Equation, "e");
|
||||
AddMathText(document, mathScript.Script, "-t");
|
||||
|
||||
//Adds a math text in n Array equation
|
||||
AddMathText(document, mathNAry.Equation, "dt");
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, math.MathParagraph.Maths.Add(), "=");
|
||||
|
||||
//Adds a fraction equation
|
||||
IOfficeMathFraction mathFraction = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction;
|
||||
//Adds a math script
|
||||
mathScript = AddMathScript(mathFraction.Numerator, MathScriptType.Superscript);
|
||||
|
||||
//Adds a math text for Superscript
|
||||
AddMathText(document, mathScript.Equation, "e");
|
||||
AddMathText(document, mathScript.Script, "-");
|
||||
//Unicode of small gamma
|
||||
string smallGamma = "\u03B3";
|
||||
AddMathText(document, mathScript.Script, smallGamma);
|
||||
AddMathText(document, mathScript.Script, "z");
|
||||
|
||||
|
||||
//Adds a math text for denominator
|
||||
AddMathText(document, mathFraction.Denominator, "z");
|
||||
|
||||
//Adds an n-array element
|
||||
mathNAry = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.NArray) as IOfficeMathNArray;
|
||||
//Unicode value of n-array product
|
||||
string symbol = "\u220F";
|
||||
//Adds a n-array character
|
||||
mathNAry.NArrayCharacter = symbol;
|
||||
//Adds a math text
|
||||
AddMathText(document, mathNAry.Subscript, "k=1");
|
||||
//Adds a math text
|
||||
AddMathText(document, mathNAry.Superscript, infinitySymbol);
|
||||
|
||||
//Adds a math script
|
||||
mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript);
|
||||
//Adds a math delimiter element
|
||||
mathDelimiter = mathScript.Equation.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Adds a equation to the delimiter equation collection
|
||||
officeMath = mathDelimiter.Equation.Add();
|
||||
//Adds a math text
|
||||
AddMathText(document, officeMath, "1+");
|
||||
|
||||
//Adds a fraction element
|
||||
mathFraction = officeMath.Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction;
|
||||
//Adds a math text for numerator
|
||||
AddMathText(document, mathFraction.Numerator, "z");
|
||||
//Adds a math text for denominator
|
||||
AddMathText(document, mathFraction.Denominator, "k");
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, mathScript.Script, "-1");
|
||||
//Adds a Superscript equation
|
||||
mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript);
|
||||
//Adds a math text for Superscript
|
||||
AddMathText(document, mathScript.Equation, "e");
|
||||
AddMathText(document, mathScript.Script, "z");
|
||||
officeMathParaItem = AddMathText(document, mathScript.Script, "/");
|
||||
officeMathParaItem.MathFormat.HasLiteral = true;
|
||||
AddMathText(document, mathScript.Script, "k");
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, math.MathParagraph.Maths.Add(), ",");
|
||||
|
||||
//Adds a math text
|
||||
officeMathParaItem = AddMathText(document, math.MathParagraph.Maths.Add(), " ");
|
||||
//Sets style for math text
|
||||
officeMathParaItem.MathFormat.Style = MathStyleType.Regular;
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, math.MathParagraph.Maths.Add(), smallGamma);
|
||||
string text = "\u2248" + "0.577216";
|
||||
AddMathText(document, math.MathParagraph.Maths.Add(), text);
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a Fourier series equation
|
||||
/// </summary>
|
||||
/// <param name="paragraph">Represents a paragraph to add MathML element</param>
|
||||
private void CreateFourierseries(IWParagraph paragraph)
|
||||
{
|
||||
WordDocument document = paragraph.Document;
|
||||
//Creates a new MathML element
|
||||
WMath math = paragraph.AppendMath();
|
||||
|
||||
//Adds a math
|
||||
IOfficeMath officeMath = math.MathParagraph.Maths.Add();
|
||||
//Adds a math text
|
||||
AddMathText(document, officeMath, "f");
|
||||
|
||||
//Adds a math delimiter
|
||||
IOfficeMathDelimiter mathDelimiter = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Adds a math in the delimiter
|
||||
officeMath = mathDelimiter.Equation.Add() as IOfficeMath;
|
||||
//Adds a math text
|
||||
AddMathText(document, officeMath, "x");
|
||||
AddMathText(document, math.MathParagraph.Maths.Add(), "=");
|
||||
//Adds a Subscript equation
|
||||
IOfficeMathScript mathScript = AddMathScript(math.MathParagraph.Maths.Add(), MathScriptType.Subscript);
|
||||
//Adds a math text
|
||||
AddMathText(document, mathScript.Equation, "a");
|
||||
AddMathText(document, mathScript.Script, "0");
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, math.MathParagraph.Maths.Add(), "+");
|
||||
|
||||
//Adds a math n-array
|
||||
IOfficeMathNArray mathNAry = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.NArray) as IOfficeMathNArray;
|
||||
//Unicode value of n-array summation
|
||||
string sigma = "\u2211";
|
||||
//Sets the value as the n-array character
|
||||
mathNAry.NArrayCharacter = sigma;
|
||||
mathNAry.HasGrow = true;
|
||||
//Adds a math text
|
||||
AddMathText(document, mathNAry.Subscript, "n=1");
|
||||
|
||||
//Adds a math text
|
||||
string infinitySymbol = "\u221E";
|
||||
AddMathText(document, mathNAry.Superscript, infinitySymbol);
|
||||
//Adds a math delimiter
|
||||
mathDelimiter = mathNAry.Equation.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter;
|
||||
//Adds an math in the delimiter equation collection
|
||||
officeMath = mathDelimiter.Equation.Add() as IOfficeMath;
|
||||
//Adds a math script
|
||||
mathScript = AddMathScript(officeMath, MathScriptType.Subscript);
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, mathScript.Equation, "a");
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, mathScript.Script, "n");
|
||||
|
||||
//Adds a math function
|
||||
IOfficeMathFunction mathFunction = officeMath.Functions.Add(MathFunctionType.Function) as IOfficeMathFunction;
|
||||
//Adds a math text
|
||||
IOfficeMathRunElement mathParaItem = AddMathText(document, mathFunction.FunctionName, "cos");
|
||||
mathParaItem.MathFormat.Style = MathStyleType.Regular;
|
||||
|
||||
//Adds a math fraction
|
||||
IOfficeMathFraction mathFraction = mathFunction.Equation.Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction;
|
||||
//Adds a math text
|
||||
//Unicode value of PI
|
||||
string pi = "\uD835\uDF0B";
|
||||
string text = "n" + pi + "x";
|
||||
AddMathText(document, mathFraction.Numerator, text);
|
||||
AddMathText(document, mathFraction.Denominator, "L");
|
||||
|
||||
//Adds a math text
|
||||
AddMathText(document, officeMath, "+");
|
||||
//Adds a math script
|
||||
mathScript = AddMathScript(officeMath, MathScriptType.Subscript);
|
||||
//Adds a math text
|
||||
AddMathText(document, mathScript.Equation, "b");
|
||||
AddMathText(document, mathScript.Script, "n");
|
||||
|
||||
//Adds a function
|
||||
mathFunction = officeMath.Functions.Add(MathFunctionType.Function) as IOfficeMathFunction;
|
||||
//Adds a math text
|
||||
mathParaItem = AddMathText(document, mathFunction.FunctionName, "sin");
|
||||
mathParaItem.MathFormat.Style = MathStyleType.Regular;
|
||||
|
||||
//Adds a math fraction element
|
||||
mathFraction = mathFunction.Equation.Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction;
|
||||
//Adds a math text for numerator
|
||||
AddMathText(document, mathFraction.Numerator, text);
|
||||
//Adds a math text for denominator
|
||||
AddMathText(document, mathFraction.Denominator, "L");
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a math text
|
||||
/// </summary>
|
||||
/// <param name="document">Represents a Word document to add math text</param>
|
||||
/// <param name="officeMath">Represents an office math to add math text</param>
|
||||
/// <param name="text">Represents the text to set for math item</param>
|
||||
private IOfficeMathRunElement AddMathText(WordDocument document, IOfficeMath officeMath, string text)
|
||||
{
|
||||
//Adds math text
|
||||
IOfficeMathRunElement officeMathParaItem = officeMath.Functions.Add(MathFunctionType.RunElement) as IOfficeMathRunElement;
|
||||
officeMathParaItem.Item = new WTextRange(document);
|
||||
//Set math text value
|
||||
(officeMathParaItem.Item as WTextRange).Text = text;
|
||||
return officeMathParaItem;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a math Subscript or Superscript equation
|
||||
/// </summary>
|
||||
private IOfficeMathScript AddMathScript(IOfficeMath officeMath, MathScriptType mathScriptType)
|
||||
{
|
||||
IOfficeMathScript mathScript = officeMath.Functions.Add(MathFunctionType.SubSuperscript) as IOfficeMathScript;
|
||||
//Sets the script type as Subscript or Superscript
|
||||
mathScript.ScriptType = mathScriptType;
|
||||
return mathScript;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a accent equation
|
||||
/// </summary>
|
||||
/// <param name="document">Represents a Word document</param>
|
||||
/// <param name="officeMath">Represents a office math to add accent equation</param>
|
||||
/// <param name="accentCharValue">Represents a accent character</param>
|
||||
/// <param name="text">Represents a text for accent equation</param>
|
||||
private void AddMathAccent(WordDocument document, IOfficeMath officeMath, short accentCharValue, string text)
|
||||
{
|
||||
IOfficeMathAccent mathAccent = officeMath.Functions.Add(MathFunctionType.Accent) as IOfficeMathAccent;
|
||||
//Sets the accent character from short value
|
||||
mathAccent.AccentCharacter = ConvertShortToString(accentCharValue);
|
||||
//Adds a math text
|
||||
IOfficeMathRunElement officeMathParaItem = AddMathText(document, mathAccent.Equation, text);
|
||||
}
|
||||
/// <summary>
|
||||
/// Add values in matrix row
|
||||
/// </summary>
|
||||
/// <param name="document">Represents a Word document to add matrix</param>
|
||||
/// <param name="mathMatrixRow">Represents a matrix row to add values</param>
|
||||
/// <param name="text">Represents a base text value for Subscript and Superscript equation</param>
|
||||
private void AddMatrixRowValues(WordDocument document, IOfficeMathMatrixRow mathMatrixRow, string text)
|
||||
{
|
||||
//Adds arguments for matrix row
|
||||
IOfficeMath officeMath = mathMatrixRow.Arguments[0];
|
||||
//Adds a Subscript
|
||||
IOfficeMathScript mathScript = AddMathScript(officeMath, MathScriptType.Subscript);
|
||||
//Adds a math text
|
||||
IOfficeMathRunElement officeMathParaItem = AddMathText(document, mathScript.Equation, text);
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, mathScript.Script, "x");
|
||||
|
||||
//Adds arguments for matrix row
|
||||
officeMath = mathMatrixRow.Arguments[1];
|
||||
//Adds a script
|
||||
mathScript = AddMathScript(officeMath, MathScriptType.Subscript);
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, mathScript.Equation, text);
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, mathScript.Script, "y");
|
||||
|
||||
//Adds arguments for matrix row
|
||||
officeMath = mathMatrixRow.Arguments[2];
|
||||
//Adds a script
|
||||
mathScript = AddMathScript(officeMath, MathScriptType.Subscript);
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, mathScript.Equation, text);
|
||||
//Adds math text
|
||||
officeMathParaItem = AddMathText(document, mathScript.Script, "z");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.CustomStyle">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to format the Word document contents with user defined styles." FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,122 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class CustomStyle : SampleView
|
||||
{
|
||||
public CustomStyle()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
// if (!SampleBrowser.DocIO.App.isUWP)
|
||||
//{
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
//}
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
WordDocument document = new WordDocument();
|
||||
IWParagraphStyle style = null;
|
||||
// Adding a new section to the document.
|
||||
WSection section = document.AddSection() as WSection;
|
||||
//Set Margin of the section
|
||||
section.PageSetup.Margins.All = 72;
|
||||
IWParagraph par = document.LastSection.AddParagraph();
|
||||
WTextRange range = par.AppendText("Using CustomStyles") as WTextRange;
|
||||
range.CharacterFormat.TextBackgroundColor = Syncfusion.Drawing.Color.Red;
|
||||
range.CharacterFormat.TextColor = Syncfusion.Drawing.Color.White;
|
||||
range.CharacterFormat.FontSize = 18f;
|
||||
document.LastParagraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
|
||||
// Create Paragraph styles
|
||||
style = document.AddParagraphStyle("MyStyle_Normal");
|
||||
style.CharacterFormat.FontName = "Bitstream Vera Serif";
|
||||
style.CharacterFormat.FontSize = 10f;
|
||||
style.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify;
|
||||
style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(0, 21, 84);
|
||||
|
||||
style = document.AddParagraphStyle("MyStyle_Low");
|
||||
style.CharacterFormat.FontName = "Times New Roman";
|
||||
style.CharacterFormat.FontSize = 16f;
|
||||
style.CharacterFormat.Bold = true;
|
||||
|
||||
style = document.AddParagraphStyle("MyStyle_Medium");
|
||||
style.CharacterFormat.FontName = "Monotype Corsiva";
|
||||
style.CharacterFormat.FontSize = 18f;
|
||||
style.CharacterFormat.Bold = true;
|
||||
style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(51, 66, 125);
|
||||
|
||||
style = document.AddParagraphStyle("Mystyle_High");
|
||||
style.CharacterFormat.FontName = "Bitstream Vera Serif";
|
||||
style.CharacterFormat.FontSize = 20f;
|
||||
style.CharacterFormat.Bold = true;
|
||||
style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50);
|
||||
|
||||
IWParagraph paragraph = null;
|
||||
for (int i = 1; i < document.Styles.Count; i++)
|
||||
{
|
||||
//Skip to apply the document default styles and also paragraph style.
|
||||
if(document.Styles[i].Name=="Normal"||document.Styles[i].Name=="Default Paragraph Font"||document.Styles[i].StyleType!=StyleType.ParagraphStyle)
|
||||
continue;
|
||||
// Getting styles from Document.
|
||||
style = (IWParagraphStyle)document.Styles[i];
|
||||
// Adding a new paragraph
|
||||
section.AddParagraph();
|
||||
paragraph = section.AddParagraph();
|
||||
// Applying styles to the current paragraph.
|
||||
paragraph.ApplyStyle(style.Name);
|
||||
// Writing Text with the current style and formatting.
|
||||
paragraph.AppendText("Northwind Database with [" + style.Name + "] Style");
|
||||
// Adding a new paragraph
|
||||
section.AddParagraph();
|
||||
paragraph = section.AddParagraph();
|
||||
// Applying another style to the current paragraph.
|
||||
paragraph.ApplyStyle("MyStyle_Normal");
|
||||
// Writing text with current style.
|
||||
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that illustrate features you might want to implement in your own databases. Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.");
|
||||
}
|
||||
#region Saving Document
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("WordDocument_CustomStyles.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("WordDocument_CustomStyles.docx", "application/msword", stream);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.DocIO_BarChart">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to create a bar chart in a Word document with the data from an existing Excel file."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,118 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using SampleBrowser.Core;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using Syncfusion.DocIO;
|
||||
using Syncfusion.OfficeChart;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class DocIO_BarChart : SampleView
|
||||
{
|
||||
public DocIO_BarChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Xamarin.Forms.Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
//if (!SampleBrowser.DocIO.App.isUWP)
|
||||
//{
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
//}
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(DocIO_BarChart).GetTypeInfo().Assembly;
|
||||
//A new document is created.
|
||||
WordDocument document = new WordDocument();
|
||||
//Add new section to the Word document
|
||||
IWSection section = document.AddSection();
|
||||
//Set page margins of the section
|
||||
section.PageSetup.Margins.All = 72;
|
||||
//Add new paragraph to the section
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
//Apply heading style to the title paragraph
|
||||
paragraph.ApplyStyle(BuiltinStyle.Heading1);
|
||||
//Apply center alignment to the paragraph
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
//Append text to the paragraph
|
||||
paragraph.AppendText("Northwind Management Report").CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(46, 116, 181);
|
||||
//Add new paragraph
|
||||
paragraph = section.AddParagraph();
|
||||
//Set before spacing to the paragraph
|
||||
paragraph.ParagraphFormat.BeforeSpacing = 20;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
//Load the excel template as stream
|
||||
Stream excelStream = assembly.GetManifestResourceStream(rootPath + "Excel_Template.xlsx");
|
||||
//Create and Append chart to the paragraph with excel stream as parameter
|
||||
WChart barChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
|
||||
//Set chart data
|
||||
barChart.ChartType = OfficeChartType.Bar_Clustered;
|
||||
barChart.ChartTitle = "Purchase Details";
|
||||
barChart.ChartTitleArea.FontName = "Calibri (Body)";
|
||||
barChart.ChartTitleArea.Size = 14;
|
||||
//Set name to chart series
|
||||
barChart.Series[0].Name = "Sum of Purchases";
|
||||
barChart.Series[1].Name = "Sum of Future Expenses";
|
||||
//Set Chart Data table
|
||||
barChart.HasDataTable = true;
|
||||
barChart.DataTable.HasBorders = true;
|
||||
barChart.DataTable.HasHorzBorder = true;
|
||||
barChart.DataTable.HasVertBorder = true;
|
||||
barChart.DataTable.ShowSeriesKeys = true;
|
||||
barChart.HasLegend = false;
|
||||
//Setting background color
|
||||
barChart.ChartArea.Fill.ForeColor = Syncfusion.Drawing.Color.FromArgb(208, 206, 206);
|
||||
barChart.PlotArea.Fill.ForeColor = Syncfusion.Drawing.Color.FromArgb(208, 206, 206);
|
||||
//Setting line pattern to the chart area
|
||||
barChart.PrimaryCategoryAxis.Border.LinePattern = OfficeChartLinePattern.None;
|
||||
barChart.PrimaryValueAxis.Border.LinePattern = OfficeChartLinePattern.None;
|
||||
barChart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
|
||||
barChart.PrimaryValueAxis.MajorGridLines.Border.LineColor = Syncfusion.Drawing.Color.FromArgb(175, 171, 171);
|
||||
//Set label for primary catagory axis
|
||||
barChart.PrimaryCategoryAxis.CategoryLabels = barChart.ChartData[2, 1, 6, 1];
|
||||
#region Saving Document
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("BarChart.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("BarChart.docx", "application/msword", stream);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.DocIO_PieChart">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to create a pie chart in a Word document."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,204 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using SampleBrowser.Core;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Syncfusion.DocIO;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using Syncfusion.OfficeChart;
|
||||
using Xamarin.Forms;
|
||||
using System.Xml.Linq;
|
||||
using System.Globalization;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class DocIO_PieChart : SampleView
|
||||
{
|
||||
public DocIO_PieChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Xamarin.Forms.Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
//if (!SampleBrowser.DocIO.App.isUWP)
|
||||
// {
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
this.Content_1.FontSize = 13.5;
|
||||
//}
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(DocIO_PieChart).GetTypeInfo().Assembly;
|
||||
//A new document is created.
|
||||
WordDocument document = new WordDocument();
|
||||
//Add new section to the Word document
|
||||
IWSection section = document.AddSection();
|
||||
//Set page margins of the section
|
||||
section.PageSetup.Margins.All = 72;
|
||||
//Add new paragraph to the section
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
//Apply heading style to the title paragraph
|
||||
paragraph.ApplyStyle(BuiltinStyle.Heading1);
|
||||
//Apply center alignment to the paragraph
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
//Append text to the paragraph
|
||||
paragraph.AppendText("Northwind Management Report").CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(46, 116, 181);
|
||||
//Add new paragraph
|
||||
paragraph = section.AddParagraph();
|
||||
//Get chart data from xml file
|
||||
List<ProductDetail> Products = LoadXMLData();
|
||||
//Create and Append chart to the paragraph
|
||||
WChart pieChart = document.LastParagraph.AppendChart(446, 270);
|
||||
//Set chart data
|
||||
pieChart.ChartType = OfficeChartType.Pie;
|
||||
pieChart.ChartTitle = "Best Selling Products";
|
||||
pieChart.ChartTitleArea.FontName = "Calibri (Body)";
|
||||
pieChart.ChartTitleArea.Size = 14;
|
||||
for (int i = 0; i < Products.Count; i++)
|
||||
{
|
||||
ProductDetail product = Products[i];
|
||||
pieChart.ChartData.SetValue(i + 2, 1, product.ProductName);
|
||||
pieChart.ChartData.SetValue(i + 2, 2, product.Sum);
|
||||
}
|
||||
//Create a new chart series with the name “Sales”
|
||||
IOfficeChartSerie pieSeries = pieChart.Series.Add("Sales");
|
||||
pieSeries.Values = pieChart.ChartData[2, 2, 11, 2];
|
||||
//Setting data label
|
||||
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsPercentage = true;
|
||||
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside;
|
||||
//Setting background color
|
||||
pieChart.ChartArea.Fill.ForeColor = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
|
||||
pieChart.PlotArea.Fill.ForeColor = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
|
||||
pieChart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
|
||||
pieChart.PrimaryCategoryAxis.CategoryLabels = pieChart.ChartData[2, 1, 11, 1];
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>()
|
||||
.Save("PieChart.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("PieChart.docx", "application/msword", stream);
|
||||
}
|
||||
|
||||
private List<ProductDetail> LoadXMLData()
|
||||
{
|
||||
XDocument productXml;
|
||||
List<ProductDetail> Products = new List<ProductDetail>();
|
||||
ProductDetail productDetails;
|
||||
Assembly assembly = typeof(DocIO_PieChart).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
Stream productXMLStream = assembly.GetManifestResourceStream(rootPath + "Products.xml");
|
||||
productXml = XDocument.Load(productXMLStream);
|
||||
IEnumerable<XElement> pc = from p in productXml.Descendants("Product") select p;
|
||||
string serailNo = string.Empty;
|
||||
string productName = string.Empty;
|
||||
string sum = string.Empty;
|
||||
foreach (XElement dt in pc)
|
||||
{
|
||||
|
||||
foreach (XElement el in dt.Descendants())
|
||||
{
|
||||
var xElement = dt.Element(el.Name);
|
||||
if (xElement != null)
|
||||
{
|
||||
string value = xElement.Value;
|
||||
string elementName = el.Name.ToString();
|
||||
switch (elementName)
|
||||
{
|
||||
case "SNO":
|
||||
serailNo = value;
|
||||
break;
|
||||
case "ProductName":
|
||||
productName = value;
|
||||
break;
|
||||
case "Sum":
|
||||
sum = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
productDetails = new ProductDetail(int.Parse(serailNo), productName, decimal.Parse(sum, CultureInfo.InvariantCulture));
|
||||
Products.Add(productDetails);
|
||||
}
|
||||
return Products;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProductDetail
|
||||
{
|
||||
#region fields
|
||||
|
||||
private int m_serialNo;
|
||||
private string m_productName;
|
||||
private decimal m_sum;
|
||||
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
|
||||
public int SNO
|
||||
{
|
||||
get { return m_serialNo; }
|
||||
set { m_serialNo = value; }
|
||||
}
|
||||
|
||||
public string ProductName
|
||||
{
|
||||
get { return m_productName; }
|
||||
set { m_productName = value; }
|
||||
}
|
||||
|
||||
public decimal Sum
|
||||
{
|
||||
get { return m_sum; }
|
||||
set { m_sum = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public ProductDetail(int serialNumber, string productName, decimal sum)
|
||||
{
|
||||
SNO = serialNumber;
|
||||
ProductName = productName;
|
||||
Sum = Math.Round(sum, 3);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.EmployeeList_MailMerge">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
<Label x:Name="Content_1" Text="This sample demonstrates how to create an employee report using Mail merge functionality of Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,177 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
using System.Data;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class EmployeeList_MailMerge : SampleView
|
||||
{
|
||||
public EmployeeList_MailMerge()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(MailMerge).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
// Creating a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "EmployeesReportDemo.doc");
|
||||
//Open Template document
|
||||
document.Open(inputStream, FormatType.Word2013);
|
||||
inputStream.Dispose();
|
||||
|
||||
System.Data.DataTable table = GetDataTable();
|
||||
//Uses the mail merge events handler for image fields
|
||||
|
||||
document.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MergeField_ProductImage);
|
||||
|
||||
document.MailMerge.ExecuteGroup(table);
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("EmployeeList.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("EmployeeList.docx", "application/msword", stream);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the Employees record in DataTable format
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private DataTable GetDataTable()
|
||||
{
|
||||
//Data source
|
||||
DataSet ds = new DataSet();
|
||||
ds.Tables.Add();
|
||||
//Defining columns
|
||||
ds.Tables[0].TableName = "Employees";
|
||||
ds.Tables[0].Columns.Add("Photo");
|
||||
ds.Tables[0].Columns.Add("FirstName");
|
||||
ds.Tables[0].Columns.Add("LastName");
|
||||
ds.Tables[0].Columns.Add("Title");
|
||||
ds.Tables[0].Columns.Add("Address");
|
||||
ds.Tables[0].Columns.Add("City");
|
||||
ds.Tables[0].Columns.Add("Region");
|
||||
ds.Tables[0].Columns.Add("Country");
|
||||
ds.Tables[0].Columns.Add("PostalCode");
|
||||
ds.Tables[0].Columns.Add("HomePhone");
|
||||
ds.Tables[0].Columns.Add("Extension");
|
||||
ds.Tables[0].Columns.Add("BirthDate");
|
||||
//Set values.
|
||||
DataRow row;
|
||||
row = ds.Tables["Employees"].NewRow();
|
||||
row["Photo"] = "SampleImage.png";
|
||||
row["FirstName"] = "Nancy";
|
||||
row["LastName"] = "Davolio";
|
||||
row["Title"] = "Sales Representative";
|
||||
row["Address"] = "507 - 20th Ave. E.Apt. 2A";
|
||||
row["City"] = "Seattle";
|
||||
row["Region"] = "WA";
|
||||
row["Country"] = "USA";
|
||||
row["PostalCode"] = "98122";
|
||||
row["HomePhone"] = "(206) 555-9857";
|
||||
row["Extension"] = "5467";
|
||||
row["BirthDate"] = "08-12-1948 12:00:00 AM";
|
||||
ds.Tables["Employees"].Rows.Add(row);
|
||||
|
||||
row = ds.Tables["Employees"].NewRow();
|
||||
row["Photo"] = "SampleImage.png";
|
||||
row["FirstName"] = "Andrew";
|
||||
row["LastName"] = "Fuller";
|
||||
row["Title"] = "Vice President, Sales";
|
||||
row["Address"] = "507 - 20th Ave. E.Apt. 2A";
|
||||
row["City"] = "Tacoma";
|
||||
row["Region"] = "WA";
|
||||
row["Country"] = "USA";
|
||||
row["PostalCode"] = "98401";
|
||||
row["HomePhone"] = "(206) 555-9842";
|
||||
row["Extension"] = "3457";
|
||||
row["BirthDate"] = "19-02-1952 12:00:00 AM";
|
||||
ds.Tables["Employees"].Rows.Add(row);
|
||||
|
||||
row = ds.Tables["Employees"].NewRow();
|
||||
row["Photo"] = "SampleImage.png";
|
||||
row["FirstName"] = "Janet";
|
||||
row["LastName"] = "Leverling";
|
||||
row["Title"] = "Sales Representative";
|
||||
row["Address"] = "722 Moss Bay Blvd";
|
||||
row["City"] = "Kirkland";
|
||||
row["Region"] = "WA";
|
||||
row["Country"] = "USA";
|
||||
row["PostalCode"] = "98033";
|
||||
row["HomePhone"] = "(206) 555-3412";
|
||||
row["Extension"] = "3355";
|
||||
row["BirthDate"] = "30-08-1963 12:00:00 AM";
|
||||
ds.Tables["Employees"].Rows.Add(row);
|
||||
DataTable table = ds.Tables["Employees"];
|
||||
return table;
|
||||
}
|
||||
/// <summary>
|
||||
/// Execute the MergeImageFieldEvent to merge the images to corresponding image fields
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
private void MergeField_ProductImage(object sender, MergeImageFieldEventArgs args)
|
||||
|
||||
{
|
||||
Assembly assembly = typeof(MailMerge).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
|
||||
//Binds image from file system during mail merge
|
||||
|
||||
if (args.FieldName == "Photo")
|
||||
|
||||
{
|
||||
|
||||
string ProductFileName = args.FieldValue.ToString();
|
||||
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + ProductFileName);
|
||||
|
||||
args.ImageStream = inputStream;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns:SfRadio="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.EncryptAndDecrypt">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding="10">
|
||||
<Label x:Name="Description" Text="This sample demonstrates how to encrypt and decrypt the Word document using Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<SfRadio:SfRadioGroup Grid.Column="0" Grid.Row="1" HeightRequest="60" Orientation="Vertical">
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="encryptButton" Text="Encrypt Document"/>
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="decryptButton" Text="Decrypt Document"/>
|
||||
</SfRadio:SfRadioGroup>
|
||||
<Button Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
</local:SampleView>
|
|
@ -0,0 +1,119 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using SampleBrowser.DocIO;
|
||||
using Syncfusion.DocIORenderer;
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.OfficeChart;
|
||||
using Syncfusion.Drawing;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class EncryptAndDecrypt : SampleView
|
||||
{
|
||||
public EncryptAndDecrypt()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.encryptButton.IsChecked = true;
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Description.HorizontalOptions = Xamarin.Forms.LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = Xamarin.Forms.LayoutOptions.Start;
|
||||
this.Description.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Xamarin.Forms.Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
{
|
||||
this.Description.FontSize = 13.5;
|
||||
}
|
||||
|
||||
this.Description.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
WordDocument document = null;
|
||||
if (this.encryptButton != null && (bool)this.encryptButton.IsChecked)
|
||||
{
|
||||
//Creates a new Word document
|
||||
document = new WordDocument();
|
||||
|
||||
document.EnsureMinimal();
|
||||
|
||||
// Getting last section of the document.
|
||||
IWSection section = document.LastSection;
|
||||
|
||||
// Adding a paragraph to the section.
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
|
||||
// Writing text
|
||||
IWTextRange text = paragraph.AppendText("This document was encrypted with password");
|
||||
text.CharacterFormat.FontSize = 16f;
|
||||
text.CharacterFormat.FontName = "Bitstream Vera Serif";
|
||||
|
||||
// Encrypt the document by giving password
|
||||
document.EncryptDocument("syncfusion");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assembly assembly = typeof(EncryptAndDecrypt).GetTypeInfo().Assembly;
|
||||
document = new WordDocument();
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
// Open an existing template document.
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "Security Settings.docx");
|
||||
document.Open(inputStream, FormatType.Docx, "syncfusion");
|
||||
inputStream.Dispose();
|
||||
|
||||
// Getting last section of the document.
|
||||
IWSection section = document.LastSection;
|
||||
|
||||
// Adding a paragraph to the section.
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
|
||||
// Writing text
|
||||
IWTextRange text = paragraph.AppendText("\nDemo For Document Decryption with Essential DocIO");
|
||||
text.CharacterFormat.FontSize = 16f;
|
||||
text.CharacterFormat.FontName = "Bitstream Vera Serif";
|
||||
|
||||
text = paragraph.AppendText("\nThis document is Decrypted");
|
||||
text.CharacterFormat.FontSize = 16f;
|
||||
text.CharacterFormat.FontName = "Bitstream Vera Serif";
|
||||
}
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Docx);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("Encrypt and Decrypt.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("Encrypt and Decrypt.docx", "application/msword", stream);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.FormFillingAndProtection">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to fill data and protect the content controls in an existing Word document."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,236 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
/// <summary>
|
||||
/// A sample view that can be used on FormFillingAndProtection.
|
||||
/// </summary>
|
||||
public partial class FormFillingAndProtection : SampleView
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for FormFillingAndProtection.
|
||||
/// </summary>
|
||||
public FormFillingAndProtection()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Xamarin.Forms.Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
//if (!SampleBrowser.DocIO.App.isUWP)
|
||||
//{
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
// }
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Button click event for FormFillingAndProtection.
|
||||
/// </summary>
|
||||
/// <param name="sender">Sender</param>
|
||||
/// <param name="e">Event args</param>
|
||||
private void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
// Load Template document stream.
|
||||
Stream inputStream = typeof(FormFillingAndProtection).GetTypeInfo().Assembly.GetManifestResourceStream(rootPath + "ContentControlTemplate.docx");
|
||||
|
||||
// Creates an empty Word document instance.
|
||||
WordDocument document = new WordDocument();
|
||||
// Opens template document.
|
||||
document.Open(inputStream, FormatType.Docx);
|
||||
|
||||
IWTextRange textRange;
|
||||
//Gets table from the template document.
|
||||
IWTable table = document.LastSection.Tables[0];
|
||||
WTableRow row = table.Rows[1];
|
||||
|
||||
#region Inserting content controls
|
||||
|
||||
#region Calendar content control
|
||||
IWParagraph cellPara = row.Cells[0].Paragraphs[0];
|
||||
//Accesses the date picker content control.
|
||||
IInlineContentControl inlineControl = (cellPara.ChildEntities[2] as IInlineContentControl);
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
//Sets today's date to display.
|
||||
textRange.Text = DateTime.Now.ToString("d");
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
//Protects the content control.
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
#endregion
|
||||
|
||||
#region Plain text content controls
|
||||
table = document.LastSection.Tables[1];
|
||||
row = table.Rows[0];
|
||||
cellPara = row.Cells[0].LastParagraph;
|
||||
//Accesses the plain text content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
//Protects the content control.
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
//Sets text in plain text content control.
|
||||
textRange.Text = "Northwind Analytics";
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
|
||||
cellPara = row.Cells[1].LastParagraph;
|
||||
//Accesses the plain text content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
//Protects the content control.
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
//Sets text in plain text content control.
|
||||
textRange.Text = "Northwind";
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
|
||||
row = table.Rows[1];
|
||||
cellPara = row.Cells[0].LastParagraph;
|
||||
//Accesses the plain text content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
//Protects the content control.
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets text in plain text content control.
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
textRange.Text = "10";
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
|
||||
|
||||
cellPara = row.Cells[1].LastParagraph;
|
||||
//Accesses the plain text content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
//Protects the content control.
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets text in plain text content control.
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
textRange.Text = "Nancy Davolio";
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
#endregion
|
||||
|
||||
#region CheckBox Content control
|
||||
row = table.Rows[2];
|
||||
cellPara = row.Cells[0].LastParagraph;
|
||||
//Inserts checkbox content control.
|
||||
inlineControl = cellPara.AppendInlineContentControl(ContentControlType.CheckBox);
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets checkbox as checked state.
|
||||
inlineControl.ContentControlProperties.IsChecked = true;
|
||||
textRange = cellPara.AppendText("C#, ");
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
|
||||
//Inserts checkbox content control.
|
||||
inlineControl = cellPara.AppendInlineContentControl(ContentControlType.CheckBox);
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets checkbox as checked state.
|
||||
inlineControl.ContentControlProperties.IsChecked = true;
|
||||
textRange = cellPara.AppendText("VB");
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Drop down list content control
|
||||
cellPara = row.Cells[1].LastParagraph;
|
||||
//Accesses the dropdown list content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets default option to display.
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
textRange.Text = "ASP.NET";
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
inlineControl.ParagraphItems.Add(textRange);
|
||||
|
||||
//Adds items to the dropdown list.
|
||||
ContentControlListItem item;
|
||||
item = new ContentControlListItem();
|
||||
item.DisplayText = "ASP.NET MVC";
|
||||
item.Value = "2";
|
||||
inlineControl.ContentControlProperties.ContentControlListItems.Add(item);
|
||||
|
||||
item = new ContentControlListItem();
|
||||
item.DisplayText = "Windows Forms";
|
||||
item.Value = "3";
|
||||
inlineControl.ContentControlProperties.ContentControlListItems.Add(item);
|
||||
|
||||
item = new ContentControlListItem();
|
||||
item.DisplayText = "WPF";
|
||||
item.Value = "4";
|
||||
inlineControl.ContentControlProperties.ContentControlListItems.Add(item);
|
||||
|
||||
item = new ContentControlListItem();
|
||||
item.DisplayText = "Xamarin";
|
||||
item.Value = "5";
|
||||
inlineControl.ContentControlProperties.ContentControlListItems.Add(item);
|
||||
#endregion
|
||||
|
||||
#region Calendar content control
|
||||
row = table.Rows[3];
|
||||
cellPara = row.Cells[0].LastParagraph;
|
||||
//Accesses the date picker content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets default date to display.
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
textRange.Text = DateTime.Now.AddDays(-5).ToString("d");
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
|
||||
cellPara = row.Cells[1].LastParagraph;
|
||||
//Inserts date picker content control.
|
||||
inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl);
|
||||
inlineControl.ContentControlProperties.LockContents = true;
|
||||
//Sets default date to display.
|
||||
textRange = inlineControl.ParagraphItems[0] as WTextRange;
|
||||
textRange.Text = DateTime.Now.AddDays(10).ToString("d");
|
||||
textRange.CharacterFormat.FontSize = 14;
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Block content control
|
||||
//Accesses the block content control.
|
||||
BlockContentControl blockContentControl = ((document.ChildEntities[0] as WSection).Body.ChildEntities[2] as BlockContentControl);
|
||||
//Protects the block content control
|
||||
blockContentControl.ContentControlProperties.LockContents = true;
|
||||
#endregion
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Docx);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
DependencyService.Get<ISaveWindowsPhone>()
|
||||
.Save("FormFillingAndProtection.docx", "application/msword", stream);
|
||||
else
|
||||
DependencyService.Get<ISave>().Save("FormFillingAndProtection.docx", "application/msword", stream);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.FormatTable">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to format the tables in the Word document using Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,220 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
using Syncfusion.Office;
|
||||
using Syncfusion.DocIORenderer;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class FormatTable : SampleView
|
||||
{
|
||||
public FormatTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
// if (!SampleBrowser.DocIO.App.isUWP)
|
||||
// {
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
// {
|
||||
this.Content_1.FontSize = 13.5;
|
||||
// }
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(FormatTable).GetTypeInfo().Assembly;
|
||||
// Create a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
// Adding a new section to the document.
|
||||
IWSection section = document.AddSection();
|
||||
section.PageSetup.Margins.All = 50;
|
||||
section.PageSetup.DifferentFirstPage = true;
|
||||
IWTextRange textRange;
|
||||
IWParagraph paragraph = section.AddParagraph();
|
||||
|
||||
|
||||
#region Table Cell Spacing.
|
||||
// --------------------------------------------
|
||||
// Table Cell Spacing.
|
||||
// --------------------------------------------
|
||||
paragraph.AppendText("Table Cell spacing...").CharacterFormat.FontSize = 14;
|
||||
|
||||
section.AddParagraph();
|
||||
paragraph = section.AddParagraph();
|
||||
WTextBody textBody = section.Body;
|
||||
|
||||
// Adding a new Table to the textbody.
|
||||
IWTable table = textBody.AddTable();
|
||||
table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Single;
|
||||
table.TableFormat.Paddings.All = 5.4f;
|
||||
RowFormat format = new RowFormat();
|
||||
|
||||
format.Paddings.All = 5;
|
||||
format.CellSpacing = 2;
|
||||
format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash;
|
||||
format.IsBreakAcrossPages = true;
|
||||
table.ResetCells(25, 5, format, 90);
|
||||
IWTextRange text;
|
||||
table.Rows[0].IsHeader = true;
|
||||
|
||||
for (int i = 0; i < table.Rows[0].Cells.Count; i++)
|
||||
{
|
||||
paragraph = table[0, i].AddParagraph() as WParagraph;
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
text = paragraph.AppendText(string.Format("Header {0}", i + 1));
|
||||
text.CharacterFormat.FontName = "Calibri";
|
||||
text.CharacterFormat.FontSize = 10;
|
||||
text.CharacterFormat.Bold = true;
|
||||
text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(0, 21, 84);
|
||||
table[0, i].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(203, 211, 226);
|
||||
}
|
||||
|
||||
for (int i = 1; i < table.Rows.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
paragraph = table[i, j].AddParagraph() as WParagraph;
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
|
||||
text = paragraph.AppendText(string.Format("Cell {0} , {1}", i, j + 1));
|
||||
text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50);
|
||||
text.CharacterFormat.Bold = true;
|
||||
if (i % 2 != 1)
|
||||
table[i, j].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(231, 235, 245);
|
||||
else
|
||||
table[i, j].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(246, 249, 255);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//table.TableFormat.IsAutoResized = true;
|
||||
(table as WTable).AutoFit(AutoFitType.FitToContent);
|
||||
#endregion Table Cell Spacing.
|
||||
|
||||
#region Nested Table
|
||||
// --------------------------------------------
|
||||
// Nested Table.
|
||||
// --------------------------------------------
|
||||
|
||||
section.AddParagraph();
|
||||
paragraph = section.AddParagraph();
|
||||
paragraph.ParagraphFormat.PageBreakBefore = true;
|
||||
paragraph.AppendText("Nested Table...").CharacterFormat.FontSize = 14;
|
||||
|
||||
section.AddParagraph();
|
||||
paragraph = section.AddParagraph();
|
||||
textBody = section.Body;
|
||||
|
||||
// Adding a new Table to the textbody.
|
||||
table = textBody.AddTable();
|
||||
|
||||
format = new RowFormat();
|
||||
format.Paddings.All = 5;
|
||||
format.CellSpacing = 2.5f;
|
||||
format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash;
|
||||
table.ResetCells(5, 3, format, 100);
|
||||
|
||||
for (int i = 0; i < table.Rows[0].Cells.Count; i++)
|
||||
{
|
||||
paragraph = table[0, i].AddParagraph() as WParagraph;
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
text = paragraph.AppendText(string.Format("Header {0}", i + 1));
|
||||
text.CharacterFormat.FontName = "Calibri";
|
||||
text.CharacterFormat.FontSize = 10;
|
||||
text.CharacterFormat.Bold = true;
|
||||
text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(0, 21, 84);
|
||||
table[0, i].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50);
|
||||
}
|
||||
table[0, 2].Width = 200;
|
||||
for (int i = 1; i < table.Rows.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
paragraph = table[i, j].AddParagraph() as WParagraph;
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
|
||||
if ((i == 2) && (j == 2))
|
||||
{
|
||||
text = paragraph.AppendText("Nested Table");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
text = paragraph.AppendText(string.Format("Cell {0} , {1}", i, j + 1));
|
||||
}
|
||||
|
||||
if ((j == 2))
|
||||
table[i, j].Width = 200;
|
||||
|
||||
text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50);
|
||||
text.CharacterFormat.Bold = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding a nested Table.
|
||||
IWTable nestTable = table[2, 2].AddTable();
|
||||
|
||||
format = new RowFormat();
|
||||
|
||||
format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash;
|
||||
format.HorizontalAlignment = RowAlignment.Center;
|
||||
nestTable.ResetCells(3, 3, format, 45);
|
||||
|
||||
for (int i = 0; i < nestTable.Rows.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
paragraph = nestTable[i, j].AddParagraph() as WParagraph;
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
|
||||
nestTable[i, j].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(231, 235, 245);
|
||||
text = paragraph.AppendText(string.Format("Cell {0} , {1}", i, j + 1));
|
||||
text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.Black;
|
||||
text.CharacterFormat.Bold = true;
|
||||
}
|
||||
}
|
||||
(nestTable as WTable).AutoFit(AutoFitType.FitToContent);
|
||||
(table as WTable).AutoFit(AutoFitType.FitToWindow);
|
||||
#endregion Nested Table
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Docx);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("FormatTable.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("FormatTable.docx", "application/msword", stream);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.GettingStartedDocIO">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
|
||||
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to create simple Word document with text, images and tables."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,289 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class GettingStartedDocIO : SampleView
|
||||
{
|
||||
public GettingStartedDocIO()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
//if (!SampleBrowser.DocIO.App.isUWP)
|
||||
//{
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
//}
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(GettingStartedDocIO).GetTypeInfo().Assembly;
|
||||
// Creating a new document.
|
||||
// Creating a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
//Adding a new section to the document.
|
||||
WSection section = document.AddSection() as WSection;
|
||||
//Set Margin of the section
|
||||
section.PageSetup.Margins.All = 72;
|
||||
//Set page size of the section
|
||||
section.PageSetup.PageSize = new Syncfusion.Drawing.SizeF(612, 792);
|
||||
|
||||
//Create Paragraph styles
|
||||
WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle;
|
||||
style.CharacterFormat.FontName = "Calibri";
|
||||
style.CharacterFormat.FontSize = 11f;
|
||||
style.ParagraphFormat.BeforeSpacing = 0;
|
||||
style.ParagraphFormat.AfterSpacing = 8;
|
||||
style.ParagraphFormat.LineSpacing = 13.8f;
|
||||
|
||||
style = document.AddParagraphStyle("Heading 1") as WParagraphStyle;
|
||||
style.ApplyBaseStyle("Normal");
|
||||
style.CharacterFormat.FontName = "Calibri Light";
|
||||
style.CharacterFormat.FontSize = 16f;
|
||||
style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(46, 116, 181);
|
||||
style.ParagraphFormat.BeforeSpacing = 12;
|
||||
style.ParagraphFormat.AfterSpacing = 0;
|
||||
style.ParagraphFormat.Keep = true;
|
||||
style.ParagraphFormat.KeepFollow = true;
|
||||
style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1;
|
||||
IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
Stream imageStream = assembly.GetManifestResourceStream(rootPath + "AdventureCycle.jpg");
|
||||
WPicture picture = paragraph.AppendPicture(imageStream) as WPicture;
|
||||
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
|
||||
picture.VerticalOrigin = VerticalOrigin.Margin;
|
||||
picture.VerticalPosition = -24;
|
||||
picture.HorizontalOrigin = HorizontalOrigin.Column;
|
||||
picture.HorizontalPosition = 263.5f;
|
||||
picture.WidthScale = 20;
|
||||
picture.HeightScale = 15;
|
||||
|
||||
paragraph.ApplyStyle("Normal");
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left;
|
||||
WTextRange textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Calibri";
|
||||
textRange.CharacterFormat.TextColor = Syncfusion.Drawing.Color.Red;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = section.AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 18f;
|
||||
textRange.CharacterFormat.FontName = "Calibri";
|
||||
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = section.AddParagraph();
|
||||
paragraph.ParagraphFormat.FirstLineIndent = 36;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
textRange = paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
|
||||
paragraph = section.AddParagraph();
|
||||
paragraph.ParagraphFormat.FirstLineIndent = 36;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
textRange = paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
|
||||
paragraph = section.AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left;
|
||||
textRange = paragraph.AppendText("Product Overview") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 16f;
|
||||
textRange.CharacterFormat.FontName = "Calibri";
|
||||
|
||||
|
||||
//Appends table.
|
||||
IWTable table = section.AddTable();
|
||||
table.ResetCells(3, 2);
|
||||
table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.None;
|
||||
table.TableFormat.IsAutoResized = true;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[0, 0].AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
imageStream = assembly.GetManifestResourceStream(rootPath + "Mountain-200.jpg");
|
||||
//Appends picture to the paragraph.
|
||||
picture = paragraph.AppendPicture(imageStream) as WPicture;
|
||||
picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom;
|
||||
picture.VerticalOrigin = VerticalOrigin.Paragraph;
|
||||
picture.VerticalPosition = 0;
|
||||
picture.HorizontalOrigin = HorizontalOrigin.Column;
|
||||
picture.HorizontalPosition = -5.15f;
|
||||
picture.WidthScale = 79;
|
||||
picture.HeightScale = 79;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[0, 1].AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.AppendText("Mountain-200");
|
||||
//Appends paragraph.
|
||||
paragraph = table[0, 1].AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
paragraph.BreakCharacterFormat.FontName = "Times New Roman";
|
||||
|
||||
textRange = paragraph.AppendText("Product No: BK-M68B-38\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Size: 38\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Weight: 25\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Price: $2,294.99\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[0, 1].AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[1, 0].AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.AppendText("Mountain-300 ");
|
||||
//Appends paragraph.
|
||||
paragraph = table[1, 0].AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
paragraph.BreakCharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Product No: BK-M47B-38\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Size: 35\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Weight: 22\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Price: $1,079.99\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[1, 0].AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[1, 1].AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
imageStream = assembly.GetManifestResourceStream(rootPath + "Mountain-300.jpg");
|
||||
//Appends picture to the paragraph.
|
||||
picture = paragraph.AppendPicture(imageStream) as WPicture;
|
||||
picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom;
|
||||
picture.VerticalOrigin = VerticalOrigin.Paragraph;
|
||||
picture.VerticalPosition = 8.2f;
|
||||
picture.HorizontalOrigin = HorizontalOrigin.Column;
|
||||
picture.HorizontalPosition = -14.95f;
|
||||
picture.WidthScale = 75;
|
||||
picture.HeightScale = 75;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[2, 0].AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
imageStream = assembly.GetManifestResourceStream(rootPath + "Road-550-W.jpg");
|
||||
//Appends picture to the paragraph.
|
||||
picture = paragraph.AppendPicture(imageStream) as WPicture;
|
||||
picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom;
|
||||
picture.VerticalOrigin = VerticalOrigin.Paragraph;
|
||||
picture.VerticalPosition = 0;
|
||||
picture.HorizontalOrigin = HorizontalOrigin.Column;
|
||||
picture.HorizontalPosition = -4.9f;
|
||||
picture.WidthScale = 92;
|
||||
picture.HeightScale = 92;
|
||||
|
||||
//Appends paragraph.
|
||||
paragraph = table[2, 1].AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.AppendText("Road-150 ");
|
||||
//Appends paragraph.
|
||||
paragraph = table[2, 1].AddParagraph();
|
||||
paragraph.ParagraphFormat.AfterSpacing = 0;
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
paragraph.BreakCharacterFormat.FontSize = 12f;
|
||||
paragraph.BreakCharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Product No: BK-R93R-44\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Size: 44\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Weight: 14\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
textRange = paragraph.AppendText("Price: $3,578.27\r") as WTextRange;
|
||||
textRange.CharacterFormat.FontSize = 12f;
|
||||
textRange.CharacterFormat.FontName = "Times New Roman";
|
||||
//Appends paragraph.
|
||||
paragraph = table[2, 1].AddParagraph();
|
||||
paragraph.ApplyStyle("Heading 1");
|
||||
paragraph.ParagraphFormat.LineSpacing = 12f;
|
||||
|
||||
//Appends paragraph.
|
||||
section.AddParagraph();
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("GettingStarted.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("GettingStarted.docx", "application/msword", stream);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns:SfRadio="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.GroupShapes">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding="10">
|
||||
<Label x:Name="Description" Text="This sample illustrates how to create a Word document with Group shapes using Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label FontSize="Medium" Text="Save As:" Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="Start" VerticalTextAlignment="Center"/>
|
||||
<SfRadio:SfRadioGroup Grid.Column="1" Grid.Row="0" HeightRequest="30" Orientation="Horizontal">
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="docxButton" Text="DOCX"/>
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="pdfButton" Text="PDF"/>
|
||||
</SfRadio:SfRadioGroup>
|
||||
<Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
</local:SampleView>
|
|
@ -0,0 +1,226 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using SampleBrowser.DocIO;
|
||||
using Syncfusion.DocIORenderer;
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.OfficeChart;
|
||||
using Syncfusion.Drawing;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class GroupShapes : SampleView
|
||||
{
|
||||
public GroupShapes()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.docxButton.IsChecked = true;
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Description.HorizontalOptions = Xamarin.Forms.LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = Xamarin.Forms.LayoutOptions.Start;
|
||||
this.Description.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Xamarin.Forms.Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
{
|
||||
this.Description.FontSize = 13.5;
|
||||
}
|
||||
|
||||
this.Description.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
//Creates a new Word document
|
||||
WordDocument document = new WordDocument();
|
||||
//Adds new section to the document
|
||||
IWSection section = document.AddSection();
|
||||
//Sets page setup options
|
||||
section.PageSetup.Orientation = PageOrientation.Landscape;
|
||||
section.PageSetup.Margins.All = 72;
|
||||
section.PageSetup.PageSize = new SizeF(792f, 612f);
|
||||
//Adds new paragraph to the section
|
||||
WParagraph paragraph = section.AddParagraph() as WParagraph;
|
||||
//Creates new group shape
|
||||
GroupShape groupShape = new GroupShape(document);
|
||||
//Adds group shape to the paragraph.
|
||||
paragraph.ChildEntities.Add(groupShape);
|
||||
|
||||
//Create a RoundedRectangle shape with "Management" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(324f, 107.7f, 144f, 45f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(50, 48, 142), "Management", groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "Development" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(177.75f, 176.25f, 210f, 50f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "Sales" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(403.5f, 175.5f, 210f, 50f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a DownArrow shape to connect with "Production" shape
|
||||
CreateChildShape(AutoShapeType.DownArrow, new RectangleF(381f, 153f, 29.25f, 72.5f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Development" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(135f, 226.45f, 110f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(104, 57, 157), "Development", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Production" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(341f, 226.5f, 110f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(149, 50, 118), "Production", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Sales" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(546.75f, 226.5f, 110f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(179, 63, 62), "Sales", groupShape, document);
|
||||
|
||||
//Create a DownArrow shape to connect with "Software" and "Hardware" shape
|
||||
CreateChildShape(AutoShapeType.DownArrow, new RectangleF(177f, 265.5f, 25.5f, 20.25f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a DownArrow shape to connect with "Series" and "Parts" shape
|
||||
CreateChildShape(AutoShapeType.DownArrow, new RectangleF(383.25f, 265.5f, 25.5f, 20.25f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a DownArrow shape to connect with "North" and "South" shape
|
||||
CreateChildShape(AutoShapeType.DownArrow, new RectangleF(588.75f, 266.25f, 25.5f, 20.25f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "Software" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(129.5f, 286.5f, 60f, 33f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "Hardware" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(190.5f, 286.5f, 60f, 33f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "Series" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(336f, 287.25f, 60f, 33f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "Parts" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(397f, 287.25f, 60f, 33f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "North" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(541.5f, 288f, 60f, 33f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a BentUpArrow shape to connect with "South" shape
|
||||
CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(602.5f, 288f, 60f, 33f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Software" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(93f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(23, 187, 189), "Software", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Hardware" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(197.2f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(24, 159, 106), "Hardware", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Series" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(299.25f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(23, 187, 189), "Series", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "Parts" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(404.2f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(24, 159, 106), "Parts", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "North" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(505.5f, 321.75f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(23, 187, 189), "North", groupShape, document);
|
||||
|
||||
//Create a RoundedRectangle shape with "South" text
|
||||
CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(609.7f, 321.75f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(24, 159, 106), "South", groupShape, document);
|
||||
|
||||
string filename = "";
|
||||
string contenttype = "";
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
if (this.pdfButton.IsChecked != null && (bool)this.pdfButton.IsChecked)
|
||||
{
|
||||
filename = "GroupShapes.pdf";
|
||||
contenttype = "application/pdf";
|
||||
DocIORenderer renderer = new DocIORenderer();
|
||||
PdfDocument pdfDoc = renderer.ConvertToPDF(document);
|
||||
pdfDoc.Save(outputStream);
|
||||
pdfDoc.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = "GroupShapes.docx";
|
||||
contenttype = "application/msword";
|
||||
document.Save(outputStream, FormatType.Docx);
|
||||
}
|
||||
document.Close();
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
DependencyService.Get<ISaveWindowsPhone>()
|
||||
.Save(filename, contenttype, outputStream);
|
||||
else
|
||||
DependencyService.Get<ISave>().Save(filename, contenttype, outputStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a child shape with its specified properties and add into specified group shape
|
||||
/// </summary>
|
||||
/// <param name="autoShapeType">Represent the AutoShapeType of child shape</param>
|
||||
/// <param name="bounds">Represent the bounds of child shape to be placed</param>
|
||||
/// <param name="rotation">Represent the rotation of child shape</param>
|
||||
/// <param name="flipH">Represent the horizontal flip of child shape</param>
|
||||
/// <param name="flipV">Represent the vertical flip of child shape</param>
|
||||
/// <param name="fillColor">Represent the fill color of child shape</param>
|
||||
/// <param name="text">Represent the text that to be append in child shape</param>
|
||||
/// <param name="groupShape">Represent the group shape to add a child shape</param>
|
||||
/// <param name="wordDocument">Represent the Word document instance</param>
|
||||
private static void CreateChildShape(AutoShapeType autoShapeType, RectangleF bounds, float rotation, bool flipH, bool flipV, Syncfusion.Drawing.Color fillColor, string text, GroupShape groupShape, WordDocument wordDocument)
|
||||
{
|
||||
//Creates new shape to add into group
|
||||
Shape shape = new Shape(wordDocument, autoShapeType);
|
||||
//Sets height and width for shape
|
||||
shape.Height = bounds.Height;
|
||||
shape.Width = bounds.Width;
|
||||
//Sets horizontal and vertical position
|
||||
shape.HorizontalPosition = bounds.X;
|
||||
shape.VerticalPosition = bounds.Y;
|
||||
//Set rotation and flipH for the shape
|
||||
if (rotation != 0)
|
||||
shape.Rotation = rotation;
|
||||
if (flipH)
|
||||
shape.FlipHorizontal = true;
|
||||
if (flipV)
|
||||
shape.FlipVertical = true;
|
||||
//Applies fill color for shape
|
||||
if (fillColor != Syncfusion.Drawing.Color.White)
|
||||
{
|
||||
shape.FillFormat.Fill = true;
|
||||
shape.FillFormat.Color = fillColor;
|
||||
}
|
||||
//Set wrapping style for shape
|
||||
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
|
||||
//Sets horizontal and vertical origin
|
||||
shape.HorizontalOrigin = HorizontalOrigin.Page;
|
||||
shape.VerticalOrigin = VerticalOrigin.Page;
|
||||
//Sets no line to RoundedRectangle shapes
|
||||
if (autoShapeType == AutoShapeType.RoundedRectangle)
|
||||
shape.LineFormat.Line = false;
|
||||
//Add paragraph for the shape textbody
|
||||
if (text != null)
|
||||
{
|
||||
IWParagraph paragraph = shape.TextBody.AddParagraph();
|
||||
//Set required textbody alignments
|
||||
shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
|
||||
//Set required paragraph alignments
|
||||
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
IWTextRange textRange = paragraph.AppendText(text);
|
||||
//Applies a required text formatting's
|
||||
textRange.CharacterFormat.FontName = "Calibri";
|
||||
textRange.CharacterFormat.FontSize = 15;
|
||||
textRange.CharacterFormat.TextColor = Syncfusion.Drawing.Color.White;
|
||||
textRange.CharacterFormat.Bold = true;
|
||||
textRange.CharacterFormat.Italic = true;
|
||||
}
|
||||
//Adds the specified shape to group shape
|
||||
groupShape.Add(shape);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.MailMerge">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
<Label x:Name="Content_1" Text="This sample illustrates how to create a letter format document by filling the data using Mail merge functionality of DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,227 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class MailMerge : SampleView
|
||||
{
|
||||
public MailMerge()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
// if (!SampleBrowser.DocIO.App.isUWP)
|
||||
// {
|
||||
// this.Content_1.FontSize = 18.5;
|
||||
//}
|
||||
//else
|
||||
// {
|
||||
this.Content_1.FontSize = 13.5;
|
||||
// }
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(MailMerge).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
// Creating a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "Letter Formatting.docx");
|
||||
//Open Template document
|
||||
document.Open(inputStream, FormatType.Word2013);
|
||||
inputStream.Dispose();
|
||||
List<Customer> source = new List<Customer>();
|
||||
source.Add(new Customer("ALFKI", "Alfreds Futterkiste", "Maria Anders", "Sales Representative", "Obere Str. 57", "Berlin", "12209", "Germany", "030-0074321", "030-0076545"));
|
||||
//source.Add(new Customer("ANATR", "Ana Trujillo Emparedados y helados", "Ana Trujillo", "Owner", "Avda. de la Constitución 2222", "México D.F.", "05021", "Mexico", "(5) 555-4729", "(5) 555-3745"));
|
||||
document.MailMerge.Execute(source);
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("LetterFormatting.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("LetterFormatting.docx", "application/msword", stream);
|
||||
}
|
||||
}
|
||||
public class Customer
|
||||
{
|
||||
#region fields
|
||||
string m_customerID;
|
||||
string m_companyName;
|
||||
string m_contactName;
|
||||
string m_contactTitle;
|
||||
string m_address;
|
||||
string m_city;
|
||||
string m_postalCode;
|
||||
string m_country;
|
||||
string m_phone;
|
||||
string m_fax;
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
public string CustomerID
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_customerID;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_customerID = value;
|
||||
}
|
||||
}
|
||||
public string CompanyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_companyName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_companyName = value;
|
||||
}
|
||||
}
|
||||
public string ContactName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_contactName;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_contactName = value;
|
||||
}
|
||||
}
|
||||
public string ContactTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_contactTitle;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_contactTitle = value;
|
||||
}
|
||||
}
|
||||
public string Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_address = value;
|
||||
}
|
||||
}
|
||||
public string City
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_city;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_city = value;
|
||||
}
|
||||
}
|
||||
public string PostalCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_postalCode;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_postalCode = value;
|
||||
}
|
||||
}
|
||||
public string Country
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_country;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_country = value;
|
||||
}
|
||||
}
|
||||
public string Phone
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_phone;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_phone = value;
|
||||
}
|
||||
}
|
||||
public string Fax
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_fax;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_fax = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region constructor
|
||||
public Customer()
|
||||
{ }
|
||||
|
||||
public Customer(string customerID, string companyName, string contactName, string contactTitle, string address, string city, string postalCode, string country, string phone, string fax)
|
||||
{
|
||||
m_customerID = customerID;
|
||||
m_companyName = companyName;
|
||||
m_contactName = contactName;
|
||||
m_contactTitle = contactTitle;
|
||||
m_address = address;
|
||||
m_city = city;
|
||||
m_postalCode = postalCode;
|
||||
m_country = country;
|
||||
m_phone = phone;
|
||||
m_fax = fax;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns:SfRadio="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.MarkdownToWord">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
<Label x:Name="Content_1" Text="This sample demonstrates how to convert the Markdown file to Word document using .NET Word (DocIO) library."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label FontSize="Medium" Text="Save As:" Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="Start" VerticalTextAlignment="Center"/>
|
||||
<SfRadio:SfRadioGroup Grid.Column="0" Grid.Row="1" HeightRequest="30" Orientation="Horizontal">
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="docxButton" Text="DOCX"/>
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="htmlButton" Text="HTML"/>
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="pdfButton" Text="PDF"/>
|
||||
</SfRadio:SfRadioGroup>
|
||||
<Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Document" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,108 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
using Syncfusion.Office;
|
||||
using Syncfusion.DocIORenderer;
|
||||
using Syncfusion.Pdf;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class MarkdownToWord : SampleView
|
||||
{
|
||||
public MarkdownToWord()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.docxButton.IsChecked = true;
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(MarkdownToWord).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "MarkdownToWord.md");
|
||||
|
||||
// Loads the stream into Word Document.
|
||||
WordDocument document = new WordDocument(inputStream, Syncfusion.DocIO.FormatType.Markdown);
|
||||
string filename = "";
|
||||
string contenttype = "";
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
if (this.pdfButton.IsChecked != null && (bool)this.pdfButton.IsChecked)
|
||||
{
|
||||
filename = "MarkdownToWord.pdf";
|
||||
contenttype = "application/pdf";
|
||||
DocIORenderer renderer = new DocIORenderer();
|
||||
PdfDocument pdfDoc = renderer.ConvertToPDF(document);
|
||||
pdfDoc.Save(outputStream);
|
||||
pdfDoc.Close();
|
||||
}
|
||||
else if(this.htmlButton.IsChecked != null && (bool)this.htmlButton.IsChecked)
|
||||
{
|
||||
filename = "MarkdownToWord.html";
|
||||
contenttype = "application/html";
|
||||
document.Save(outputStream, FormatType.Html);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = "MarkdownToWord.docx";
|
||||
contenttype = "application/msword";
|
||||
document.Save(outputStream, FormatType.Docx);
|
||||
}
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save(filename, contenttype, outputStream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save(filename, contenttype, outputStream);
|
||||
|
||||
if (contenttype == "application/html" && !(Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP))
|
||||
{
|
||||
//Set the stream to start position to read the content as string
|
||||
outputStream.Position = 0;
|
||||
StreamReader reader = new StreamReader(outputStream);
|
||||
string htmlString = reader.ReadToEnd();
|
||||
|
||||
//Set the HtmlWebViewSource to the html string
|
||||
HtmlWebViewSource html = new HtmlWebViewSource();
|
||||
html.Html = htmlString;
|
||||
|
||||
//Create the web view control to view the web page
|
||||
WebView view = new WebView();
|
||||
view.Source = html;
|
||||
ContentPage webpage = new ContentPage();
|
||||
webpage.Content = view;
|
||||
this.Content.Navigation.PushAsync(webpage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.NestedMailMerge">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding ="10">
|
||||
<Label x:Name="Content_1" Text="This sample demonstrates how to perform Mail merge for nested groups in Word document using Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center">
|
||||
</Label>
|
||||
|
||||
<Label></Label>
|
||||
|
||||
<Button x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Word" HorizontalOptions="Center" VerticalOptions="Center"></Button>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
<local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView.PropertyView>
|
||||
|
||||
</local:SampleView>
|
|
@ -0,0 +1,93 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class NestedMailMerge : SampleView
|
||||
{
|
||||
public NestedMailMerge()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
|
||||
this.Content_1.HorizontalOptions = LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = LayoutOptions.Start;
|
||||
|
||||
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Content_1.FontSize = 13.5;
|
||||
this.Content_1.VerticalOptions = LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Assembly assembly = typeof(MailMerge).GetTypeInfo().Assembly;
|
||||
#if COMMONSB
|
||||
string rootPath = "SampleBrowser.Samples.DocIO.Samples.Templates.";
|
||||
#else
|
||||
string rootPath = "SampleBrowser.DocIO.Samples.Templates.";
|
||||
#endif
|
||||
// Creating a new document.
|
||||
WordDocument document = new WordDocument();
|
||||
Stream inputStream = assembly.GetManifestResourceStream(rootPath + "Template_Letter.doc");
|
||||
//Open Template document
|
||||
document.Open(inputStream, FormatType.Word2013);
|
||||
inputStream.Dispose();
|
||||
inputStream = assembly.GetManifestResourceStream(rootPath + "Employees.xml");
|
||||
System.Data.DataSet ds = new DataSet();
|
||||
ds.ReadXml(inputStream);
|
||||
System.Collections.ArrayList commands = new ArrayList();
|
||||
|
||||
//DictionaryEntry contain "Source table" (KEY) and "Command" (VALUE)
|
||||
System.Collections.DictionaryEntry entry = new DictionaryEntry("Employees", string.Empty);
|
||||
commands.Add(entry);
|
||||
|
||||
// To retrive customer details
|
||||
DataTable table = ds.Tables["Customers"];
|
||||
string relation = table.ParentRelations[0].ChildColumns[0].ColumnName + " = %Employees." + table.ParentRelations[0].ParentColumns[0].ColumnName + "%";
|
||||
entry = new DictionaryEntry("Customers", relation);
|
||||
commands.Add(entry);
|
||||
|
||||
// To retrieve order details
|
||||
table = ds.Tables["Orders"];
|
||||
relation = table.ParentRelations[0].ChildColumns[0].ColumnName + " = %Customers." + table.ParentRelations[0].ParentColumns[0].ColumnName + "%";
|
||||
entry = new DictionaryEntry("Orders", relation);
|
||||
commands.Add(entry);
|
||||
|
||||
//Executes nested Mail merge using explicit relational data.
|
||||
document.MailMerge.ExecuteNestedGroup(ds, commands);
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Save(stream, FormatType.Word2013);
|
||||
document.Close();
|
||||
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
Xamarin.Forms.DependencyService.Get<ISaveWindowsPhone>().Save("NestedMailMerge.docx", "application/msword", stream);
|
||||
else
|
||||
Xamarin.Forms.DependencyService.Get<ISave>().Save("NestedMailMerge.docx", "application/msword", stream);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:SampleView
|
||||
xmlns:local="clr-namespace:SampleBrowser.Core;assembly=SampleBrowser.Core"
|
||||
xmlns:SfRadio="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="SampleBrowser.DocIO.TableOfContents">
|
||||
|
||||
<local:SampleView.Content>
|
||||
<StackLayout Padding="10">
|
||||
<Label x:Name="Description" Text="This sample demonstrates how to insert and update the Table of Contents (TOC) in a Word document using Essential DocIO."
|
||||
FontSize="Medium" VerticalOptions="Center"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label FontSize="Medium" Text="Save As:" Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="Start" VerticalTextAlignment="Center"/>
|
||||
<SfRadio:SfRadioGroup Grid.Column="1" Grid.Row="0" HeightRequest="30" Orientation="Horizontal">
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="docxButton" Text="DOCX"/>
|
||||
<SfRadio:SfRadioButton FontSize="13" WidthRequest="70" x:Name="pdfButton" Text="PDF"/>
|
||||
</SfRadio:SfRadioGroup>
|
||||
<Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="btnGenerate" Clicked ="OnButtonClicked" Text ="Generate Document" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</local:SampleView.Content>
|
||||
</local:SampleView>
|
|
@ -0,0 +1,168 @@
|
|||
#region Copyright Syncfusion Inc. 2001-2023.
|
||||
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
|
||||
// Use of this code is subject to the terms of our license.
|
||||
// A copy of the current license can be obtained at any time by e-mailing
|
||||
// licensing@syncfusion.com. Any infringement will be prosecuted under
|
||||
// applicable laws.
|
||||
#endregion
|
||||
using Syncfusion.DocIO;
|
||||
using SampleBrowser.Core;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using SampleBrowser.DocIO;
|
||||
using Syncfusion.DocIORenderer;
|
||||
using Syncfusion.Pdf;
|
||||
using Syncfusion.OfficeChart;
|
||||
using Syncfusion.Drawing;
|
||||
|
||||
namespace SampleBrowser.DocIO
|
||||
{
|
||||
public partial class TableOfContents : SampleView
|
||||
{
|
||||
public TableOfContents()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.docxButton.IsChecked = true;
|
||||
|
||||
if (Device.Idiom != TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
this.Description.HorizontalOptions = Xamarin.Forms.LayoutOptions.Start;
|
||||
this.btnGenerate.HorizontalOptions = Xamarin.Forms.LayoutOptions.Start;
|
||||
this.Description.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.BackgroundColor = Xamarin.Forms.Color.Gray;
|
||||
}
|
||||
else if (Device.Idiom == TargetIdiom.Phone && Device.RuntimePlatform == Device.UWP)
|
||||
{
|
||||
{
|
||||
this.Description.FontSize = 13.5;
|
||||
}
|
||||
|
||||
this.Description.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
this.btnGenerate.VerticalOptions = Xamarin.Forms.LayoutOptions.Center;
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
WordDocument doc = new WordDocument();
|
||||
doc.EnsureMinimal();
|
||||
|
||||
WParagraph para = doc.LastParagraph;
|
||||
para.AppendText("Essential DocIO - Table of Contents");
|
||||
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
para.ApplyStyle(BuiltinStyle.Heading4);
|
||||
|
||||
para = doc.LastSection.AddParagraph() as WParagraph;
|
||||
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
|
||||
para.ApplyStyle(BuiltinStyle.Heading4);
|
||||
|
||||
para = doc.LastSection.AddParagraph() as WParagraph;
|
||||
|
||||
//Insert TOC
|
||||
TableOfContent toc = para.AppendTOC(1, 3);
|
||||
|
||||
para.ApplyStyle(BuiltinStyle.Heading4);
|
||||
|
||||
//Apply built-in paragraph formatting
|
||||
WSection section = doc.LastSection;
|
||||
#region Default Styles
|
||||
WParagraph newPara = section.AddParagraph() as WParagraph;
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendBreak(BreakType.PageBreak);
|
||||
WTextRange text = newPara.AppendText("Document with Default styles") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading1);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading1 of built in style. This sample demonstrates the TOC insertion in a word document. Note that DocIO can only insert TOC field in a word document. It can not refresh or create TOC field. MS Word refreshes the TOC field after insertion. Please update the field or press F9 key to refresh the TOC.");
|
||||
|
||||
section.AddParagraph();
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
text = newPara.AppendText("Section1") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading2);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks.");
|
||||
|
||||
section.AddParagraph();
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
text = newPara.AppendText("Paragraph1") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading3);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text.");
|
||||
|
||||
section.AddParagraph();
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
text = newPara.AppendText("Paragraph2") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading3);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph.");
|
||||
|
||||
section.AddParagraph();
|
||||
section = doc.AddSection() as WSection;
|
||||
section.BreakCode = SectionBreakCode.NewPage;
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
text = newPara.AppendText("Section2") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading2);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks.");
|
||||
|
||||
section.AddParagraph();
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
text = newPara.AppendText("Paragraph1") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading3);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text.");
|
||||
|
||||
section.AddParagraph();
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
text = newPara.AppendText("Paragraph2") as WTextRange;
|
||||
newPara.ApplyStyle(BuiltinStyle.Heading3);
|
||||
newPara = section.AddParagraph() as WParagraph;
|
||||
newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph.");
|
||||
#endregion
|
||||
|
||||
toc.IncludePageNumbers = true;
|
||||
toc.RightAlignPageNumbers = true;
|
||||
toc.UseHyperlinks = true;
|
||||
toc.LowerHeadingLevel = 1;
|
||||
toc.UpperHeadingLevel = 3;
|
||||
|
||||
toc.UseOutlineLevels = true;
|
||||
|
||||
//Updates the table of contents.
|
||||
doc.UpdateTableOfContents();
|
||||
string filename = "";
|
||||
string contenttype = "";
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
if (pdfButton != null && (bool)pdfButton.IsChecked)
|
||||
{
|
||||
filename = "Table Of Contents.pdf";
|
||||
contenttype = "application/pdf";
|
||||
DocIORenderer renderer = new DocIORenderer();
|
||||
PdfDocument pdfDoc = renderer.ConvertToPDF(doc);
|
||||
pdfDoc.Save(outputStream);
|
||||
pdfDoc.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = "Table Of Contents.docx";
|
||||
contenttype = "application/msword";
|
||||
doc.Save(outputStream, FormatType.Docx);
|
||||
}
|
||||
|
||||
doc.Close();
|
||||
if (Device.RuntimePlatform == Device.UWP)
|
||||
DependencyService.Get<ISaveWindowsPhone>()
|
||||
.Save(filename, contenttype, outputStream);
|
||||
else
|
||||
DependencyService.Get<ISave>().Save(filename, contenttype, outputStream);
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 79 KiB |
|
@ -0,0 +1,258 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EmployeesList>
|
||||
<Employees>
|
||||
<FirstName>Nancy</FirstName>
|
||||
<LastName>Davolio</LastName>
|
||||
<EmployeeID>1</EmployeeID>
|
||||
<Extension>5467</Extension>
|
||||
<Address>507 - 20th Ave. E. Apt. 2A</Address>
|
||||
<City>Seattle</City>
|
||||
<Country>USA</Country>
|
||||
<Customers>
|
||||
<CustomerID>ALFKI</CustomerID>
|
||||
<EmployeeID>1</EmployeeID>
|
||||
<CompanyName>Alfreds Futterkiste</CompanyName>
|
||||
<ContactName>Maria Anders</ContactName>
|
||||
<City>Berlin</City>
|
||||
<Country>Germany</Country>
|
||||
<Orders>
|
||||
<OrderID>10835</OrderID>
|
||||
<CustomerID>ALFKI</CustomerID>
|
||||
<OrderDate>1/15/1998</OrderDate>
|
||||
<ShippedDate>1/21/1998</ShippedDate>
|
||||
<RequiredDate>2/12/1998</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10952</OrderID>
|
||||
<CustomerID>ALFKI</CustomerID>
|
||||
<OrderDate>3/16/1998</OrderDate>
|
||||
<ShippedDate>3/24/1998</ShippedDate>
|
||||
<RequiredDate>4/27/1998</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>ANTON</CustomerID>
|
||||
<EmployeeID>1</EmployeeID>
|
||||
<CompanyName>Antonio Moreno Taquería</CompanyName>
|
||||
<ContactName>Antonio Moreno</ContactName>
|
||||
<City>México D.F.</City>
|
||||
<Country>Mexico</Country>
|
||||
<Orders>
|
||||
<OrderID>10677</OrderID>
|
||||
<CustomerID>ANTON</CustomerID>
|
||||
<OrderDate>9/22/1997</OrderDate>
|
||||
<ShippedDate>9/26/1997</ShippedDate>
|
||||
<RequiredDate>10/20/1997</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>AROUT</CustomerID>
|
||||
<EmployeeID>1</EmployeeID>
|
||||
<CompanyName>Around the Horn</CompanyName>
|
||||
<ContactName>Thomas Hardy</ContactName>
|
||||
<City>London</City>
|
||||
<Country>UK</Country>
|
||||
<Orders>
|
||||
<OrderID>10453</OrderID>
|
||||
<CustomerID>AROUT</CustomerID>
|
||||
<OrderDate>2/21/1997</OrderDate>
|
||||
<ShippedDate>2/26/1997</ShippedDate>
|
||||
<RequiredDate>3/21/1997</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10558</OrderID>
|
||||
<CustomerID>AROUT</CustomerID>
|
||||
<OrderDate>6/4/1997</OrderDate>
|
||||
<ShippedDate>6/10/1997</ShippedDate>
|
||||
<RequiredDate>7/2/1997</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10743</OrderID>
|
||||
<CustomerID>AROUT</CustomerID>
|
||||
<OrderDate>11/17/1997</OrderDate>
|
||||
<ShippedDate>11/21/1997</ShippedDate>
|
||||
<RequiredDate>12/15/1997</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>BOTTM</CustomerID>
|
||||
<EmployeeID>1</EmployeeID>
|
||||
<CompanyName>Bottom-Dollar Markets</CompanyName>
|
||||
<ContactName>Elizabeth Lincoln</ContactName>
|
||||
<City>Tsawassen</City>
|
||||
<Country>Canada</Country>
|
||||
<Orders>
|
||||
<OrderID>10975</OrderID>
|
||||
<CustomerID>BOTTM</CustomerID>
|
||||
<OrderDate>3/25/1998</OrderDate>
|
||||
<ShippedDate>3/27/1998</ShippedDate>
|
||||
<RequiredDate>4/22/1998</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>11027</OrderID>
|
||||
<CustomerID>BOTTM</CustomerID>
|
||||
<OrderDate>4/16/1998</OrderDate>
|
||||
<ShippedDate>4/20/1998</ShippedDate>
|
||||
<RequiredDate>5/14/1998</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
</Employees>
|
||||
<Employees>
|
||||
<FirstName>Andrew</FirstName>
|
||||
<LastName>Fuller</LastName>
|
||||
<EmployeeID>2</EmployeeID>
|
||||
<Extension>3457</Extension>
|
||||
<Address>908 W. Capital Way</Address>
|
||||
<City>Tacoma</City>
|
||||
<Country>USA</Country>
|
||||
<Customers>
|
||||
<CustomerID>BERGS</CustomerID>
|
||||
<EmployeeID>2</EmployeeID>
|
||||
<CompanyName>Berglunds snabbköp</CompanyName>
|
||||
<ContactName>Christina Berglund</ContactName>
|
||||
<City>Luleå</City>
|
||||
<Country>Sweden</Country>
|
||||
<Orders>
|
||||
<OrderID>10280</OrderID>
|
||||
<CustomerID>BERGS</CustomerID>
|
||||
<OrderDate>8/14/1996</OrderDate>
|
||||
<ShippedDate>9/12/1996</ShippedDate>
|
||||
<RequiredDate>9/11/1996</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>BONAP</CustomerID>
|
||||
<EmployeeID>2</EmployeeID>
|
||||
<CompanyName>Bon app'</CompanyName>
|
||||
<ContactName>Laurence Lebihan</ContactName>
|
||||
<City>Marseille</City>
|
||||
<Country>France</Country>
|
||||
<Orders>
|
||||
<OrderID>10663</OrderID>
|
||||
<CustomerID>BONAP</CustomerID>
|
||||
<OrderDate>9/10/1997</OrderDate>
|
||||
<ShippedDate>10/3/1997</ShippedDate>
|
||||
<RequiredDate>9/24/1997</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>ERNSH</CustomerID>
|
||||
<EmployeeID>2</EmployeeID>
|
||||
<CompanyName>Ernst Handel</CompanyName>
|
||||
<ContactName>Roland Mendel</ContactName>
|
||||
<City>Graz</City>
|
||||
<Country>Austria</Country>
|
||||
<Orders>
|
||||
<OrderID>10368</OrderID>
|
||||
<CustomerID>ERNSH</CustomerID>
|
||||
<OrderDate>11/29/1996</OrderDate>
|
||||
<ShippedDate>12/2/1996</ShippedDate>
|
||||
<RequiredDate>12/27/1996</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10595</OrderID>
|
||||
<CustomerID>ERNSH</CustomerID>
|
||||
<OrderDate>7/10/1997</OrderDate>
|
||||
<ShippedDate>7/14/1997</ShippedDate>
|
||||
<RequiredDate>8/7/1997</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10990</OrderID>
|
||||
<CustomerID>ERNSH</CustomerID>
|
||||
<OrderDate>4/1/1998</OrderDate>
|
||||
<ShippedDate>4/7/1998</ShippedDate>
|
||||
<RequiredDate>5/13/1998</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
</Employees>
|
||||
<Employees>
|
||||
<FirstName>Margaret</FirstName>
|
||||
<LastName>Peacock</LastName>
|
||||
<EmployeeID>3</EmployeeID>
|
||||
<Extension>5176</Extension>
|
||||
<Address>4110 Old Redmond Rd.</Address>
|
||||
<City>Redmond</City>
|
||||
<Country>USA</Country>
|
||||
<Customers>
|
||||
<CustomerID>ANATR</CustomerID>
|
||||
<EmployeeID>3</EmployeeID>
|
||||
<CompanyName>Ana Trujillo Emparedados y helados</CompanyName>
|
||||
<ContactName>Ana Trujillo</ContactName>
|
||||
<City>México D.F.</City>
|
||||
<Country>Mexico</Country>
|
||||
<Orders>
|
||||
<OrderID>10926</OrderID>
|
||||
<CustomerID>ANATR</CustomerID>
|
||||
<OrderDate>3/4/1998</OrderDate>
|
||||
<ShippedDate>3/11/1998</ShippedDate>
|
||||
<RequiredDate>4/1/1998</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>BLONP</CustomerID>
|
||||
<EmployeeID>3</EmployeeID>
|
||||
<CompanyName>Blondel père et fils</CompanyName>
|
||||
<ContactName>Frédérique Citeaux</ContactName>
|
||||
<City>Strasbourg</City>
|
||||
<Country>France</Country>
|
||||
<Orders>
|
||||
<OrderID>10360</OrderID>
|
||||
<CustomerID>BLONP</CustomerID>
|
||||
<OrderDate>11/22/1996</OrderDate>
|
||||
<ShippedDate>12/2/1996</ShippedDate>
|
||||
<RequiredDate>12/20/1996</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10584</OrderID>
|
||||
<CustomerID>BLONP</CustomerID>
|
||||
<OrderDate>6/30/1997</OrderDate>
|
||||
<ShippedDate>7/4/1997</ShippedDate>
|
||||
<RequiredDate>7/28/1997</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10628</OrderID>
|
||||
<CustomerID>BLONP</CustomerID>
|
||||
<OrderDate>8/12/1997</OrderDate>
|
||||
<ShippedDate>8/20/1997</ShippedDate>
|
||||
<RequiredDate>9/9/1997</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>COMMI</CustomerID>
|
||||
<EmployeeID>3</EmployeeID>
|
||||
<CompanyName>Comércio Mineiro</CompanyName>
|
||||
<ContactName>Pedro Afonso</ContactName>
|
||||
<City>São Paulo</City>
|
||||
<Country>Brazil</Country>
|
||||
<Orders>
|
||||
<OrderID>10558</OrderID>
|
||||
<CustomerID>COMMI</CustomerID>
|
||||
<OrderDate>6/4/1997</OrderDate>
|
||||
<ShippedDate>6/10/1997</ShippedDate>
|
||||
<RequiredDate>7/2/1997</RequiredDate>
|
||||
</Orders>
|
||||
<Orders>
|
||||
<OrderID>10542</OrderID>
|
||||
<CustomerID>COMMI</CustomerID>
|
||||
<OrderDate>5/1/1997</OrderDate>
|
||||
<ShippedDate>5/7/1997</ShippedDate>
|
||||
<RequiredDate>5/29/1997</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
<Customers>
|
||||
<CustomerID>DRACD</CustomerID>
|
||||
<EmployeeID>3</EmployeeID>
|
||||
<CompanyName>Drachenblut Delikatessen</CompanyName>
|
||||
<ContactName>Sven Ottlieb</ContactName>
|
||||
<City>Aachen</City>
|
||||
<Country>Germany</Country>
|
||||
<Orders>
|
||||
<OrderID>10955</OrderID>
|
||||
<CustomerID>DRACD</CustomerID>
|
||||
<OrderDate>3/16/1998</OrderDate>
|
||||
<ShippedDate>3/24/1998</ShippedDate>
|
||||
<RequiredDate>4/27/1998</RequiredDate>
|
||||
</Orders>
|
||||
</Customers>
|
||||
</Employees>
|
||||
</EmployeesList>
|
|
@ -0,0 +1,70 @@
|
|||
# A tour of the C\# language
|
||||
|
||||
C\# (pronounced "See Sharp") is a modern, object\-oriented, and type\-safe programming language. C\# enables developers to build many types of secure and robust applications that run in .NET. C\# has its roots in the C family of languages and will be immediately familiar to C, C\+\+, Java, and JavaScript programmers. This tour provides an overview of the major components of the language in C\# 11 and earlier. If you want to explore the language through interactive examples, try the [introduction to C#](https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/tutorials/) tutorials.
|
||||
|
||||
Several C\# features help create robust and durable applications. [Garbage collection](https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/) automatically reclaims memory occupied by unreachable unused objects. [Nullable types](https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references) guard against variables that don't refer to allocated objects. [Exception handling](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/exceptions/) provides a structured and extensible approach to error detection and recovery. [Lambda expressions](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-expressions) support functional programming techniques. [Language Integrated Query (LINQ)](https://learn.microsoft.com/en-us/dotnet/csharp/linq/) syntax creates a common pattern for working with data from any source. Language support for [asynchronous operations](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/) provides syntax for building distributed systems. C\# has a [unified type system](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/). All C\# types, including primitive types such as `int` and `double`, inherit from a single root `object` type. All types share a set of common operations. Values of any type can be stored, transported, and operated upon in a consistent manner. Furthermore, C\# supports both user\-defined [reference types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types) and [value types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types). C\# allows dynamic allocation of objects and in\-line storage of lightweight structures. C\# supports generic methods and types, which provide increased type safety and performance. C\# provides iterators, which enable implementers of collection classes to define custom behaviors for client code.
|
||||
|
||||
# Hello world
|
||||
|
||||
The "Hello, World" program is traditionally used to introduce a programming language. Here it is in C\#:
|
||||
```
|
||||
using System;
|
||||
class Hello
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine("Hello, World");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
The "Hello, World" program starts with a `using` directive that references the `System` namespace. Namespaces provide a hierarchical means of organizing C\# programs and libraries. A `using` directive that references a given namespace enables unqualified use of the types that are members of that namespace. Because of the `using` directive, the program can use Console.WriteLine as shorthand for System.Console.WriteLine.
|
||||
|
||||
The Hello `class` declared by the "Hello, World" program has a single member, the method named `Main`. The `Main` method is declared with the static modifier. By convention, a static method named `Main` serves as the entry point of a C\# program.
|
||||
|
||||
The output of the program is produced by the `WriteLine` method of the `Console` class in the `System` namespace. This class is provided by the standard class libraries, which, by default, are automatically referenced by the compiler.
|
||||
|
||||
# Types and variables
|
||||
|
||||
A *type* defines the structure and behavior of any data in C\#. The declaration of a type may include its members, base type, interfaces it implements, and operations permitted for that type. A *variable* is a label that refers to an instance of a specific type.
|
||||
|
||||
There are two kinds of types in C\#:
|
||||
|
||||
1. Value types
|
||||
|
||||
1. Reference types.
|
||||
|
||||
## Value types
|
||||
|
||||
C\#'s value types are further divided into *simple types*, *enum types*, *struct types*, *nullable value types*, and *tuple value types*.
|
||||
|Value types|Details|
|
||||
|:---|:---|
|
||||
|[Simple types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types)|[Signed integral](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types), [unsigned integral](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types), [unicode characters](https://learn.microsoft.com/en-us/dotnet/standard/base-types/character-encoding-introduction), [IEEE binary floating-point](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types), [High-precision decimal floating-point](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types), and boolean. |
|
||||
|[Enum types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum)|User\-defined types of the form `enum E {...}`. An `enum` type is a distinct type with named constants. Every `enum` type has an underlying type, which must be one of the eight integral types. The set of values of an `enum` type is the same as the set of values of the underlying type.|
|
||||
|[Struct types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct)|User\-defined types of the form `struct S {...}`|
|
||||
|[Nullable value types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types)|Extensions of all other value types with a `null` value|
|
||||
|[Tuple value types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-tuples)|User\-defined types of the form `(T1, T2, ...)`|
|
||||
|
||||
|
||||
## Reference types
|
||||
|Reference types|Details|
|
||||
|:---|:---|
|
||||
|[Class types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/class) |Ultimate base class of all other types: object. Unicode strings: string, which represents a sequence of UTF\-16 code units. User\-defined types of the form class C {...}|
|
||||
|[Interface types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface) |User\-defined types of the form interface I {...}|
|
||||
|[Array types](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/) |Single\-dimensional, multi\-dimensional, and jagged. For example: int\[], int\[,], and int\[]\[] |
|
||||
|[Delegate types](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types) |User\-defined types of the form delegate int D(...) |
|
||||
|
||||
|
||||
C\# programs use *type declarations* to create new types. A type declaration specifies the name and the members of the new type. Six of C\#'s categories of types are user\-definable: class types, struct types, interface types, enum types, delegate types, and tuple value types. You can also declare `record` types, either `record struct`, or `record class`. Record types have compiler\-synthesized members. You use records primarily for storing values, with minimal associated behavior.
|
||||
|
||||
- A `class` type defines a data structure that contains data members (fields) and function members (methods, properties, and others). Class types support single inheritance and polymorphism, mechanisms whereby derived classes can extend and specialize base classes.
|
||||
|
||||
- A `struct` type is similar to a class type in that it represents a structure with data members and function members. However, unlike classes, structs are value types and don't typically require heap allocation. Struct types don't support user\-specified inheritance, and all struct types implicitly inherit from type `object`.
|
||||
|
||||
- An `interface` type defines a contract as a named set of public members. A `class` or `struct` that implements an `interface` must provide implementations of the interface's members. An `interface` may inherit from multiple base interfaces, and a `class` or `struct` may implement multiple interfaces.
|
||||
|
||||
- A `delegate` type represents references to methods with a particular parameter list and return type. Delegates make it possible to treat methods as entities that can be assigned to variables and passed as parameters. Delegates are analogous to function types provided by functional languages. They're also similar to the concept of function pointers found in some other languages. Unlike function pointers, delegates are object\-oriented and type\-safe.
|
||||
|
||||
You can explore more about C\# in this [tutorials](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/tutorials/classes).
|
После Ширина: | Высота: | Размер: 20 KiB |