This commit is contained in:
buildautomation 2021-12-29 14:17:41 +05:30
Родитель 5c7cd2fdcc
Коммит 3e5f202727
786 изменённых файлов: 293857 добавлений и 1 удалений

2112
DocIO/App.xaml Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

118
DocIO/App.xaml.cs Normal file
Просмотреть файл

@ -0,0 +1,118 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.Licensing;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
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 Syncfusion.SampleBrowser.UWP.DocIO
{
/// <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()
{
SyncfusionLicenseProvider.RegisterLicense(Common.DemoCommon.FindLicenseKey("Syncfusion.SampleBrowser.UWP.DocIO.SyncfusionLicense.txt"));
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)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
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;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (e.PrelaunchActivated == false)
{
new SamplesConfiguration();
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,3 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns = "http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
</ApplicationInsights>

Двоичные данные
DocIO/Assets/Export.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Двоичные данные
DocIO/Assets/LockScreenLogo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
DocIO/Assets/SplashScreen.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.5 KiB

Двоичные данные
DocIO/Assets/Square150x150Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.9 KiB

Двоичные данные
DocIO/Assets/Square44x44Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Двоичные данные
DocIO/Assets/Square44x44Logo.targetsize-24_altform-unplated.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичные данные
DocIO/Assets/StoreLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
DocIO/Assets/Wide310x150Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

Просмотреть файл

@ -0,0 +1,11 @@
Syncfusion.SampleBrowser.UWP.Common.dll
Syncfusion.Licensing.dll
Syncfusion.SfAccordion.UWP.dll
Syncfusion.SfInput.UWP.dll
Syncfusion.SfShared.UWP.dll
Syncfusion.SfTabControl.UWP.dll
Syncfusion.DocIO.UWP.dll
Syncfusion.OfficeChart.UWP.dll
Syncfusion.Pdf.UWP.dll
Syncfusion.XlsIO.UWP.dll
Syncfusion.Licensing.dll

Двоичные данные
DocIO/DocIO/Assets/AdventureCycle.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 79 KiB

Двоичные данные
DocIO/DocIO/Assets/Apple.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.7 KiB

Двоичные данные
DocIO/DocIO/Assets/BkmkDocumentPart_Template.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Bookmark_Template.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/ContentControlTemplate.docx Normal file

Двоичный файл не отображается.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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>

Двоичные данные
DocIO/DocIO/Assets/Excel_Template.xlsx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Grape.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.4 KiB

Двоичные данные
DocIO/DocIO/Assets/Image.gif Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 19 KiB

Двоичные данные
DocIO/DocIO/Assets/Letter Formatting.doc Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Letter Formatting.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Letter Formatting_WP.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/MetroStudio1.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 13 KiB

Двоичные данные
DocIO/DocIO/Assets/MetroStudio2.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 10 KiB

Двоичные данные
DocIO/DocIO/Assets/MetroStudio3.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 21 KiB

Двоичные данные
DocIO/DocIO/Assets/Mountain-200.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 20 KiB

Двоичные данные
DocIO/DocIO/Assets/Mountain-300.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Двоичные данные
DocIO/DocIO/Assets/Northwind.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 87 KiB

Двоичные данные
DocIO/DocIO/Assets/Northwind_logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.9 KiB

Просмотреть файл

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<Products>
<Product>
<SNO>1</SNO>
<ProductName>Côte de Blaye</ProductName>
<Sum>141.396</Sum>
</Product>
<Product>
<SNO>2</SNO>
<ProductName>Thüringer Rostbratwurst</ProductName>
<Sum>80.368</Sum>
</Product>
<Product>
<SNO>3</SNO>
<ProductName>Raclette Courdavault</ProductName>
<Sum>71.155</Sum>
</Product>
<Product>
<SNO>4</SNO>
<ProductName>Tarte au sucre </ProductName>
<Sum>47.234</Sum>
</Product>
<Product>
<SNO>5</SNO>
<ProductName>Camembert Pierrot </ProductName>
<Sum>46.825</Sum>
</Product>
<Product>
<SNO>6</SNO>
<ProductName>Gnocchi di nonna Alice</ProductName>
<Sum>42.593</Sum>
</Product>
<Product>
<SNO>7</SNO>
<ProductName>Manjimup Dried Apples</ProductName>
<Sum>41.819</Sum>
</Product>
<Product>
<SNO>8</SNO>
<ProductName>Alice Mutton</ProductName>
<Sum>32.698</Sum>
</Product>
<Product>
<SNO>9</SNO>
<ProductName>Carnarvon Tigers</ProductName>
<Sum>29.171</Sum>
</Product>
<Product>
<SNO>10</SNO>
<ProductName>Rössle Sauerkraut.</ProductName>
<Sum>25.696</Sum>
</Product>
</Products>

Двоичные данные
DocIO/DocIO/Assets/Road-550-W.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 20 KiB

Двоичные данные
DocIO/DocIO/Assets/Security Settings.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Soup.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.5 KiB

Двоичные данные
DocIO/DocIO/Assets/Template_Letter.doc Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Template_Letter_WP.doc Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Template_Report.doc Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/TrackChangesTemplate.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/WinFAQ.txt Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/Word to ODT.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Assets/syncfusion_logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.0 KiB

Двоичные данные
DocIO/DocIO/Assets/wordtoodt.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Просмотреть файл

@ -0,0 +1,43 @@
<View:SampleLayout
x:Class="EssentialDocIO.AutoShapesDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="AutoShapes" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample demonstrates to create Autoshapes for Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock6" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<Button x:Name="Button1" Grid.Row="10" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Padding="30,10,30,10"/>
<TextBlock x:Name="TextBlock7" Grid.Row="11" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,242 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class AutoShapesDemo : SampleLayout
{
public AutoShapesDemo()
{
InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
TextBlock4.Visibility = Visibility.Collapsed;
}
}
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
AutoShapes.ClearValue(Grid.BackgroundProperty);
AutoShapes.ClearValue(Grid.PaddingProperty);
AutoShapes.Children.Clear();
AutoShapes.ColumnDefinitions.Clear();
AutoShapes.RowDefinitions.Clear();
AutoShapes = null;
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
//Initialize Word document
WordDocument doc = new WordDocument();
//Ensure Minimum
doc.EnsureMinimal();
//Append AutoShape
Shape shape = doc.LastParagraph.AppendShape(AutoShapeType.RoundedRectangle, 130, 45);
//Set horizontal alignment
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
//Set horizontal origin
shape.HorizontalOrigin = HorizontalOrigin.Page;
//Set vertical origin
shape.VerticalOrigin = VerticalOrigin.Page;
//Set vertical position
shape.VerticalPosition = 50;
//Set AllowOverlap to true for overlapping shapes
shape.WrapFormat.AllowOverlap = true;
//Set Fill Color
shape.FillFormat.Color = Color.Blue;
//Set Content vertical alignment
shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
//Add Texbody contents to Shape
IWParagraph para = shape.TextBody.AddParagraph();
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
para.AppendText("Requirement").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
shape = doc.LastParagraph.AppendShape(AutoShapeType.DownArrow, 45, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 95;
shape.WrapFormat.AllowOverlap = true;
shape = doc.LastParagraph.AppendShape(AutoShapeType.RoundedRectangle, 130, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 140;
shape.WrapFormat.AllowOverlap = true;
shape.FillFormat.Color = Color.Orange;
shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
para = shape.TextBody.AddParagraph();
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
para.AppendText("Design").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
shape = doc.LastParagraph.AppendShape(AutoShapeType.DownArrow, 45, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 185;
shape.WrapFormat.AllowOverlap = true;
shape = doc.LastParagraph.AppendShape(AutoShapeType.RoundedRectangle, 130, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 230;
shape.WrapFormat.AllowOverlap = true;
shape.FillFormat.Color = Color.Blue;
shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
para = shape.TextBody.AddParagraph();
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
para.AppendText("Execution").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
shape = doc.LastParagraph.AppendShape(AutoShapeType.DownArrow, 45, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 275;
shape.WrapFormat.AllowOverlap = true;
shape = doc.LastParagraph.AppendShape(AutoShapeType.RoundedRectangle, 130, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 320;
shape.WrapFormat.AllowOverlap = true;
shape.FillFormat.Color = Color.Violet;
shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
para = shape.TextBody.AddParagraph();
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
para.AppendText("Testing").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
shape = doc.LastParagraph.AppendShape(AutoShapeType.DownArrow, 45, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 365;
shape.WrapFormat.AllowOverlap = true;
shape = doc.LastParagraph.AppendShape(AutoShapeType.RoundedRectangle, 130, 45);
shape.HorizontalAlignment = ShapeHorizontalAlignment.Center;
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.VerticalPosition = 410;
shape.WrapFormat.AllowOverlap = true;
shape.FillFormat.Color = Color.PaleVioletRed;
shape.TextFrame.TextVerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle;
para = shape.TextBody.AddParagraph();
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
para.AppendText("Release").ApplyCharacterFormat(new WCharacterFormat(doc) { Bold = true, TextColor = Color.White, FontSize = 12, FontName = "Verdana" });
SaveDocx(doc);
}
/// <summary>
/// Save as Docx Format
/// </summary>
/// <param name="doc"></param>
private async void SaveDocx(WordDocument doc)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Sample";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
await doc.SaveAsync(stream, FormatType.Docx);
doc.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
//Save as Docx Format
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,45 @@
<View:SampleLayout
x:Class="EssentialDocIO.BarChartDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="BarChart" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample illustrates inserting bar chart into a Word document with data from an existing Excel file." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock6" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<Button x:Name="Button1" Grid.Row="12" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Height="Auto" Width="Auto" Padding="30,10,30,10" />
<TextBlock x:Name="TextBlock7" Grid.Row="13" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,187 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.OfficeChart;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace EssentialDocIO
{
public sealed partial class BarChartDemo : SampleLayout
{
public BarChartDemo()
{
InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
BarChart.Margin = new Thickness(10, 10, 10, 10);
TextBlock4.Visibility = Visibility.Collapsed;
}
}
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
BarChart.ClearValue(Grid.BackgroundProperty);
BarChart.ClearValue(Grid.PaddingProperty);
BarChart.Children.Clear();
BarChart.ColumnDefinitions.Clear();
BarChart.RowDefinitions.Clear();
BarChart = null;
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
button.ClearValue(Button.HeightProperty);
button.ClearValue(Button.WidthProperty);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Assembly execAssem = typeof(BarChartDemo).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 = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
//Append text to the paragraph
paragraph.AppendText("Northwind Management Report").CharacterFormat.TextColor = Syncfusion.DocIO.DLS.Color.FromArgb(46, 116, 181);
//Add new paragraph
paragraph = section.AddParagraph();
//Set before spacing to the paragraph
paragraph.ParagraphFormat.BeforeSpacing = 20;
//Load the excel template as stream
Stream excelStream = execAssem.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.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
SaveDocx(document);
#endregion
}
private async void SaveDocx(WordDocument doc)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Sample";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
await doc.SaveAsync(stream, FormatType.Docx);
doc.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
//Save as Docx Format
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,53 @@
<View:SampleLayout
x:Class="EssentialDocIO.BookmarkNavigationDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="BookmarkNavigatioin" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample demonstrates the bookmark navigation in Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock6" Grid.Row="5" TextWrapping="Wrap" Text="Save As" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock7" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<StackPanel Name="stackPnlOptions" Grid.Row="9" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Left">
<RadioButton GroupName="Save As" Content="DOC" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDoc" Width="150" />
<RadioButton GroupName="Save As" Content="DOCX" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDocx" Width="150" IsChecked="True"/>
</StackPanel>
<TextBlock x:Name="TextBlock8" Grid.Row="10" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<TextBlock x:Name="TextBlock9" Grid.Row="11" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<Button x:Name="Button2" Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="4" Content="View Template" Click="Button_Click_2" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Height="Auto" Width="Auto" Padding="30,10,30,10"/>
<Button x:Name="Button1" Grid.Row="12" Grid.Column="1" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Height="Auto" Width="Auto" Padding="30,10,30,10" />
<TextBlock x:Name="TextBlock10" Grid.Row="13" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,411 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class BookmarkNavigationDemo : SampleLayout
{
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
DisposeTextBlock(TextBlock8);
TextBlock8 = null;
DisposeTextBlock(TextBlock9);
TextBlock9 = null;
DisposeTextBlock(TextBlock10);
TextBlock10 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
Button2.Click -= Button_Click_2;
DisposeButton(Button2);
Button2 = null;
DisposeRadioButton(rdDoc);
rdDoc = null;
DisposeRadioButton(rdDocx);
rdDocx = null;
stackPnlOptions.ClearValue(StackPanel.OrientationProperty);
stackPnlOptions.ClearValue(StackPanel.HorizontalAlignmentProperty);
stackPnlOptions = null;
BookmarkNavigatioin.ClearValue(Grid.BackgroundProperty);
BookmarkNavigatioin.ClearValue(Grid.PaddingProperty);
BookmarkNavigatioin.Children.Clear();
BookmarkNavigatioin.ColumnDefinitions.Clear();
BookmarkNavigatioin.RowDefinitions.Clear();
BookmarkNavigatioin = null;
}
public void DisposeRadioButton(RadioButton radioButton)
{
radioButton.ClearValue(RadioButton.GroupNameProperty);
radioButton.ClearValue(RadioButton.ContentProperty);
radioButton.ClearValue(RadioButton.FontFamilyProperty);
radioButton.ClearValue(RadioButton.FontSizeProperty);
radioButton.ClearValue(RadioButton.ForegroundProperty);
radioButton.ClearValue(RadioButton.WidthProperty);
radioButton.ClearValue(RadioButton.IsCheckedProperty);
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
button.ClearValue(Button.HeightProperty);
button.ClearValue(Button.WidthProperty);
}
private async void Button_Click_2(object sender, RoutedEventArgs e)
{
Assembly execAssm = typeof(BookmarkNavigationDemo).GetTypeInfo().Assembly;
Stream inputStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Bookmark_Template.docx");
MemoryStream stream = new MemoryStream();
inputStream.CopyTo(stream);
inputStream.Dispose();
stream.Position = 0;
ViewTemplate(stream);
}
public BookmarkNavigationDemo()
{
InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
BookmarkNavigatioin.Margin = new Thickness(10, 10, 10, 10);
stackPnlOptions.Visibility = Visibility.Collapsed;
TextBlock5.Visibility = Visibility.Collapsed;
TextBlock6.Visibility = Visibility.Collapsed;
TextBlock7.Visibility = Visibility.Collapsed;
TextBlock4.Visibility = Visibility.Collapsed;
}
else
{
stackPnlOptions.Visibility = Visibility.Visible;
TextBlock6.Visibility = Visibility.Visible;
TextBlock5.Visibility = Visibility.Visible;
TextBlock7.Visibility = Visibility.Visible;
}
}
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
Assembly execAssem = typeof(BookmarkNavigationDemo).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();
Stream inputStream = execAssem.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Bookmark_Template.docx");
// Open an existing template document.
await nwdInformation.OpenAsync(inputStream, FormatType.Doc);
inputStream.Dispose();
// Open an existing template document with multiple section.
WordDocument templateDocument = new WordDocument();
inputStream = execAssem.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.BkmkDocumentPart_Template.docx");
// Open an existing template document.
await templateDocument.OpenAsync(inputStream, FormatType.Doc);
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
//Move to image bookmark
bk.MoveToBookmark("Image");
//Deletes the bookmark
bk.DeleteBookmarkContent(true);
// Inserting image to the bookmark.
IWPicture pic = bk.InsertParagraphItem(ParagraphItemType.Picture) as WPicture;
inputStream = execAssem.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.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.
Save(rdDoc.IsChecked == true, document);
}
private async void Save(bool isDocFormat, WordDocument document)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
if (isDocFormat)
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".doc" });
else
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Bookmark Navigation";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
if (isDocFormat)
await document.SaveAsync(stream, FormatType.Doc);
else
await document.SaveAsync(stream, FormatType.Docx);
document.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
//Save as Docx Format
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
private async void ViewTemplate(MemoryStream stream)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Bookmark_Template";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("Bookmark_Template.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
//Save as Docx Format
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,43 @@
<View:SampleLayout
x:Class="EssentialDocIO.CreateEquationDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="CreateEquation" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample demonstrates how to create a Word document with mathematical equations using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock6" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<Button x:Name="Button1" Grid.Row="10" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Padding="30,10,30,10"/>
<TextBlock x:Name="TextBlock7" Grid.Row="11" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,729 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.Office;
using System;
using System.Collections.Generic;
using System.IO;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class CreateEquationDemo : SampleLayout
{
public CreateEquationDemo()
{
InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
TextBlock4.Visibility = Visibility.Collapsed;
}
}
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
CreateEquation.ClearValue(Grid.BackgroundProperty);
CreateEquation.ClearValue(Grid.PaddingProperty);
CreateEquation.Children.Clear();
CreateEquation.ColumnDefinitions.Clear();
CreateEquation.RowDefinitions.Clear();
CreateEquation = null;
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
//Creates a new word document instance
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//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 = Syncfusion.DocIO.DLS.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
SaveDocx(document);
}
/// <summary>
/// Save as Docx Format
/// </summary>
/// <param name="doc"></param>
private async void SaveDocx(WordDocument doc)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Sample";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
await doc.SaveAsync(stream, FormatType.Docx);
doc.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
//Save as Docx Format
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
#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,53 @@
<View:SampleLayout
x:Class="EssentialDocIO.EncryptAndDecryptDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="EncryptAndDecrypt" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample demonstrates how to encrypt and decrypt the Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<StackPanel Name="securityOptions" Grid.Row="5" Grid.ColumnSpan="4" Orientation="Vertical" VerticalAlignment="Top">
<RadioButton GroupName="Security" Content="Encrypt Document" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdEncrypt" Width="200" IsChecked="True"/>
<RadioButton GroupName="Security" Content="Decrypt Document" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDecrypt" Width="200"/>
</StackPanel>
<TextBlock x:Name="TextBlock6" Grid.Row="13" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<TextBlock x:Name="TextBlock7" Grid.Row="14" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<Button x:Name="Button1" Grid.Row="15" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Height="Auto" Width="Auto" Padding="30,10,30,10" />
<TextBlock x:Name="TextBlock8" Grid.Row="16" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,219 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class EncryptAndDecryptDemo : SampleLayout
{
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
DisposeTextBlock(TextBlock8);
TextBlock8 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
DisposeRadioButton(rdEncrypt);
rdEncrypt = null;
DisposeRadioButton(rdDecrypt);
rdDecrypt = null;
securityOptions.ClearValue(StackPanel.OrientationProperty);
securityOptions.ClearValue(StackPanel.VerticalAlignmentProperty);
securityOptions = null;
EncryptAndDecrypt.ClearValue(Grid.BackgroundProperty);
EncryptAndDecrypt.ClearValue(Grid.PaddingProperty);
EncryptAndDecrypt.Children.Clear();
EncryptAndDecrypt.ColumnDefinitions.Clear();
EncryptAndDecrypt.RowDefinitions.Clear();
EncryptAndDecrypt = null;
}
public void DisposeRadioButton(RadioButton radioButton)
{
radioButton.ClearValue(RadioButton.GroupNameProperty);
radioButton.ClearValue(RadioButton.ContentProperty);
radioButton.ClearValue(RadioButton.FontFamilyProperty);
radioButton.ClearValue(RadioButton.FontSizeProperty);
radioButton.ClearValue(RadioButton.ForegroundProperty);
radioButton.ClearValue(RadioButton.WidthProperty);
radioButton.ClearValue(RadioButton.IsCheckedProperty);
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
button.ClearValue(Button.HeightProperty);
button.ClearValue(Button.WidthProperty);
}
public EncryptAndDecryptDemo()
{
InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
EncryptAndDecrypt.Margin = new Thickness(10, 10, 10, 10);
securityOptions.Visibility = Visibility.Collapsed;
TextBlock5.Visibility = Visibility.Collapsed;
TextBlock6.Visibility = Visibility.Collapsed;
TextBlock7.Visibility = Visibility.Collapsed;
TextBlock4.Visibility = Visibility.Collapsed;
}
else
{
securityOptions.Visibility = Visibility.Visible;
TextBlock6.Visibility = Visibility.Visible;
TextBlock5.Visibility = Visibility.Visible;
TextBlock7.Visibility = Visibility.Visible;
}
}
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
Assembly execAssem = typeof(EncryptAndDecryptDemo).GetTypeInfo().Assembly;
WordDocument document = null;
if (rdEncrypt.IsChecked==true)
{
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
{
// Open an existing template document with single section.
document = new WordDocument();
Stream inputStream = execAssem.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Security Settings.docx");
// Open an existing template document.
await document.OpenAsync(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";
}
Save(document);
}
private async void Save(WordDocument document)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// File types the user can save the file as
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Encrypt and Decrypt";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
await document.SaveAsync(stream, FormatType.Docx);
document.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
//Save as Docx Format
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,72 @@
<View:SampleLayout
x:Class="EssentialDocIO.FindAndReplaceDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="FindAndReplace" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample demonstrates the find and replace functionality in Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" TextWrapping="Wrap" Text="Look in :" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBox x:Name="InputFile1" Grid.Row="3" Grid.Column="1" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<Button x:Name="Button1" Grid.Row="3" Grid.Column="2" Content=". . ." Click="Button_Click_3" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Padding="15,7,15,5"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock6" Grid.Row="5" TextWrapping="Wrap" Text="Find what :" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBox x:Name="FindTextBox" Grid.Row="5" Grid.Column="1" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock7" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock8" Grid.Row="7" FontFamily="Segoe UI" FontSize="16" TextWrapping="Wrap" Text="Replace with :" Foreground="#333333"/>
<TextBox x:Name="ReplaceTextBox" Grid.Row="7" Grid.Column="1" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock9" Grid.Row="8" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock10" Grid.Row="9" TextWrapping="Wrap" Text="Search Options : " FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<CheckBox x:Name="chkBoxMatchCase" Grid.Row="9" Grid.Column="1" Content="Match Case" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<CheckBox x:Name="chkBoxWholeWord" Grid.Row="9" Grid.Column="2" Content="Whole Word" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock11" Grid.Row="10" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock12" Grid.Row="11" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock13" Grid.Row="12" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock14" Grid.Row="13" TextWrapping="Wrap" Text="Save As" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock15" Grid.Row="14" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<StackPanel Name="stackPnlOptions" Grid.Row="15" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Left">
<RadioButton GroupName="Save As" Content="DOC" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDoc" Width="150" />
<RadioButton GroupName="Save As" Content="DOCX" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDocx" Width="150" IsChecked="True"/>
</StackPanel>
<TextBlock x:Name="TextBlock16" Grid.Row="16" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock17" Grid.Row="17" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<Button Grid.Row="18" Grid.ColumnSpan="4" x:Name="generateButton" IsEnabled="False" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Padding="30,10,30,10"/>
<TextBlock x:Name="TextBlock18" Grid.Row="19" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,237 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class FindAndReplaceDemo : SampleLayout
{
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
DisposeTextBlock(TextBlock8);
TextBlock8 = null;
DisposeTextBlock(TextBlock9);
TextBlock9 = null;
DisposeTextBlock(TextBlock10);
TextBlock10 = null;
DisposeTextBlock(TextBlock11);
TextBlock11 = null;
DisposeTextBlock(TextBlock12);
TextBlock12 = null;
DisposeTextBlock(TextBlock13);
TextBlock13 = null;
DisposeTextBlock(TextBlock14);
TextBlock14 = null;
DisposeTextBlock(TextBlock15);
TextBlock15 = null;
DisposeTextBlock(TextBlock16);
TextBlock16 = null;
DisposeTextBlock(TextBlock17);
TextBlock17 = null;
DisposeTextBlock(TextBlock18);
TextBlock18 = null;
DisposeTextBox(InputFile1);
InputFile1 = null;
DisposeTextBox(FindTextBox);
FindTextBox = null;
DisposeTextBox(ReplaceTextBox);
ReplaceTextBox = null;
DisposeCheckBox(chkBoxMatchCase);
chkBoxMatchCase = null;
DisposeCheckBox(chkBoxWholeWord);
chkBoxWholeWord = null;
Button1.Click -= Button_Click_3;
DisposeButton(Button1);
Button1 = null;
generateButton.Click -= Button_Click_1;
DisposeButton(generateButton);
generateButton = null;
DisposeRadioButton(rdDoc);
rdDoc = null;
DisposeRadioButton(rdDocx);
rdDocx = null;
stackPnlOptions.ClearValue(StackPanel.OrientationProperty);
stackPnlOptions.ClearValue(StackPanel.HorizontalAlignmentProperty);
stackPnlOptions = null;
FindAndReplace.ClearValue(Grid.BackgroundProperty);
FindAndReplace.ClearValue(Grid.PaddingProperty);
FindAndReplace.Children.Clear();
FindAndReplace.ColumnDefinitions.Clear();
FindAndReplace.RowDefinitions.Clear();
FindAndReplace = null;
}
public void DisposeCheckBox(CheckBox checkBox)
{
checkBox.ClearValue(CheckBox.FontFamilyProperty);
checkBox.ClearValue(CheckBox.FontSizeProperty);
checkBox.ClearValue(CheckBox.FontSizeProperty);
}
public void DisposeTextBox(TextBox textBox)
{
textBox.ClearValue(TextBox.FontFamilyProperty);
textBox.ClearValue(TextBox.FontSizeProperty);
textBox.ClearValue(TextBox.ForegroundProperty);
}
public void DisposeRadioButton(RadioButton radioButton)
{
radioButton.ClearValue(RadioButton.GroupNameProperty);
radioButton.ClearValue(RadioButton.ContentProperty);
radioButton.ClearValue(RadioButton.FontFamilyProperty);
radioButton.ClearValue(RadioButton.FontSizeProperty);
radioButton.ClearValue(RadioButton.ForegroundProperty);
radioButton.ClearValue(RadioButton.WidthProperty);
radioButton.ClearValue(RadioButton.IsCheckedProperty);
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
button.ClearValue(Button.HeightProperty);
button.ClearValue(Button.WidthProperty);
button.ClearValue(Button.IsEnabledProperty);
}
public FindAndReplaceDemo()
{
InitializeComponent();
}
StorageFile file;
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
WordDocument document = new WordDocument();
//Open an existing word document.
await document.OpenAsync(file);
if (FindTextBox.Text.Trim() == string.Empty || ReplaceTextBox.Text.Trim() == string.Empty)
{
MessageDialog msgDialog = new MessageDialog("Please fill the find and replacement text in appropriate textboxes...");
UICommand okCmd = new UICommand("Ok");
msgDialog.Commands.Add(okCmd);
IUICommand cmd = await msgDialog.ShowAsync();
}
else
{
document.Replace(FindTextBox.Text, ReplaceTextBox.Text, chkBoxMatchCase.IsChecked.Value, chkBoxWholeWord.IsChecked.Value);
StorageFile stgFile = null;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
savePicker.SuggestedFileName = "Sample";
if (rdDoc.IsChecked.Value)
{
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".doc" });
stgFile = await savePicker.PickSaveFileAsync();
if (stgFile != null)
await document.SaveAsync(stgFile, FormatType.Doc);
}
else
{
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
stgFile = await savePicker.PickSaveFileAsync();
if (stgFile != null)
{
await document.SaveAsync(stgFile, FormatType.Docx);
}
}
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
if (stgFile != null)
{
await document.SaveAsync(stgFile, FormatType.Docx);
}
}
if (stgFile != null)
{
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
private async void Button_Click_3(object sender, RoutedEventArgs e)
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openPicker.FileTypeFilter.Add(".doc");
openPicker.FileTypeFilter.Add(".docx");
StorageFile tempFile = await openPicker.PickSingleFileAsync();
if (tempFile != null)
file = tempFile;
if (file == null)
generateButton.IsEnabled = false;
else
{
// Application now has read/write access to the picked file
InputFile1.Text = file.Name;
generateButton.IsEnabled = true;
}
}
}
}

Просмотреть файл

@ -0,0 +1,43 @@
<View:SampleLayout
x:Class="EssentialDocIO.FormFillingAndProtectionDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="FormFillingAndProtection" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample illustrates filling form and protecting the content controls in an existing Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Click the button to view the generated Word document. Please note that Microsoft Word Viewer or Microsoft Word is required to view the resultant Word document." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock6" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<Button x:Name="Button1" Grid.Row="10" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Padding="30,10,30,10"/>
<TextBlock x:Name="TextBlock7" Grid.Row="11" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,318 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using System.Reflection;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class FormFillingAndProtectionDemo : SampleLayout
{
#region Fields
// Gets current executing assembly.
Assembly execAssm = typeof(FormFillingAndProtectionDemo).GetTypeInfo().Assembly;
#endregion
/// <summary>
/// Constructor for FormFillingAndProtectionDemo.
/// </summary>
public FormFillingAndProtectionDemo()
{
InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
TextBlock4.Visibility = Visibility.Collapsed;
}
}
/// <summary>
/// Disposes the objects such as text blocks, buttons, and etc., of FormFillingAndProtection.
/// </summary>
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
FormFillingAndProtection.ClearValue(Grid.BackgroundProperty);
FormFillingAndProtection.ClearValue(Grid.PaddingProperty);
FormFillingAndProtection.Children.Clear();
FormFillingAndProtection.ColumnDefinitions.Clear();
FormFillingAndProtection.RowDefinitions.Clear();
FormFillingAndProtection = null;
}
/// <summary>
/// Disposes the objects from text block.
/// </summary>
/// <param name="textBlock">Text Block</param>
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
/// <summary>
/// Disposes the object from button.
/// </summary>
/// <param name="button">Button</param>
public void DisposeButton(Button button)
{
button.ClearValue(FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
}
/// <summary>
/// Button click event for FormFillingAndProtection.
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">Event args</param>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
// Load Template document stream.
Stream inputStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.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
Save(document);
}
/// <summary>
/// Saves Word document.
/// </summary>
/// <param name="document">Word document</param>
private async void Save(WordDocument document)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Sample";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
await document.SaveAsync(stream, FormatType.Docx);
document.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,53 @@
<View:SampleLayout
x:Class="EssentialDocIO.GettingStartedDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="GettingStarted" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="WinRTText1" Grid.Row="1" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="This sample demonstrates to create Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock2" Grid.Row="2" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="WinRTText2" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="text1" Grid.Row="4" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock Grid.Row="5" TextWrapping="Wrap" Text="Save As" FontFamily="Segoe UI" FontSize="16" x:Name="saveas" Foreground="#333333"/>
<TextBlock x:Name="text2" Grid.Row="6" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="14"/>
<StackPanel Name="stackPnlOptions" Grid.Row="9" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Left">
<RadioButton GroupName="Save As" Content="DOC" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDoc" Width="150" />
<RadioButton GroupName="Save As" Content="DOCX" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDocx" Width="150" IsChecked="True"/>
</StackPanel>
<TextBlock x:Name="TextBlock4" Grid.Row="10" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock5" Grid.Row="11" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
<Button x:Name="Button1" Grid.Row="12" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Height="Auto" Width="Auto" Padding="30,10,30,10" />
<TextBlock x:Name="TextBlock6" Grid.Row="13" Grid.ColumnSpan="4" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,413 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using System.Reflection;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class GettingStartedDemo : SampleLayout
{
#region Fields
Assembly execAssm = typeof(GettingStartedDemo).GetTypeInfo().Assembly;
#endregion
public GettingStartedDemo()
{
this.InitializeComponent();
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
GettingStarted.Margin = new Thickness(10, 10, 10, 10);
stackPnlOptions.Visibility = Visibility.Collapsed;
saveas.Visibility = Visibility.Collapsed;
text1.Visibility = Visibility.Collapsed;
text2.Visibility = Visibility.Collapsed;
WinRTText2.Visibility = Visibility.Collapsed;
}
else
{
stackPnlOptions.Visibility = Visibility.Visible;
saveas.Visibility = Visibility.Visible;
text1.Visibility = Visibility.Visible;
text2.Visibility = Visibility.Visible;
}
}
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(saveas);
saveas = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(WinRTText1);
WinRTText1 = null;
DisposeTextBlock(WinRTText2);
WinRTText2 = null;
DisposeTextBlock(text1);
text1 = null;
DisposeTextBlock(text2);
text2 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
DisposeRadioButton(rdDoc);
rdDoc = null;
DisposeRadioButton(rdDocx);
rdDocx = null;
stackPnlOptions.ClearValue(StackPanel.OrientationProperty);
stackPnlOptions.ClearValue(StackPanel.HorizontalAlignmentProperty);
stackPnlOptions = null;
GettingStarted.ClearValue(Grid.BackgroundProperty);
GettingStarted.ClearValue(Grid.PaddingProperty);
GettingStarted.Children.Clear();
GettingStarted.ColumnDefinitions.Clear();
GettingStarted.RowDefinitions.Clear();
GettingStarted = null;
}
public void DisposeRadioButton(RadioButton radioButton)
{
radioButton.ClearValue(RadioButton.GroupNameProperty);
radioButton.ClearValue(RadioButton.ContentProperty);
radioButton.ClearValue(RadioButton.FontFamilyProperty);
radioButton.ClearValue(RadioButton.FontSizeProperty);
radioButton.ClearValue(RadioButton.ForegroundProperty);
radioButton.ClearValue(RadioButton.WidthProperty);
radioButton.ClearValue(RadioButton.IsCheckedProperty);
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
button.ClearValue(Button.HeightProperty);
button.ClearValue(Button.WidthProperty);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
// 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.Width = 612;
section.PageSetup.PageSize.Height = 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 = 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();
Stream imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.AdventureCycle.jpg");
//Appends picture to the paragraph.
WPicture picture = paragraph.AppendPicture(imageStream) as WPicture;
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
picture.VerticalOrigin = VerticalOrigin.Margin;
picture.VerticalPosition = -45;
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";
//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 = BorderStyle.None;
table.TableFormat.IsAutoResized = true;
//Appends paragraph.
paragraph = table[0, 0].AddParagraph();
paragraph.ParagraphFormat.AfterSpacing = 0;
paragraph.BreakCharacterFormat.FontSize = 12f;
//Appends picture to the paragraph.
imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Mountain-200.jpg");
//Appends picture to the paragraph.
picture = paragraph.AppendPicture(imageStream) as WPicture;
picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom;
picture.VerticalOrigin = VerticalOrigin.Paragraph;
picture.VerticalPosition = 4.5f;
picture.HorizontalOrigin = HorizontalOrigin.Column;
picture.HorizontalPosition = -2.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;
//Appends picture to the paragraph.
imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.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;
//Appends picture to the paragraph.
imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.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 = 3.75f;
picture.HorizontalOrigin = HorizontalOrigin.Column;
picture.HorizontalPosition = -5f;
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();
Save(rdDoc.IsChecked == true, document);
}
private async void Save(bool isDocFormat, WordDocument document)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
if (isDocFormat)
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".doc" });
else
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Sample";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
if (isDocFormat)
await document.SaveAsync(stream, FormatType.Doc);
else
await document.SaveAsync(stream, FormatType.Docx);
document.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,72 @@
<View:SampleLayout
x:Class="EssentialDocIO.HeadersAndFootersDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:common="using:Common"
xmlns:Controls ="using:Syncfusion.UI.Xaml.Controls.Input">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="HeaderFooter" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width=".5*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width=".5*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock2" Grid.Row="1" Grid.ColumnSpan="6" TextWrapping="Wrap" Text="This sample demonstrates the header and footer in Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock3" Grid.Row="2" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="TextBlock4" Grid.Row="3" Grid.ColumnSpan="2" TextWrapping="Wrap" Text="Header and Footer" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<Rectangle Grid.Row="3" Grid.RowSpan="5" Grid.Column="2" Width="1" StrokeThickness="0.75" Stroke="#666666"></Rectangle>
<TextBlock x:Name="TextBlock5" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" TextWrapping="Wrap" Text="Page Number" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock6" Grid.Row="4" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<CheckBox x:Name="checkBox1" Grid.Row="5" Grid.ColumnSpan="6" Content="Header and Footer for First page" IsChecked="True" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" Width="256"/>
<TextBlock Grid.Row="5" Grid.Column="3" TextWrapping="Wrap" Text="Number Format" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<ComboBox x:Name="comboBox1" Grid.Row="5" Grid.Column="4" Grid.ColumnSpan="1" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock Grid.Row="6" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<CheckBox x:Name="checkBox2" Grid.Row="7" Grid.ColumnSpan="6" Content="Header and Footer for All pages" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" Width="252"/>
<TextBlock x:Name="TextBlock7" Grid.Row="7" Grid.Column="3" TextWrapping="Wrap" Text="Start At" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<Controls:SfNumericUpDown FormatString="##" x:Name="numericUpDown1" Grid.Row="7" Grid.Column="4" Grid.ColumnSpan="1" Minimum="1" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" AccentBrush="#FF656868"/>
<TextBlock x:Name="TextBlock8" Grid.Row="8" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock9" Grid.Row="9" Grid.ColumnSpan="6" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock10" Grid.Row="10" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock11" Grid.Row="11" TextWrapping="Wrap" Text="Save As" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="TextBlock12" Grid.Row="12" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="14"/>
<StackPanel Name="stackPnlOptions" Grid.Row="13" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Left">
<RadioButton GroupName="Save As" Content="DOC" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDoc" Width="150" />
<RadioButton GroupName="Save As" Content="DOCX" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDocx" Width="150" IsChecked="True"/>
</StackPanel>
<TextBlock x:Name="TextBlock13" Grid.Row="14" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="TextBlock14" Grid.Row="15" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<Button x:Name="Button1" Grid.Row="16" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Padding="30,10,30,10"/>
<TextBlock x:Name="TextBlock15" Grid.Row="17" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Просмотреть файл

@ -0,0 +1,356 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Common;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace EssentialDocIO
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class HeadersAndFootersDemo : SampleLayout
{
public HeadersAndFootersDemo()
{
InitializeComponent();
//Associate PageNumberStyle Enum values to comboBox
foreach (String str in Enum.GetNames(typeof(PageNumberStyle)))
comboBox1.Items.Add(str);
comboBox1.SelectedIndex = 2;
}
public override void Dispose()
{
base.Dispose();
DisposeTextBlock(TextBlock1);
TextBlock1 = null;
DisposeTextBlock(TextBlock2);
TextBlock2 = null;
DisposeTextBlock(TextBlock3);
TextBlock3 = null;
DisposeTextBlock(TextBlock4);
TextBlock4 = null;
DisposeTextBlock(TextBlock5);
TextBlock5 = null;
DisposeTextBlock(TextBlock6);
TextBlock6 = null;
DisposeTextBlock(TextBlock7);
TextBlock7 = null;
DisposeTextBlock(TextBlock8);
TextBlock8 = null;
DisposeTextBlock(TextBlock9);
TextBlock9 = null;
DisposeTextBlock(TextBlock10);
TextBlock10 = null;
DisposeTextBlock(TextBlock11);
TextBlock11 = null;
DisposeTextBlock(TextBlock12);
TextBlock12 = null;
DisposeTextBlock(TextBlock13);
TextBlock13 = null;
DisposeTextBlock(TextBlock14);
TextBlock14 = null;
DisposeTextBlock(TextBlock15);
TextBlock15 = null;
Button1.Click -= Button_Click_1;
DisposeButton(Button1);
Button1 = null;
DisposeRadioButton(rdDoc);
rdDoc = null;
DisposeRadioButton(rdDocx);
rdDocx = null;
DisposeCheckBox(checkBox1);
checkBox1 = null;
DisposeCheckBox(checkBox2);
checkBox2 = null;
comboBox1.ClearValue(ComboBox.FontFamilyProperty);
comboBox1.ClearValue(ComboBox.FontSizeProperty);
comboBox1.ClearValue(ComboBox.ForegroundProperty);
comboBox1 = null;
stackPnlOptions.ClearValue(StackPanel.OrientationProperty);
stackPnlOptions.ClearValue(StackPanel.HorizontalAlignmentProperty);
stackPnlOptions = null;
HeaderFooter.ClearValue(Grid.BackgroundProperty);
HeaderFooter.ClearValue(Grid.PaddingProperty);
HeaderFooter.Children.Clear();
HeaderFooter.ColumnDefinitions.Clear();
HeaderFooter.RowDefinitions.Clear();
HeaderFooter = null;
}
public void DisposeCheckBox(CheckBox checkBox)
{
checkBox.ClearValue(CheckBox.FontFamilyProperty);
checkBox.ClearValue(CheckBox.FontSizeProperty);
checkBox.ClearValue(CheckBox.FontSizeProperty);
}
public void DisposeRadioButton(RadioButton radioButton)
{
radioButton.ClearValue(RadioButton.GroupNameProperty);
radioButton.ClearValue(RadioButton.ContentProperty);
radioButton.ClearValue(RadioButton.FontFamilyProperty);
radioButton.ClearValue(RadioButton.FontSizeProperty);
radioButton.ClearValue(RadioButton.ForegroundProperty);
radioButton.ClearValue(RadioButton.WidthProperty);
radioButton.ClearValue(RadioButton.IsCheckedProperty);
}
public void DisposeTextBlock(TextBlock textBlock)
{
textBlock.ClearValue(TextBlock.FontFamilyProperty);
textBlock.ClearValue(TextBlock.FontSizeProperty);
textBlock.ClearValue(TextBlock.TextProperty);
textBlock.ClearValue(TextBlock.TextWrappingProperty);
textBlock.ClearValue(TextBlock.ForegroundProperty);
}
public void DisposeButton(Button button)
{
button.ClearValue(Button.FontFamilyProperty);
button.ClearValue(Button.FontSizeProperty);
button.ClearValue(Button.PaddingProperty);
button.ClearValue(Button.ForegroundProperty);
button.ClearValue(Button.BackgroundProperty);
button.ClearValue(Button.ContentProperty);
button.ClearValue(Button.HeightProperty);
button.ClearValue(Button.WidthProperty);
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
// Creating a new document.
WordDocument doc = new WordDocument();
// Add a new section to the document.
IWSection section1 = doc.AddSection();
Assembly execAssm = typeof(HeadersAndFootersDemo).GetTypeInfo().Assembly;
#region Header Footer
//Add different Header Footer for first and other pages
if (checkBox1.IsChecked == true && checkBox2.IsChecked == true)
{
// Set the header/footer setup.
section1.PageSetup.DifferentFirstPage = true;
// Inserting Header Footer to first page
InsertFirstPageHeaderFooter(doc, section1);
// Inserting Header Footer to all pages
InsertPageHeaderFooter(doc, section1);
}
//Add Header Footer only for first page
if (checkBox1.IsChecked == true && checkBox2.IsChecked != true)
{
// Set the header/footer setup.
section1.PageSetup.DifferentFirstPage = true;
// Inserting Header Footer to first page
InsertFirstPageHeaderFooter(doc, section1);
}
//Add same Header Footer for all the pages
if (checkBox2.IsChecked == true && checkBox1.IsChecked != true)
{
// Inserting Header Footer to all pages
InsertPageHeaderFooter(doc, section1);
}
#endregion
// Add text to the document body section.
IWParagraph par;
par = section1.AddParagraph();
//Insert Text into the word Document.
Stream inputStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.WinFAQ.txt");
StreamReader reader = new StreamReader(inputStream, System.Text.Encoding.Unicode);
string text = reader.ReadToEnd();
par.AppendText(text);
Save(rdDoc.IsChecked == true, doc);
}
private async void Save(bool isDocFormat, WordDocument document)
{
StorageFile stgFile;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
if (isDocFormat)
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".doc" });
else
savePicker.FileTypeChoices.Add("Word Document", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Sample";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
MemoryStream stream = new MemoryStream();
if (isDocFormat)
await document.SaveAsync(stream, FormatType.Doc);
else
await document.SaveAsync(stream, FormatType.Docx);
document.Close();
stream.Position = 0;
Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite);
Stream st = fileStream.AsStreamForWrite();
st.SetLength(0);
st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length);
st.Flush();
st.Dispose();
fileStream.Dispose();
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
#region Helper Methods
#region InsertFirstPageHeaderFooter
private void InsertFirstPageHeaderFooter(WordDocument doc, IWSection section)
{
Assembly execAssm = typeof(HeadersAndFootersDemo).GetTypeInfo().Assembly;
Stream inputStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Northwind_logo.png");
// Add a new paragraph for header to the document.
IWParagraph headerPar = new WParagraph(doc);
// Add a new table to the header.
IWTable table = section.HeadersFooters.FirstPageHeader.AddTable();
RowFormat format = new RowFormat();
// Setting cleared table border style.
format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
// Inserting table with a row and two columns.
table.ResetCells(1, 2, format, 265);
// Inserting logo image to the table first cell.
headerPar = table[0, 0].AddParagraph() as WParagraph;
headerPar.AppendPicture(inputStream);
//Set Image size
(headerPar.Items[0] as WPicture).Width = 232.5f;
(headerPar.Items[0] as WPicture).Height = 54.75f;
// Inserting text to the table second cell.
headerPar = table[0, 1].AddParagraph() as WParagraph;
IWTextRange txt = headerPar.AppendText("Company Headquarters,\n2501 Aerial Center Parkway,\nSuite 110, Morrisville, NC 27560,\nTEL 1-888-936-8638.");
txt.CharacterFormat.FontSize = 12;
txt.CharacterFormat.CharacterSpacing = 1.7f;
headerPar.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Right;
// Add a new paragraph to the header with address text.
headerPar = new WParagraph(doc);
headerPar.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
txt = headerPar.AppendText("\nFirst Page Header");
txt.CharacterFormat.CharacterSpacing = 1.7f;
section.HeadersFooters.FirstPageHeader.Paragraphs.Add(headerPar);
// Add a footer paragraph text to the document.
WParagraph footerPar = new WParagraph(doc);
footerPar.ParagraphFormat.Tabs.AddTab(523f, TabJustification.Right, TabLeader.NoLeader);
// Add text.
footerPar.AppendText("Copyright Northwind Inc. 2001 - 2015");
// Add page and Number of pages field to the document.
footerPar.AppendText("\tFirst Page ");
footerPar.AppendField("Page", FieldType.FieldPage);
section.HeadersFooters.FirstPageFooter.Paragraphs.Add(footerPar);
#region Page Number Settings
section.PageSetup.RestartPageNumbering = true;
section.PageSetup.PageStartingNumber = Convert.ToInt32(this.numericUpDown1.Value);
section.PageSetup.PageNumberStyle = (PageNumberStyle)Enum.Parse(typeof(PageNumberStyle), this.comboBox1.SelectedItem.ToString(), true);
#endregion
}
#endregion
#region InsertPageHeaderFooter
private void InsertPageHeaderFooter(WordDocument doc, IWSection section1)
{
Assembly execAssm = typeof(HeadersAndFootersDemo).GetTypeInfo().Assembly;
Stream inputStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Northwind_logo.png");
// Add a new paragraph for header to the document.
IWParagraph headerPar = new WParagraph(doc);
// Add a new table to the header
IWTable table = section1.HeadersFooters.Header.AddTable();
RowFormat format = new RowFormat();
// Setting Single table border style.
format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Single;
// Inserting table with a row and two columns.
table.ResetCells(1, 2, format, 265);
// Inserting logo image to the table first cell.
headerPar = table[0, 0].AddParagraph() as WParagraph;
headerPar.AppendPicture(inputStream);
//Set Image size.
(headerPar.Items[0] as WPicture).Width = 232.5f;
(headerPar.Items[0] as WPicture).Height = 54.75f;
// Inserting text to the table second cell.
headerPar = table[0, 1].AddParagraph() as WParagraph;
IWTextRange txt = headerPar.AppendText("Company Headquarters,\n2501 Aerial Center Parkway,\nSuite 110, Morrisville, NC 27560,\nTEL 1-888-936-8638.");
txt.CharacterFormat.FontSize = 12;
txt.CharacterFormat.CharacterSpacing = 1.7f;
headerPar.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Right;
// Add a footer paragraph text to the document.
WParagraph footerPar = new WParagraph(doc);
footerPar.ParagraphFormat.Tabs.AddTab(523f, TabJustification.Right, TabLeader.NoLeader);
// Add text.
footerPar.AppendText("Copyright Northwind Inc. 2001 - 2015");
// Add page and Number of pages field to the document.
footerPar.AppendText("\tPage ");
IWField ff = footerPar.AppendField("Page", FieldType.FieldPage);
section1.HeadersFooters.Footer.Paragraphs.Add(footerPar);
#region Page Number Settings
section1.PageSetup.RestartPageNumbering = true;
section1.PageSetup.PageStartingNumber = Convert.ToInt32(this.numericUpDown1.Value);
section1.PageSetup.PageNumberStyle = (PageNumberStyle)Enum.Parse(typeof(PageNumberStyle), this.comboBox1.SelectedItem.ToString(), true);
#endregion
}
#endregion
#endregion
}
}

Просмотреть файл

@ -0,0 +1,131 @@
<Page
xmlns:Controls="using:Syncfusion.UI.Xaml.Controls.Input"
x:Class="Invoice.Address"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///DocIO/Invoice/Common/IOStandardStyles.Xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="outerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="0"></Grid>
<Grid x:Name="RootPanel" Grid.Row="1" Background="#FF004051">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="0.25*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="1.5*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource BasicTextStyle}" x:Name="Title" HorizontalAlignment="Center" VerticalAlignment="Bottom" Text="BILL TO" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" FontSize="32" FontWeight="Light"></TextBlock>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="Name" Grid.Column="1" Grid.Row="1" FontSize="18" Padding="0,0,15,5"></TextBlock>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Bottom" Text="Address" Grid.Column="1" Grid.Row="2" FontSize="18" Padding="0,0,15,5"></TextBlock>
<Grid Grid.Column="3" Grid.Row="3">
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" VerticalAlignment="Top" Text="DueDate" Grid.Column="3" Grid.Row="3" FontSize="18" Padding="0,0,15,5"></TextBlock>
</Grid>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="Date" Grid.Column="3" Grid.Row="1" FontSize="18" Padding="0,0,15,5"></TextBlock>
<Grid Grid.Column="3" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Stretch" TextAlignment="Right" VerticalAlignment="Center" Text="Invoice No" FontSize="18" Grid.Row="1" Padding="0,0,15,5"></TextBlock>
</Grid>
<Grid Grid.Row="1" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Text="{Binding Mode=TwoWay, Path=Name}" HorizontalAlignment="Left" Width="200" VerticalAlignment="Bottom" Name="nameField" FontFamily="Segoe UI" FontSize="18" Grid.Row="1" Grid.RowSpan="2"></TextBox>
</Grid>
<Grid Grid.Row="2" Grid.Column="2" Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox FontFamily="Segoe UI" FontSize="18" Text="{Binding Mode=TwoWay, Path=Address}" TextWrapping="Wrap" HorizontalAlignment="Left" Width="200" VerticalAlignment="Stretch" Name="address" Grid.Row="1" Margin="0,0,0,4"/>
</Grid>
<Grid Grid.Row="3" Grid.Column="4">
<Grid.RowDefinitions>
<RowDefinition Height="0.15*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
</Grid.RowDefinitions>
<Controls:SfDatePicker Value="{Binding Mode=TwoWay, Path=DueDate}" Width="200" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Name="dueDate" AccentBrush="#087196" />
</Grid>
<Grid Grid.Row="1" Grid.Column="4">
<Grid Grid.Row="3" Grid.Column="4">
<Controls:SfDatePicker Value="{Binding Mode=TwoWay, Path=Date}" Width="200" HorizontalAlignment="Left" VerticalAlignment="Bottom" Name="Date" AccentBrush="#087196" />
</Grid>
</Grid>
<Grid Grid.Row="2" Grid.Column="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.15*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
</Grid.RowDefinitions>
<TextBox Text="{Binding Mode=TwoWay, Path=InvoiceNumber}" HorizontalAlignment="Left" Width="200" VerticalAlignment="Center" Name="invoiceNo" Grid.Row="1" TextChanged="invoiceNo_TextChanged" Grid.ColumnSpan="2" Margin="0,13"></TextBox>
</Grid>
<Grid Grid.Row="4" Grid.Column="4">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="18" VerticalAlignment="Top" Name="updtButton" Content="Update" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Click="updtButton_Click"></Button>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="18" VerticalAlignment="Top" Name="cancelButton" Content="Cancel" Grid.Row="0" Grid.Column="2" Grid.RowSpan="2" Click="cancelButton_Click"></Button>
</Grid>
<Grid Grid.Row="4" Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="2"></Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,176 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 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;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace Invoice
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Address : Page,IDisposable
{
public event EventHandler CloseRequested;
public event EventHandler UpdateRequested;
BillingInformation info;
/// <summary>
///
/// </summary>
public Address():this(new BillingInformation())
{
}
/// <summary>
///
/// </summary>
/// <param name="billInfo"></param>
public Address(BillingInformation billInfo)
{
this.InitializeComponent();
var bounds = Window.Current.Bounds;
this.Height = bounds.Height;
info = billInfo;
this.DataContext = info;
}
///// <summary>
///// Invoked when this page is about to be displayed in a Frame.
///// </summary>
///// <param name="e">Event data that describes how this page was reached. The Parameter
///// property is typically used to configure the page.</param>
//protected override void OnNavigatedTo(NavigationEventArgs e)
//{
//}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cancelButton_Click(object sender, RoutedEventArgs e)
{
if (CloseRequested != null)
CloseRequested(this, EventArgs.Empty);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void updtButton_Click(object sender, RoutedEventArgs e)
{
BillingInfoEventArgs args = new BillingInfoEventArgs();
args.BillingInformation = info;
if (UpdateRequested != null)
UpdateRequested(this, args);
}
private void invoiceNo_TextChanged(object sender, TextChangedEventArgs e)
{
int value = 0;
if (int.TryParse(invoiceNo.Text, out value))
{
invoiceNo.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 64, 81));
}
else
{
invoiceNo.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 37, 37));
}
}
#region Implementation
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
public void Dispose()
{
UnlinkChildrens(this);
this.Resources.Clear();
Loaded -= cancelButton_Click;
Loaded -= updtButton_Click;
info = null;
}
/// <summary>
/// Unlinks the child elements from page.
/// </summary>
/// <param name="element"></param>
void UnlinkChildrens(UIElement element)
{
if (element == null)
return;
if (element is Panel)
{
for (int i = 0; i < (element as Panel).Children.Count; i++)
{
UIElement childElement = (element as Panel).Children[i];
UnlinkChildrens(childElement);
(element as Panel).Children.Remove(childElement);
i--;
}
}
else if (element is ItemsControl)
{
for (int j = 0; j < (element as ItemsControl).Items.Count; j++)
{
UIElement childElement = ((element as ItemsControl).Items[j] as UIElement);
if (childElement == null)
{
//(element as ItemsControl).Items.RemoveAt(j);
//j--;
}
else
{
UnlinkChildrens(childElement);
(element as ItemsControl).Items.Remove(childElement);
j--;
}
}
}
else if (element is ContentControl)
{
UnlinkChildrens((element as ContentControl).Content as UIElement);
(element as ContentControl).Content = null;
}
else if (element is UserControl)
{
UnlinkChildrens((element as UserControl).Content as UIElement);
(element as UserControl).Content = null;
}
}
#endregion
}
/// <summary>
///
/// </summary>
public class BillingInfoEventArgs : EventArgs,IDisposable
{
BillingInformation m_billInfo;
public BillingInformation BillingInformation
{
get { return m_billInfo; }
set { m_billInfo = value; }
}
public void Dispose()
{
m_billInfo = null;
}
}
}

Просмотреть файл

@ -0,0 +1,20 @@
<Application
x:Class="Invoice.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--
Styles that define common aspects of the platform look and feel
Required by Visual Studio project and item templates
-->
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,105 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 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;
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
namespace Invoice
{
/// <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 when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
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();
if (args.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
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
if (args.Arguments != "")
{
MainPage mainPage = rootFrame.Content as MainPage;
// Frame f=Window.Current.Content as Page;
mainPage.LaunchedFromToast(args.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
/// <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();
}
}
}

Двоичные данные
DocIO/DocIO/Invoice/Assets/About.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/Add.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/Delete.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/Edit.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.0 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/Edit.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 391 B

Двоичные данные
DocIO/DocIO/Invoice/Assets/Excel.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.8 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/Export.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/InvoiceTemplate.xlsx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Invoice/Assets/Logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 801 B

Двоичные данные
DocIO/DocIO/Invoice/Assets/PDF.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Просмотреть файл

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<Products>
<Product>
<Name>ASP.NET MVC </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>ASP.NET Core </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>ASP.NET Web Forms </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>JavaScript </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>Xamarin </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>UWP </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>WinForms </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>WPF </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>File Formats </Name>
<Rate>995</Rate>
</Product>
<Product>
<Name>Dashboard Platform </Name>
<Rate>1995</Rate>
</Product>
<Product>
<Name>Data Integration Platform</Name>
<Rate>1995</Rate>
</Product>
<Product>
<Name>Big Data Platform </Name>
<Rate>1995</Rate>
</Product>
<Product>
<Name>Report Platform </Name>
<Rate>1995</Rate>
</Product>
</Products>

Двоичные данные
DocIO/DocIO/Invoice/Assets/SmallLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 329 B

Двоичные данные
DocIO/DocIO/Invoice/Assets/SplashScreen.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/StoreLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 429 B

Двоичные данные
DocIO/DocIO/Invoice/Assets/Syncfusion.PNG Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 24 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/SyncfusionLogo.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 80 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/Template.docx Normal file

Двоичный файл не отображается.

Двоичные данные
DocIO/DocIO/Invoice/Assets/Word.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Двоичные данные
DocIO/DocIO/Invoice/Assets/invoice.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 27 KiB

Просмотреть файл

@ -0,0 +1,75 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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;
namespace Invoice
{
public class BillingInformation
{
#region Fields
private string m_Name;
private string m_Address;
private DateTime m_DueDate;
private string m_InvoiveNumber;
private DateTime m_date;
#endregion
#region Properties
/// <summary>
/// Gets or Sets the Name
/// </summary>
public string Name
{
get { return m_Name; }
set { m_Name = value; }
}
/// <summary>
/// Gets or Sets the Address
/// </summary>
public string Address
{
get { return m_Address; }
set { m_Address = value; }
}
/// <summary>
/// Gets or Sets the Date
/// </summary>
public DateTime Date
{
get { return m_date; }
set { m_date = value; }
}
/// <summary>
/// Gets or Sets the Invoice
/// </summary>
public string InvoiceNumber
{
get { return m_InvoiveNumber; }
set { m_InvoiveNumber = value; }
}
/// <summary>
/// Gets or Sets the Due Date
/// </summary>
public DateTime DueDate
{
get { return m_DueDate; }
set { m_DueDate = value; }
}
#endregion
#region Constructor
/// <summary>
///
/// </summary>
public BillingInformation()
{
}
#endregion
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,65 @@
<Page
xmlns:Controls="using:Syncfusion.UI.Xaml.Controls.Input"
x:Class="Invoice.Address"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///DocIO/Invoice/Common/IOStandardStyles.Xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="outerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1.2*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="0"></Grid>
<Grid x:Name="RootPanel" Grid.Row="1" Background="#FF004051">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="1.5*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource BasicTextStyle}" x:Name="Title" HorizontalAlignment="Left" VerticalAlignment="Center" Text="BILL TO" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" FontSize="32" FontWeight="Bold" Padding="10,0,0,0"></TextBlock>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Name" Grid.Column="0" Grid.Row="1" FontSize="13.333" ></TextBlock>
<TextBox Text="{Binding Mode=TwoWay, Path=Name}" HorizontalAlignment="Left" Width="Auto" VerticalAlignment="Center" Name="nameField" FontFamily="Segoe UI" FontSize="13.333" Grid.Row="1" Grid.Column="1"></TextBox>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Address" Grid.Column="0" Grid.Row="2" FontSize="13.333" ></TextBlock>
<TextBox FontFamily="Segoe UI" FontSize="13.333" Text="{Binding Mode=TwoWay, Path=Address}" TextWrapping="Wrap" HorizontalAlignment="Left" Width="200" VerticalAlignment="Stretch" Name="address" Grid.Row="2" Grid.Column="1" />
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Date" Grid.Column="0" Grid.Row="3" FontSize="13.333" ></TextBlock>
<Controls:SfDatePicker Value="{Binding Mode=TwoWay, Path=Date}" Width="200" HorizontalAlignment="Left" VerticalAlignment="Center" Name="Date" AccentBrush="#087196" Grid.Column="1" Grid.Row="3" FontSize="13.333"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" Text="Invoice No" FontSize="13.333" Grid.Row="4" ></TextBlock>
<TextBox Text="{Binding Mode=TwoWay, Path=InvoiceNumber}" HorizontalAlignment="Left" Width="200" VerticalAlignment="Center" Name="invoiceNo" Grid.Row="4" Grid.Column="1" TextChanged="invoiceNo_TextChanged" FontSize="13.333"></TextBox>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="DueDate" Grid.Column="0" Grid.Row="5" FontSize="13.333" ></TextBlock>
<Controls:SfDatePicker Value="{Binding Mode=TwoWay, Path=DueDate}" Width="200" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" VerticalAlignment="Center" Name="dueDate" AccentBrush="#087196" FontSize="13.333" />
<Grid Grid.Row="6" Grid.ColumnSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="16" VerticalAlignment="Center" Name="updtButton" Content="Update" Grid.Column="0" Click="updtButton_Click" Grid.ColumnSpan="2" Margin="9,0,10.333,0" Height="36"></Button>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="16" VerticalAlignment="Center" Name="cancelButton" Content="Cancel" Grid.Column="2" Click="cancelButton_Click"></Button>
</Grid>
</Grid>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="2"></Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,67 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="using:Syncfusion.UI.Xaml.Controls.Input"
x:Class="Invoice.Dialog"
IsTabStop="false"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///DocIO/Invoice/Common/IOStandardStyles.Xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="outerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1.2*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="0"/>
<Grid x:Name="RootPanel" Grid.Row="1" Background="#FF004051">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource BasicTextStyle}" x:Name="Title" HorizontalAlignment="Left" VerticalAlignment="Center" Text="Edit the fields" Grid.Row="0" Grid.ColumnSpan="2" FontSize="32" FontWeight="Bold" Padding="10,0,0,0"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Item" Grid.Column="0" Grid.Row="1" FontSize="13.333" Padding="0,0,15,5"/>
<ComboBox TabIndex="0" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="13.333" HorizontalAlignment="Stretch" x:Name="item" Grid.Row="1" Grid.Column="1" SelectionChanged="item_SelectionChanged" TabNavigation="Local" />
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Text="Quantity" Grid.Column="0" Grid.Row="2" FontSize="13.333" Padding="0,0,15,5"/>
<Controls:SfNumericUpDown FormatString="##" AccentBrush="#087196" FontFamily="Segoe UI" FontSize="13.333" Value="{Binding Quantity, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Center" x:Name="quantity" Grid.Row="2" Grid.Column="1" Minimum="1" ValueChanged="quantity_ValueChanged" TabIndex="1" />
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Price" Grid.Column="0" Grid.Row="3" FontSize="13.333" Padding="0,0,15,5"/>
<Controls:SfNumericTextBox IsReadOnly="True" FormatString="$##.##" FontFamily="Segoe UI" FontSize="13.333" Text="{Binding Rate, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Center" x:Name="rate" Grid.Row="3" Grid.Column="1" />
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Taxes" Grid.Column="0" Grid.Row="4" FontSize="13.333" Padding="0,0,15,3"/>
<TextBlock HorizontalAlignment="Stretch" Text="{Binding Taxes, Mode=TwoWay}" FontFamily="Segoe UI" FontWeight="Light" FontSize="21.333" VerticalAlignment="Center" x:Name="taxesTextBlock" Grid.Row="4" Grid.Column="1" Foreground="#FF549BAE"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Center" TextAlignment="Right" VerticalAlignment="Center" Text="Total Amount" Grid.Column="0" Grid.Row="5" FontSize="13.333" Padding="0,10,15,5"/>
<TextBlock HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontWeight="Light" FontSize="21.333" VerticalAlignment="Center" x:Name="totalAmount" Foreground="#FF549BAE" Grid.Column="1" Grid.Row="5"/>
<Grid Grid.Row="6" Grid.ColumnSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="16" VerticalAlignment="Center" x:Name="updtButton" Content="Update" Grid.Row="0" Grid.Column="0" Click="updtButton_Click" TabIndex="4" Grid.ColumnSpan="2" Margin="9,0,10,0"/>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="16" VerticalAlignment="Center" x:Name="cancelButton" Content="Cancel" Grid.Row="0" Grid.Column="2" Click="cancelButton_Click" TabIndex="5"/>
</Grid>
</Grid>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="2"/>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,222 @@
<Page
x:Class="Invoice.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Foreground="White">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///DocIO/Invoice/Common/IOStandardStyles.Xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Page.BottomAppBar>
<AppBar Background="#087196" BorderBrush="#087196" x:Name="BottomAppBar1" AutomationProperties.Name="Bottom App Bar">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<AppBarButton Grid.Column="1" x:Name="PDFExport" Style="{StaticResource PDFExportAppBarButtonStyle}" Click="PDFExport_Click" Tag="Export To PDF"/>
<AppBarButton Grid.Column="3" x:Name="WordExport" Style="{StaticResource WordExportAppBarButtonStyle}" Click="WordExport_Click" Tag="Export To Word"/>
<AppBarButton Grid.Column="5" x:Name="ExcelExport" Style="{StaticResource ExcelExportAppBarButtonStyle}" Click="ExcelExport_Click" Tag="Export To Excel"/>
</Grid>
</AppBar>
</Page.BottomAppBar>
<Grid x:Name="root">
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="0.25*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
<Grid x:Name = "Header" Background="#087196">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.02*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource HeaderTextStyle}" x:Name="pageTitle" VerticalAlignment="Center" Text="Invoice" FontSize="56" FontFamily="Segoe UI" FontWeight="Light"/>
<Button Style="{StaticResource ExportButtonStyle}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Export"/>
</Grid>
</Grid>
<Grid x:Name="ContentGrid" Grid.Row="1" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.05*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="0.05*"/>
</Grid.ColumnDefinitions>
<Grid x:Name = "Layer1" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="0.05*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name = "Level1" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" x:Name = "BILLTO" Text = "BILL TO" FontSize="13.333" Foreground="#404435" Padding="0,2,0,0" FontWeight="Bold"/>
<Button Style="{ StaticResource EditButtonStyle}" VerticalAlignment="Top" Padding="0" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="1" Click="EditBillingDetails">
<Image Source="Assets/Edit.jpg"/>
</Button>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name = "NameTextBlock" FontSize="13.333" Foreground="#808285" Padding="0,1,0,0"/>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name = "BillingAddress" TextWrapping="Wrap" FontSize="13.333" Foreground="#808285" Padding="0,1,0,0"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text = "DATE: " FontWeight="Bold" FontSize="13.333" Foreground="#404435" Padding="0,1,0,0"/>
<TextBlock Grid.Row="3" Grid.Column="1" x:Name = "DATE" FontSize="13.333" Foreground="#808285" Padding="0,1,0,0"/>
<TextBlock Grid.Row="4" Grid.Column="0" Text = "INVOICE NO: " FontWeight="Bold" FontSize="13.333" Foreground="#404435" Padding="0,1,0,0"/>
<TextBlock Grid.Row="4" Grid.Column="1" x:Name = "InvoiceNumber" FontSize="13.333" Foreground="#808285" Padding="0,1,0,0"/>
<TextBlock Grid.Row="5" Grid.Column="0" Text = "DUE DATE: " FontWeight="Bold" FontSize="13.333" Foreground="#404435" Padding="0,1,0,0"/>
<TextBlock Grid.Row="5" Grid.Column="1" x:Name = "DueDate" FontSize="13.333" Foreground="#808285" Padding="0,1,0,0"/>
</Grid>
<Grid Grid.Row="1" Name="InvoiceGridHeader">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.7*"/>
</Grid.ColumnDefinitions>
<StackPanel Background="#B3D1E8" Grid.Column="0">
<Grid Height="25">
<TextBlock Padding="10,0,0,0" x:Name="Item" Text="Item" HorizontalAlignment="Stretch" TextAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="13.333"/>
</Grid>
</StackPanel>
<StackPanel Background="#B3D1E8" Grid.Column="1">
<Grid Height="25">
<TextBlock x:Name="Quantity" Text="Quantity" Padding="0,0,10,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Bold" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="13.333" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
<StackPanel Background="#B3D1E8" Grid.Column="2">
<Grid Height="25">
<TextBlock x:Name="Rate" Text="Rate" Padding="0,0,10,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Bold" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="13.333" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
<StackPanel Background="#B3D1E8" Grid.Column="3">
<Grid Height="25">
<TextBlock x:Name="Taxes" Text="Taxes" Padding="0,0,10,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Bold" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="13.333" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
<StackPanel VerticalAlignment="Stretch" Background="#B3D1E8" Grid.Column="4">
<Grid Height="25">
<TextBlock x:Name="Amount" Text="Amount" Padding="0,0,10,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Bold" VerticalAlignment="Center" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="13.333"/>
</Grid>
</StackPanel>
</Grid>
<ScrollViewer x:Name="GridScrollViewer" Grid.Row="2" Height="{Binding InvoiceGrid.ActualHeight}" VerticalScrollBarVisibility="Auto" BorderBrush="AliceBlue" FontSize="9.333">
<Grid Name="InvoiceGrid" Tapped="InvoiceGrid_Tapped" DoubleTapped="InvoiceGrid_DoubleTapped">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.7*"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="1" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="2" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="3" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="4" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="5" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
</Grid>
</ScrollViewer>
<Grid x:Name="Events" Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.1*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.4*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Style="{StaticResource EditButtonStyle}" HorizontalAlignment="Center" VerticalAlignment="Top" x:Name="AddButton" Click="Add" >
<Image Source="ms-appx:///DocIO/Invoice/Assets/Add.png" Width="50" Height="50" VerticalAlignment="Top"/>
</Button>
<Button Grid.Column="2" IsEnabled="False" Style="{StaticResource EditButtonStyle}" HorizontalAlignment="Center" VerticalAlignment="Top" x:Name="DeleteButton" Click="Delete" >
<Image Source="ms-appx:///DocIO/Invoice/Assets/Delete.png" Height="50" Width="50" VerticalAlignment="Top"/>
</Button>
</Grid>
<Grid Grid.Column="3" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" TextWrapping="Wrap" Text="Total Due:" Foreground="#404435" FontSize="13.333" FontWeight="Bold"/>
<TextBlock Grid.Row="1" Grid.Column="1" x:Name="TotalAmount" TextWrapping="Wrap" HorizontalAlignment="Stretch" TextAlignment="Center" Foreground="#404435" FontSize="18.667" VerticalAlignment="Top"/>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center"
Background="#087196" x:Name="progress" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ProgressRing Width="30" Height="30" Foreground="White" IsActive="True" Margin="15"
VerticalAlignment="Center"/>
<TextBlock Text="Generating invoice" Foreground="White" Margin="10"
VerticalAlignment="Center" FontSize="13.333" Grid.Column="1"/>
</Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,82 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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.XlsIO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Notifications;
using Windows.UI.Popups;
namespace Invoice
{
public class ExportToExcel
{
public async void GenerateReport(IList<InvoiceItem> items, BillingInformation billInfo)
{
Assembly executingAssembly = typeof(MainPage).GetTypeInfo().Assembly;
Stream inputStream = executingAssembly.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Invoice.Assets.InvoiceTemplate.xlsx");
ExcelEngine excelEngine = new ExcelEngine();
IWorkbook book = await excelEngine.Excel.Workbooks.OpenAsync(inputStream);
inputStream.Dispose();
//Create Template Marker Processor
ITemplateMarkersProcessor marker = book.CreateTemplateMarkersProcessor();
//Binding the business object with the marker.
marker.AddVariable("InvoiceItem", items);
marker.AddVariable("BillInfo", billInfo);
marker.AddVariable("Company", billInfo);
//Applies the marker.
marker.ApplyMarkers(UnknownVariableAction.Skip);
StorageFile storageFile = null;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
savePicker.SuggestedFileName = "Invoice";
savePicker.FileTypeChoices.Add("Invoice", new List<string>() { ".xlsx", });
storageFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
storageFile = await local.CreateFileAsync("SpreadsheetSample.xlsx", CreationCollisionOption.ReplaceExisting);
}
if (storageFile != null)
{
IWorksheet sheet = book.Worksheets[0];
sheet["G1"].ColumnWidth = 10;
//XlsIO saves the file Asynchronously
await book.SaveAsAsync(storageFile);
book.Close();
excelEngine.Dispose();
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the saved file
bool success = await Windows.System.Launcher.LaunchFileAsync(storageFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,121 @@
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="using:Syncfusion.UI.Xaml.Controls.Input"
x:Class="Invoice.Dialog"
IsTabStop="false"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///DocIO/Invoice/Common/IOStandardStyles.Xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="outerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="0"/>
<Grid x:Name="RootPanel" Grid.Row="1" Background="#FF004051">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="*"/>
<RowDefinition Height="0.15*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource BasicTextStyle}" x:Name="Title" HorizontalAlignment="Center" VerticalAlignment="Bottom" Text="Edit the fields" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" FontSize="32" FontWeight="Light"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="Item" Grid.Column="1" Grid.Row="1" FontSize="18" Padding="0,0,15,5"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Bottom" Text="Quantity" Grid.Column="1" Grid.Row="2" FontSize="18" Padding="0,0,15,5"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="Price" Grid.Column="1" Grid.Row="3" FontSize="18" Padding="0,0,15,5"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="Taxes" Grid.Column="3" Grid.Row="1" FontSize="18" Padding="0,0,15,3"/>
<TextBlock Style="{StaticResource BasicTextStyle}" HorizontalAlignment="Stretch" TextAlignment="Right" VerticalAlignment="Center" Text="Total Amount" Grid.Column="3" Grid.Row="2" Grid.RowSpan="2" FontSize="18" Padding="0,10,15,5"/>
<Grid Grid.Row="1" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ComboBox TabIndex="0" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="18" HorizontalAlignment="Stretch" x:Name="item" Grid.Row="1" Grid.RowSpan="2" SelectionChanged="item_SelectionChanged" TabNavigation="Local" Height="40" Margin="0,3.5,0,-0.5" />
</Grid>
<Grid Grid.Row="2" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Controls:SfNumericUpDown FormatString="##" AccentBrush="#087196" FontFamily="Segoe UI" FontSize="18" Value="{Binding Quantity, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" x:Name="quantity" Grid.Row="1" Grid.RowSpan="2" Minimum="1" ValueChanged="quantity_ValueChanged" TabIndex="1" /><!--Background="#FF004051"-->
</Grid>
<Grid Grid.Row="3" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Controls:SfNumericTextBox IsReadOnly="True" FormatString="$##.##" FontFamily="Segoe UI" FontSize="18" Text="{Binding Rate, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" x:Name="rate" Grid.Row="1" Grid.RowSpan="2" />
</Grid>
<Grid Grid.Row="1" Grid.Column="4">
<Grid.RowDefinitions>
<RowDefinition Height="17*"/>
<RowDefinition Height="17"/>
<RowDefinition Height="16*"/>
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Stretch" Text="{Binding Taxes, Mode=TwoWay}" FontFamily="Segoe UI" FontWeight="Light" FontSize="26" VerticalAlignment="Center" x:Name="taxesTextBlock" Grid.Row="1" Grid.RowSpan="2" Foreground="#FF549BAE"/>
</Grid>
<Grid Grid.Row="2" Grid.RowSpan="2" Grid.Column="4">
<TextBlock HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontWeight="Light" FontSize="32" VerticalAlignment="Center" x:Name="totalAmount" Foreground="#FF549BAE"/>
</Grid>
<Grid Grid.Row="4" Grid.Column="4">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="18" VerticalAlignment="Stretch" x:Name="updtButton" Content="Update" Grid.Row="0" Grid.Column="0" Click="updtButton_Click" TabIndex="4" Grid.ColumnSpan="2" Margin="9,0,10,0"/>
<Button Foreground="White" HorizontalAlignment="Stretch" FontFamily="Segoe UI" FontSize="18" VerticalAlignment="Top" x:Name="cancelButton" Content="Cancel" Grid.Row="0" Grid.Column="2" Grid.RowSpan="2" Click="cancelButton_Click" TabIndex="5"/>
</Grid>
<Grid Grid.Row="4" Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
<Grid Background="#FF004051" Opacity="0.7" Grid.Row="2"/>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,356 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace Invoice
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Dialog : Page,IDisposable
{
#region Fields
public event EventHandler CloseRequested;
public event EventHandler UpdateRequested;
InvoiceItem m_invoiceItem;
ProductList m_productlist;
const double DefaultTaxInPercent = 7;
bool onInit;
#endregion
#region Constructor
/// <summary>
///
/// </summary>
public Dialog()
: this(null, "Add Item", new ProductList())
{
}
/// <summary>
///
/// </summary>
public Dialog(ProductList productList)
: this(null, "Add Item", productList)
{
}
/// <summary>
///
/// </summary>
/// <param name="newItem"></param>
/// <param name="title"></param>
/// <param name="productList"></param>
public Dialog(InvoiceItem newItem, string title, ProductList productList)
: this(newItem, title, productList, 0)
{
}
/// <summary>
///
/// </summary>
/// <param name="newItem"></param>
/// <param name="title"></param>
public Dialog(InvoiceItem newItem, string title, ProductList productList, int productIndex)
{
this.InitializeComponent();
var bounds = Window.Current.Bounds;
this.Height = bounds.Height;
if (newItem == null)
{
newItem = new InvoiceItem();
newItem.ItemName = productList[0].Name;
newItem.Rate = productList[0].Rate;
}
m_invoiceItem = newItem;
onInit = true;
this.DataContext = m_invoiceItem;
this.Title.Text = title;
double currentRate = m_invoiceItem.Rate;
m_productlist = productList;
this.item.ItemsSource = m_productlist;
this.item.DisplayMemberPath = "Name";
this.item.SelectedItem = m_productlist[productIndex];
if (currentRate != 0)
this.rate.Value = currentRate;
if (!newItem.Taxes.Equals("0"))
{
this.taxesTextBlock.Text = newItem.Taxes.ToString();
}
if (newItem.Rate!=0)
{
this.rate.Value = newItem.Rate;
UpdateTotalAmount();
}
if (newItem.Quantity==0)
{
newItem.Quantity = 1;
this.quantity.Value = 1;
CalculateTax();
UpdateTotalAmount();
}
onInit = false;
}
#endregion
#region Implementation
#region Events
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cancelButton_Click(object sender, RoutedEventArgs e)
{
if (CloseRequested != null)
CloseRequested(this, EventArgs.Empty);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void updtButton_Click(object sender, RoutedEventArgs e)
{
FieldsUpdateEventArgs args = new FieldsUpdateEventArgs();
args.UpdatedFields = m_invoiceItem;
if (UpdateRequested != null)
{
UpdateRequested(this, args);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void item_GotFocus(object sender, RoutedEventArgs e)
{
TextBox textBox = (TextBox)e.OriginalSource;
textBox.SelectAll();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void quantity_TextChanged(object sender, TextChangedEventArgs e)
{
if (onInit)
return;
int value = 0;
if (int.TryParse((string)quantity.Value, out value))
{
CalculateTax();
UpdateTotalAmount();
quantity.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 64, 81));
}
else
{
quantity.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 37, 37));
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void rate_TextChanged(object sender, TextChangedEventArgs e)
{
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void item_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (onInit)
return;
Product product = item.SelectedItem as Product;
m_invoiceItem.ItemName = product.Name;
if (!m_invoiceItem.Rate.Equals(product.Rate.ToString()))
{
m_invoiceItem.Rate = product.Rate;
rate.Value = m_invoiceItem.Rate;
CalculateTax();
UpdateTotalAmount();
}
}
#endregion
#region Helper Method
/// <summary>
///
/// </summary>
public void InitializeFocus()
{
this.item.Focus(Windows.UI.Xaml.FocusState.Programmatic);
}
/// <summary>
///
/// </summary>
public Product SelectedProduct
{
set
{
if (value != null)
{
item.SelectedItem = value;
}
}
}
/// <summary>
///
/// </summary>
private void UpdateTotalAmount()
{
int quantityValue = GetQuantityAsInt();
double rateValue = (double)rate.Value;
double calculatedTax = m_invoiceItem.Taxes;
double taxedAmount = (quantityValue * rateValue) + calculatedTax;
this.totalAmount.Text = "$" + taxedAmount.ToString();
}
public int GetQuantityAsInt()
{
int result;
if (int.TryParse(quantity.Value.ToString(), out result))
return result;
return 1;
}
/// <summary>
///
/// </summary>
private void CalculateTax()
{
double currentRate = (double)rate.Value;
int currentQuantity = GetQuantityAsInt();
{
double calculatedTax = 0.0;
calculatedTax = (currentRate * currentQuantity) * (DefaultTaxInPercent / 100);
m_invoiceItem.Taxes = calculatedTax;
taxesTextBlock.Text = "$" + calculatedTax.ToString();
}
}
#endregion
private void quantity_ValueChanged(object sender,Syncfusion.UI.Xaml.Controls.Input.ValueChangedEventArgs e)
{
if (onInit)
return;
if (rate != null)
{
double value = (double) rate.Value;
{
rate.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 64, 81));
CalculateTax();
UpdateTotalAmount();
}
}
}
#region Implementation
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
public void Dispose()
{
UnlinkChildrens(this);
this.Resources.Clear();
Loaded -= cancelButton_Click;
Loaded -= updtButton_Click;
m_invoiceItem = null;
m_productlist = null;
}
/// <summary>
/// Unlink the child elements from the page.
/// </summary>
/// <param name="element"></param>
void UnlinkChildrens(UIElement element)
{
if (element == null)
return;
if (element is Panel)
{
for (int i = 0; i < (element as Panel).Children.Count; i++)
{
UIElement childElement = (element as Panel).Children[i];
UnlinkChildrens(childElement);
(element as Panel).Children.Remove(childElement);
i--;
}
}
else if (element is ItemsControl)
{
for (int j = 0; j < (element as ItemsControl).Items.Count; j++)
{
UIElement childElement = ((element as ItemsControl).Items[j] as UIElement);
if (childElement == null)
{
//(element as ItemsControl).Items.RemoveAt(j);
//j--;
}
else
{
UnlinkChildrens(childElement);
(element as ItemsControl).Items.Remove(childElement);
j--;
}
}
}
else if (element is ContentControl)
{
UnlinkChildrens((element as ContentControl).Content as UIElement);
(element as ContentControl).Content = null;
}
else if (element is UserControl)
{
UnlinkChildrens((element as UserControl).Content as UIElement);
(element as UserControl).Content = null;
}
}
#endregion
#endregion
}
/// <summary>
///
/// </summary>
public class FieldsUpdateEventArgs : EventArgs,IDisposable
{
private InvoiceItem m_invoiceItem;
public InvoiceItem UpdatedFields
{
get
{
return m_invoiceItem;
}
set
{
m_invoiceItem = value;
}
}
public void Dispose()
{
m_invoiceItem = null;
}
}
}

Просмотреть файл

@ -0,0 +1,102 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Invoice
{
public class InvoiceItem
{
private string _item;
private int _quantity;
private double _rate;
private double _taxes;
private double _totalAmount;
#region Properties
//public string ItemID
//{
// get
// {
// return _itemID.ToString();
// }
// set
// {
// _itemID = Convert.ToInt32(value);
// }
//}
public string ItemName
{
get
{
return _item;
}
set
{
_item=value;
}
}
public int Quantity
{
get
{
return _quantity;
}
set
{
_quantity = value;
UpdateTotalAmount();
}
}
public double Rate
{
get
{
return _rate;
}
set
{
_rate = value;
UpdateTotalAmount();
}
}
public double Taxes
{
get
{
return _taxes;
}
set
{
_taxes = value;
UpdateTotalAmount();
}
}
public double TotalAmount
{
get
{
return _totalAmount;
}
set
{
_totalAmount = value;
}
}
#endregion
void UpdateTotalAmount()
{
TotalAmount = (_quantity * _rate + _taxes);
}
}
}

Просмотреть файл

@ -0,0 +1,309 @@
<Page
x:Class="Invoice.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Invoice"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Foreground="White">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///DocIO/Invoice/Common/IOStandardStyles.Xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Page.BottomAppBar>
<AppBar Background="#087196" BorderBrush="#087196" x:Name="BottomAppBar1" Padding="10,5,10,5" AutomationProperties.Name="Bottom App Bar">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" x:Name="PDFExport" Style="{StaticResource PDFExportAppBarButtonStyle}" Click="PDFExport_Click" Tag="Export To PDF"/>
<Button Grid.Column="2" x:Name="WordExport" Style="{StaticResource WordExportAppBarButtonStyle}" Click="WordExport_Click" Tag="Export To Word"/>
<Button Grid.Column="3" x:Name="ExcelExport" Style="{StaticResource ExcelExportAppBarButtonStyle}" Click="ExcelExport_Click" Tag="Export To Excel"/>
</Grid>
</Grid>
</AppBar>
</Page.BottomAppBar>
<Grid x:Name="root">
<Grid x:Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="0.25*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
<Grid x:Name = "Header" Background="#087196">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.075*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="0.2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource HeaderTextStyle}" x:Name="pageTitle" VerticalAlignment="Center" Text="Invoice" FontSize="56" FontFamily="Segoe UI" FontWeight="Light"/>
<Button Style="{StaticResource ExportButtonStyle}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Export"/>
</Grid>
</Grid>
<Grid x:Name="ContentGrid" Grid.Row="1" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="0.2*"/>
</Grid.ColumnDefinitions>
<Grid x:Name = "Layer1" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="0.05*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name = "Level1" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.4*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image Grid.Row="1" x:Name="CompanyLogo" HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Column="0" Source="Assets/Syncfusion.PNG" />
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name = "Address" FontSize="15" Foreground="#404435" FontWeight="Light">
2501 Aerial Center Parkway,<LineBreak/>Suite 200 Morrisville,<LineBreak/>NC 27560 USA,<LineBreak/>Tel +1 888.936.8638 <LineBreak/>Fax +1 919.573.0306
</TextBlock>
</Grid>
<Grid Grid.Column="2" Grid.ColumnSpan="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Rectangle Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Grid.RowSpan="2" StrokeThickness="1" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Grid.RowSpan="3" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Style="{ StaticResource EditButtonStyle}" VerticalAlignment="Top" Padding="0" HorizontalAlignment="Right" Grid.Column="2" Click="EditBillingDetails">
<Image Source="Assets/Edit.jpg"/>
</Button>
<Grid Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"></ColumnDefinition>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" >
<TextBlock x:Name = "BILLTO" Text = "BILL TO" FontSize="18" Foreground="#404435" FontWeight="Light" Padding="0,20,0,0"/>
<TextBlock x:Name = "NameTextBlock" FontSize="18" Foreground="#808285" Padding="0,5,0,0"/>
<TextBlock x:Name = "BillingAddress" TextWrapping="Wrap" FontSize="18" Foreground="#808285"/>
</StackPanel>
</Grid>
<Grid Grid.Column="2" Grid.RowSpan="2" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"></ColumnDefinition>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text = "DATE: " FontWeight="Light" FontSize="18" Foreground="#404435" Padding="0,20,0,0"/>
<TextBlock Grid.Column="1" x:Name = "DATE" FontSize="18" Foreground="#808285" Padding="5,20,0,0"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text = "INVOICE NO: " FontWeight="Light" FontSize="18" Foreground="#404435" Padding="0,10,0,0"/>
<TextBlock Grid.Column="1" x:Name = "InvoiceNumber" FontSize="18" Foreground="#808285" Padding="5,10,0,0"/>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text = "DUE DATE: " FontWeight="Light" FontSize="18" Foreground="#404435" Padding="0,0,0,0"/>
<TextBlock Grid.Column="1" x:Name = "DueDate" FontSize="18" Foreground="#808285" Padding="5,0,0,0"/>
</Grid>
</Grid>
</Grid>
</Grid>
</Border>
</Grid>
</Grid>
<Grid Grid.Row="1" Name="InvoiceGridHeader">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<StackPanel Background="#B3D1E8" Grid.Column="0">
<Grid Height="40">
<TextBlock Padding="10,0,0,0" x:Name="Item" Text="Item" HorizontalAlignment="Stretch" TextAlignment="Left" VerticalAlignment="Center" FontWeight="Normal" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="18"/>
</Grid>
</StackPanel>
<StackPanel Background="#B3D1E8" Grid.Column="1">
<Grid Height="40">
<TextBlock x:Name="Quantity" Text="Quantity" Padding="0,0,20,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Normal" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="18" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
<StackPanel Background="#B3D1E8" Grid.Column="2">
<Grid Height="40">
<TextBlock x:Name="Rate" Text="Rate" Padding="0,0,15,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Normal" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="18" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
<StackPanel Background="#B3D1E8" Grid.Column="3">
<Grid Height="40">
<TextBlock x:Name="Taxes" Text="Taxes" Padding="0,0,15,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Normal" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="18" VerticalAlignment="Center"/>
</Grid>
</StackPanel>
<StackPanel VerticalAlignment="Stretch" Background="#B3D1E8" Grid.Column="4">
<Grid Height="40">
<TextBlock x:Name="Amount" Text="Amount" Padding="0,0,15,0" TextAlignment="Right" HorizontalAlignment="Stretch" FontWeight="Normal" VerticalAlignment="Center" FontFamily="Segoe UI" Foreground="#3F3F3F" FontSize="18"/>
</Grid>
</StackPanel>
</Grid>
<ScrollViewer x:Name="GridScrollViewer" Grid.Row="2" Height="{Binding InvoiceGrid.ActualHeight}" VerticalScrollBarVisibility="Auto" BorderBrush="AliceBlue">
<Grid Name="InvoiceGrid" Tapped="InvoiceGrid_Tapped" DoubleTapped="InvoiceGrid_DoubleTapped">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="1" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="2" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="3" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="4" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
<Rectangle Grid.Row="5" Height="1" StrokeThickness="0.75" VerticalAlignment="Bottom" Grid.ColumnSpan="5" StrokeDashArray="4,4" Stroke="#FFCECECE"></Rectangle>
</Grid>
</ScrollViewer>
<Grid x:Name="Events" Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Grid.ColumnSpan="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" FontWeight="Normal" Style="{StaticResource AddItemStyle}" Width="120" Height="40" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="AddButton" Content="Add Item" Click="Add" FontSize="16"/>
<Button Grid.Column="1" FontWeight="Normal" IsEnabled="False" Style="{StaticResource RemoveItemStyle}" Width="120" Height="40" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="DeleteButton" Content="Delete Item" Click="Delete" FontSize="16"/>
</Grid>
<Grid Grid.Column="3" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" Padding="0,0,10,20" VerticalAlignment="Center" HorizontalAlignment="Right" Text="Total Due:" Foreground="#404435" FontSize="18"/>
<TextBlock Grid.Row="1" Padding="0,0,0,20" Grid.Column="1" x:Name="TotalAmount" TextWrapping="Wrap" HorizontalAlignment="Stretch" TextAlignment="Center" Foreground="#404435" FontSize="42" VerticalAlignment="Center"/>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center"
Background="#087196" x:Name="progress" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ProgressRing Width="30" Height="30" Foreground="White" IsActive="True" Margin="15"
VerticalAlignment="Center"/>
<TextBlock Text="Generating invoice" Foreground="White" Margin="15"
VerticalAlignment="Center" FontSize="18" Grid.Column="1"/>
</Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,751 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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.Globalization;
using Windows.Phone.UI.Input;
using Windows.Storage;
using Windows.UI;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Shapes;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace Invoice
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page, IDisposable
{
#region Fields
const int m_columnCount = 5;
private double m_totalDue;
private IList<InvoiceItem> m_items;
int m_currentRowIndex = 0;
int m_selectedIndex = -1;
int m_prevSelectedIndex = -1;
const int m_rowHeight = 30;
Border m_border;
Popup m_fieldsPopup;
Popup m_addressPopup;
BillingInformation m_billInfo;
ProductList m_productList;
#endregion
#region Properties
/// <summary>
///
/// </summary>
public double TotalDue
{
get
{
return m_totalDue;
}
}
#endregion
#region Constructor
/// <summary>
///
/// </summary>
public MainPage()
{
this.InitializeComponent();
//Initialize
Initialize();
this.Unloaded += MainPage_Unloaded;
}
private void MainPage_Unloaded(object sender, RoutedEventArgs e)
{
this.Unloaded -= MainPage_Unloaded;
}
/// <summary>
/// Initialize
/// </summary>
private void Initialize()
{
m_productList = new ProductList();
m_items = new List<InvoiceItem>();
m_fieldsPopup = new Popup();
m_addressPopup = new Popup();
m_border = new Windows.UI.Xaml.Controls.Border();
m_billInfo = new BillingInformation();
//Load price list from XML document
m_productList.LoadFromXml();
//Set Billing information
this.NameTextBlock.Text = m_billInfo.Name = "Fran Wilson";
this.BillingAddress.Text = m_billInfo.Address = "89, Chiaroscuro Road, Portland, 97219.";
this.DATE.Text = (m_billInfo.Date = DateTime.Now.Date).ToString("d");
this.InvoiceNumber.Text = m_billInfo.InvoiceNumber = new Random().Next(100, 10000).ToString();
this.DueDate.Text = (m_billInfo.DueDate = DateTime.Now.Date).ToString("d");
InvoiceItem defaultItem = new InvoiceItem() { ItemName = m_productList[0].Name, Quantity = 1, Rate = m_productList[0].Rate };
defaultItem.Taxes = m_productList[0].Rate * 0.07;
//Add an item by default
AddItem(defaultItem, false);
}
#endregion
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
}
private void OnGoBack(object parameter)
{
Frame.GoBack();
}
#region Events
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Add(object sender, RoutedEventArgs e)
{
Dialog myDialog = new Dialog(m_productList);
myDialog.CloseRequested += myDialog_CloseRequested;
myDialog.UpdateRequested += myDialog_UpdateRequested;
m_fieldsPopup = new Popup();
m_fieldsPopup.Child = myDialog;
myDialog.Width = this.ActualWidth;
double verticalOff = this.ActualHeight - myDialog.Height;
m_fieldsPopup.VerticalOffset = verticalOff / 2;
m_fieldsPopup.Opened += fieldsPopup_Opened;
m_fieldsPopup.IsOpen = true;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void fieldsPopup_Opened(object sender, object e)
{
((sender as Popup).Child as Dialog).InitializeFocus();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void myDialog_UpdateRequested(object sender, EventArgs e)
{
InvoiceItem item = (e as FieldsUpdateEventArgs).UpdatedFields;
AddItem(item, false);
UpdateTotal();
m_fieldsPopup.IsOpen = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void myDialog_CloseRequested(object sender, EventArgs e)
{
m_fieldsPopup.IsOpen = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GoBack(object sender, RoutedEventArgs e)
{
Frame.GoBack();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Delete(object sender, RoutedEventArgs e)
{
if (m_selectedIndex == -1)
return;
RemoveItem(m_selectedIndex);
this.DeleteButton.IsEnabled = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void EditBillingDetails(object sender, RoutedEventArgs e)
{
#region Popup
Address addressDialog = new Address(m_billInfo);
addressDialog.CloseRequested += addressDialog_CloseRequested;
addressDialog.UpdateRequested += addressDialog_UpdateRequested;
m_addressPopup = new Popup();
m_addressPopup.Child = addressDialog;
addressDialog.Width = this.ActualWidth;
double verticalOff = this.ActualHeight - addressDialog.Height;
m_addressPopup.VerticalOffset = verticalOff / 2;
m_addressPopup.IsOpen = true;
#endregion
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void addressDialog_UpdateRequested(object sender, EventArgs e)
{
this.NameTextBlock.Text = m_billInfo.Name;
this.BillingAddress.Text = m_billInfo.Address;
this.DATE.Text = m_billInfo.Date.ToString("d");
this.InvoiceNumber.Text = m_billInfo.InvoiceNumber;
this.DueDate.Text = m_billInfo.DueDate.ToString("d");
m_addressPopup.IsOpen = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void addressDialog_CloseRequested(object sender, EventArgs e)
{
m_addressPopup.IsOpen = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InvoiceGrid_Tapped(object sender, TappedRoutedEventArgs e)
{
FrameworkElement element = null;
this.DeleteButton.IsEnabled = true;
if ((element = e.OriginalSource as FrameworkElement) != null)
{
m_selectedIndex = Grid.GetRow(element);
}
if (m_border != null && m_selectedIndex == m_prevSelectedIndex)
{
InvoiceGrid.Children.Remove(m_border);
m_prevSelectedIndex = -1;
// m_Border = new Border();
return;
}
m_border.Height = m_rowHeight;
m_border.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 243, 122, 1));
m_border.BorderThickness = new Thickness(1);
Grid.SetColumnSpan(m_border, m_columnCount);
Grid.SetRow(m_border, m_selectedIndex);
if (m_border.Parent == null)
InvoiceGrid.Children.Add(m_border);
m_prevSelectedIndex = m_selectedIndex;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InvoiceGrid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
FrameworkElement element = null;
if ((element = e.OriginalSource as FrameworkElement) != null)
{
m_selectedIndex = Grid.GetRow(element);
}
InvoiceItem invoiceItem = m_items[m_selectedIndex];
int selectedProductIndex = m_productList.IndexOf(m_productList[invoiceItem.ItemName]);
Dialog EditDialog = new Dialog(invoiceItem, "Edit the Fields", m_productList, selectedProductIndex);
EditDialog.UpdateRequested += EditDialog_UpdateRequested;
EditDialog.CloseRequested += EditDialog_CloseRequested;
EditDialog.Width = this.ActualWidth;
double verticalOff = this.ActualHeight - EditDialog.Height;
m_fieldsPopup.VerticalOffset = verticalOff / 2;
m_fieldsPopup.Child = EditDialog;
m_fieldsPopup.IsOpen = true;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void EditDialog_CloseRequested(object sender, EventArgs e)
{
m_fieldsPopup.IsOpen = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void EditDialog_UpdateRequested(object sender, EventArgs e)
{
UpdateGrid();
m_fieldsPopup.IsOpen = false;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void PDFExport_Click(object sender, RoutedEventArgs e)
{
MainGrid.IsHitTestVisible = false;
MainGrid.Opacity = 0.5;
progress.Visibility = Windows.UI.Xaml.Visibility.Visible;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, (() =>
{
PdfExport export = new PdfExport();
export.CreatePDF(m_items, m_billInfo, TotalDue);
}));
MainGrid.IsHitTestVisible = true;
MainGrid.Opacity = 1;
progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void WordExport_Click(object sender, RoutedEventArgs e)
{
MainGrid.IsHitTestVisible = false;
MainGrid.Opacity = 0.5;
progress.Visibility = Windows.UI.Xaml.Visibility.Visible;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, (() =>
{
ExportWord exportWord = new ExportWord();
exportWord.CreateWord(m_items, m_billInfo, TotalDue);
}));
MainGrid.IsHitTestVisible = true;
MainGrid.Opacity = 1;
progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void ExcelExport_Click(object sender, RoutedEventArgs e)
{
MainGrid.IsHitTestVisible = false;
MainGrid.Opacity = 0.5;
progress.Visibility = Windows.UI.Xaml.Visibility.Visible;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, (() =>
{
ExportToExcel exportToExcel = new ExportToExcel();
exportToExcel.GenerateReport(m_items, m_billInfo);
}));
MainGrid.IsHitTestVisible = true;
MainGrid.Opacity = 1;
progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Export(object sender, RoutedEventArgs e)
{
this.BottomAppBar1.IsOpen = true;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void About(object sender, RoutedEventArgs e)
{
}
#endregion
#region HelperMethods
/// <summary>
///
/// </summary>
/// <param name="height"></param>
/// <returns></returns>
private RowDefinition CreateRowDefinition(double height)
{
RowDefinition rowDefinition = new RowDefinition();
rowDefinition.Height = new GridLength(height);
return rowDefinition;
}
/// <summary>
///
/// </summary>
/// <param name="width"></param>
/// <returns></returns>
private ColumnDefinition CreateColumnDefinition(double width)
{
ColumnDefinition columnDefinition = new ColumnDefinition();
columnDefinition.Width = new GridLength(width);
return columnDefinition;
}
/// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <param name="addToGridAlone"></param>
public void AddItem(InvoiceItem item, bool addToGridAlone)
{
int rowIndex = m_currentRowIndex;
if (!addToGridAlone)
m_items.Add(item);
if (!(InvoiceGrid.RowDefinitions.Count > m_currentRowIndex))
{
InvoiceGrid.RowDefinitions.Add(CreateRowDefinition(m_rowHeight));
}
DrawBorder(rowIndex);
SetCell(rowIndex, 0, item.ItemName.ToString());
SetCell(rowIndex, 1, item.Quantity.ToString());
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
SetCell(rowIndex, 2, "$ " + item.Rate.ToString("#,###.00", CultureInfo.InvariantCulture));
SetCell(rowIndex, 3, "$ " + item.Taxes.ToString("#,###.00", CultureInfo.InvariantCulture));
SetCell(rowIndex, 4, "$ " + item.TotalAmount.ToString("#,###.00", CultureInfo.InvariantCulture));
}
else
{
SetCell(rowIndex, 2, "$" + item.Rate.ToString("#,###.00", CultureInfo.InvariantCulture));
SetCell(rowIndex, 3, "$" + item.Taxes.ToString("#,###.00", CultureInfo.InvariantCulture));
SetCell(rowIndex, 4, "$" + item.TotalAmount.ToString("#,###.00", CultureInfo.InvariantCulture));
}
m_totalDue += Convert.ToDouble(item.TotalAmount);
m_currentRowIndex++;
m_selectedIndex = m_items.Count;
UpdateTotal();
}
private void DrawBorder(int rowIndex)
{
Rectangle rect = new Rectangle();
rect.Height = 1;
rect.StrokeThickness = 0.75;
rect.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom;
rect.StrokeDashArray.Add(4);
rect.StrokeDashArray.Add(4);
rect.Stroke = new SolidColorBrush(Color.FromArgb(255, 206, 206, 206));
Grid.SetColumn(rect, 0);
Grid.SetColumnSpan(rect, 5);
Grid.SetRow(rect, rowIndex);
InvoiceGrid.Children.Add(rect);
}
/// <summary>
///
/// </summary>
/// <param name="rowIndex"></param>
/// <param name="columnIndex"></param>
/// <param name="value"></param>
private void SetCell(int rowIndex, int columnIndex, string value)
{
if (columnIndex == 2 || columnIndex == 3 || columnIndex == 4)
{
Grid amountGrid = new Grid();
Grid.SetColumn(amountGrid, columnIndex);
Grid.SetRow(amountGrid, rowIndex);
InvoiceGrid.Children.Add(amountGrid);
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
amountGrid.ColumnDefinitions.Add(new ColumnDefinition());
TextBlock textBlockDollor = null;
textBlockDollor = new TextBlock();
textBlockDollor.Text = value;
textBlockDollor.FontSize = 10;
textBlockDollor.FontFamily = new FontFamily("Segoe UI");
textBlockDollor.Foreground = new SolidColorBrush(Color.FromArgb(255, 63, 63, 63));
//textBlockDollor.Foreground = new SolidColorBrush(Colors.Black);
textBlockDollor.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
textBlockDollor.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
textBlockDollor.TextAlignment = TextAlignment.Right;
textBlockDollor.Padding = new Thickness(0, 0, 10, 0);
Grid.SetColumn(textBlockDollor, 0);
Grid.SetRow(textBlockDollor, 0);
amountGrid.Children.Add(textBlockDollor);
}
else
{
amountGrid.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
if (columnIndex == 2)
amountGrid.ColumnDefinitions.Add(new ColumnDefinition());
amountGrid.ColumnDefinitions.Add(new ColumnDefinition());
amountGrid.ColumnDefinitions.Add(new ColumnDefinition());
//amountGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength( new double(),GridUnitType.Auto)});
//Dollar
TextBlock textBlockDollor = null;
textBlockDollor = new TextBlock();
textBlockDollor.Text = "$";
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
textBlockDollor.FontSize = 10;
else
textBlockDollor.FontSize = 18;
textBlockDollor.FontFamily = new FontFamily("Segoe UI");
textBlockDollor.Foreground = new SolidColorBrush(Color.FromArgb(255, 63, 63, 63));
//textBlockDollor.Foreground = new SolidColorBrush(Colors.Black);
textBlockDollor.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
textBlockDollor.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
textBlockDollor.TextAlignment = TextAlignment.Right;
if (columnIndex == 2)
Grid.SetColumn(textBlockDollor, 1);
else
Grid.SetColumn(textBlockDollor, 0);
Grid.SetRow(textBlockDollor, 0);
amountGrid.Children.Add(textBlockDollor);
//Data
TextBlock textBlock = null;
textBlock = new TextBlock();
textBlock.Text = value.Trim('$');
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
textBlock.FontSize = 10;
else
textBlock.FontSize = 18;
textBlock.FontFamily = new FontFamily("Segoe UI");
textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 63, 63, 63));
//HorizontalAlignment="Center" FontWeight="Normal" FontFamily="Segoe UI" Foreground="#3F3F3F"
if (columnIndex == 0)
textBlock.Padding = new Thickness(10, 0, 0, 0);
else
{
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
textBlock.Padding = new Thickness(0, 0, 10, 0);
else
textBlock.Padding = new Thickness(0, 0, 15, 0);
}
//textBlock.Foreground = new SolidColorBrush(Colors.Black);
textBlock.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
textBlock.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
if (columnIndex > 0)
textBlock.TextAlignment = TextAlignment.Right;
if (columnIndex == 2)
Grid.SetColumn(textBlock, 2);
else
Grid.SetColumn(textBlock, 1);
Grid.SetRow(textBlock, 0);
amountGrid.Children.Add(textBlock);
}
}
else
{
//Data
TextBlock textBlock = null;
textBlock = new TextBlock();
textBlock.Text = value.Trim('$');
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
textBlock.FontSize = 10;
else
textBlock.FontSize = 18;
textBlock.FontFamily = new FontFamily("Segoe UI");
textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 63, 63, 63));
//HorizontalAlignment="Center" FontWeight="Normal" FontFamily="Segoe UI" Foreground="#3F3F3F"
if (columnIndex == 0)
{
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
textBlock.Padding = new Thickness(10, 2, 0, 2);
else
textBlock.Padding = new Thickness(10, 0, 0, 0);
}
else
{
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
textBlock.Padding = new Thickness(0, 0, 10, 0);
else
textBlock.Padding = new Thickness(0, 0, 15, 0);
}
//textBlock.Foreground = new SolidColorBrush(Colors.Black);
textBlock.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
textBlock.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
textBlock.TextWrapping = TextWrapping.Wrap;
if (columnIndex > 0)
textBlock.TextAlignment = TextAlignment.Right;
SetCell(rowIndex, columnIndex, textBlock);
}
}
/// <summary>
///
/// </summary>
/// <param name="rowIndex"></param>
/// <param name="columnIndex"></param>
/// <param name="textBlock"></param>
private void SetCell(int rowIndex, int columnIndex, TextBlock textBlock)
{
Grid.SetColumn(textBlock, columnIndex);
Grid.SetRow(textBlock, rowIndex);
if ((Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) &&
columnIndex == 0 && InvoiceGrid.Children[InvoiceGrid.Children.Count - 1] is Rectangle)
(InvoiceGrid.Children[InvoiceGrid.Children.Count - 1] as Rectangle).Height = textBlock.Height;
InvoiceGrid.Children.Add(textBlock);
}
/// <summary>
///
/// </summary>
/// <param name="index"></param>
private void RemoveItem(int index)
{
if (index < 0)
return;
if (InvoiceGrid.Children.Count <= 0)
return;
if (index < m_items.Count)
{
m_items.RemoveAt(index);
UpdateGrid();
}
}
/// <summary>
///
/// </summary>
private void UpdateGrid()
{
m_totalDue = 0;
m_currentRowIndex = 0;
InvoiceGrid.Children.Clear();
//InvoiceGrid.RowDefinitions.RemoveAt(InvoiceGrid.RowDefinitions.Count - 1);
for (int i = 0; i < InvoiceGrid.RowDefinitions.Count; i++)
DrawBorder(i);
foreach (InvoiceItem item in m_items)
{
AddItem(item, true);
}
UpdateTotal();
}
/// <summary>
///
/// </summary>
void UpdateTotal()
{
this.TotalAmount.Text = "$" + TotalDue.ToString("#,###.00", CultureInfo.InvariantCulture);
}
public async void LaunchedFromToast(String arguments)
{
StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile file = await folder.GetFileAsync(arguments);
bool success = await Windows.System.Launcher.LaunchFileAsync(file);
if (!success)
{
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the retrieved file
success = await Windows.System.Launcher.LaunchFileAsync(file);
}
}
}
#region Implementation
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
public void Dispose()
{
UnlinkChildrens(this);
m_productList = null;
m_items = null;
m_fieldsPopup = null;
m_addressPopup = null;
m_border = null;
m_billInfo = null;
m_items.Clear();
}
/// <summary>
/// Unlink the child elements from page.
/// </summary>
/// <param name="element"></param>
void UnlinkChildrens(UIElement element)
{
if (element == null)
return;
if (element is Panel)
{
for (int i = 0; i < (element as Panel).Children.Count; i++)
{
UIElement childElement = (element as Panel).Children[i];
UnlinkChildrens(childElement);
(element as Panel).Children.Remove(childElement);
i--;
}
}
else if (element is ItemsControl)
{
for (int j = 0; j < (element as ItemsControl).Items.Count; j++)
{
UIElement childElement = ((element as ItemsControl).Items[j] as UIElement);
if (childElement == null)
{
//(element as ItemsControl).Items.RemoveAt(j);
//j--;
}
else
{
UnlinkChildrens(childElement);
(element as ItemsControl).Items.Remove(childElement);
j--;
}
}
}
else if (element is ContentControl)
{
UnlinkChildrens((element as ContentControl).Content as UIElement);
(element as ContentControl).Content = null;
}
else if (element is UserControl)
{
UnlinkChildrens((element as UserControl).Content as UIElement);
(element as UserControl).Content = null;
}
}
#endregion
#endregion
}
}

Просмотреть файл

@ -0,0 +1,210 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Grid;
using System.Drawing;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Notifications;
using Windows.UI.Popups;
using System.Reflection;
using System.Globalization;
namespace Invoice
{
class PdfExport
{
public PdfExport()
{
}
/// <summary>
/// Creates PDF
/// </summary>
public async void CreatePDF(IList<InvoiceItem> dataSource, BillingInformation billInfo, double totalDue)
{
PdfDocument document = new PdfDocument();
document.PageSettings.Orientation = PdfPageOrientation.Portrait;
document.PageSettings.Margins.All = 50;
PdfPage page = document.Pages.Add();
PdfGraphics g = page.Graphics;
PdfTextElement element = new PdfTextElement(@"Syncfusion Software
2501 Aerial Center Parkway
Suite 200 Morrisville, NC 27560 USA
Tel +1 888.936.8638 Fax +1 919.573.0306");
element.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12);
element.Brush = new PdfSolidBrush(new PdfColor(0, 0, 0));
PdfLayoutResult result = element.Draw(page, new RectangleF(0, 0, page.Graphics.ClientSize.Width / 2, 200));
Stream imgStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Invoice.Assets.SyncfusionLogo.jpg");
PdfImage img = PdfImage.FromStream(imgStream);
page.Graphics.DrawImage(img, new RectangleF(g.ClientSize.Width - 200, result.Bounds.Y, 190, 45));
PdfFont subHeadingFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 14);
g.DrawRectangle(new PdfSolidBrush(new PdfColor(34, 83, 142)), new RectangleF(0, result.Bounds.Bottom + 40, g.ClientSize.Width, 30));
element = new PdfTextElement("INVOICE " + billInfo.InvoiceNumber.ToString(), subHeadingFont);
element.Brush = PdfBrushes.White;
result = element.Draw(page, new PointF(10, result.Bounds.Bottom + 48));
string currentDate = "DATE " + billInfo.Date.ToString("d");
SizeF textSize = subHeadingFont.MeasureString(currentDate);
g.DrawString(currentDate, subHeadingFont, element.Brush, new PointF(g.ClientSize.Width - textSize.Width - 10, result.Bounds.Y));
element = new PdfTextElement("BILL TO ", new PdfStandardFont(PdfFontFamily.TimesRoman, 12));
element.Brush = new PdfSolidBrush(new PdfColor(34, 83, 142));
result = element.Draw(page, new PointF(10, result.Bounds.Bottom + 25));
g.DrawLine(new PdfPen(new PdfColor(34, 83, 142), 0.70f), new PointF(0, result.Bounds.Bottom + 3), new PointF(g.ClientSize.Width, result.Bounds.Bottom + 3));
element = new PdfTextElement(billInfo.Name, new PdfStandardFont(PdfFontFamily.TimesRoman, 11));
element.Brush = new PdfSolidBrush(new PdfColor(0, 0, 0));
result = element.Draw(page, new RectangleF(10, result.Bounds.Bottom + 5, g.ClientSize.Width / 2, 100));
element = new PdfTextElement(billInfo.Address, new PdfStandardFont(PdfFontFamily.TimesRoman, 11));
element.Brush = new PdfSolidBrush(new PdfColor(0, 0, 0));
result = element.Draw(page, new RectangleF(10, result.Bounds.Bottom + 3, g.ClientSize.Width / 2, 100));
string[] headers = new string[] { "Item", "Quantity", "Rate", "Taxes", "Amount" };
PdfGrid grid = new PdfGrid();
grid.Columns.Add(headers.Length);
//Adding headers in to the grid
grid.Headers.Add(1);
PdfGridRow headerRow = grid.Headers[0];
int count = 0;
foreach (string columnName in headers)
{
headerRow.Cells[count].Value = columnName;
count++;
}
//Adding rows into the grid
foreach (var item in dataSource)
{
PdfGridRow row = grid.Rows.Add();
row.Cells[0].Value = item.ItemName;
row.Cells[1].Value = item.Quantity.ToString();
row.Cells[2].Value = "$" + item.Rate.ToString("#,###.00", CultureInfo.InvariantCulture);
row.Cells[3].Value = "$" + item.Taxes.ToString("#,###.00", CultureInfo.InvariantCulture);
row.Cells[4].Value = "$" + item.TotalAmount.ToString("#,###.00", CultureInfo.InvariantCulture);
}
PdfGridCellStyle cellStyle = new PdfGridCellStyle();
cellStyle.Borders.All = PdfPens.White;
PdfGridRow header = grid.Headers[0];
PdfGridCellStyle headerStyle = new PdfGridCellStyle();
headerStyle.Borders.All = new PdfPen(new PdfColor(34, 83, 142));
headerStyle.BackgroundBrush = new PdfSolidBrush(new PdfColor(34, 83, 142));
headerStyle.TextBrush = PdfBrushes.White;
headerStyle.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12f, PdfFontStyle.Regular);
for (int i = 0; i < header.Cells.Count; i++)
{
if (i == 0)
header.Cells[i].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
else
header.Cells[i].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
}
header.Cells[0].Value = "ITEM";
header.Cells[1].Value = "QUANTITY";
header.Cells[2].Value = "RATE";
header.Cells[3].Value = "TAXES";
header.Cells[4].Value = "AMOUNT";
header.ApplyStyle(headerStyle);
grid.Columns[0].Width = 180;
cellStyle.Borders.Bottom = new PdfPen(new PdfColor(34, 83, 142), 0.70f);
cellStyle.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11f);
cellStyle.TextBrush = new PdfSolidBrush(new PdfColor(0, 0, 0));
foreach (PdfGridRow row in grid.Rows)
{
row.ApplyStyle(cellStyle);
for (int i = 0; i < row.Cells.Count; i++)
{
PdfGridCell cell = row.Cells[i];
if (i == 0)
cell.StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
else
cell.StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
if (i > 1)
{
if (cell.Value.ToString().Contains("$"))
{
cell.Value = cell.Value.ToString();
}
else
{
if (cell.Value is double)
cell.Value = "$" + ((double)cell.Value).ToString("#,###.00", CultureInfo.InvariantCulture);
else
cell.Value = "$" + cell.Value.ToString();
}
}
}
}
PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat();
layoutFormat.Layout = PdfLayoutType.Paginate;
PdfGridLayoutResult gridResult = grid.Draw(page, new RectangleF(new PointF(0, result.Bounds.Bottom + 40), new SizeF(g.ClientSize.Width, g.ClientSize.Height - 100)), layoutFormat);
float pos = 0.0f;
for (int i = 0; i < grid.Columns.Count - 1; i++)
pos += grid.Columns[i].Width;
PdfFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 12f, PdfFontStyle.Bold);
gridResult.Page.Graphics.DrawString("TOTAL DUE", font, new PdfSolidBrush(new PdfColor(34, 83, 142)), new RectangleF(new PointF(pos, gridResult.Bounds.Bottom + 10), new SizeF(grid.Columns[3].Width - pos, 20)), new PdfStringFormat(PdfTextAlignment.Right));
gridResult.Page.Graphics.DrawString("Thank you for your business!", new PdfStandardFont(PdfFontFamily.TimesRoman, 12), new PdfSolidBrush(new PdfColor(0, 0, 0)), new PointF(pos - 210, gridResult.Bounds.Bottom + 60));
pos += grid.Columns[4].Width;
gridResult.Page.Graphics.DrawString("$" + totalDue.ToString("#,###.00", CultureInfo.InvariantCulture), font, new PdfSolidBrush(new PdfColor(0, 0, 0)), new RectangleF(pos, gridResult.Bounds.Bottom + 10, grid.Columns[4].Width - pos, 20), new PdfStringFormat(PdfTextAlignment.Right));
StorageFile stFile = null;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.DefaultFileExtension = ".pdf";
savePicker.SuggestedFileName = "Invoice";
savePicker.FileTypeChoices.Add("Adobe PDF Document", new List<string>() { ".pdf" });
stFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stFile = await local.CreateFileAsync("Invoice.pdf", CreationCollisionOption.ReplaceExisting);
}
if (stFile != null)
{
Stream stream = await stFile.OpenStreamForWriteAsync();
await document.SaveAsync(stream);
stream.Flush();
stream.Dispose();
document.Close(true);
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the saved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,113 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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.Xml.Linq;
namespace Invoice
{
/// <summary>
///
/// </summary>
public class Product
{
#region Members
private string m_name;
private double m_rate;
#endregion
#region Properties
/// <summary>
/// Gets or sets the product Name
/// </summary>
public string Name
{
get { return m_name; }
set { m_name = value; }
}
/// <summary>
/// Gets or sets the rate of the product
/// </summary>
public double Rate
{
get { return m_rate; }
set { m_rate = value; }
}
#endregion
#region Constructor
/// <summary>
///
/// </summary>
public Product()
{
}
/// <summary>
///
/// </summary>
/// <param name="name">Name</param>
/// <param name="rate">Rate</param>
public Product(string name, double rate)
{
m_name = name;
m_rate = rate;
}
#endregion
}
/// <summary>
///
/// </summary>
public class ProductList : List<Product>
{
#region Properties
/// <summary>
/// Returns the product based on the index
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public Product this[string item]
{
get
{
foreach (Product product in this)
if (product.Name == item)
return product;
return null;
}
}
#endregion
#region Methods
/// <summary>
/// Load product information from Embedded XML file
/// </summary>
public void LoadFromXml()
{
Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;
Stream xmlStream = assembly.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Invoice.Assets.ProdutsPriceList.xml");
//Load XML file
XElement xElement = XElement.Load(xmlStream);
IEnumerable<XElement> searched = from c in xElement.Elements("Product")
select c;
//Retreive product information
foreach (XElement pdt in searched)
{
Product product = new Product();
product.Name = pdt.Element("Name").Value;
product.Rate = Convert.ToDouble(pdt.Element("Rate").Value);
Add(product);
}
}
#endregion
}
}

Просмотреть файл

@ -0,0 +1,96 @@
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. 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 Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.UI.Notifications;
using Windows.UI.Popups;
namespace Invoice
{
/// <summary>
/// Helper Class to export invoice details to a Word document
/// </summary>
class ExportWord
{
/// <summary>
/// Export the UI data to Word document.
/// </summary>
/// <param name="invoiceItems">The InvoiceItems.</param>
/// <param name="billInfo">The BillingInformation.</param>
/// <param name="totalDue">The TotalDue.</param>
public async void CreateWord(IList<InvoiceItem> invoiceItems, BillingInformation billInfo, double totalDue)
{
//Load Template document stream
Stream inputStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Invoice.Assets.Template.docx");
//Create instance
WordDocument document = new WordDocument();
//Open Template document
await document.OpenAsync(inputStream, FormatType.Word2013);
//Dispose input stream
inputStream.Dispose();
//Set Clear Fields to false
document.MailMerge.ClearFields = false;
//Create Mail Merge Data Table
MailMergeDataTable mailMergeDataTable = new MailMergeDataTable("Invoice", invoiceItems);
//Executes mail merge using the data generated in the app.
document.MailMerge.ExecuteGroup(mailMergeDataTable);
//Mail Merge Billing information
string[] fieldNames = { "Name", "Address", "Date", "InvoiceNumber", "DueDate", "TotalDue" };
string[] fieldValues = { billInfo.Name, billInfo.Address, billInfo.Date.ToString("d"), billInfo.InvoiceNumber, billInfo.DueDate.ToString("d"), totalDue.ToString("#,###.00", CultureInfo.InvariantCulture) };
document.MailMerge.Execute(fieldNames, fieldValues);
StorageFile stgFile = null;
if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Invoice", new List<string>() { ".docx" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "Invoice";
stgFile = await savePicker.PickSaveFileAsync();
}
else
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stgFile = await local.CreateFileAsync("Invoice.docx", CreationCollisionOption.ReplaceExisting);
}
if (stgFile != null)
{
//Save as Docx format
await document.SaveAsync(stgFile, FormatType.Word2013);
//Close instance
document.Close();
MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
UICommand yesCmd = new UICommand("Yes");
msgDialog.Commands.Add(yesCmd);
UICommand noCmd = new UICommand("No");
msgDialog.Commands.Add(noCmd);
IUICommand cmd = await msgDialog.ShowAsync();
if (cmd == yesCmd)
{
// Launch the saved file
bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,179 @@
<View:SampleLayout
x:Class="EssentialDocIO.LetterFormattingDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EssentialDocIO" xmlns:View="using:Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<View:SampleLayout.Sample>
<ContentControl>
<Grid x:Name="mailMerge" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Padding="10,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TextBlock1" Grid.Row="0" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="18"/>
<TextBlock x:Name="WinRTText1" Grid.Row="1" Grid.ColumnSpan="6" TextWrapping="Wrap" Text="This sample demonstrates the Mail merge functionality in Word document using Essential DocIO." FontFamily="Segoe UI" FontSize="20" Foreground="#333333"/>
<TextBlock x:Name="TextBlock2" Grid.Row="2" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="18"/>
<StackPanel x:Name="list" Grid.Row="3" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock x:Name="TextBlock3" Grid.Row="3" Grid.ColumnSpan="2" TextWrapping="Wrap" Text="Select the Customer ID :" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock Grid.Row="3" x:Name="ForAlignListBox" Grid.ColumnSpan="2" Padding="0,0,170,0" TextWrapping="Wrap" Text="" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<ListBox x:Name="listBox1" Grid.Row="3" Grid.ColumnSpan="6" Grid.Column="1" SelectionMode="Extended" FontFamily="Segoe UI" FontSize="16" Height="150" Foreground="#333333" Width="470">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="Padding" Value="8,10"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="White">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPointerOverBackgroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="LayoutRoot">
<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemDisabledForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PressedBackground"/>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPressedForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected"/>
<VisualState x:Name="Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="#DDDDDD"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="#333333"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedUnfocused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="#DDDDDD"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="#333333"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedDisabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="#DDDDDD"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="#333333"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedPointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPointerOverBackgroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedPressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="#DDDDDD"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="#333333"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualWhite"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualBlack"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused"/>
<VisualState x:Name="PointerFocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="InnerGrid" Background="Transparent">
<Rectangle x:Name="PressedBackground" Fill="{StaticResource ListBoxItemPressedBackgroundThemeBrush}" Opacity="0"/>
<ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<Rectangle x:Name="FocusVisualWhite" Opacity="0" StrokeDashOffset=".5" StrokeEndLineCap="Square" Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}" StrokeDashArray="1,1"/>
<Rectangle x:Name="FocusVisualBlack" Opacity="0" StrokeDashOffset="1.5" StrokeEndLineCap="Square" Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}" StrokeDashArray="1,1"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</StackPanel>
<TextBlock x:Name="TextBlock5" Grid.Row="4" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="WinRTText2" Grid.Row="5" Grid.ColumnSpan="6" TextWrapping="Wrap" Text="Please click the Generate button to save and view the Word document generated by Essential DocIO." FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="text1" Grid.Row="6" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="saveas" Grid.Row="7" Grid.Column="0" TextWrapping="Wrap" Text="Save As" FontFamily="Segoe UI" FontSize="16" Foreground="#333333"/>
<TextBlock x:Name="text2" Grid.Row="8" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="14"/>
<StackPanel Name="stackPnlOptions" Grid.Row="9" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Left">
<RadioButton GroupName="Save As" Content="DOC" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDoc" Width="150" />
<RadioButton GroupName="Save As" Content="DOCX" FontFamily="Segoe UI" FontSize="16" Foreground="#333333" x:Name="rdDOcx" Width="150" IsChecked="True"/>
</StackPanel>
<TextBlock x:Name="text3" Grid.Row="12" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<TextBlock x:Name="text4" Grid.Row="13" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
<Button x:Name="Button1" Grid.Row="14" Grid.ColumnSpan="4" Content="Generate" Click="Button_Click_1" FontFamily="Segoe UI" FontSize="16" Foreground="#FFFFFF" Background="#656868" Height="Auto" Width="Auto" Padding="30,10,30,10" />
<TextBlock x:Name="TextBlock7" Grid.Row="15" Grid.ColumnSpan="6" FontFamily="Segoe UI" FontSize="16"/>
</Grid>
</ContentControl>
</View:SampleLayout.Sample>
</View:SampleLayout>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше