summaryrefslogtreecommitdiff
path: root/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample
diff options
context:
space:
mode:
Diffstat (limited to 'print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample')
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml7
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs146
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs154
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Fabrikam_Logo.pngbin0 -> 2589 bytes
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml147
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs467
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintSchemaHelper.cs190
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj219
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs62
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.Designer.cs63
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.resx117
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.Designer.cs26
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.settings7
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs82
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.resx129
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml19
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs108
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs83
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config9
-rw-r--r--print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml74
20 files changed, 2109 insertions, 0 deletions
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml
new file mode 100644
index 00000000..f97fc473
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml
@@ -0,0 +1,7 @@
+<Application x:Class="Microsoft.Samples.Printing.PrinterExtension.App"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ Startup="Application_Startup"
+ Exit="Application_Exit"
+ >
+</Application>
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs
new file mode 100644
index 00000000..d37585c4
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs
@@ -0,0 +1,146 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+//
+// Abstract:
+//
+// This file contains the entry point to the application.
+
+using System;
+using System.Windows;
+using System.Runtime;
+
+using Microsoft.Samples.Printing.PrinterExtension.Types;
+using Microsoft.Samples.Printing.PrinterExtension.Helpers;
+
+using System.Windows.Interop;
+
+namespace Microsoft.Samples.Printing.PrinterExtension
+{
+ /// <summary>
+ /// Interaction logic for App.xaml.
+ /// </summary>
+ public partial class App : Application
+ {
+ /// <summary>
+ /// This is the event handler invoked on various driver events.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="eventArgs"></param>
+ private static void OnDriverEvent(object sender, PrinterExtensionEventArgs eventArgs)
+ {
+ //
+ // Display the print preferences window.
+ //
+
+ if (eventArgs.ReasonId.Equals(PrinterExtensionReason.PrintPreferences))
+ {
+ PrintPreferenceWindow printPreferenceWindow = new PrintPreferenceWindow();
+ printPreferenceWindow.Initialize(eventArgs);
+
+ //
+ // Set the caller application's window as parent/owner of the newly created printing preferences window.
+ //
+
+ WindowInteropHelper wih = new WindowInteropHelper(printPreferenceWindow);
+ wih.Owner = eventArgs.WindowParent;
+
+ //
+ // Display a modal/non-modal window based on the 'WindowModal' parameter.
+ //
+
+ if (eventArgs.WindowModal)
+ {
+ printPreferenceWindow.ShowDialog();
+ }
+ else
+ {
+ printPreferenceWindow.Show();
+
+ // Flash the window to draw the user's attention. This is required
+ // because the printer extension may be drawn behind the parent window.
+ // The return value of FlashWindow can be safely ignored if there is no need
+ // to know if the window has focus or not.
+ WindowHelper.FlashWindow(wih.Handle);
+ }
+ }
+ else if (eventArgs.ReasonId.Equals(PrinterExtensionReason.DriverEvent))
+ {
+ //
+ // Handle driver events here.
+ //
+ }
+ }
+
+ /// <summary>
+ /// Perform initialization tasks for the printer extension in this event handler.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void Application_Startup(object sender, StartupEventArgs e)
+ {
+ //
+ // It is recommended that exactly one instance of the PrinterExtensionManager be created per instance of
+ // the printer extension.
+ //
+
+ if (manager != null)
+ {
+ return;
+ }
+ manager = new PrinterExtensionManager();
+
+ //
+ // Enable events to be received on one printer driver id.
+ //
+ // Note: The order of adding the delegate to PrinterExtensionManager.OnDriverEvent
+ // and invoking PrinterExtensionManager::EnableEvents is important.
+ // Adding the delegate should be done first.
+ //
+
+ manager.OnDriverEvent += OnDriverEvent;
+
+ //
+ // It is recommended that an instance of a printer extension invoke PrinterExtensionManager::EnableEvents
+ // for exactly one printer driver id. The printer driver id could come in from a command line argument,
+ // thereby allowing one application binary to dynamically invoke PrinterExtensionManager::EnableEvents against
+ // the appropriate printer driver id.
+ //
+
+ manager.EnableEvents(Guid.Parse(PrinterDriverID));
+ }
+
+ /// <summary>
+ /// Perform uninitialization tasks for the printer extension in this event handler.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void Application_Exit(object sender, ExitEventArgs e)
+ {
+ manager.OnDriverEvent -= OnDriverEvent;
+ manager.DisableEvents();
+
+ manager = null;
+ }
+
+ /// <summary>
+ /// This is the printer driver id, as defined in the printer driver manifest file.
+ /// Please replace this GUID with the printer driver id from your manifest file.
+ ///
+ /// It is recommended that you invoke PrinterExtensionManager::EnableEvents() on exactly
+ /// one printer driver id. The id could come in from a command line argument, thereby enabling
+ /// one application binary to work with multiple printer driver ids.
+ /// </summary>
+ private const string PrinterDriverID = "{E0691E8D-F7CC-456E-A7B5-D1FC19BA2279}";
+
+ /// <summary>
+ /// Instance of the PrinterExtensionManager. It is recommended that you have only instance
+ /// of the PrinterExtensionManager per application instance.
+ /// </summary>
+ private static PrinterExtensionManager manager = null;
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs
new file mode 100644
index 00000000..c975ee7c
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs
@@ -0,0 +1,154 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+//
+// Abstract:
+//
+// This file contains helper methods that provide a data-binding friendly way to access and parse bidi response data.
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Media;
+using System.Xml;
+
+namespace Microsoft.Samples.Printing.PrinterExtension.Helpers
+{
+ /// <summary>
+ /// Provide a data-binding friendly way to access and parse bidi response data.
+ /// </summary>
+ public class BidiHelper
+ {
+ /// <summary>
+ /// Parse the bidi response.
+ /// </summary>
+ /// <param name="bidiResponse">Bidi response XML data.</param>
+ public BidiHelper(string bidiResponse)
+ {
+ BidiResponseParser parser = new BidiResponseParser(bidiResponse);
+ InkLevelC = parser.GetInkLevel(Colors.Cyan);
+ InkLevelM = parser.GetInkLevel(Colors.Magenta);
+ InkLevelY = parser.GetInkLevel(Colors.Yellow);
+ InkLevelK = parser.GetInkLevel(Colors.Black);
+ }
+
+ /// <summary>
+ /// Get the Cyan ink level.
+ /// </summary>
+ public double InkLevelC
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Get the Magenta ink level.
+ /// </summary>
+ public double InkLevelM
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Get the Yellow ink level.
+ /// </summary>
+ public double InkLevelY
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Get the Black ink level.
+ /// </summary>
+ public double InkLevelK
+ {
+ get;
+ private set;
+ }
+ }
+
+ /// <summary>
+ /// This class parses bidi response xml data and provides wrapper methods that operate upon the xml.
+ /// </summary>
+ internal class BidiResponseParser
+ {
+ /// <summary>
+ /// Parse the bidi response.
+ /// </summary>
+ /// <param name="bidiResponse">Bidi response XML data.</param>
+ internal BidiResponseParser(string bidiResponse)
+ {
+ bidiData = new XmlDocument();
+ bidiData.LoadXml(bidiResponse);
+
+ namespaceManager = new XmlNamespaceManager(bidiData.NameTable);
+ namespaceManager.AddNamespace("bidi", "http://schemas.microsoft.com/windows/2005/03/printing/bidi");
+ }
+
+ /// <summary>
+ /// Get the ink level for a given color.
+ /// </summary>
+ /// <param name="color">Color</param>
+ /// <returns>Ink level percentage</returns>
+ internal double GetInkLevel(Color color)
+ {
+ XmlElement root = bidiData.DocumentElement;
+ XmlNode inkNode = root.SelectSingleNode(CreateInkXPathQuery(color), namespaceManager);
+ return double.Parse(inkNode.FirstChild.Value) / 100;
+ }
+
+ /// <summary>
+ /// Create an XPath query that retrieves the ink level from a standard bidi response.
+ /// </summary>
+ /// <param name="color"></param>
+ /// <returns></returns>
+ private static string CreateInkXPathQuery(Color color)
+ {
+ string colorName = null;
+
+ if (color.Equals(Colors.Black))
+ {
+ colorName = "Black";
+ }
+ else if (color.Equals(Colors.Red))
+ {
+ colorName = "Red";
+ }
+ else if (color.Equals(Colors.Green))
+ {
+ colorName = "Green";
+ }
+ else if (color.Equals(Colors.Blue))
+ {
+ colorName = "Blue";
+ }
+ else if (color.Equals(Colors.Cyan))
+ {
+ colorName = "Cyan";
+ }
+ else if (color.Equals(Colors.Magenta))
+ {
+ colorName = "Magenta";
+ }
+ else if (color.Equals(Colors.Yellow))
+ {
+ colorName = "Yellow";
+ }
+ else
+ {
+ throw new ArgumentException("Unsupported color");
+ }
+
+ return "/bidi:Get/Query/Schema[@name='\\Printer.Consumables." + colorName + "Ink" + ":Level']/BIDI_INT";
+ }
+
+ private XmlDocument bidiData;
+ private XmlNamespaceManager namespaceManager;
+ }
+
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Fabrikam_Logo.png b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Fabrikam_Logo.png
new file mode 100644
index 00000000..196cd5f6
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Fabrikam_Logo.png
Binary files differ
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml
new file mode 100644
index 00000000..924efc21
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml
@@ -0,0 +1,147 @@
+<Window x:Class="Microsoft.Samples.Printing.PrinterExtension.PrintPreferenceWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:c="clr-namespace:Microsoft.Samples.Printing.PrinterExtension"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
+ Title="{Binding Path=PrinterQueue.Name}" Height="405" Width="565"
+ ResizeMode="NoResize"
+ Icon="Fabrikam_Logo.png"
+ Closing="PrintPreferenceWindow_Closing"
+ >
+
+ <Window.Resources>
+ <!-- Resources required to create the basic window -->
+ <Style x:Key="GraySingleBorder" TargetType="Border">
+ <Setter Property="BorderBrush" Value="Gray" />
+ </Style>
+
+ <SolidColorBrush x:Key="InkStatusBorderBrush" Color="Black"/>
+
+ <BitmapImage x:Key="FabrikamLogo" UriSource="Fabrikam_Logo.png" />
+
+ <Style x:Key="SimpleGroupBox" TargetType="GroupBox">
+ <Setter Property="Margin" Value="5,5,5,5" />
+ <Setter Property="Padding" Value="0,5,0,0" />
+ </Style>
+
+ <!--
+ Each brush below is bound to BidiHelperSource, which provides a data-biding friendly way to
+ access ink levels.
+ -->
+ <LinearGradientBrush x:Key="InkBrushC" StartPoint="0, 1" EndPoint="0, 0">
+ <GradientStop Color="Cyan" Offset="{Binding Path=BidiHelperSource.InkLevelC}" />
+ <GradientStop Color="White" Offset="{Binding Path=BidiHelperSource.InkLevelC}" />
+ </LinearGradientBrush>
+ <LinearGradientBrush x:Key="InkBrushM" StartPoint="0, 1" EndPoint="0, 0">
+ <GradientStop Color="Magenta" Offset="{Binding Path=BidiHelperSource.InkLevelM}" />
+ <GradientStop Color="White" Offset="{Binding Path=BidiHelperSource.InkLevelM}" />
+ </LinearGradientBrush>
+ <LinearGradientBrush x:Key="InkBrushY" StartPoint="0, 1" EndPoint="0, 0">
+ <GradientStop Color="Yellow" Offset="{Binding Path=BidiHelperSource.InkLevelY}" />
+ <GradientStop Color="White" Offset="{Binding Path=BidiHelperSource.InkLevelY}" />
+ </LinearGradientBrush>
+ <LinearGradientBrush x:Key="InkBrushK" StartPoint="0, 1" EndPoint="0, 0">
+ <GradientStop Color="Black" Offset="{Binding Path=BidiHelperSource.InkLevelK}" />
+ <GradientStop Color="White" Offset="{Binding Path=BidiHelperSource.InkLevelK}" />
+ </LinearGradientBrush>
+
+ <c:OptionConstrainedToDisplayColorConverter x:Key="OptionConstrainedToColor" />
+ </Window.Resources>
+
+ <Grid x:Name="MainGrid">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition x:Name="LeftHalf" Width="3*"/>
+ <ColumnDefinition x:Name="RightHalf" Width="5*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition x:Name="BrandingRow" Height="1*"/>
+ <RowDefinition x:Name="ContentRow" Height="2*"/>
+ <RowDefinition x:Name="StatusRow" />
+ </Grid.RowDefinitions>
+
+ <Border Style="{DynamicResource GraySingleBorder}" Grid.Row="0" Grid.ColumnSpan="2" BorderThickness="0,0,0,1"/>
+ <Border Style="{DynamicResource GraySingleBorder}" Grid.Row="1" Grid.Column="0" BorderThickness="0,0,0,1" />
+ <Border Style="{DynamicResource GraySingleBorder}" Grid.Row="1" Grid.Column="1" BorderThickness="1,0,0,1" />
+ <Border Style="{DynamicResource GraySingleBorder}" Grid.Row="2" Grid.Column="0" BorderThickness="0,0,0,0" />
+ <Border Style="{DynamicResource GraySingleBorder}" Grid.Row="2" Grid.Column="1" BorderThickness="1,0,0,0" />
+
+ <Image Source="{StaticResource FabrikamLogo}" Grid.Row="0" Grid.Column="0" Stretch="None"/>
+
+ <!--
+ Display the name of the current print queue.
+ -->
+ <TextBlock FontFamily="Verdana" Grid.Row="0" Grid.Column="1" TextAlignment="Left"
+ VerticalAlignment="Center" FontSize="16" Foreground="DarkOrchid" Text="{Binding Path=PrinterQueue.Name}" />
+
+ <!--
+ Lay out multiple GroupBoxes, with one ComboBox inside each. The number of GroupBoxes is determined by the number of features returned by
+ binding property: PrintSchemaHelperSource.Features.
+
+ Each GroupBox Header displays the print schema feature's display name, bound to PrintSchemaFeatureHelper.DisplayName.
+ Each ComboBox's ItemSource property is bound to the list of valid options for that feature i.e. bound to PrintSchemaFeatureHelper.Options.
+ Additionally, the ComboBox is bound two-way to to PrintSchemaFeatureHelper.SelectedOption. Therefore, in addition to displaying the option
+ selected in the current print ticket, when the selected option is changed via UI selection,
+ a 'set' property is invoked on PrintSchemaFeatureHelper.SelectedOption.
+
+ Each item in the ComboBox has the following structure:
+ It's displays the option name via a TextBlock, bound to the IPrintSchemaOption.DisplayName.
+ It's 'ForeGround' font color changes based on the IPrintSchemaOption.Constrained property.
+
+ *Note*: Since this is an expensive operation to perfom, the data is retrieved asynchronously (IsAsync=true, below).
+ -->
+ <StackPanel Grid.Row="1" Grid.Column="1">
+ <ItemsControl ItemsSource="{Binding Path=PrintSchemaHelperSource.Features, IsAsync=True}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <GroupBox Style="{DynamicResource SimpleGroupBox}" Header="{Binding Path=DisplayName}">
+ <ComboBox ItemsSource="{Binding Path=Options}" SelectedItem="{Binding Path=SelectedOption}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal" >
+ <TextBlock Text="{Binding Path=DisplayName}" Foreground="{Binding Converter={StaticResource OptionConstrainedToColor}, Path=Constrained}"/>
+ </StackPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ComboBox>
+ </GroupBox>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </StackPanel>
+
+ <!--
+ This modal dialog prevents the user from making changes to print preferences
+ when print ticket validation is in progress. This dialog is hidden when validation is not in progress.
+ -->
+ <c:ValidationModalDialog x:Name="ValidationModalDialog" Grid.Row="1" Grid.Column="1" Visibility="Hidden"/>
+
+ <!--
+ This GroupBox displays ink status. There are 4 rectangles that display ink status. The brush that paints color/level is bound to code.
+ -->
+ <GroupBox Header="{Binding Path=InkStatusTitle}" Grid.Column="0" Grid.Row="2" Margin="5,0,5,5">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="24*"/>
+ <RowDefinition Height="43*"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition />
+ <ColumnDefinition />
+ <ColumnDefinition />
+ <ColumnDefinition />
+ </Grid.ColumnDefinitions>
+
+ <Rectangle Grid.Column="0" Fill="{DynamicResource InkBrushC}" Margin="2,0,2,0" Name="InkIndicatorC" Stroke="{DynamicResource InkStatusBorderBrush}" Grid.RowSpan="2"/>
+ <Rectangle Grid.Column="1" Fill="{DynamicResource InkBrushM}" Margin="2,0,2,0" Name="InkIndicatorM" Stroke="{DynamicResource InkStatusBorderBrush}" Grid.RowSpan="2"/>
+ <Rectangle Grid.Column="2" Fill="{DynamicResource InkBrushY}" Margin="2,0,2,0" Name="InkIndicatorY" Stroke="{DynamicResource InkStatusBorderBrush}" Grid.RowSpan="2"/>
+ <Rectangle Grid.Column="3" Fill="{DynamicResource InkBrushK}" Margin="0,0,2,0" Name="InkIndicatorK" Stroke="{DynamicResource InkStatusBorderBrush}" HorizontalAlignment="Right" Width="43" Grid.RowSpan="2"/>
+ </Grid>
+ </GroupBox>
+
+ <UniformGrid Grid.Row="2" Grid.Column="2" Rows="1" Columns="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,10">
+ <Button Content="_Ok" Name="OkButton" Margin="0,0,5,0" Click="Button_Click" />
+ <Button Content="_Cancel" Name="CancelButton" Margin="5,0,5,0" Padding="10,0,10,0" Click="Button_Click" />
+ <Button Content="_Verify settings" Name="VerifyButton" Margin="5,0,0,0" Click="Button_Click" />
+ </UniformGrid>
+ </Grid>
+</Window>
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs
new file mode 100644
index 00000000..a6266662
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs
@@ -0,0 +1,467 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+//
+// Abstract:
+//
+// This file contains as the interaction logic and data-binding code/sources for the WPF print preferences window.
+
+using System;
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Media;
+
+using System.Reflection;
+using System.IO;
+
+using System.Xml.Linq;
+
+using System.Runtime.InteropServices;
+
+using Microsoft.Samples.Printing.PrinterExtension.Types;
+using Microsoft.Samples.Printing.PrinterExtension.Helpers;
+
+namespace Microsoft.Samples.Printing.PrinterExtension
+{
+ /// <summary>
+ /// Interaction logic for PrintPreferenceWindow.xaml.
+ /// </summary>
+ public partial class PrintPreferenceWindow : Window, INotifyPropertyChanged
+ {
+ public PrintPreferenceWindow()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// This method sets up data binding sources and performs other initialization tasks.
+ /// </summary>
+ /// <param name="eventArgs"></param>
+ public void Initialize(PrinterExtensionEventArgs eventArgs)
+ {
+ //
+ // Populate the data binding sources.
+ //
+
+ DataContext = this;
+
+ printerExtensionEventArgs = eventArgs;
+ PrinterQueue = eventArgs.Queue;
+ displayedPrintTicket = eventArgs.Ticket;
+
+ //
+ // Send a bidi query requesting ink levels.
+ //
+ // Please note: As this event will fire many times, it is recommended to maintain event
+ // listeners for the life time of the application. Furthermore, the relationship to this
+ // being invoked and the calling SendBidiQuery() is not 1:1; in fact, it is *:N, where the
+ // listener may be called several times with bidi updates.
+ //
+ //
+
+ PrinterQueue.OnBidiResponseReceived += OnBidiResponseReceived;
+ PrinterQueue.SendBidiQuery("\\Printer.consumables");
+ }
+
+ #region UI code
+
+ /// <summary>
+ /// This event handler is invoked when the window is closing. It is important to Cancel or Complete the request when the window is closing.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ void PrintPreferenceWindow_Closing(object sender, EventArgs e)
+ {
+ // Since we are a different process from the printing application we need to hand focus back when complete.
+ WindowHelper.SetForegroundWindow(printerExtensionEventArgs.WindowParent);
+
+ if (!requestCompleted)
+ {
+ printerExtensionEventArgs.Request.Cancel((int)HRESULT.S_FALSE, "The user canceled the operation.");
+ requestCompleted = true;
+ }
+ }
+
+ /// <summary>
+ /// Button click event handler.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ Button clickedButton = (Button)sender;
+
+ switch (clickedButton.Name)
+ {
+ case "CancelButton":
+ CancelRequestAndCloseWindow();
+ break;
+
+ case "OkButton":
+ //
+ // Validate the print ticket asynchronously. The event handler is invoked when the validation is completed.
+ //
+
+ IPrintSchemaAsyncOperation asyncOperation = displayedPrintTicket.ValidateAsync();
+
+ //
+ // Pop up a modal dialog that prevents the user from changing selections when validation is in progress.
+ // Since this dialog lives as long as the parent window, it is not mandatory to unregister the delegate for the
+ // 'Completed' event.
+ //
+
+ ValidationModalDialog.Completed += PrintTicketValidateCompleted; // This operation is idempotent.
+ ValidationModalDialog.StartAsyncOperation(asyncOperation);
+ break;
+
+ case "VerifyButton":
+ //
+ // Force WPF Data binding to refresh the UI. This operation retrieves
+ // a fresh print capabilities for the print ticket based on the user selections.
+ //
+
+ PropertyChanged(this, new PropertyChangedEventArgs("PrintSchemaHelperSource"));
+ break;
+ }
+ }
+
+ /// <summary>
+ /// Close the window in a thread-safe way.
+ /// </summary>
+ private void CloseWindow()
+ {
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ this.Close();
+ }));
+ }
+
+ #endregion
+
+
+ #region Data binding sources
+
+ /// <summary>
+ /// The Print queue for which this window is being displayed.
+ /// </summary>
+ public IPrinterQueue PrinterQueue { get; private set; }
+
+ /// <summary>
+ /// The title for the ink status display.
+ /// </summary>
+ public string InkStatusTitle { get; private set; }
+
+ /// <summary>
+ /// Retrieve a new instance of PrintSchemaHelper, based on the current print ticket being displayed.
+ /// PrintSchemaHelper encapsulates all the features and options required to populate the print preferences UI.
+ /// </summary>
+ public PrintSchemaHelper PrintSchemaHelperSource
+ {
+ get
+ {
+ //
+ // Below is the list of features that will be displayed in the print preferences window.
+ // The features are declared here for convenience/readability.
+ //
+ // In performant code, this array would be allocated only once per run of the application.
+ //
+
+ string[] featureNames = {
+ "DocumentNUp",
+ "PageMediaSize",
+ "DocumentInputBin",
+ "PageOrientation",
+ "PageMediaType",
+ "PageBorderless",
+ "JobInputBin",
+ "PageOutputColor",
+ "DocumentCollate",
+ "DocumentDuplex"
+ };
+
+ return new PrintSchemaHelper(displayedPrintTicket, featureNames);
+ }
+ }
+
+ /// <summary>
+ /// Encapsulates the information required to populate ink level.
+ /// </summary>
+ public BidiHelper BidiHelperSource { get; private set; }
+
+ /// <summary>
+ /// This event is raised when a data from a binding source is modified.
+ /// </summary>
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ #endregion
+
+ #region Ink level display
+ /// <summary>
+ /// This is the method invoked when a bidi response is received.
+ /// </summary>
+ /// <param name="sender">IPrinterQueue object.</param>
+ /// <param name="e">The results of the bidi response.</param>
+ private void OnBidiResponseReceived(object sender, PrinterQueueEventArgs e)
+ {
+ if (e.StatusHResult != (int)HRESULT.S_OK)
+ {
+ MockInkStatus();
+ return;
+ }
+
+ //
+ // Display the ink levels from the mock data.
+ //
+
+ BidiHelperSource = new BidiHelper(e.Response);
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs("BidiHelperSource"));
+ }
+ InkStatusTitle = "Ink status (Live data)";
+ }
+
+ /// <summary>
+ /// This method is invoked when there is an error retrieving Bidi information.
+ /// A mock bidi response is loaded from resource and displayed.
+ /// </summary>
+ private void MockInkStatus()
+ {
+ //
+ // Load mock bidi response resource.
+ //
+
+ Assembly a = Assembly.GetExecutingAssembly();
+ Stream xmlData = a.GetManifestResourceStream("PrinterExtensionSample.bidi_Ink_mock.xml");
+ StreamReader sr = new StreamReader(xmlData);
+ string xmlString = sr.ReadToEnd();
+
+ //
+ // Display the ink levels from the mock data.
+ //
+
+ BidiHelperSource = new BidiHelper(xmlString);
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs("BidiHelperSource"));
+ }
+ InkStatusTitle = "Ink status (Mocked data)";
+ }
+ #endregion
+
+ #region PrintSchema-related code
+ /// <summary>
+ /// Cancel the current printer extension event and close the current window.
+ /// </summary>
+ private void CancelRequestAndCloseWindow()
+ {
+ printerExtensionEventArgs.Request.Cancel((int)HRESULT.S_FALSE, "User canceled the operation");
+ requestCompleted = true;
+ CloseWindow();
+ }
+
+ /// <summary>
+ /// Invoked when asynchronous print ticket validation is complete.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void PrintTicketValidateCompleted(object sender, PrintSchemaAsyncOperationEventArgs e)
+ {
+ //
+ // Print ticket validation completed successfully i.e. print ticket selections are not constrained.
+ // The print ticket needs to be committed, and then window can be closed.
+ //
+
+ if (e.StatusHResult == (int)HRESULT.S_PT_NO_CONFLICT)
+ {
+ this.Dispatcher.Invoke(new Action(() =>
+ {
+ CommitPrintTicketAsync(e.Ticket);
+ }));
+
+ }
+ else
+ {
+ //
+ // The ticket selections are constrained.
+ //
+
+ this.Dispatcher.Invoke(new Action(() =>
+ {
+ HandleTicketConstraints(e.Ticket);
+ }));
+ }
+ }
+
+ /// <summary>
+ /// Invoked when there are constraints in the print ticket selections.
+ /// </summary>
+ /// <param name="validatedTicket"></param>
+ private void HandleTicketConstraints(IPrintSchemaTicket validatedTicket)
+ {
+ //
+ // Retrieved localized display strings from a resource file/
+ //
+ string selectionConflictsFound = PrinterExtensionSample.Strings.SelectionConflictsFound;
+ string selectionConflictsTitle = PrinterExtensionSample.Strings.SelectionConflictsTitle;
+
+ MessageBoxResult result = MessageBox.Show(
+ this,
+ selectionConflictsFound,
+ selectionConflictsTitle,
+ MessageBoxButton.YesNoCancel);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ CommitPrintTicketAsync(validatedTicket);
+ }
+ else
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs("PrintSchemaHelperSource"));
+ }
+ }
+
+ /// <summary>
+ /// Commits the input print ticket asynchronously. The completed event handler is expected to close the window.
+ /// </summary>
+ /// <param name="validatedTicket"></param>
+ private void CommitPrintTicketAsync(IPrintSchemaTicket validatedTicket)
+ {
+ IPrintSchemaAsyncOperation commitAsyncOperation = printerExtensionEventArgs.Ticket.CommitAsync(validatedTicket);
+ commitAsyncOperation.Completed += PrintTicketCommitCompleted;
+ commitAsyncOperation.Start();
+ }
+
+ /// <summary>
+ /// Invoked when the user's selections have been committed into the print ticket.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void PrintTicketCommitCompleted(object sender, PrintSchemaAsyncOperationEventArgs e)
+ {
+ CompleteRequestAndCloseWindow();
+ }
+
+ /// <summary>
+ /// Complete the current printer extension request and close the current window.
+ /// </summary>
+ private void CompleteRequestAndCloseWindow()
+ {
+ //
+ // It is important to invoke the IPrinterExtensionRequest::Complete method from the thread the
+ // class instance was create on (i.e. the UI thread).
+ //
+
+ this.Dispatcher.Invoke(new Action(() =>
+ {
+ printerExtensionEventArgs.Request.Complete();
+ }));
+
+ requestCompleted = true;
+ CloseWindow();
+ }
+
+ /// <summary>
+ /// Demonstrates how to modify print ticket XML. This piece of code does not perform any functionality.
+ /// It serves to demonstrate the usage of IPrintSchemaTicket::GetReadStream()/GetWriteStream()
+ /// </summary>
+ private void ModifyPrintTicketXml()
+ {
+ //
+ // Load the ticket XML (as a Stream) into an XElement object.
+ //
+
+ XElement ticketRootXElement = null;
+ using (Stream ticketReadStream = displayedPrintTicket.GetReadStream())
+ {
+ ticketRootXElement = XElement.Load(ticketReadStream);
+ }
+
+ //
+ // Perform any modifications on the XElement object.
+ //
+
+
+ //
+ // Write the changes back to the print ticket.
+ //
+ using (Stream ticketWriteStream = displayedPrintTicket.GetWriteStream())
+ {
+ ticketRootXElement.Save(ticketWriteStream);
+ }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// The arguments passed in for this print preferences event.
+ /// </summary>
+ private PrinterExtensionEventArgs printerExtensionEventArgs = null;
+
+ /// <summary>
+ /// Reflects the currently displayed print preference options.
+ /// </summary>
+ private IPrintSchemaTicket displayedPrintTicket = null;
+
+ /// <summary>
+ /// Determines if IPrinterExtensionRequest::Complete()/Cancel() has been invoked for this Window.
+ /// instance
+ /// </summary>
+ private bool requestCompleted = false;
+ }
+
+ /// <summary>
+ /// This class transforms the boolean 'IPrintSchemaOption.Constrained' into a visual form.
+ /// </summary>
+ public class OptionConstrainedToDisplayColorConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ {
+ return "Black";
+ }
+
+ //
+ // If the option is not constrained, it will be diplayed in black.
+ //
+
+ PrintSchemaConstrainedSetting constrained = (PrintSchemaConstrainedSetting)value;
+ if (constrained == PrintSchemaConstrainedSetting.None)
+ {
+ return "Black";
+ }
+
+ //
+ // If the option is constrained, it will be displayed in red.
+ //
+
+ return "Red";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ /// <summary>
+ /// Provides a friendlier way to use HRESULT error codes.
+ /// </summary>
+ enum HRESULT : int
+ {
+ S_OK = 0x0000,
+ S_FALSE = 0x0001,
+ S_PT_NO_CONFLICT = 0x40001,
+ E_INVALIDARG = unchecked((int)0x80070057),
+ E_OUTOFMEMORY = unchecked((int)0x8007000E),
+ ERROR_NOT_FOUND = unchecked((int)0x80070490)
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintSchemaHelper.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintSchemaHelper.cs
new file mode 100644
index 00000000..e9201162
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintSchemaHelper.cs
@@ -0,0 +1,190 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+//
+// Abstract:
+//
+// This file contains helper methods that provide a data-binding friendly way to access PrintSchema APIs.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using System.Runtime.InteropServices;
+
+using Microsoft.Samples.Printing.PrinterExtension.Types;
+
+namespace Microsoft.Samples.Printing.PrinterExtension.Helpers
+{
+ /// <summary>
+ /// Contains helper methods that provide a data-binding friendly way to access PrintSchema APIs.
+ /// </summary>
+ public class PrintSchemaHelper
+ {
+ /// <summary>
+ /// Constructor. Warning constructing this object is expensive, and is best performed
+ /// asynchronously.
+ /// </summary>
+ /// <param name="ticket">The print ticket for which features/options will be retrieved</param>
+ /// <param name="featureNameCollection">List of features requested</param>
+ internal PrintSchemaHelper(IPrintSchemaTicket ticket, IEnumerable<String> featureNameCollection)
+ {
+ _ticket = ticket;
+ _featureNameCollection = featureNameCollection;
+ _capabilities = _ticket.GetCapabilities();
+ }
+
+ /// <summary>
+ /// Retrieve the list of features from the current print ticket.
+ /// </summary>
+ public List<PrintSchemaFeatureHelper> Features
+ {
+ get
+ {
+ _featureHelperCollection = new List<PrintSchemaFeatureHelper>();
+
+ //
+ // Retrieve the list of features supported by the driver
+ //
+
+ foreach (string name in _featureNameCollection)
+ {
+ //
+ // If the feature is not present in the print ticket or the print capabilities,
+ // ignore it and continue.
+ //
+
+ IPrintSchemaFeature ticketFeature = _ticket.GetFeatureByKeyName(name);
+ if (ticketFeature == null)
+ {
+ continue;
+ }
+
+ IPrintSchemaFeature capabilitiesFeature = _capabilities.GetFeatureByKeyName(name);
+ if (capabilitiesFeature == null)
+ {
+ continue;
+ }
+
+ // If the feature is not meant to be displayed on the UI, ignore it and continue.
+ if (!capabilitiesFeature.DisplayUI)
+ {
+ continue;
+ }
+
+ _featureHelperCollection.Add(new PrintSchemaFeatureHelper(ticketFeature, _capabilities, capabilitiesFeature));
+ }
+
+ return _featureHelperCollection;
+ }
+ }
+
+ /// <summary>
+ /// List of features requested.
+ /// </summary>
+ private IEnumerable<string> _featureNameCollection;
+
+ /// <summary>
+ /// Helper objects that wrap an IPrintSchemaFeature object.
+ /// </summary>
+ private List<PrintSchemaFeatureHelper> _featureHelperCollection = null;
+
+ /// <summary>
+ /// Print ticket passed into this class.
+ /// </summary>
+ private IPrintSchemaTicket _ticket = null;
+
+ /// <summary>
+ /// Print capabilities object.
+ /// </summary>
+ private IPrintSchemaCapabilities _capabilities = null;
+ }
+
+ /// <summary>
+ /// Contains helper methods that provide a data-binding friendly way to access IPrintSchemaFeature APIs.
+ ///
+ /// Note: This sample does not handle Print Ticket/Print Capabilities Options which rely on parameters to
+ /// be specified, such as psk:Custom , psk:CustomSquare, or psk:CustomMediaSize. If these options are
+ /// supported by compatible print drivers, then the printer extension should be modified to support them
+ /// appropriately.
+ /// </summary>
+ public class PrintSchemaFeatureHelper
+ {
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="ticketFeature">Object retrieved via a call to IPrintSchemaTicket::GetFeature/GetFeatureByKeyName</param>
+ /// <param name="capabilities">Print capabilities object</param>
+ /// <param name="capabilitiesFeature">Object retrieved via a call to IPrintSchemaCapabilities::GetFeature/GetFeatureByKeyName</param>
+ internal PrintSchemaFeatureHelper(IPrintSchemaFeature ticketFeature, IPrintSchemaCapabilities capabilities, IPrintSchemaFeature capabilitiesFeature)
+ {
+ //
+ // Populate the properties exposed by this class.
+ //
+
+ DisplayName = capabilitiesFeature.DisplayName;
+ Options = new List<IPrintSchemaOption>(capabilities.GetOptions(ticketFeature));
+
+ foreach (IPrintSchemaOption option in Options)
+ {
+ if (option.Selected)
+ {
+ _selectedOption = option;
+ break;
+ }
+ }
+
+ _printTicketFeature = ticketFeature;
+ }
+
+ /// <summary>
+ /// Returns the display name for the current IPrintSchemaFeature object.
+ /// </summary>
+ public string DisplayName
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Retrieve the list of options supported for the current feature.
+ /// </summary>
+ public List<IPrintSchemaOption> Options
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// A 'get' invocation on this property returns the selected option for this print ticket feature.
+ /// A 'set' invocation on this property sets the selected option for this print ticket feature.
+ /// </summary>
+ public IPrintSchemaOption SelectedOption
+ {
+ get
+ {
+ return _selectedOption;
+ }
+ set
+ {
+ _selectedOption = value;
+ _printTicketFeature.SelectedOption = _selectedOption;
+ }
+ }
+
+ /// <summary>
+ /// Feature object retrieved from the print ticket.
+ /// </summary>
+ private IPrintSchemaFeature _printTicketFeature = null;
+
+ /// <summary>
+ /// Selected option for the print ticket feature.
+ /// </summary>
+ private IPrintSchemaOption _selectedOption = null;
+
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj
new file mode 100644
index 00000000..bbb7f044
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{CF554A99-6889-4B86-934F-B6AADBFEFC01}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>PrinterExtensionSample</RootNamespace>
+ <AssemblyName>PrinterExtensionSample</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Win8 Debug|x86' ">
+ <OutputPath>bin\Win8 Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Win8 Release|x86' ">
+ <OutputPath>bin\Win8 Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Win8 Debug|x64'">
+ <OutputPath>bin\x64\Win8 Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <PlatformTarget>x64</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Win8 Release|x64'">
+ <OutputPath>bin\x64\Win8 Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <PlatformTarget>x64</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Win8.1 Debug|x86' ">
+ <OutputPath>bin\Win8.1 Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Win8.1 Release|x86' ">
+ <OutputPath>bin\Win8.1 Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Win8.1 Debug|x64'">
+ <OutputPath>bin\x64\Win8.1 Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <PlatformTarget>x64</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Win8.1 Release|x64'">
+ <OutputPath>bin\x64\Win8.1 Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <PlatformTarget>x64</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Xaml">
+ <RequiredTargetFramework>4.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="WindowsBase" />
+ <Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BidiHelper.cs" />
+ <Compile Include="PrintSchemaHelper.cs" />
+ <Compile Include="Strings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Strings.resx</DependentUpon>
+ </Compile>
+ <Compile Include="ValidationModalDialog.xaml.cs">
+ <DependentUpon>ValidationModalDialog.xaml</DependentUpon>
+ </Compile>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Compile Include="WindowHelper.cs" />
+ <Page Include="PrintPreferenceWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="PrintPreferenceWindow.xaml.cs">
+ <DependentUpon>PrintPreferenceWindow.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Page Include="ValidationModalDialog.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Strings.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Strings.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <None Include="app.config" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Fabrikam_Logo.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\PrinterExtensionLibrary\PrinterExtensionLibrary.csproj">
+ <Project>{d8da0c4d-f972-4546-9068-8eb256f222f7}</Project>
+ <Name>PrinterExtensionLibrary</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="bidi_Ink_mock.xml" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..c3198284
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs
@@ -0,0 +1,62 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("PrinterExtensionSample")]
+[assembly: AssemblyDescription("Printer Extension Sample for v4 print drivers")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("PrinterExtensionSample")]
+[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation. All rights reserved")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
+//inside a <PropertyGroup>. For example, if you are using US english
+//in your source files, set the <UICulture> to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.Designer.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..b6af3bc4
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.17325
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace PrinterExtensionSample.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PrinterExtensionSample.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.resx b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.resx
new file mode 100644
index 00000000..af7dbebb
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.resx
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.Designer.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..c0a373ef
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.17325
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace PrinterExtensionSample.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.settings b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.settings
new file mode 100644
index 00000000..033d7a5e
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile> \ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs
new file mode 100644
index 00000000..6ea88a35
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs
@@ -0,0 +1,82 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.17361
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace PrinterExtensionSample {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Strings {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Strings() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PrinterExtensionSample.Strings", typeof(Strings).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Selection conflicts were encountered.
+ ///Would you like them auto-resolved?.
+ /// </summary>
+ internal static string SelectionConflictsFound {
+ get {
+ return ResourceManager.GetString("SelectionConflictsFound", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Selection conflicts.
+ /// </summary>
+ internal static string SelectionConflictsTitle {
+ get {
+ return ResourceManager.GetString("SelectionConflictsTitle", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.resx b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.resx
new file mode 100644
index 00000000..8f4878a4
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.resx
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="SelectionConflictsFound" xml:space="preserve">
+ <value>Selection conflicts were encountered.
+Would you like them auto-resolved?</value>
+ <comment>String to display in the message box when print ticket settings have conflicts.</comment>
+ </data>
+ <data name="SelectionConflictsTitle" xml:space="preserve">
+ <value>Selection conflicts</value>
+ <comment>Title string on the message box that displays the selection conflicts message.</comment>
+ </data>
+</root> \ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml
new file mode 100644
index 00000000..c949efd4
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml
@@ -0,0 +1,19 @@
+<UserControl x:Class="Microsoft.Samples.Printing.PrinterExtension.ValidationModalDialog"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
+ <Grid DataContext="{Binding ElementName=root}">
+ <Border Background="#60000000">
+ <Border BorderBrush="Black" BorderThickness="1" Background="AliceBlue"
+ CornerRadius="10,0,10,0" VerticalAlignment="Center" HorizontalAlignment="Center">
+ <Border.BitmapEffect>
+ <DropShadowBitmapEffect Color="Black" Opacity="0.5" Direction="90" ShadowDepth="0.7" />
+ </Border.BitmapEffect>
+ <UniformGrid Grid.Row="1" Margin="10" Rows="2" Columns="1" HorizontalAlignment="Center" VerticalAlignment="Bottom">
+ <TextBlock>Validating.. please wait</TextBlock>
+ <Button x:Name="CancelValidationButton" Content="Cancel" Click="CancelValidationButton_Click"/>
+ </UniformGrid>
+ </Border>
+ </Border>
+ </Grid>
+</UserControl>
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs
new file mode 100644
index 00000000..0728c84c
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs
@@ -0,0 +1,108 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+//
+// Abstract:
+//
+// This file contains as the interaction logic for ValidationModaldialog.
+// This dialog prevents the user from making changes to print ticket settings when asynchronous
+// validation is being performed.
+
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+using Microsoft.Samples.Printing.PrinterExtension.Types;
+
+namespace Microsoft.Samples.Printing.PrinterExtension
+{
+ /// <summary>
+ /// Interaction logic for ValidationModalDialog.xaml
+ /// This dialog prevents the user from changing print preferences when validation is in progress.
+ /// </summary>
+ public partial class ValidationModalDialog : UserControl
+ {
+ public ValidationModalDialog()
+ {
+ InitializeComponent();
+ Visibility = Visibility.Hidden;
+ }
+
+ /// <summary>
+ /// Starts the asynchronous operation.
+ /// </summary>
+ /// <param name="asyncOperationToStart">Async operation context.</param>
+ public void StartAsyncOperation(IPrintSchemaAsyncOperation asyncOperationToStart)
+ {
+ this.asyncOperationContext = asyncOperationToStart;
+ Visibility = Visibility.Visible;
+ asyncOperationToStart.Completed += asyncOperation_Completed;
+ asyncOperationToStart.Start();
+ }
+
+
+ /// <summary>
+ /// This method is invoked from a different thread once asynchronous validation is completed.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void asyncOperation_Completed(object sender, PrintSchemaAsyncOperationEventArgs e)
+ {
+ ValidationHResult = e.StatusHResult;
+ HideWindow();
+
+ if (Completed != null)
+ {
+ Completed(this, e);
+ }
+ }
+
+ /// <summary>
+ /// Hides the current window.
+ /// </summary>
+ private void HideWindow()
+ {
+ this.Dispatcher.Invoke(new Action(() =>
+ {
+ Visibility = Visibility.Hidden;
+ }));
+ }
+
+
+ /// <summary>
+ /// Result of the validation operation.
+ /// </summary>
+ public int ValidationHResult
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Invoked then the "Cancel" button is clicked.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void CancelValidationButton_Click(object sender, RoutedEventArgs e)
+ {
+ asyncOperationContext.Cancel();
+ HideWindow();
+ }
+
+ /// <summary>
+ /// Invoked when the asynchronous operation is completed.
+ /// </summary>
+ public event EventHandler<PrintSchemaAsyncOperationEventArgs> Completed;
+
+ /// <summary>
+ /// Asynchronous operation context.
+ /// </summary>
+ private IPrintSchemaAsyncOperation asyncOperationContext;
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs
new file mode 100644
index 00000000..fe830921
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs
@@ -0,0 +1,83 @@
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
+// PARTICULAR PURPOSE.
+//
+// Copyright (c) Microsoft Corporation. All rights reserved
+//
+//
+// Abstract:
+//
+// This file contains helper methods that provide a friendly way to access win32 window functions.
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Microsoft.Samples.Printing.PrinterExtension.Helpers
+{
+ class WindowHelper
+ {
+ /// <summary>
+ /// P/Invoke signature for Win32 function "SetForegroundWindow".
+ /// </summary>
+ /// <param name="hwnd">Handle to window</param>
+ [return: MarshalAs(UnmanagedType.Bool)]
+ [DllImport("User32", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
+ public static extern bool SetForegroundWindow(IntPtr hwnd);
+
+ /// <summary>
+ /// Wrapper for Win32 function "FlashWindowEx"
+ /// </summary>
+ /// <param name="hWnd">Handle of the window to flash</param>
+ public static bool FlashWindow(IntPtr hWnd)
+ {
+ FLASHWINFO fInfo = new FLASHWINFO();
+
+ fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
+ fInfo.hwnd = hWnd; // Handle to window
+ fInfo.uCount = UInt32.MaxValue; // Number of times to flash
+ fInfo.dwTimeout = 0; // Use default cursor blink rate
+ // Flash both window caption and taskbar button, until the window is brought to the foreground.
+ fInfo.dwFlags = (uint)(FLASHW.ALL | FLASHW.TIMERNOFG);
+
+ return FlashWindowEx(ref fInfo);
+ }
+
+ #region private members
+
+ /// <summary>
+ /// P/Invoke signature for Win32 function "FlashWindowEx".
+ /// </summary>
+ [return: MarshalAs(UnmanagedType.Bool)]
+ [DllImport("User32", CharSet = CharSet.Auto, SetLastError = false, ExactSpelling = true)]
+ private static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct FLASHWINFO
+ {
+ public UInt32 cbSize;
+ public IntPtr hwnd;
+ public UInt32 dwFlags;
+ public UInt32 uCount;
+ public UInt32 dwTimeout;
+ }
+
+ /// <summary>
+ /// Represents the FLASH_Xxx flags
+ /// </summary>
+ [Flags]
+ private enum FLASHW : uint
+ {
+ /// <summary>
+ /// Flash both the window caption and taskbar button
+ /// </summary>
+ ALL = 3,
+ /// <summary>
+ /// Flash continuously until the window comes to the foreground.
+ /// </summary>
+ TIMERNOFG = 12
+ }
+
+ #endregion
+ }
+}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config
new file mode 100644
index 00000000..bfc57c55
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<configuration>
+ <appSettings>
+ <add key="UseSetWindowPosForTopmostWindows" value="True" />
+ </appSettings>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+ </startup>
+</configuration>
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml
new file mode 100644
index 00000000..b1a685f1
--- /dev/null
+++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<bidi:Get xmlns:bidi="http://schemas.microsoft.com/windows/2005/03/printing/bidi">
+ <Query schema="\Printer.Consumables">
+ <Schema name="\Printer.Consumables.BlackInk:Color">
+ <BIDI_STRING>Black</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.BlackInk:Installed">
+ <BIDI_BOOL>true</BIDI_BOOL>
+ </Schema>
+ <Schema name="\Printer.Consumables.BlackInk:Level">
+ <BIDI_INT>86</BIDI_INT>
+ </Schema>
+ <Schema name="\Printer.Consumables.BlackInk:Type">
+ <BIDI_STRING>InkSupply</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.CyanInk:Color">
+ <BIDI_STRING>Cyan</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.CyanInk:Installed">
+ <BIDI_BOOL>true</BIDI_BOOL>
+ </Schema>
+ <Schema name="\Printer.Consumables.CyanInk:Level">
+ <BIDI_INT>79</BIDI_INT>
+ </Schema>
+ <Schema name="\Printer.Consumables.CyanInk:Type">
+ <BIDI_STRING>InkSupply</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.LightBlackInk:Color">
+ <BIDI_STRING>LightBlack</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.LightBlackInk:Installed">
+ <BIDI_BOOL>true</BIDI_BOOL>
+ </Schema>
+ <Schema name="\Printer.Consumables.LightBlackInk:Level">
+ <BIDI_INT>0</BIDI_INT>
+ </Schema>
+ <Schema name="\Printer.Consumables.LightBlackInk:Type">
+ <BIDI_STRING>InkSupply</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.MagentaInk:Color">
+ <BIDI_STRING>Magenta</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.MagentaInk:Installed">
+ <BIDI_BOOL>true</BIDI_BOOL>
+ </Schema>
+ <Schema name="\Printer.Consumables.MagentaInk:Level">
+ <BIDI_INT>79</BIDI_INT>
+ </Schema>
+ <Schema name="\Printer.Consumables.MagentaInk:Type">
+ <BIDI_STRING>InkSupply</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.PrintHead:Installed">
+ <BIDI_BOOL>true</BIDI_BOOL>
+ </Schema>
+ <Schema name="\Printer.Consumables.PrintHead:Level">
+ <BIDI_INT>-1</BIDI_INT>
+ </Schema>
+ <Schema name="\Printer.Consumables.PrintHead:Type">
+ <BIDI_STRING>PrintHead</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.YellowInk:Color">
+ <BIDI_STRING>Yellow</BIDI_STRING>
+ </Schema>
+ <Schema name="\Printer.Consumables.YellowInk:Installed">
+ <BIDI_BOOL>true</BIDI_BOOL>
+ </Schema>
+ <Schema name="\Printer.Consumables.YellowInk:Level">
+ <BIDI_INT>87</BIDI_INT>
+ </Schema>
+ <Schema name="\Printer.Consumables.YellowInk:Type">
+ <BIDI_STRING>InkSupply</BIDI_STRING>
+ </Schema>
+ </Query>
+</bidi:Get>