<< Click to Display Table of Contents >>

Running Viewer - C# - WinUWP Viewer

Add OZ viewer into Visual Studio project

Run C# and create a new project.

Add ozrv, res, and custom_ui folder into the project folder.

Select ARM/x86/x64 folder depending on your platform to build and then copy all files in the selected folder to the ozrv folder.

Click add Reference of the References pop-up menu in the Visual Studio Solution Explorer.

Select Browse in the bottom left of the Reference Manager Dialog, add the oz.winmd, OZWRTManagedRuntime.winmd and ZXing.winmd file, and then click the [OK] button.

Add the "res" and "custom_ui" folders in the project. Select all the images in the "res" and "custom_ui" folders and add them to your project.

Execute the Properties windows of all xaml files added in the custom_ui and res folders and set the "Custom Tool" option to an empty value in the [Advanced] tab. Also, for the OZUserSignKeyPad.xaml and OZUserSignRatio.xaml files, set the "Build Action" option to "Content".

Add script in App.xaml as below:

<Application.Resources>

   <ResourceDictionary>

       <ResourceDictionary.MergedDictionaries>

           <ResourceDictionary Source="res/OZXElementStyles.xaml"/>

           <ResourceDictionary Source="res/AdditionalResource.xaml"/>

       </ResourceDictionary.MergedDictionaries>

   </ResourceDictionary>

</Application.Resources>

Add script in MainPage.xaml as below:

<Border x:Name="_viewerFrame" Margin="0, 0, 0, 0"/>

Add script in MainPage.xaml.cs as below:

using oz.api;

Declare an Viewer object as below:

private OZReportViewer _viewer = null;

Add script

Add script to run the OZ Viewer.

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;

using oz.api;

 

namespace OZWinUWPViewerSample

{

   public sealed partial class MainPage : Page

   {

       private OZReportViewer _viewer = null;

       public MainPage()

       {

           this.InitializeComponent();

           onCreate();

       }

       public void onCreate()

       {

           try

           {

               if (_viewer != null) {

                   _viewer.ResetViewer();

               }

               string param = "connection.servlet=http://127.0.0.1:8080/oz/server";

               param += "\n" + "connection.reportname=category_path/sample.ozr";

 

               _viewer = OZReportAPI.CreateViewer(_viewerFrame, param);

           }

           catch (Exception ex)

           {

               string s = ex.Message;

           }

       }

   }

}

Set Package.appxmanifest

Set Package.appxmanifest as below:

<?xml version="1.0" encoding="utf-8"?>

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">

...

   <Capabilities>

       <Capability Name="internetClient" />

       <Capability Name="privateNetworkClientServer" />

       <Capability Name="internetClientServer" />

       <Capability Name="codeGeneration" />

       <uap:Capability Name="picturesLibrary" />

       <uap:Capability Name="videosLibrary" />

       <uap:Capability Name="userAccountInformation" />

       <uap:Capability Name="musicLibrary" />

       <uap:Capability Name="removableStorage" />

       <DeviceCapability Name="bluetooth" />

       <DeviceCapability Name="microphone" />

       <DeviceCapability Name="webcam" />

       <DeviceCapability Name="location" />

   </Capabilities>

</Package>

Run Project

Run the project.