From cbbd53eda55fbdf65f22b5f57c7dbc4b1ea594fd Mon Sep 17 00:00:00 2001
From: alexke-dev <65682333+alexke-dev@users.noreply.github.com>
Date: Thu, 10 Aug 2023 16:28:02 -0700
Subject: Remove Print Driver Samples (#1017)
* Remove print driver samples. Add README.md to redirect consumers to Print Support App (PSA) development guide.
* Remove en-us from URL.
---
.../ExtensionSample/App.xaml | 7 -
.../ExtensionSample/App.xaml.cs | 146 --
.../ExtensionSample/BidiHelper.cs | 154 --
.../ExtensionSample/Fabrikam_Logo.png | Bin 2589 -> 0 bytes
.../ExtensionSample/PrintPreferenceWindow.xaml | 147 --
.../ExtensionSample/PrintPreferenceWindow.xaml.cs | 467 -----
.../ExtensionSample/PrintSchemaHelper.cs | 190 --
.../ExtensionSample/PrinterExtensionSample.csproj | 285 ---
.../ExtensionSample/Properties/AssemblyInfo.cs | 62 -
.../Properties/Resources.Designer.cs | 63 -
.../ExtensionSample/Properties/Resources.resx | 117 --
.../Properties/Settings.Designer.cs | 26 -
.../ExtensionSample/Properties/Settings.settings | 7 -
.../ExtensionSample/Strings.Designer.cs | 82 -
.../ExtensionSample/Strings.resx | 129 --
.../ExtensionSample/ValidationModalDialog.xaml | 19 -
.../ExtensionSample/ValidationModalDialog.xaml.cs | 108 --
.../ExtensionSample/WindowHelper.cs | 83 -
.../ExtensionSample/app.config | 9 -
.../ExtensionSample/bidi_Ink_mock.xml | 74 -
.../PrinterExtensionAdapters.cs | 2051 --------------------
.../PrinterExtensionLibrary.csproj | 101 -
.../PrinterExtensionManager.cs | 121 --
.../PrinterExtensionTypes.cs | 921 ---------
.../Properties/AssemblyInfo.cs | 33 -
.../PrinterExtensionSample.sln | 149 --
.../PrinterExtensionSample/README.md | 22 -
27 files changed, 5573 deletions(-)
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Fabrikam_Logo.png
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintSchemaHelper.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.Designer.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.resx
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.Designer.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.settings
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.resx
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionAdapters.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionManager.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionTypes.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/Properties/AssemblyInfo.cs
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln
delete mode 100644 print/v4PrintDriverSamples/PrinterExtensionSample/README.md
(limited to 'print/v4PrintDriverSamples/PrinterExtensionSample')
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml
deleted file mode 100644
index f97fc473..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs
deleted file mode 100644
index d37585c4..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/App.xaml.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-// 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
-{
- ///
- /// Interaction logic for App.xaml.
- ///
- public partial class App : Application
- {
- ///
- /// This is the event handler invoked on various driver events.
- ///
- ///
- ///
- 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.
- //
- }
- }
-
- ///
- /// Perform initialization tasks for the printer extension in this event handler.
- ///
- ///
- ///
- 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));
- }
-
- ///
- /// Perform uninitialization tasks for the printer extension in this event handler.
- ///
- ///
- ///
- private void Application_Exit(object sender, ExitEventArgs e)
- {
- manager.OnDriverEvent -= OnDriverEvent;
- manager.DisableEvents();
-
- manager = null;
- }
-
- ///
- /// 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.
- ///
- private const string PrinterDriverID = "{E0691E8D-F7CC-456E-A7B5-D1FC19BA2279}";
-
- ///
- /// Instance of the PrinterExtensionManager. It is recommended that you have only instance
- /// of the PrinterExtensionManager per application instance.
- ///
- private static PrinterExtensionManager manager = null;
- }
-}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs
deleted file mode 100644
index c975ee7c..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/BidiHelper.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-// 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
-{
- ///
- /// Provide a data-binding friendly way to access and parse bidi response data.
- ///
- public class BidiHelper
- {
- ///
- /// Parse the bidi response.
- ///
- /// Bidi response XML data.
- 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);
- }
-
- ///
- /// Get the Cyan ink level.
- ///
- public double InkLevelC
- {
- get;
- private set;
- }
-
- ///
- /// Get the Magenta ink level.
- ///
- public double InkLevelM
- {
- get;
- private set;
- }
-
- ///
- /// Get the Yellow ink level.
- ///
- public double InkLevelY
- {
- get;
- private set;
- }
-
- ///
- /// Get the Black ink level.
- ///
- public double InkLevelK
- {
- get;
- private set;
- }
- }
-
- ///
- /// This class parses bidi response xml data and provides wrapper methods that operate upon the xml.
- ///
- internal class BidiResponseParser
- {
- ///
- /// Parse the bidi response.
- ///
- /// Bidi response XML data.
- 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");
- }
-
- ///
- /// Get the ink level for a given color.
- ///
- /// Color
- /// Ink level percentage
- internal double GetInkLevel(Color color)
- {
- XmlElement root = bidiData.DocumentElement;
- XmlNode inkNode = root.SelectSingleNode(CreateInkXPathQuery(color), namespaceManager);
- return double.Parse(inkNode.FirstChild.Value) / 100;
- }
-
- ///
- /// Create an XPath query that retrieves the ink level from a standard bidi response.
- ///
- ///
- ///
- 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
deleted file mode 100644
index 196cd5f6..00000000
Binary files a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Fabrikam_Logo.png and /dev/null differ
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml
deleted file mode 100644
index 924efc21..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs
deleted file mode 100644
index a6266662..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintPreferenceWindow.xaml.cs
+++ /dev/null
@@ -1,467 +0,0 @@
-// 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
-{
- ///
- /// Interaction logic for PrintPreferenceWindow.xaml.
- ///
- public partial class PrintPreferenceWindow : Window, INotifyPropertyChanged
- {
- public PrintPreferenceWindow()
- {
- InitializeComponent();
- }
-
- ///
- /// This method sets up data binding sources and performs other initialization tasks.
- ///
- ///
- 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
-
- ///
- /// This event handler is invoked when the window is closing. It is important to Cancel or Complete the request when the window is closing.
- ///
- ///
- ///
- 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;
- }
- }
-
- ///
- /// Button click event handler.
- ///
- ///
- ///
- 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;
- }
- }
-
- ///
- /// Close the window in a thread-safe way.
- ///
- private void CloseWindow()
- {
- this.Dispatcher.BeginInvoke(new Action(() =>
- {
- this.Close();
- }));
- }
-
- #endregion
-
-
- #region Data binding sources
-
- ///
- /// The Print queue for which this window is being displayed.
- ///
- public IPrinterQueue PrinterQueue { get; private set; }
-
- ///
- /// The title for the ink status display.
- ///
- public string InkStatusTitle { get; private set; }
-
- ///
- /// 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.
- ///
- 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);
- }
- }
-
- ///
- /// Encapsulates the information required to populate ink level.
- ///
- public BidiHelper BidiHelperSource { get; private set; }
-
- ///
- /// This event is raised when a data from a binding source is modified.
- ///
- public event PropertyChangedEventHandler PropertyChanged;
-
- #endregion
-
- #region Ink level display
- ///
- /// This is the method invoked when a bidi response is received.
- ///
- /// IPrinterQueue object.
- /// The results of the bidi response.
- 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)";
- }
-
- ///
- /// This method is invoked when there is an error retrieving Bidi information.
- /// A mock bidi response is loaded from resource and displayed.
- ///
- 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
- ///
- /// Cancel the current printer extension event and close the current window.
- ///
- private void CancelRequestAndCloseWindow()
- {
- printerExtensionEventArgs.Request.Cancel((int)HRESULT.S_FALSE, "User canceled the operation");
- requestCompleted = true;
- CloseWindow();
- }
-
- ///
- /// Invoked when asynchronous print ticket validation is complete.
- ///
- ///
- ///
- 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);
- }));
- }
- }
-
- ///
- /// Invoked when there are constraints in the print ticket selections.
- ///
- ///
- 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"));
- }
- }
-
- ///
- /// Commits the input print ticket asynchronously. The completed event handler is expected to close the window.
- ///
- ///
- private void CommitPrintTicketAsync(IPrintSchemaTicket validatedTicket)
- {
- IPrintSchemaAsyncOperation commitAsyncOperation = printerExtensionEventArgs.Ticket.CommitAsync(validatedTicket);
- commitAsyncOperation.Completed += PrintTicketCommitCompleted;
- commitAsyncOperation.Start();
- }
-
- ///
- /// Invoked when the user's selections have been committed into the print ticket.
- ///
- ///
- ///
- private void PrintTicketCommitCompleted(object sender, PrintSchemaAsyncOperationEventArgs e)
- {
- CompleteRequestAndCloseWindow();
- }
-
- ///
- /// Complete the current printer extension request and close the current window.
- ///
- 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();
- }
-
- ///
- /// 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()
- ///
- 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
-
- ///
- /// The arguments passed in for this print preferences event.
- ///
- private PrinterExtensionEventArgs printerExtensionEventArgs = null;
-
- ///
- /// Reflects the currently displayed print preference options.
- ///
- private IPrintSchemaTicket displayedPrintTicket = null;
-
- ///
- /// Determines if IPrinterExtensionRequest::Complete()/Cancel() has been invoked for this Window.
- /// instance
- ///
- private bool requestCompleted = false;
- }
-
- ///
- /// This class transforms the boolean 'IPrintSchemaOption.Constrained' into a visual form.
- ///
- 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();
- }
- }
-
- ///
- /// Provides a friendlier way to use HRESULT error codes.
- ///
- 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
deleted file mode 100644
index e9201162..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrintSchemaHelper.cs
+++ /dev/null
@@ -1,190 +0,0 @@
-// 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
-{
- ///
- /// Contains helper methods that provide a data-binding friendly way to access PrintSchema APIs.
- ///
- public class PrintSchemaHelper
- {
- ///
- /// Constructor. Warning constructing this object is expensive, and is best performed
- /// asynchronously.
- ///
- /// The print ticket for which features/options will be retrieved
- /// List of features requested
- internal PrintSchemaHelper(IPrintSchemaTicket ticket, IEnumerable featureNameCollection)
- {
- _ticket = ticket;
- _featureNameCollection = featureNameCollection;
- _capabilities = _ticket.GetCapabilities();
- }
-
- ///
- /// Retrieve the list of features from the current print ticket.
- ///
- public List Features
- {
- get
- {
- _featureHelperCollection = new List();
-
- //
- // 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;
- }
- }
-
- ///
- /// List of features requested.
- ///
- private IEnumerable _featureNameCollection;
-
- ///
- /// Helper objects that wrap an IPrintSchemaFeature object.
- ///
- private List _featureHelperCollection = null;
-
- ///
- /// Print ticket passed into this class.
- ///
- private IPrintSchemaTicket _ticket = null;
-
- ///
- /// Print capabilities object.
- ///
- private IPrintSchemaCapabilities _capabilities = null;
- }
-
- ///
- /// 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.
- ///
- public class PrintSchemaFeatureHelper
- {
- ///
- /// Constructor
- ///
- /// Object retrieved via a call to IPrintSchemaTicket::GetFeature/GetFeatureByKeyName
- /// Print capabilities object
- /// Object retrieved via a call to IPrintSchemaCapabilities::GetFeature/GetFeatureByKeyName
- internal PrintSchemaFeatureHelper(IPrintSchemaFeature ticketFeature, IPrintSchemaCapabilities capabilities, IPrintSchemaFeature capabilitiesFeature)
- {
- //
- // Populate the properties exposed by this class.
- //
-
- DisplayName = capabilitiesFeature.DisplayName;
- Options = new List(capabilities.GetOptions(ticketFeature));
-
- foreach (IPrintSchemaOption option in Options)
- {
- if (option.Selected)
- {
- _selectedOption = option;
- break;
- }
- }
-
- _printTicketFeature = ticketFeature;
- }
-
- ///
- /// Returns the display name for the current IPrintSchemaFeature object.
- ///
- public string DisplayName
- {
- get;
- private set;
- }
-
- ///
- /// Retrieve the list of options supported for the current feature.
- ///
- public List Options
- {
- get;
- private set;
- }
-
- ///
- /// 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.
- ///
- public IPrintSchemaOption SelectedOption
- {
- get
- {
- return _selectedOption;
- }
- set
- {
- _selectedOption = value;
- _printTicketFeature.SelectedOption = _selectedOption;
- }
- }
-
- ///
- /// Feature object retrieved from the print ticket.
- ///
- private IPrintSchemaFeature _printTicketFeature = null;
-
- ///
- /// Selected option for the print ticket feature.
- ///
- private IPrintSchemaOption _selectedOption = null;
-
- }
-}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj
deleted file mode 100644
index 293ca0e4..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj
+++ /dev/null
@@ -1,285 +0,0 @@
-
-
-
- Debug
- x86
- 8.0.30703
- 2.0
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}
- WinExe
- Properties
- PrinterExtensionSample
- PrinterExtensionSample
- v4.0
-
-
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
-
-
- bin\Win8 Debug\
- DEBUG;TRACE
- x86
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\Win8 Release\
- TRACE
- x86
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
- bin\x64\Win8 Debug\
- DEBUG;TRACE
- x64
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\x64\Win8 Release\
- TRACE
- x64
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
- bin\Win8.1 Debug\
- DEBUG;TRACE
- x86
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\Win8.1 Release\
- TRACE
- x86
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
- bin\x64\Win8.1 Debug\
- DEBUG;TRACE
- x64
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\x64\Win8.1 Release\
- TRACE
- x64
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
- bin\Win10 Debug\
- DEBUG;TRACE
- x86
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\Win10 Release\
- TRACE
- x86
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
- bin\x64\Win10 Debug\
- DEBUG;TRACE
- x64
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\x64\Win10 Release\
- TRACE
- x64
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
- bin\ARM64\Win10 Debug\
- DEBUG;TRACE
- ARM64
- true
- full
- false
- prompt
- 4
- false
-
-
- bin\ARM64\Win10 Release\
- TRACE
- ARM64
- true
- pdbonly
- true
- prompt
- 4
- false
-
-
-
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
-
-
- True
- True
- Strings.resx
-
-
- ValidationModalDialog.xaml
-
-
- MSBuild:Compile
- Designer
-
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
- PrintPreferenceWindow.xaml
- Code
-
-
- MSBuild:Compile
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
- ResXFileCodeGenerator
- Strings.Designer.cs
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
-
-
-
- {d8da0c4d-f972-4546-9068-8eb256f222f7}
- PrinterExtensionLibrary
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs
deleted file mode 100644
index c3198284..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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
-//CultureYouAreCodingWith in your .csproj file
-//inside a . For example, if you are using US english
-//in your source files, set the 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
deleted file mode 100644
index b6af3bc4..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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.
-//
-//------------------------------------------------------------------------------
-
-namespace PrinterExtensionSample.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // 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() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [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;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [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
deleted file mode 100644
index af7dbebb..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ 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
deleted file mode 100644
index c0a373ef..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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.
-//
-//------------------------------------------------------------------------------
-
-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
deleted file mode 100644
index 033d7a5e..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs
deleted file mode 100644
index 6ea88a35..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.Designer.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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.
-//
-//------------------------------------------------------------------------------
-
-namespace PrinterExtensionSample {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // 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() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [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;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to Selection conflicts were encountered.
- ///Would you like them auto-resolved?.
- ///
- internal static string SelectionConflictsFound {
- get {
- return ResourceManager.GetString("SelectionConflictsFound", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Selection conflicts.
- ///
- 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
deleted file mode 100644
index 8f4878a4..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/Strings.resx
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- Selection conflicts were encountered.
-Would you like them auto-resolved?
- String to display in the message box when print ticket settings have conflicts.
-
-
- Selection conflicts
- Title string on the message box that displays the selection conflicts message.
-
-
\ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml
deleted file mode 100644
index c949efd4..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
- Validating.. please wait
-
-
-
-
-
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs
deleted file mode 100644
index 0728c84c..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/ValidationModalDialog.xaml.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-// 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
-{
- ///
- /// Interaction logic for ValidationModalDialog.xaml
- /// This dialog prevents the user from changing print preferences when validation is in progress.
- ///
- public partial class ValidationModalDialog : UserControl
- {
- public ValidationModalDialog()
- {
- InitializeComponent();
- Visibility = Visibility.Hidden;
- }
-
- ///
- /// Starts the asynchronous operation.
- ///
- /// Async operation context.
- public void StartAsyncOperation(IPrintSchemaAsyncOperation asyncOperationToStart)
- {
- this.asyncOperationContext = asyncOperationToStart;
- Visibility = Visibility.Visible;
- asyncOperationToStart.Completed += asyncOperation_Completed;
- asyncOperationToStart.Start();
- }
-
-
- ///
- /// This method is invoked from a different thread once asynchronous validation is completed.
- ///
- ///
- ///
- private void asyncOperation_Completed(object sender, PrintSchemaAsyncOperationEventArgs e)
- {
- ValidationHResult = e.StatusHResult;
- HideWindow();
-
- if (Completed != null)
- {
- Completed(this, e);
- }
- }
-
- ///
- /// Hides the current window.
- ///
- private void HideWindow()
- {
- this.Dispatcher.Invoke(new Action(() =>
- {
- Visibility = Visibility.Hidden;
- }));
- }
-
-
- ///
- /// Result of the validation operation.
- ///
- public int ValidationHResult
- {
- get;
- private set;
- }
-
- ///
- /// Invoked then the "Cancel" button is clicked.
- ///
- ///
- ///
- private void CancelValidationButton_Click(object sender, RoutedEventArgs e)
- {
- asyncOperationContext.Cancel();
- HideWindow();
- }
-
- ///
- /// Invoked when the asynchronous operation is completed.
- ///
- public event EventHandler Completed;
-
- ///
- /// Asynchronous operation context.
- ///
- private IPrintSchemaAsyncOperation asyncOperationContext;
- }
-}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs
deleted file mode 100644
index fe830921..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/WindowHelper.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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
- {
- ///
- /// P/Invoke signature for Win32 function "SetForegroundWindow".
- ///
- /// Handle to window
- [return: MarshalAs(UnmanagedType.Bool)]
- [DllImport("User32", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
- public static extern bool SetForegroundWindow(IntPtr hwnd);
-
- ///
- /// Wrapper for Win32 function "FlashWindowEx"
- ///
- /// Handle of the window to flash
- 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
-
- ///
- /// P/Invoke signature for Win32 function "FlashWindowEx".
- ///
- [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;
- }
-
- ///
- /// Represents the FLASH_Xxx flags
- ///
- [Flags]
- private enum FLASHW : uint
- {
- ///
- /// Flash both the window caption and taskbar button
- ///
- ALL = 3,
- ///
- /// Flash continuously until the window comes to the foreground.
- ///
- TIMERNOFG = 12
- }
-
- #endregion
- }
-}
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config
deleted file mode 100644
index bfc57c55..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/app.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml
deleted file mode 100644
index b1a685f1..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/bidi_Ink_mock.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
- Black
-
-
- true
-
-
- 86
-
-
- InkSupply
-
-
- Cyan
-
-
- true
-
-
- 79
-
-
- InkSupply
-
-
- LightBlack
-
-
- true
-
-
- 0
-
-
- InkSupply
-
-
- Magenta
-
-
- true
-
-
- 79
-
-
- InkSupply
-
-
- true
-
-
- -1
-
-
- PrintHead
-
-
- Yellow
-
-
- true
-
-
- 87
-
-
- InkSupply
-
-
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionAdapters.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionAdapters.cs
deleted file mode 100644
index 60277c61..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionAdapters.cs
+++ /dev/null
@@ -1,2051 +0,0 @@
-// 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 Adapters that wrap the PrinterExtension COM Interop types.
-//
-using System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Runtime;
-using System.Runtime.InteropServices;
-using Microsoft.Samples.Printing.PrinterExtension.Types;
-
-namespace Microsoft.Samples.Printing.PrinterExtension
-{
- // The following three classes are constructable adapters for the root of the
- // object model. The balance of the types will typically be interfaces. This
- // choice was made so we can share the interface file between projects and enforce
- // the same public surface from both the "Reference" and "Implementation" projects.
-
- #region PrinterExtension adapter classes
-
- ///
- /// Wraps an COM pointer to IPrinterExtensionContext
- ///
- public class PrinterExtensionContext : IPrinterExtensionContext
- {
- ///
- /// Wraps an opaque COM pointer to IPrinterExtensionContext and provides usable methods
- ///
- /// Opaque COM pointer to IPrinterExtensionContext
- public PrinterExtensionContext(Object comContext)
- {
- _context = (PrinterExtensionLib.IPrinterExtensionContext)comContext;
- }
-
- #region IPrinterExtensionContext methods
-
- ///
- /// Maps to COM IPrinterExtensionContext::PrinterQueue
- ///
- public IPrinterQueue Queue
- {
- get { return new PrinterQueue(_context.PrinterQueue); }
- }
-
- ///
- /// Maps to COM IPrinterExtensionContext::PrintSchemaTicket
- ///
- public IPrintSchemaTicket Ticket
- {
- get { return new PrintSchemaTicket(_context.PrintSchemaTicket); }
- }
-
- ///
- /// Maps to COM IPrinterExtensionContext::DriverProperties
- ///
- public IPrinterPropertyBag DriverProperties
- {
- get
- {
- try
- {
- return new PrinterPropertyBag(_context.DriverProperties, PrintPropertyBagType.DriverProperties);
- }
- catch (Exception)
- {
- // If the property bag is not found, instead of
- // throwing an exception, return null, which is more appropriate for a property 'get' operation.
- return null;
- }
- }
- }
-
- ///
- /// Maps to COM IPrinterExtensionContext::UserProperties
- ///
- public IPrinterPropertyBag UserProperties
- {
- get { return new PrinterPropertyBag(_context.UserProperties, PrintPropertyBagType.UserProperties); }
- }
-
- #endregion
-
- #region Implementation details
-
- private PrinterExtensionLib.IPrinterExtensionContext _context;
-
- // Prevent default construction
- private PrinterExtensionContext()
- {
- }
-
- #endregion
- }
-
- ///
- /// Wraps an COM pointer to IPrinterExtensionEventArgs
- ///
- public class PrinterExtensionEventArgs : EventArgs, IPrinterExtensionEventArgs
- {
- ///
- /// Wraps an opaque COM pointer to IPrinterExtensionEventArgs and provides usable methods
- ///
- /// Opaque COM pointer to IPrinterExtensionEventArgs
- public PrinterExtensionEventArgs(Object eventArgs)
- {
- _eventArgs = (PrinterExtensionLib.IPrinterExtensionEventArgs)eventArgs;
- _context = new PrinterExtensionContext(eventArgs);
- }
-
- #region IPrinterExtensionEventArgs methods
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::BidiNotification
- ///
- public string BidiNotification
- {
- get { return _eventArgs.BidiNotification; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::ReasonId
- ///
- public Guid ReasonId
- {
- get { return _eventArgs.ReasonId; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::Request
- ///
- public IPrinterExtensionRequest Request
- {
- get { return new PrinterExtensionRequest(_eventArgs.Request); }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::SourceApplication
- ///
- public string SourceApplication
- {
- get { return _eventArgs.SourceApplication; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::DetailedReasonId
- ///
- public Guid DetailedReasonId
- {
- get { return _eventArgs.DetailedReasonId; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::WindowModal
- ///
- public bool WindowModal
- {
- get
- {
- if (_eventArgs.WindowModal != 0)
- {
- return true;
- }
- return false;
- }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::WindowParent
- ///
- public IntPtr WindowParent
- {
- get { return _eventArgs.WindowParent; }
- }
-
- #endregion
-
- #region IPrinterExtensionContext methods
-
- ///
- /// Maps to COM IPrinterExtensionContext::PrinterQueue
- ///
- public IPrinterQueue Queue
- {
- get { return _context.Queue; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionContext::PrintSchemaTicket
- ///
- public IPrintSchemaTicket Ticket
- {
- get { return _context.Ticket; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionContext::DriverProperties
- ///
- public IPrinterPropertyBag DriverProperties
- {
- get { return _context.DriverProperties; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionContext::UserProperties
- ///
- public IPrinterPropertyBag UserProperties
- {
- get { return _context.UserProperties; }
- }
-
- #endregion
-
- #region Implementation details
-
- private PrinterExtensionLib.IPrinterExtensionEventArgs _eventArgs;
-
- ///
- /// Containment - since multiple inheritance is not possible in C#.
- ///
- private PrinterExtensionContext _context;
-
- #endregion
- }
-
- ///
- /// This class provides wraps IPrinterExtensionContextCollection in a IEnumerable interface
- ///
- public sealed class PrinterQueuesEnumeratedEventArgs : EventArgs, IEnumerable
- {
-
- #region IEnumerable methods
-
- public IEnumerator GetEnumerator()
- {
- for (uint i = 0; i < _contextCollection.Count; i++)
- {
- yield return new PrinterExtensionContext(_contextCollection.GetAt(i));
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return (IEnumerator)GetEnumerator();
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrinterQueuesEnumeratedEventArgs(PrinterExtensionLib.IPrinterExtensionContextCollection contextCollection)
- {
- _contextCollection = contextCollection;
- }
-
- private PrinterExtensionLib.IPrinterExtensionContextCollection _contextCollection;
-
- #endregion
- }
-
-#if WINDOWS_81_APIS
- internal sealed class PrinterExtensionAsyncOperation : IPrinterExtensionAsyncOperation
- {
- #region IPrinterExtensionAsyncOperation methods
-
- public void Cancel()
- {
- _asyncOperation.Cancel();
- }
-
- #endregion
-
- #region Implementation methods
-
- internal PrinterExtensionAsyncOperation(PrinterExtensionLib.IPrinterExtensionAsyncOperation asyncOperation)
- {
- _asyncOperation = asyncOperation;
- }
-
- private PrinterExtensionLib.IPrinterExtensionAsyncOperation _asyncOperation;
-
- #endregion
- }
-#endif
- #endregion
-
- #region COM Adapter Classes
-
- //
- // The following class provide an adapter that exposes a 'Stream' and wraps a
- // COM pointer to PrinterExtensionLib.IStream
- //
- internal class PrinterExtensionLibIStreamAdapter : Stream, IDisposable
- {
- public PrinterExtensionLibIStreamAdapter(PrinterExtensionLib.IStream stream, bool canWrite = false, bool canSeek = false, bool canRead = true)
- {
- if (stream != null)
- {
- _printerExtensionIStream = stream;
- }
- else
- {
- throw new ArgumentNullException("stream");
- }
- _streamValidation = new StreamValidation(canWrite, canSeek, canRead);
- }
-
- ~PrinterExtensionLibIStreamAdapter()
- {
- Dispose(false);
- }
-
- #region Overridden Stream methods
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- _streamValidation.ValidateRead(buffer, offset, count);
-
- uint bytesRead = 0;
-
- // Pin the byte array so that it will not be moved by the garbage collector
- byte[] tempBuffer = new byte[count];
- GCHandle gcHandle = GCHandle.Alloc(tempBuffer, GCHandleType.Pinned);
- try
- {
- _printerExtensionIStream.RemoteRead(out tempBuffer[0], Convert.ToUInt32(count), out bytesRead);
-
- Array.Copy(tempBuffer, 0, buffer, offset, (int)bytesRead); // Safe to cast. Cannot be bigger than 'int count'
- }
- finally
- {
- gcHandle.Free();
- }
-
- return (int)bytesRead; // Safe to cast; bytesRead can never be larger than 'int count'
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- _streamValidation.ValidateWrite(buffer, offset, count);
-
- uint written;
-
- // Pin the byte array so that it will not be moved by the garbage collector
- byte[] tempBuffer = new byte[count];
- GCHandle gcHandle = GCHandle.Alloc(tempBuffer, GCHandleType.Pinned);
- try
- {
- Array.Copy(buffer, offset, tempBuffer, 0, count);
- _printerExtensionIStream.RemoteWrite(ref tempBuffer[0], Convert.ToUInt32(count), out written);
- }
- finally
- {
- gcHandle.Free();
- }
-
- if ((int)written < count)
- {
- throw new IOException();
- }
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- _streamValidation.ValidateSeek(offset, origin);
-
- uint istreamSeekOrigin = 0;
-
- switch (origin)
- {
- case SeekOrigin.Begin:
- istreamSeekOrigin = (uint)PrinterExtensionLib.tagSTREAM_SEEK.STREAM_SEEK_SET;
- break;
-
- case SeekOrigin.Current:
- istreamSeekOrigin = (uint)PrinterExtensionLib.tagSTREAM_SEEK.STREAM_SEEK_CUR;
- break;
-
- case SeekOrigin.End:
- istreamSeekOrigin = (uint)PrinterExtensionLib.tagSTREAM_SEEK.STREAM_SEEK_END;
- break;
- }
-
- PrinterExtensionLib._LARGE_INTEGER dlibMove;
- PrinterExtensionLib._ULARGE_INTEGER plibNewPosition;
-
- dlibMove.QuadPart = offset;
-
- _printerExtensionIStream.RemoteSeek(dlibMove, istreamSeekOrigin, out plibNewPosition);
- return Convert.ToInt64(plibNewPosition.QuadPart);
- }
-
- public override long Length
- {
- get
- {
- _streamValidation.ValidateSeek();
-
- PrinterExtensionLib.tagSTATSTG statstg;
- _printerExtensionIStream.Stat(out statstg, 1 /* STATSFLAG_NONAME*/ );
- return Convert.ToInt64(statstg.cbSize.QuadPart);
- }
- }
- public override long Position
- {
- get { return Seek(0, SeekOrigin.Current); }
- set { Seek(value, SeekOrigin.Begin); }
- }
-
- public override void SetLength(long value)
- {
- _streamValidation.ValidateSeek();
-
- PrinterExtensionLib._ULARGE_INTEGER libNewSize;
- libNewSize.QuadPart = Convert.ToUInt64(value);
- _printerExtensionIStream.SetSize(libNewSize);
- }
-
- public override void Flush()
- {
- _printerExtensionIStream.Commit(0);
- }
-
- public override bool CanRead
- {
- get { return _streamValidation.CanRead; }
- }
-
- public override bool CanWrite
- {
- get { return _streamValidation.CanWrite; }
- }
-
- public override bool CanSeek
- {
- get { return _streamValidation.CanSeek; }
- }
-
- #endregion
-
- #region IDisposable methods
-
- protected override void Dispose(bool disposing)
- {
- if (_disposed)
- {
- return;
- }
-
- try
- {
- if (disposing)
- {
- _streamValidation.Dispose();
- }
-
- if (_printerExtensionIStream != null)
- {
- Marshal.ReleaseComObject(_printerExtensionIStream);
- _printerExtensionIStream = null;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- _disposed = true;
- }
-
- #endregion
-
- #region Implementation details
-
- // Prevent default construction
- private PrinterExtensionLibIStreamAdapter() { }
-
- private bool _disposed = false;
- private PrinterExtensionLib.IStream _printerExtensionIStream = null;
- private StreamValidation _streamValidation = null;
-
- #endregion
- }
-
-
- //
- // The following class provide an adapter that exposes a 'Stream' and wraps a
- // COM pointer to the standard COM 'IStream' interface
- //
- internal class ComIStreamAdapter : Stream, IDisposable
- {
- public ComIStreamAdapter(System.Runtime.InteropServices.ComTypes.IStream stream, bool canWrite = false, bool canSeek = false, bool canRead = true)
- {
- if (stream != null)
- {
- _comIstream = stream;
- }
- else
- {
- throw new ArgumentNullException("stream");
- }
- _streamValidation = new StreamValidation(canWrite, canSeek, canRead);
- }
-
- ~ComIStreamAdapter()
- {
- Dispose(false);
- }
-
- #region Overridden Stream methods
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- _streamValidation.ValidateRead(buffer, offset, count);
-
- uint bytesRead = 0;
-
- // Pin the byte array so that it will not be moved by the garbage collector
- byte[] tempBuffer = new byte[count];
- GCHandle gcHandle = GCHandle.Alloc(tempBuffer, GCHandleType.Pinned);
- IntPtr bytesReadPtr = Marshal.AllocHGlobal(sizeof(int));
- try
- {
- _comIstream.Read(tempBuffer, count, bytesReadPtr);
- bytesRead = (uint)Marshal.ReadInt32(bytesReadPtr);
-
- Array.Copy(tempBuffer, 0, buffer, offset, (int)bytesRead); // Safe to cast. Cannot be bigger than 'int count'
- }
- finally
- {
- Marshal.FreeHGlobal(bytesReadPtr);
- gcHandle.Free();
- }
-
- return (int)bytesRead; // Safe to cast; bytesRead can never be larger than 'int count'
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- _streamValidation.ValidateWrite(buffer, offset, count);
-
- uint written;
-
- // Pin the byte array so that it will not be moved by the garbage collector
- byte[] tempBuffer = new byte[count];
- GCHandle gcHandle = GCHandle.Alloc(tempBuffer, GCHandleType.Pinned);
- IntPtr writeCountPointer = Marshal.AllocHGlobal(sizeof(int));
- try
- {
- Array.Copy(buffer, offset, tempBuffer, 0, count);
-
- _comIstream.Write(tempBuffer, count, writeCountPointer);
- written = (uint)Marshal.ReadInt32(writeCountPointer); // safe to cast. 'written' is always non-negative
- }
- finally
- {
- gcHandle.Free();
- Marshal.FreeHGlobal(writeCountPointer);
- }
-
- if ((int)written < count)
- {
- throw new IOException();
- }
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- _streamValidation.ValidateSeek(offset, origin);
-
- uint istreamSeekOrigin = 0;
-
- switch (origin)
- {
- case SeekOrigin.Begin:
- istreamSeekOrigin = (uint)PrinterExtensionLib.tagSTREAM_SEEK.STREAM_SEEK_SET;
- break;
-
- case SeekOrigin.Current:
- istreamSeekOrigin = (uint)PrinterExtensionLib.tagSTREAM_SEEK.STREAM_SEEK_CUR;
- break;
-
- case SeekOrigin.End:
- istreamSeekOrigin = (uint)PrinterExtensionLib.tagSTREAM_SEEK.STREAM_SEEK_END;
- break;
- }
-
- IntPtr seekPositionPointer = Marshal.AllocHGlobal(sizeof(long));
- long seekPosition = 0;
- try
- {
- _comIstream.Seek(offset, (int)istreamSeekOrigin, seekPositionPointer);
- seekPosition = Marshal.ReadInt64(seekPositionPointer);
- }
- finally
- {
- Marshal.FreeHGlobal(seekPositionPointer);
- }
-
- return seekPosition;
- }
-
- public override long Length
- {
- get
- {
- _streamValidation.ValidateSeek();
-
- System.Runtime.InteropServices.ComTypes.STATSTG statstg;
- _comIstream.Stat(out statstg, 1 /* STATSFLAG_NONAME*/ );
- return statstg.cbSize;
- }
- }
- public override long Position
- {
- get { return Seek(0, SeekOrigin.Current); }
- set { Seek(value, SeekOrigin.Begin); }
- }
-
- public override void SetLength(long value)
- {
- _streamValidation.ValidateSeek();
- _comIstream.SetSize(value);
- }
-
- public override void Flush()
- {
- _comIstream.Commit(0);
- }
-
- public override bool CanRead
- {
- get { return _streamValidation.CanRead; }
- }
-
- public override bool CanWrite
- {
- get { return _streamValidation.CanWrite; }
- }
-
- public override bool CanSeek
- {
- get { return _streamValidation.CanSeek; }
- }
-
- #endregion
-
- #region IDisposable methods
-
- protected override void Dispose(bool disposing)
- {
- if (_disposed)
- {
- return;
- }
-
- try
- {
- if (disposing)
- {
- _streamValidation.Dispose();
- }
-
- if (_comIstream != null)
- {
- Marshal.ReleaseComObject(_comIstream);
- _comIstream = null;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- _disposed = true;
- }
-
- #endregion
-
- #region Implementation details
-
- // Prevent default construction
- private ComIStreamAdapter() { }
-
- private bool _disposed = false;
- private System.Runtime.InteropServices.ComTypes.IStream _comIstream = null;
- private StreamValidation _streamValidation = null;
-
- #endregion
- }
-
- internal class StreamValidation : IDisposable
- {
- internal StreamValidation(bool canWrite = false, bool canSeek = false, bool canRead = true)
- {
- _canWrite = canWrite;
- _canSeek = canSeek;
- _canRead = canRead;
- }
-
- internal void ValidateRead(byte[] buffer, int offset, int count)
- {
- if (!_canRead)
- {
- throw new NotSupportedException();
- }
- if (_disposed == true)
- {
- throw new ObjectDisposedException("COM IStream");
- }
- if (buffer == null)
- {
- throw new ArgumentNullException("buffer");
- }
- if (offset < 0)
- {
- throw new ArgumentOutOfRangeException("offset");
- }
- if (count < 0)
- {
- throw new ArgumentOutOfRangeException("count");
- }
- if ((buffer.Length - offset) < count)
- {
- throw new ArgumentException();
- }
- }
-
- internal void ValidateWrite(byte[] buffer, int offset, int count)
- {
- if (!_canWrite)
- {
- throw new NotSupportedException();
- }
- if (_disposed == true)
- {
- throw new ObjectDisposedException("COM IStream");
- }
- if (buffer == null)
- {
- throw new ArgumentNullException("buffer");
- }
- if (offset < 0)
- {
- throw new ArgumentOutOfRangeException("offset");
- }
- if (count < 0)
- {
- throw new ArgumentOutOfRangeException("count");
- }
- if ((buffer.Length - offset) < count)
- {
- throw new ArgumentException("Insufficient buffer size");
- }
- }
-
- internal void ValidateSeek(long offset, SeekOrigin origin)
- {
- ValidateSeek();
- if ((origin < SeekOrigin.Begin) || (origin > SeekOrigin.End))
- {
- throw new ArgumentException("Invalid value", "origin");
- }
- }
-
- internal void ValidateSeek()
- {
- if (!_canSeek)
- {
- throw new NotSupportedException();
- }
- if (_disposed == true)
- {
- throw new ObjectDisposedException("COM IStream");
- }
- }
-
- public bool CanRead
- {
- get { return _canRead; }
- }
-
- public bool CanWrite
- {
- get { return _canWrite; }
- }
-
- public bool CanSeek
- {
- get { return _canSeek; }
- }
-
- #region IDisposable methods
-
- public void Dispose()
- {
- _disposed = true;
- }
-
- #endregion
-
- #region Implementation details
-
- private bool _disposed = false;
- private bool _canWrite = false;
- private bool _canSeek = false;
- private bool _canRead = true;
-
- #endregion
- }
-
- #endregion
-
- #region PrintSchema Adapter Classes
-
- //
- // Following are concrete implementation of the PrinterExtension interfaces
- // These classes wrap the underlying COM interfaces.
- //
-
- internal class PrintSchemaOption : IPrintSchemaOption
- {
-
- #region IPrintSchemaOption methods
-
- public bool Selected
- {
- get { return (0 == _option.Selected) ? false : true; }
- }
-
- public PrintSchemaConstrainedSetting Constrained
- {
- get { return (PrintSchemaConstrainedSetting)_option.Constrained; }
- }
-
- #endregion
-
- #region IPrintSchemaDisplayableElement methods
-
- public string DisplayName { get { return _option.DisplayName; } }
- public string Name { get { return _option.Name; } }
- public string XmlNamespace { get { return _option.NamespaceUri; } }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaOption(PrinterExtensionLib.IPrintSchemaOption option)
- {
- _option = option;
- }
-
- internal PrinterExtensionLib.IPrintSchemaOption InteropOption
- {
- get { return _option; }
- set { _option = value; }
- }
-
- //
- // Create the correct 'PrintSchemaOption' subclass, possibly exposing one of the these interfaces
- // 1. IPrintSchemaPageMediaSizeOption
- // 2. IPrintSchemaNUpOption
- //
- internal static IPrintSchemaOption CreateOptionSubclass(PrinterExtensionLib.IPrintSchemaOption option)
- {
- // IPrintSchemaNUpOption option
- if (option is PrinterExtensionLib.IPrintSchemaNUpOption)
- {
- return new PrintSchemaNUpOption(option);
- }
-
- // IPrintSchemaPageMediaSizeOption option
- if (option is PrinterExtensionLib.IPrintSchemaPageMediaSizeOption)
- {
- return new PrintSchemaPageMediaSizeOption(option);
- }
-
- return new PrintSchemaOption(option);
- }
-
- internal PrinterExtensionLib.IPrintSchemaOption _option;
-
- // Prevent default constuction
- private PrintSchemaOption() { }
-
- #endregion
- }
-
- internal sealed class PrintSchemaPageMediaSizeOption : PrintSchemaOption, IPrintSchemaPageMediaSizeOption
- {
- #region IPrintSchemaPageMediaSizeOption methods
-
- public uint HeightInMicrons
- {
- get { return _pageMediaSizeOption.HeightInMicrons; }
- }
-
- public uint WidthInMicrons
- {
- get { return _pageMediaSizeOption.WidthInMicrons; }
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaPageMediaSizeOption(PrinterExtensionLib.IPrintSchemaOption option)
- : base(option)
- {
- _pageMediaSizeOption = _option as PrinterExtensionLib.IPrintSchemaPageMediaSizeOption;
- if (null == _pageMediaSizeOption)
- {
- throw new NotImplementedException("Could not retrieve IPrintSchemaPageMediaSizeOption interface.");
- }
- }
-
- private PrinterExtensionLib.IPrintSchemaPageMediaSizeOption _pageMediaSizeOption;
-
- #endregion
- }
-
- internal sealed class PrintSchemaNUpOption : PrintSchemaOption, IPrintSchemaNUpOption
- {
- #region IPrintSchemaNUpOption methods
-
- public uint PagesPerSheet
- {
- get { return _nupOption.PagesPerSheet; }
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaNUpOption(PrinterExtensionLib.IPrintSchemaOption option) :
- base(option)
- {
- _nupOption = _option as PrinterExtensionLib.IPrintSchemaNUpOption;
- if (null == _nupOption)
- {
- throw new NotImplementedException("Could not retrieve IPrintSchemaNUpOption interface.");
- }
- }
-
- private PrinterExtensionLib.IPrintSchemaNUpOption _nupOption;
-
- #endregion
- }
-
- ///
- /// This class provides wraps IPrintSchemaOptionCollection in a IEnumerable interface
- ///
- internal sealed class PrintSchemaOptionsCollection : IEnumerable
- {
-
- #region IEnumerable methods
-
- public IEnumerator GetEnumerator()
- {
- for (uint i = 0; i < _optionCollection.Count; i++)
- {
- yield return new PrintSchemaOption(_optionCollection.GetAt(i));
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return (IEnumerator)GetEnumerator();
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaOptionsCollection(PrinterExtensionLib.IPrintSchemaOptionCollection optionCollection)
- {
- _optionCollection = optionCollection;
- }
-
- private PrinterExtensionLib.IPrintSchemaOptionCollection _optionCollection;
-
- #endregion
- }
-
- internal sealed class PrintSchemaFeature : IPrintSchemaFeature
- {
- #region IPrintSchemaFeature methods
-
- public PrintSchemaSelectionType SelectionType
- {
- get { return (PrintSchemaSelectionType)_feature.SelectionType; }
- }
-
- public IPrintSchemaOption GetOption(string name)
- {
- return GetOption(name, PrintSchemaConstants.KeywordsNamespaceUri);
- }
-
- public IPrintSchemaOption GetOption(string name, string xmlNamespace)
- {
- PrinterExtensionLib.IPrintSchemaOption option = _feature.GetOption(name, xmlNamespace);
- if (option != null)
- {
- return PrintSchemaOption.CreateOptionSubclass(option);
- }
-
- return null;
- }
-
- public IPrintSchemaOption SelectedOption
- {
- get
- {
- return PrintSchemaOption.CreateOptionSubclass(_feature.SelectedOption);
- }
- set
- {
- _feature.SelectedOption = (value as PrintSchemaOption).InteropOption;
- }
- }
-
- public bool DisplayUI
- {
- get
- {
- return (0 == _feature.DisplayUI) ? false : true;
- }
- }
-
- #endregion
-
- #region IPrintSchemaDisplayableElement methods
-
- public string DisplayName { get { return _feature.DisplayName; } }
- public string Name { get { return _feature.Name; } }
- public string XmlNamespace { get { return _feature.NamespaceUri; } }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaFeature(PrinterExtensionLib.IPrintSchemaFeature feature)
- {
- _feature = feature;
- }
-
- internal PrinterExtensionLib.IPrintSchemaFeature InteropFeature
- {
- get { return _feature; }
- }
-
- private PrinterExtensionLib.IPrintSchemaFeature _feature;
-
- #endregion
- }
-
- internal sealed class PrintSchemaPageImageableSize : IPrintSchemaPageImageableSize
- {
- #region IPrintSchemaPageImageableSize methods
-
- public uint ExtentHeightInMicrons
- {
- get { return _pageImageableSize.ExtentHeightInMicrons; }
- }
-
- public uint ExtentWidthInMicrons
- {
- get { return _pageImageableSize.ExtentWidthInMicrons; }
- }
-
- public uint ImageableSizeHeightInMicrons
- {
- get { return _pageImageableSize.ImageableSizeHeightInMicrons; }
- }
-
- public uint ImageableSizeWidthInMicrons
- {
- get { return _pageImageableSize.ImageableSizeWidthInMicrons; }
- }
-
- public uint OriginHeightInMicrons
- {
- get { return _pageImageableSize.OriginHeightInMicrons; }
- }
-
- public uint OriginWidthInMicrons
- {
- get { return _pageImageableSize.OriginWidthInMicrons; }
- }
-
- #endregion
-
- #region IPrintSchemaElement methods
-
- public string Name { get { return _pageImageableSize.Name; } }
- public string XmlNamespace { get { return _pageImageableSize.NamespaceUri; } }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaPageImageableSize(PrinterExtensionLib.IPrintSchemaPageImageableSize pageImageableSize)
- {
- _pageImageableSize = pageImageableSize;
- }
-
- private PrinterExtensionLib.IPrintSchemaPageImageableSize _pageImageableSize;
-
- #endregion
- }
-
-#if WINDOWS_81_APIS
- internal sealed class PrintSchemaParameterDefinition : IPrintSchemaParameterDefinition
- {
- #region IPrintSchemaParameterDefinition methods
-
- public bool UserInputRequired
- {
- get
- {
- if (_parameter.UserInputRequired != 0)
- {
- return true;
- }
- return false;
- }
- }
-
- public string UnitType
- {
- get { return _parameter.UnitType; }
- }
-
- public PrintSchemaParameterDataType DataType
- {
- get { return (PrintSchemaParameterDataType)_parameter.DataType; }
- }
-
- public int RangeMin
- {
- get { return _parameter.RangeMin; }
- }
-
- public int RangeMax
- {
- get { return _parameter.RangeMax; }
- }
- #endregion
-
- #region IPrintSchemaDisplayableItem methods
-
- public string DisplayName { get { return _parameter.DisplayName; } }
- public string Name { get { return _parameter.Name; } }
- public string XmlNamespace { get { return _parameter.NamespaceUri; } }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaParameterDefinition(PrinterExtensionLib.IPrintSchemaParameterDefinition parameter)
- {
- _parameter = parameter;
- }
-
- private PrinterExtensionLib.IPrintSchemaParameterDefinition _parameter;
-
- #endregion
- }
-
- internal sealed class PrintSchemaParameterInitializer : IPrintSchemaParameterInitializer
- {
- #region IPrintSchemaParameterInitializer methods
-
- public string StringValue
- {
- get
- {
- object value = _parameter.get_Value();
- return (string)value;
- }
- set
- {
- _parameter.set_Value(value);
- }
- }
-
- public int IntegerValue
- {
- get
- {
- object value = _parameter.get_Value();
- return (int)value;
- }
- set
- {
- _parameter.set_Value(value);
- }
- }
- #endregion
-
- #region IPrintSchemaElement methods
-
- public string Name { get { return _parameter.Name; } }
- public string XmlNamespace { get { return _parameter.NamespaceUri; } }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaParameterInitializer(PrinterExtensionLib.IPrintSchemaParameterInitializer parameter)
- {
- _parameter = parameter;
- }
-
- PrinterExtensionLib.IPrintSchemaParameterInitializer _parameter;
-
- #endregion
- }
-#endif
-
- internal sealed class PrintSchemaCapabilities : IPrintSchemaCapabilities
- {
- #region IPrintSchemaCapabilities methods
-
- public IPrintSchemaFeature GetFeatureByKeyName(string keyName)
- {
- PrinterExtensionLib.IPrintSchemaFeature feature = _capabilities.GetFeatureByKeyName(keyName);
- if (feature != null)
- {
- return new PrintSchemaFeature(feature);
- }
-
- return null;
- }
-
- public IPrintSchemaFeature GetFeature(string featureName)
- {
- return GetFeature(featureName, PrintSchemaConstants.KeywordsNamespaceUri);
- }
-
- public IPrintSchemaFeature GetFeature(string featureName, string xmlNamespace)
- {
- PrinterExtensionLib.IPrintSchemaFeature feature = _capabilities.GetFeature(featureName, xmlNamespace);
- if (feature != null)
- {
- return new PrintSchemaFeature(feature);
- }
-
- return null;
- }
-
- public IPrintSchemaPageImageableSize PageImageableSize
- {
- get { return new PrintSchemaPageImageableSize(_capabilities.PageImageableSize); }
- }
-
- public uint JobCopiesAllDocumentsMaxValue
- {
- get
- {
- uint value = _capabilities.JobCopiesAllDocumentsMaxValue;
- if (value == 0)
- {
- throw new NotSupportedException("Property \"JobCopiesAllDocumentsMaxValue\" not found in print capabilities.");
- }
-
- return value;
- }
- }
-
- public uint JobCopiesAllDocumentsMinValue
- {
- get
- {
- uint value = _capabilities.JobCopiesAllDocumentsMinValue;
- if (value == 0)
- {
- throw new NotSupportedException("Property \"JobCopiesAllDocumentsMinValue\" not found in print capabilities.");
- }
-
- return value;
- }
- }
-
- public IPrintSchemaOption GetSelectedOptionInPrintTicket(IPrintSchemaFeature feature)
- {
- PrintSchemaFeature f = feature as PrintSchemaFeature;
- PrinterExtensionLib.IPrintSchemaOption option = _capabilities.GetSelectedOptionInPrintTicket(f.InteropFeature);
-
- if (option != null)
- {
- return PrintSchemaOption.CreateOptionSubclass(option);
- }
-
- return null;
- }
-
- public IEnumerable GetOptions(IPrintSchemaFeature pFeature)
- {
- return new PrintSchemaOptionsCollection(
- _capabilities.GetOptions(
- (pFeature as PrintSchemaFeature).InteropFeature)
- );
- }
-
- public Stream GetReadStream()
- {
- return new ComIStreamAdapter(XmlStream,
- false, // canWrite
- true, // canSeek
- true // canRead
- );
- }
-
- public Stream GetWriteStream()
- {
- return new ComIStreamAdapter(XmlStream,
- true, // canWrite
- true, // canSeek
- false // canRead
- );
- }
-
-#if WINDOWS_81_APIS
- public IPrintSchemaParameterDefinition GetParameterDefinition(string parameterName)
- {
- return GetParameterDefinition(parameterName, PrintSchemaConstants.KeywordsNamespaceUri);
- }
-
- public IPrintSchemaParameterDefinition GetParameterDefinition(string parameterName, string xmlNamespace)
- {
- PrinterExtensionLib.IPrintSchemaParameterDefinition parameter = _capabilities2.GetParameterDefinition(parameterName, xmlNamespace);
- if (parameter != null)
- {
- return new PrintSchemaParameterDefinition(parameter);
- }
-
- return null;
- }
-#endif
-
- private System.Runtime.InteropServices.ComTypes.IStream XmlStream
- {
- get
- {
- System.Runtime.InteropServices.ComTypes.IStream istream = _capabilities.XmlNode as System.Runtime.InteropServices.ComTypes.IStream;
-
- return istream;
- }
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaCapabilities(PrinterExtensionLib.IPrintSchemaCapabilities caps)
- {
- _capabilities = caps;
-#if WINDOWS_81_APIS
- _capabilities2 = (PrinterExtensionLib.IPrintSchemaCapabilities2)caps;
-#endif
- }
-
- private PrinterExtensionLib.IPrintSchemaCapabilities _capabilities;
-#if WINDOWS_81_APIS
- private PrinterExtensionLib.IPrintSchemaCapabilities2 _capabilities2;
-#endif
- #endregion
- }
-
- internal class PrintSchemaAsyncOperation : IPrintSchemaAsyncOperation
- {
- #region IPrintSchemaAsyncOperation methods
-
- public void Cancel()
- {
- _asyncOperation.Cancel();
- }
-
- public void Start()
- {
- _asyncOperation.Start();
- }
-
- public event EventHandler Completed;
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaAsyncOperation(PrinterExtensionLib.PrintSchemaAsyncOperation asyncOperation)
- {
- _asyncOperation = asyncOperation;
- _asyncOperation.Completed += _asyncOperation_Completed;
- }
-
- void _asyncOperation_Completed(PrinterExtensionLib.IPrintSchemaTicket printTicket, int hrOperation)
- {
- if (Completed != null)
- {
- IPrintSchemaTicket ticket = new PrintSchemaTicket(printTicket);
- Completed(this, new PrintSchemaAsyncOperationEventArgs(ticket, hrOperation));
- }
-
- // This subscriber object (current object) holds a reference to the publishing object (i.e the underlying COM object)
- // because it is a class member, and the publishing object holds a reference to the subscriber via the registered delegate.
- // This implies neither object will be garbage collected until the application terminates.
- // It's expected the event is fired once per instance so unsubscribing the delegate has no side effects.
- _asyncOperation.Completed -= _asyncOperation_Completed;
- Marshal.ReleaseComObject(_asyncOperation);
- _asyncOperation = null;
- }
-
- private PrinterExtensionLib.PrintSchemaAsyncOperation _asyncOperation;
-
- #endregion
- }
-
- internal class PrintSchemaTicket : IPrintSchemaTicket
- {
-
- #region IPrintSchemaTicket methods
-
- public IPrintSchemaCapabilities GetCapabilities()
- {
- return new PrintSchemaCapabilities(_printTicket.GetCapabilities());
- }
-
- public IPrintSchemaFeature GetFeature(string featureName)
- {
- return GetFeature(featureName, PrintSchemaConstants.KeywordsNamespaceUri);
- }
-
- public IPrintSchemaFeature GetFeature(string featureName, string xmlNamespace)
- {
- PrinterExtensionLib.IPrintSchemaFeature feature = _printTicket.GetFeature(featureName, xmlNamespace);
- if (feature != null)
- {
- return new PrintSchemaFeature(feature);
- }
-
- return null;
- }
-
- public IPrintSchemaFeature GetFeatureByKeyName(string keyName)
- {
- PrinterExtensionLib.IPrintSchemaFeature feature = _printTicket.GetFeatureByKeyName(keyName);
- if (feature != null)
- {
- return new PrintSchemaFeature(feature);
- }
-
- return null;
- }
-
- public uint JobCopiesAllDocuments
- {
- get
- {
- uint value = _printTicket.JobCopiesAllDocuments;
- if (value == 0)
- {
- throw new NotSupportedException("Property \"JobCopiesAllDocuments\" not found in print ticket.");
- }
-
- return value;
- }
- set
- {
- _printTicket.JobCopiesAllDocuments = value;
- }
- }
-
- public Stream GetReadStream()
- {
- return new ComIStreamAdapter(XmlStream,
- false, // canWrite
- true, // canSeek
- true // canRead
- );
- }
-
- public Stream GetWriteStream()
- {
- return new ComIStreamAdapter(XmlStream,
- true, // canWrite
- true, // canSeek
- false // canRead
- );
- }
-
- private System.Runtime.InteropServices.ComTypes.IStream XmlStream
- {
- get
- {
- System.Runtime.InteropServices.ComTypes.IStream istream = _printTicket.XmlNode as System.Runtime.InteropServices.ComTypes.IStream;
-
- return istream;
- }
- }
-
- public IPrintSchemaAsyncOperation ValidateAsync()
- {
- PrinterExtensionLib.PrintSchemaAsyncOperation interopAsyncOperation;
- _printTicket.ValidateAsync(out interopAsyncOperation);
- return new PrintSchemaAsyncOperation(interopAsyncOperation);
- }
-
- public IPrintSchemaAsyncOperation CommitAsync(IPrintSchemaTicket printTicketCommit)
- {
- PrinterExtensionLib.IPrintSchemaTicket interopTicket = (printTicketCommit as PrintSchemaTicket)._printTicket;
- PrinterExtensionLib.PrintSchemaAsyncOperation interopAsyncOperation;
- _printTicket.CommitAsync(interopTicket, out interopAsyncOperation);
- return new PrintSchemaAsyncOperation(interopAsyncOperation);
- }
-
- public void NotifyXmlChanged()
- {
- _printTicket.NotifyXmlChanged();
- }
-#if WINDOWS_81_APIS
- public IPrintSchemaParameterInitializer GetParameterInitializer(string parameterName)
- {
- return GetParameterInitializer(parameterName, PrintSchemaConstants.KeywordsNamespaceUri);
- }
-
- public IPrintSchemaParameterInitializer GetParameterInitializer(string parameterName, string xmlNamespace)
- {
- PrinterExtensionLib.IPrintSchemaParameterInitializer parameter = _printTicket2.GetParameterInitializer(parameterName, xmlNamespace);
- if (parameter != null)
- {
- return new PrintSchemaParameterInitializer(parameter);
- }
-
- return null;
- }
-#endif
-
- #endregion
-
- #region Implementation details
-
- internal PrintSchemaTicket(PrinterExtensionLib.IPrintSchemaTicket printTicket)
- {
- _printTicket = printTicket;
-#if WINDOWS_81_APIS
- _printTicket2 = (PrinterExtensionLib.IPrintSchemaTicket2)printTicket;
-#endif
- }
-
- private PrinterExtensionLib.IPrintSchemaTicket _printTicket;
-#if WINDOWS_81_APIS
- private PrinterExtensionLib.IPrintSchemaTicket2 _printTicket2;
-#endif
-
- #endregion
- }
-
- internal enum PrintPropertyBagType
- {
- QueueProperties,
- DriverProperties,
- UserProperties
- }
-
- internal class PrinterPropertyBag : IPrinterPropertyBag
- {
- #region IPrinterPropertyBag methods
-
- public bool GetBool(string propertyName)
- {
- try
- {
- int integerEquivalent = _bag.GetBool(propertyName);
- bool boolEquivalent = true;
- if (integerEquivalent == 0)
- {
- boolEquivalent = false;
- }
- return boolEquivalent;
- }
- catch (ArgumentException e)
- {
- // Fix the type of exception thrown when the property does not exist.
- if (ShouldConvertExceptionType(e))
- {
- throw new FileNotFoundException("", e);
- }
- throw;
- }
- }
-
- public byte[] GetBytes(string propertyName)
- {
- try
- {
- uint count = 0;
- IntPtr intptrData = Marshal.AllocCoTaskMem(IntPtr.Size);
- _bag.GetBytes(
- propertyName,
- out count,
- intptrData);
-
- byte[] data = new byte[count];
- Marshal.Copy(Marshal.ReadIntPtr(intptrData), data, 0, (int)count);
- Marshal.FreeCoTaskMem(Marshal.ReadIntPtr(intptrData));
- Marshal.FreeCoTaskMem(intptrData);
- return data;
- }
- catch (ArgumentException e)
- {
- // Fix the type of exception thrown when the property does not exist.
- if (ShouldConvertExceptionType(e))
- {
- throw new FileNotFoundException("", e);
- }
- throw;
- }
- }
-
- public int GetInt(string propertyName)
- {
- try
- {
- return _bag.GetInt32(propertyName);
- }
- catch (ArgumentException e)
- {
- // Fix the type of exception thrown when the property does not exist.
- if (ShouldConvertExceptionType(e))
- {
- throw new FileNotFoundException("", e);
- }
- throw;
- }
- }
-
- public string GetString(string propertyName)
- {
- try
- {
- return _bag.GetString(propertyName);
- }
- catch (ArgumentException e)
- {
- // Fix the type of exception thrown when the property does not exist.
- if (ShouldConvertExceptionType(e))
- {
- throw new FileNotFoundException("", e);
- }
- throw;
- }
- }
-
- public void SetBool(string propertyName, bool value)
- {
- int integerEquivalent = 1;
- if (value == false)
- {
- integerEquivalent = 0;
- }
-
- _bag.SetBool(propertyName, integerEquivalent);
- }
-
- public void SetBytes(string propertyName, byte[] data)
- {
- // Pin the byte array so that it will not be moved by the garbage collector
- // This would not be required if the COM Interop function took in a byte[] parameter
- // as opposed to a byte parameter
- GCHandle gcHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
- try
- {
- _bag.SetBytes(propertyName, Convert.ToUInt32(data.Length), ref data[0]);
- }
- finally
- {
- gcHandle.Free();
- }
- }
-
- public void SetInt(string propertyName, int value)
- {
- _bag.SetInt32(propertyName, value);
- }
-
- public void SetString(string propertyName, string value)
- {
- _bag.SetString(propertyName, value);
- }
-
- public Stream GetReadStream(string propertyName)
- {
- try
- {
- return new PrinterExtensionLibIStreamAdapter(_bag.GetReadStream(propertyName), false, true, true);
- }
- catch (COMException e)
- {
- // Fix the type of exception thrown when the property does not exist.
- if (ShouldConvertExceptionType(e))
- {
- throw new FileNotFoundException("", e);
- }
- throw;
- }
- }
-
- public Stream GetWriteStream(string propertyName)
- {
- return new PrinterExtensionLibIStreamAdapter(_bag.GetWriteStream(propertyName), true, true, false);
- }
-
- #endregion
-
- #region Indexer
-
- public PrinterProperty this[string name]
- {
- get { return new PrinterProperty(this, name); }
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrinterPropertyBag(PrinterExtensionLib.IPrinterPropertyBag bag, PrintPropertyBagType type)
- {
- _bag = bag;
- _type = type;
- }
-
- ///
- /// Check if exception thrown when a property is not found in a property bag needs to be converted.
- ///
- ///
- /// True if the exception type needs to be converted.
- private bool ShouldConvertExceptionType(Exception e)
- {
- // Only the driver property bag throws exceptions other than 'FileNotFoundException'
- // when a property is not found.
- if (_type != PrintPropertyBagType.DriverProperties)
- {
- return false;
- }
- else if (e is ArgumentException)
- {
- return true;
- }
- else if (e is COMException)
- {
- // Since there is no portable way to check the HRESULT across classic .Net and
- // .Net for Windows Store apps, all COMExceptions encountered are converted.
- return true;
- }
- return false;
- }
-
- private PrinterExtensionLib.IPrinterPropertyBag _bag;
- private PrintPropertyBagType _type;
-
- #endregion
- }
-
-#if WINDOWS_81_APIS
- public sealed class PrintJob : IPrintJob
- {
- #region IPrintJob methods
-
- public string Name
- {
- get { return _job.Name; }
- }
-
- public ulong Id
- {
- get { return _job.Id; }
- }
-
- public ulong PrintedPages
- {
- get { return _job.PrintedPages; }
- }
-
- public ulong TotalPages
- {
- get { return _job.TotalPages; }
- }
-
- public PrintJobStatus Status
- {
- get { return (PrintJobStatus)_job.Status; }
- }
-
- public DateTime SubmissionTime
- {
- get { return _job.SubmissionTime; }
- }
-
- public void RequestCancel()
- {
- _job.RequestCancel();
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrintJob(PrinterExtensionLib.IPrintJob job)
- {
- _job = job;
- }
-
- PrinterExtensionLib.IPrintJob _job;
-
- #endregion
- }
-
- ///
- /// This class provides wraps IPrintJobCollection in a IEnumerable interface
- ///
- public sealed class PrintJobCollection : IEnumerable
- {
- #region IEnumerable methods
-
- public IEnumerator GetEnumerator()
- {
- for (uint i = 0; i < _jobCollection.Count; i++)
- {
- yield return new PrintJob(_jobCollection.GetAt(i));
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return (IEnumerator)GetEnumerator();
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrintJobCollection(PrinterExtensionLib.IPrintJobCollection jobCollection)
- {
- _jobCollection = jobCollection;
- }
-
- private PrinterExtensionLib.IPrintJobCollection _jobCollection;
-
- #endregion
- }
-
- internal sealed class PrinterQueueView : IPrinterQueueView
- {
- #region IPrinterQueueView methods
-
- public void SetViewRange(uint viewOffset, uint viewSize)
- {
- _view.SetViewRange(viewOffset, viewSize);
- }
-
- public event EventHandler OnChanged
- {
- add
- {
- if (_onChanged == null)
- {
- _view.OnChanged += _view_OnChanged;
- }
- _onChanged += value;
- }
- remove
- {
- _onChanged -= value;
- if (_onChanged == null)
- {
- _view.OnChanged -= _view_OnChanged;
- }
- }
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrinterQueueView(PrinterExtensionLib.PrinterQueueView view)
- {
- _view = view;
- }
-
- void _view_OnChanged(PrinterExtensionLib.IPrintJobCollection pCollection, uint ulViewOffset, uint ulViewSize, uint ulCountJobsInPrintQueue)
- {
- if (_onChanged != null)
- {
- _onChanged(this, new PrinterQueueViewEventArgs(new PrintJobCollection(pCollection), ulViewOffset, ulViewSize, ulCountJobsInPrintQueue));
- }
- }
-
- private PrinterExtensionLib.PrinterQueueView _view;
- private event EventHandler _onChanged;
-
- #endregion
- }
-
- internal sealed class PrinterBidiSetRequestCallback : PrinterExtensionLib.IPrinterBidiSetRequestCallback
- {
- #region IPrinterBidiSetRequestCallback methods
-
- public void Completed(string response, int statusHResult)
- {
- _callback.Completed(response, statusHResult);
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrinterBidiSetRequestCallback(IPrinterBidiSetRequestCallback callback)
- {
- _callback = callback;
- }
-
- private IPrinterBidiSetRequestCallback _callback;
-
- #endregion
- }
-#endif
-
- internal sealed class PrinterQueue : IPrinterQueue
- {
- #region IPrinterQueue methods
-
- public string Name
- {
- get { return _queue.Name; }
- }
-
- public void SendBidiQuery(string bidiQuery)
- {
- _queue.SendBidiQuery(bidiQuery);
- }
-
- public IntPtr Handle
- {
- get { return _queue.Handle; }
- }
-
- public IPrinterPropertyBag GetProperties()
- {
- return new PrinterPropertyBag(_queue.GetProperties(), PrintPropertyBagType.QueueProperties);
- }
- public event EventHandler OnBidiResponseReceived
- {
- add
- {
- if (_onBidiResponseReceived == null)
- {
- _queue.OnBidiResponseReceived += _queue_OnBidiResponseReceived;
- }
- _onBidiResponseReceived += value;
- }
- remove
- {
- _onBidiResponseReceived -= value;
- if (_onBidiResponseReceived == null)
- {
- _queue.OnBidiResponseReceived -= _queue_OnBidiResponseReceived;
- }
- }
- }
-
-#if WINDOWS_81_APIS
- public IPrinterExtensionAsyncOperation SendBidiSetRequestAsync(string bidiRequest, IPrinterBidiSetRequestCallback callback)
- {
- PrinterBidiSetRequestCallback comCallback = new PrinterBidiSetRequestCallback(callback);
- PrinterExtensionLib.IPrinterBidiSetRequestCallback comCallbackInterface = comCallback;
- return new PrinterExtensionAsyncOperation(_queue2.SendBidiSetRequestAsync(bidiRequest, comCallbackInterface));
- }
-
- public IPrinterQueueView GetPrinterQueueView(uint viewOffset, uint viewSize)
- {
- return new PrinterQueueView(_queue2.GetPrinterQueueView(viewOffset, viewSize));
- }
-#endif
-
- #endregion
-
- #region Implementation details
-
- internal PrinterQueue(PrinterExtensionLib.PrinterQueue queue)
- {
- _queue = queue;
-#if WINDOWS_81_APIS
- _queue2 = (PrinterExtensionLib.IPrinterQueue2)queue;
-#endif
- }
-
- private void _queue_OnBidiResponseReceived(string bstrResponse, int hrStatus)
- {
- if (_onBidiResponseReceived != null)
- {
- _onBidiResponseReceived(this, new PrinterQueueEventArgs(bstrResponse, hrStatus));
- }
- }
-
- private event EventHandler _onBidiResponseReceived;
-#if WINDOWS_81_APIS
- private PrinterExtensionLib.IPrinterQueue2 _queue2;
-#endif
- private PrinterExtensionLib.PrinterQueue _queue;
-
- #endregion
- }
-
- internal sealed class PrinterExtensionRequest : IPrinterExtensionRequest
- {
- #region IPrinterExtensionRequest methods
-
- public void Complete()
- {
- _request.Complete();
- }
-
- public void Cancel(int hr, string logMessage)
- {
- _request.Cancel(hr, logMessage);
- }
-
- #endregion
-
- #region Implementation details
-
- internal PrinterExtensionRequest(PrinterExtensionLib.IPrinterExtensionRequest request)
- {
- _request = request;
- }
-
- private PrinterExtensionLib.IPrinterExtensionRequest _request;
-
- #endregion
- }
-
- #endregion
-}
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj
deleted file mode 100644
index 3c24e74b..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
- Debug
- AnyCPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}
- en-US
- Library
- Properties
- Microsoft.Samples.Printing.PrinterExtension
- Microsoft.Samples.Printing.PrinterExtensionLibrary
- v4.0
- 512
-
- true
-
-
- true
- full
- false
- bin\Win8 Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- true
- pdbonly
- true
- bin\Win8 Release\
- TRACE
- prompt
- 4
-
-
- true
- full
- false
- bin\Win8.1 Debug\
- DEBUG;TRACE;WINDOWS_81_APIS
- prompt
- 4
-
-
- true
- pdbonly
- true
- bin\Win8.1 Release\
- TRACE;WINDOWS_81_APIS
- prompt
- 4
-
-
- true
- full
- false
- bin\Win10 Debug\
- DEBUG;TRACE;WINDOWS_81_APIS
- prompt
- 4
-
-
- true
- pdbonly
- true
- bin\Win10 Release\
- TRACE;WINDOWS_81_APIS
- prompt
- 4
-
-
-
-
-
-
-
- Code
-
-
-
-
-
-
- {91CE54EE-C67C-4B46-A4FF-99416F27A8BF}
- 1
- 0
- 0
- tlbimp
- False
- True
-
-
-
-
-
\ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionManager.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionManager.cs
deleted file mode 100644
index 91815d6a..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionManager.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-// 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 an Adapter that wrap the PrinterExtensionManager COM Interop type.
-//
-using System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Runtime;
-using System.Runtime.InteropServices;
-using Microsoft.Samples.Printing.PrinterExtension.Types;
-
-namespace Microsoft.Samples.Printing.PrinterExtension
-{
- public class PrinterExtensionManager
- {
- public PrinterExtensionManager()
- {
- _manager = new PrinterExtensionLib.PrinterExtensionManager();
- }
-
- #region IPrinterExtensionManager methods
-
- ///
- /// Maps to COM IPrinterExtensionManager::DisableEvents
- ///
- public void DisableEvents()
- {
- _manager.DisableEvents();
- }
-
- ///
- /// Maps to COM IPrinterExtensionManager::EnableEvents
- ///
- public void EnableEvents(Guid printerDriverId)
- {
- _manager.EnableEvents(printerDriverId);
- }
-
- ///
- /// Maps to COM IPrinterExtensionEvent::OnDriverEvent
- ///
- public event EventHandler OnDriverEvent
- {
- add
- {
- if (_onDriverEvent == null)
- {
- _manager.OnDriverEvent += OnDriverEventReceiver;
- }
- _onDriverEvent += value;
- }
- remove
- {
- _onDriverEvent -= value;
- if (_onDriverEvent == null)
- {
- _manager.OnDriverEvent -= OnDriverEventReceiver;
- }
- }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEvent::OnPrinterQueuesEnumerated
- ///
- public event EventHandler OnPrinterQueuesEnumerated
- {
- add
- {
- if (_onPrinterQueuesEnumerated == null)
- {
- _manager.OnPrinterQueuesEnumerated += OnPrinterQueuesEnumeratedReceiver;
- }
- _onPrinterQueuesEnumerated += value;
- }
- remove
- {
- _onPrinterQueuesEnumerated -= value;
- if (_onPrinterQueuesEnumerated == null)
- {
- _manager.OnPrinterQueuesEnumerated -= OnPrinterQueuesEnumeratedReceiver;
- }
- }
- }
-
- #endregion
-
- #region Implementation details
-
- private void OnDriverEventReceiver(PrinterExtensionLib.IPrinterExtensionEventArgs pEventArgs)
- {
- if (_onDriverEvent != null)
- {
- _onDriverEvent(this, new PrinterExtensionEventArgs(pEventArgs));
- }
- }
-
- private void OnPrinterQueuesEnumeratedReceiver(PrinterExtensionLib.IPrinterExtensionContextCollection contextCollection)
- {
- if (_onPrinterQueuesEnumerated != null)
- {
- _onPrinterQueuesEnumerated(this, new PrinterQueuesEnumeratedEventArgs(contextCollection));
- }
- }
-
- private event EventHandler _onDriverEvent;
- private event EventHandler _onPrinterQueuesEnumerated;
-
- private PrinterExtensionLib.PrinterExtensionManager _manager;
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionTypes.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionTypes.cs
deleted file mode 100644
index 33991cde..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionTypes.cs
+++ /dev/null
@@ -1,921 +0,0 @@
-// 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 defines all types and interfaces that may be used to build a printer
-// extension application.
-//
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace Microsoft.Samples.Printing.PrinterExtension.Types
-{
- //
- // Enums and Constants
- //
- ///
- /// Maps to COM PrintSchemaConstrainedSetting
- ///
- public enum PrintSchemaConstrainedSetting
- {
- None = 0,
- PrintTicket = 1,
- Admin = 2,
- Device = 3,
- }
-
- ///
- /// Maps to COM PrintSchemaSelectionType
- ///
- public enum PrintSchemaSelectionType
- {
- PickOne = 0,
- PickMany = 1
- }
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM PrintSchemaParameterDataType
- ///
- public enum PrintSchemaParameterDataType
- {
- Integer = 0,
- NumericString = 1,
- String = 2
- }
-
- ///
- /// Maps to COM PrintJobStatus
- ///
- [Flags]
- public enum PrintJobStatus
- {
- Paused = 0x1,
- Error = 0x2,
- Deleting = 0x4,
- Spooling = 0x8,
- Printing = 0x10,
- Offline = 0x20,
- PaperOut = 0x40,
- Printed = 0x80,
- Deleted = 0x100,
- BlockedDeviceQueue = 0x200,
- UserIntervention = 0x400,
- Restarted = 0x800,
- Complete = 0x1000,
- Retained = 0x2000,
- }
-#endif
-
- public static class PrinterExtensionReason
- {
- // An Enum was the first choice but the list of Guid is designed to be extendable.
- // A read-only property was the second choice however this would have made new copies of the Guid.
- // Using a class with static Guids balances both considerations.
-
- ///
- /// In this mode preferences for a print job or default print preferences is expected to be displayed.
- /// Maps to C++ PRINTER_EXTENSION_REASON_PRINT_PREFERENCES
- ///
- public static Guid PrintPreferences = new Guid("{EC8F261F-267C-469F-B5D6-3933023C29CC}");
-
-
- ///
- /// In this mode a status monitor for the print queue is expected to be displayed.
- /// Maps to C++ PRINTER_EXTENSION_REASON_DRIVER_EVENT
- ///
- public static Guid DriverEvent = new Guid("{23BB1328-63DE-4293-915B-A6A23D929ACB}");
- }
-
- public static class PrintSchemaConstants
- {
- ///
- /// The namespace URI for the Print Schema keywords
- ///
- public const string KeywordsNamespaceUri = "http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords";
- ///
- /// The namespace URI for the Print Schema keywords V1.1
- ///
- public const string KeywordsV11NamespaceUri = "http://schemas.microsoft.com/windows/2013/05/printing/printschemakeywordsv11";
- ///
- /// The namespace URI for the Print Schema Framework
- ///
- public const string FrameworkNamespaceUri = "http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework";
- }
-
- //
- // Interfaces
- //
-
- // The following interfaces are shared between the "Reference" and "Implementation"
- // project. These interfaces are the public surface for the adapters that will remain
- // internal to the "Implementation" project. It is done this way because the public
- // surface and strong name must be the same for "Reference" and "Implementation".
-
- ///
- /// Maps to COM IPrinterExtensionContext
- ///
- public interface IPrinterExtensionContext
- {
- ///
- /// Maps to COM IPrinterExtensionContext::PrinterQueue
- ///
- IPrinterQueue Queue { get; }
-
- ///
- /// Maps to COM IPrinterExtensionContext::PrintSchemaTicket
- ///
- IPrintSchemaTicket Ticket { get; }
-
- ///
- /// Maps to COM IPrinterExtensionContext::DriverProperties
- ///
- IPrinterPropertyBag DriverProperties { get; }
-
- ///
- /// Maps to COM IPrinterExtensionContext::UserProperties
- ///
- IPrinterPropertyBag UserProperties { get; }
- }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs
- ///
- public interface IPrinterExtensionEventArgs : IPrinterExtensionContext
- {
- ///
- /// Maps to COM IPrinterExtensionEventArgs::BidiNotification
- ///
- string BidiNotification { get; }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::ReasonId
- ///
- Guid ReasonId { get; }
-
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::Request
- ///
- IPrinterExtensionRequest Request { get; }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::SourceApplication
- ///
- string SourceApplication { get; }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::DetailedReasonId
- ///
- Guid DetailedReasonId { get; }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::WindowModal
- ///
- bool WindowModal { get; }
-
- ///
- /// Maps to COM IPrinterExtensionEventArgs::WindowParent
- ///
- IntPtr WindowParent { get; }
- }
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM IPrinterExtensionAsyncOperation
- ///
- public interface IPrinterExtensionAsyncOperation
- {
- ///
- /// Maps to COM IPrinterExtensionAsyncOperation::Cancel
- ///
- void Cancel();
- }
-#endif
-
- ///
- /// Maps to COM IPrintSchemaElement
- ///
- public interface IPrintSchemaElement
- {
- ///
- /// Maps to COM IPrintSchemaElement::Name
- ///
- string Name { get; }
-
- ///
- /// Maps to COM IPrintSchemaElement::NamespaceUri
- ///
- string XmlNamespace { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaDisplayableElement
- ///
- public interface IPrintSchemaDisplayableElement : IPrintSchemaElement
- {
- ///
- /// Maps to COM IPrintSchemaDisplayableElement::DisplayName
- ///
- string DisplayName { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaOption
- ///
- public interface IPrintSchemaOption : IPrintSchemaDisplayableElement
- {
- ///
- /// Maps to COM IPrintSchemaOption::Selected
- ///
- bool Selected { get; }
-
- ///
- /// Maps to COM IPrintSchemaOption::Constrained
- ///
- PrintSchemaConstrainedSetting Constrained { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaPageMediaSizeOption
- ///
- public interface IPrintSchemaPageMediaSizeOption : IPrintSchemaOption
- {
- ///
- /// Maps to COM IPrintSchemaPageMediaSizeOption::HeightInMicrons
- ///
- uint HeightInMicrons { get; }
-
- ///
- /// Maps to COM IPrintSchemaPageMediaSizeOption::WidthInMicrons
- ///
- uint WidthInMicrons { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaNUpOption
- ///
- public interface IPrintSchemaNUpOption : IPrintSchemaOption
- {
- ///
- /// Maps to COM IPrintSchemaNUpOption::PagesPerSheet
- ///
- uint PagesPerSheet { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaFeature
- ///
- public interface IPrintSchemaFeature : IPrintSchemaDisplayableElement
- {
- ///
- /// Maps to COM IPrintSchemaFeature::SelectedOption
- ///
- IPrintSchemaOption SelectedOption { get; set; }
-
- ///
- /// Maps to COM IPrintSchemaFeature::SelectionType
- ///
- PrintSchemaSelectionType SelectionType { get; }
-
- ///
- /// Maps to COM IPrintSchemaFeature::GetOption
- ///
- IPrintSchemaOption GetOption(string optionName);
-
- ///
- /// Maps to COM IPrintSchemaFeature::GetOption
- ///
- IPrintSchemaOption GetOption(string optionName, string xmlNamespace);
-
- ///
- /// Maps to COM IPrintSchemaFeature::DisplayUI
- ///
- bool DisplayUI { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaPageImageableSize
- ///
- public interface IPrintSchemaPageImageableSize : IPrintSchemaElement
- {
- ///
- /// Maps to COM IPrintSchemaPageImageableSize::ExtentHeightInMicrons
- ///
- uint ExtentHeightInMicrons { get; }
-
- ///
- /// Maps to COM IPrintSchemaPageImageableSize::ExtentWidthInMicrons
- ///
- uint ExtentWidthInMicrons { get; }
-
- ///
- /// Maps to COM IPrintSchemaPageImageableSize::ImageableSizeHeightInMicrons
- ///
- uint ImageableSizeHeightInMicrons { get; }
-
- ///
- /// Maps to COM IPrintSchemaPageImageableSize::ImageableSizeWidthInMicrons
- ///
- uint ImageableSizeWidthInMicrons { get; }
-
- ///
- /// Maps to COM IPrintSchemaPageImageableSize::OriginHeightInMicrons
- ///
- uint OriginHeightInMicrons { get; }
-
- ///
- /// Maps to COM IPrintSchemaPageImageableSize::OriginWidthInMicrons
- ///
- uint OriginWidthInMicrons { get; }
- }
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM IPrintSchemaParameterDefinition
- ///
- public interface IPrintSchemaParameterDefinition : IPrintSchemaDisplayableElement
- {
- ///
- /// Maps to COM IPrintSchemaParameterDefinition::UserInputRequired
- ///
- bool UserInputRequired { get; }
-
- ///
- /// Maps to COM IPrintSchemaParameterDefinition::UnitType
- ///
- string UnitType { get; }
-
- ///
- /// Maps to COM IPrintSchemaParameterDefinition::DataType
- ///
- PrintSchemaParameterDataType DataType { get; }
-
- ///
- /// Maps to COM IPrintSchemaParameterDefinition::RangeMin
- ///
- int RangeMin { get; }
-
- ///
- /// Maps to COM IPrintSchemaParameterDefinition::RangeMax
- ///
- int RangeMax { get; }
- }
-
- ///
- /// Maps to COM IPrintSchemaParameterInitializer
- ///
- public interface IPrintSchemaParameterInitializer : IPrintSchemaElement
- {
- ///
- /// Maps to COM IPrintSchemaParameterInitializer::Value
- ///
- string StringValue { get; set; }
- ///
- /// Maps to COM IPrintSchemaParameterInitializer::Value
- ///
- int IntegerValue { get; set; }
- }
-#endif
-
- ///
- /// Maps to COM IPrintSchemaCapabilities
- ///
- public interface IPrintSchemaCapabilities
- {
- ///
- /// Maps to COM IPrintSchemaCapabilities::GetFeatureByKeyName
- ///
- IPrintSchemaFeature GetFeatureByKeyName(string keyName);
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::GetFeature
- ///
- IPrintSchemaFeature GetFeature(string featureName);
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::GetFeature
- ///
- IPrintSchemaFeature GetFeature(string featureName, string xmlNamespace);
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::PageImageableSize
- ///
- IPrintSchemaPageImageableSize PageImageableSize { get; }
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::JobCopiesAllDocumentsMinValue
- ///
- uint JobCopiesAllDocumentsMaxValue { get; }
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::JobCopiesAllDocumentsMaxValue
- ///
- uint JobCopiesAllDocumentsMinValue { get; }
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::GetSelectedOptionInPrintTicket
- ///
- IPrintSchemaOption GetSelectedOptionInPrintTicket(IPrintSchemaFeature feature);
-
- ///
- /// Maps to COM IPrintSchemaCapabilities::GetOptions
- ///
- IEnumerable GetOptions(IPrintSchemaFeature feature);
-
- ///
- /// Replaces COM IPrintSchemaCapabilities::XmlNode
- ///
- Stream GetReadStream();
-
- ///
- /// Replaces COM IPrintSchemaCapabilities::XmlNode
- ///
- Stream GetWriteStream();
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM IPrintSchemaCapabilities2::GetParameterDefinition
- ///
- IPrintSchemaParameterDefinition GetParameterDefinition(string parameterName);
-
- ///
- /// Maps to COM IPrintSchemaCapabilities2::GetParameterDefinition
- ///
- IPrintSchemaParameterDefinition GetParameterDefinition(string parameterName, string xmlNamespace);
-#endif
- }
-
- ///
- /// The EventArgs for the PrintSchemaAsyncOperation
- /// Maps to COM IPrintSchemaAsyncOperationEvent
- ///
- public class PrintSchemaAsyncOperationEventArgs : EventArgs
- {
- //
- // Event arguments
- //
- ///
- /// Maps to COM IPrintSchemaAsyncOperationEvent::Completed, parameter 'hrOperation'
- ///
- public int StatusHResult { get { return _statusHResult; } }
-
- ///
- /// Maps to COM IPrintSchemaAsyncOperationEvent::Completed, parameter 'pTicket'
- ///
- public IPrintSchemaTicket Ticket { get { return _printTicket; } }
-
- //
- // Implementation details
- //
- internal PrintSchemaAsyncOperationEventArgs(IPrintSchemaTicket printTicket, int statusHResult)
- {
- _statusHResult = statusHResult;
- _printTicket = printTicket;
- }
-
- private int _statusHResult;
- private IPrintSchemaTicket _printTicket;
- }
-
- ///
- /// Maps to COM IPrintSchemaAsyncOperation
- ///
- public interface IPrintSchemaAsyncOperation
- {
- ///
- /// Maps to COM IPrintSchemaAsyncOperationEvent::Completed
- ///
- event EventHandler Completed;
-
- ///
- /// Maps to COM IPrintSchemaAsyncOperation::Start
- ///
- void Start();
-
- ///
- /// Maps to COM IPrintSchemaAsyncOperation::Cancel
- ///
- void Cancel();
- }
-
- ///
- /// Maps to COM IPrintSchemaTicket
- ///
- public interface IPrintSchemaTicket
- {
- ///
- /// Maps to COM IPrintSchemaTicket::GetFeatureByKeyName
- ///
- IPrintSchemaFeature GetFeatureByKeyName(string featureName);
-
- ///
- /// Maps to COM IPrintSchemaTicket::GetFeature
- ///
- IPrintSchemaFeature GetFeature(string featureName);
-
- ///
- /// Maps to COM IPrintSchemaTicket::GetFeature
- ///
- IPrintSchemaFeature GetFeature(string featureName, string xmlNamespace);
-
- ///
- /// Maps to COM IPrintSchemaTicket::ValidateAsync
- ///
- IPrintSchemaAsyncOperation ValidateAsync();
-
- ///
- /// Maps to COM IPrintSchemaTicket::CommitAsync
- ///
- IPrintSchemaAsyncOperation CommitAsync(IPrintSchemaTicket printTicketCommit);
-
- ///
- /// Maps to COM IPrintSchemaTicket::NotifyXmlChanged
- ///
- void NotifyXmlChanged();
-
- ///
- /// Maps to COM IPrintSchemaTicket::GetCapabilities
- ///
- IPrintSchemaCapabilities GetCapabilities();
-
- ///
- /// Maps to COM IPrintSchemaTicket::JobCopiesAllDocuments
- ///
- uint JobCopiesAllDocuments { get; set; }
-
- ///
- /// Replaces COM IPrintSchemaTicket::XmlNode
- ///
- Stream GetReadStream();
-
- ///
- /// Replaces COM IPrintSchemaTicket::XmlNode
- ///
- Stream GetWriteStream();
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM IPrintSchemaTicket2::GetParameterInitializer
- ///
- IPrintSchemaParameterInitializer GetParameterInitializer(string parameterName);
-
- ///
- /// Maps to COM IPrintSchemaTicket2::GetParameterInitializer
- ///
- IPrintSchemaParameterInitializer GetParameterInitializer(string parameterName, string xmlNamespace);
-#endif
- }
-
- ///
- /// Maps to COM IPrinterPropertyBag
- ///
- public interface IPrinterPropertyBag
- {
- ///
- /// Maps to COM IPrinterPropertyBag::GetBool
- ///
- bool GetBool(string propertyName);
-
- ///
- /// Maps to COM IPrinterPropertyBag::SetBool
- ///
- void SetBool(string propertyName, bool value);
-
- ///
- /// Maps to COM IPrinterPropertyBag::GetInt32
- ///
- int GetInt(string propertyName);
-
- ///
- /// Maps to COM IPrinterPropertyBag::SetInt32
- ///
- void SetInt(string propertyName, int value);
-
- ///
- /// Maps to COM IPrinterPropertyBag::GetString
- ///
- string GetString(string propertyName);
-
- ///
- /// Maps to COM IPrinterPropertyBag::SetString
- ///
- void SetString(string propertyName, string value);
-
- ///
- /// Maps to COM IPrinterPropertyBag::GetBytes
- ///
- byte[] GetBytes(string propertyName);
-
- ///
- /// Maps to COM IPrinterPropertyBag::SetBytes
- ///
- void SetBytes(string propertyName, byte[] value);
-
- ///
- /// Maps to COM IPrinterPropertyBag::GetReadStream
- ///
- Stream GetReadStream(string propertyName);
-
- ///
- /// Maps to COM IPrinterPropertyBag::GetWriteStream
- ///
- Stream GetWriteStream(string propertyName);
-
- ///
- /// Indexer for the properties
- ///
- /// Property name
- /// An instance of 'PrinterProperty' used to get/set values
- PrinterProperty this[string name] { get; }
- }
-
- ///
- /// Represents one property returned by the indexer in IPrinterPropertyBag
- ///
- public class PrinterProperty
- {
- internal PrinterProperty(IPrinterPropertyBag bag, string name)
- {
- _bag = bag;
- _name = name;
- }
-
- ///
- /// Prevents default construction
- ///
- private PrinterProperty()
- {
- }
-
- ///
- /// Get/Set a value of type 'bool'
- ///
- public bool Bool
- {
- get { return _bag.GetBool(_name); }
- set { _bag.SetBool(_name, value); }
- }
-
- ///
- /// Get/Set a value of type 'Int32'
- ///
- public int Int
- {
- get { return _bag.GetInt(_name); }
- set { _bag.SetInt(_name, value); }
- }
-
- ///
- /// Get/Set a value of type 'byte[]'
- ///
- public byte[] Bytes
- {
- get { return _bag.GetBytes(_name); }
- set { _bag.SetBytes(_name, value); }
- }
-
- ///
- /// Get/Set a value of type 'string'
- ///
- public string String
- {
- get { return _bag.GetString(_name); }
- set { _bag.SetString(_name, value); }
- }
-
- ///
- /// Get a read/write Stream corresponding to this property name
- ///
- public Stream WriteStream
- {
- get { return _bag.GetWriteStream(_name); }
- }
-
- ///
- /// Get a read-only Stream corresponding to this property name
- ///
- public Stream ReadStream
- {
- get { return _bag.GetReadStream(_name); }
- }
-
- //
- // Implementation details
- //
- private IPrinterPropertyBag _bag;
- private string _name;
- }
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM IPrintJob
- ///
- public interface IPrintJob
- {
- ///
- /// Maps to COM IPrintJob::Name
- ///
- string Name { get; }
-
- ///
- /// Maps to COM IPrintJob::Id
- ///
- ulong Id { get; }
-
- ///
- /// Maps to COM IPrintJob::PrintedPages
- ///
- ulong PrintedPages { get; }
-
- ///
- /// Maps to COM IPrintJob::TotalPages
- ///
- ulong TotalPages { get; }
-
- ///
- /// Maps to COM IPrintJob::Status
- ///
- PrintJobStatus Status { get; }
-
- ///
- /// Maps to COM IPrintJob::SubmissionTime
- ///
- DateTime SubmissionTime { get; }
-
- ///
- /// Maps to COM IPrintJob::RequestCancel
- ///
- void RequestCancel();
- }
-
- ///
- /// Maps to COM IPrinterQueueViewEvent
- ///
- public class PrinterQueueViewEventArgs : EventArgs
- {
- ///
- /// Maps to COM IPrinterQueueViewEvent::OnChanged, parameter 'pCollection'
- ///
- public IEnumerable Collection { get { return _collection; } }
-
- ///
- /// Maps to COM IPrinterQueueViewEvent::OnChanged, parameter 'ulViewOffset'
- ///
- public uint ViewOffset { get { return _viewOffset; } }
-
- ///
- /// Maps to COM IPrinterQueueViewEvent::OnChanged, parameter 'ulViewSize'
- ///
- public uint ViewSize { get { return _viewSize; } }
-
- ///
- /// Maps to COM IPrinterQueueViewEvent::OnChanged, parameter 'ulCountJobsInPrintQueue'
- ///
- public uint CountJobsInPrintQueue { get { return _countJobsInPrintQueue; } }
-
- #region Implementation details
-
- internal PrinterQueueViewEventArgs(IEnumerable collection, uint viewOffset, uint viewSize, uint countJobsInPrintQueue)
- {
- _collection = collection;
- _viewOffset = viewOffset;
- _viewSize = viewSize;
- _countJobsInPrintQueue = countJobsInPrintQueue;
- }
-
- private IEnumerable _collection;
- private uint _viewOffset;
- private uint _viewSize;
- private uint _countJobsInPrintQueue;
-
- #endregion
- }
-
- ///
- /// Maps to COM IPrinterQueueView
- ///
- public interface IPrinterQueueView
- {
- ///
- /// Maps to COM IPrinterQueueView::SetViewRange
- ///
- void SetViewRange(uint viewOffset, uint viewSize);
-
- ///
- /// Maps to COM IPrinterQueueViewEvent::OnChanged
- ///
- event EventHandler OnChanged;
- }
-
- ///
- /// Maps to COM IPrinterBidiSetRequestCallback
- ///
- public interface IPrinterBidiSetRequestCallback
- {
- ///
- /// Maps to COM IPrinterBidiSetRequestCallback::Completed
- ///
- void Completed(string response, int statusHResult);
- }
-#endif
-
- ///
- /// Maps to COM IPrinterQueueEvent
- ///
- public class PrinterQueueEventArgs : EventArgs
- {
- ///
- /// Maps to COM IPrinterQueueEvent::OnBidiResponseReceived, parameter 'bstrResponse'
- ///
- public string Response { get { return _response; } }
-
- ///
- /// Maps to COM IPrinterQueueEvent::OnBidiResponseReceived, parameter 'hrStatus'
- ///
- public int StatusHResult { get { return _statusHResult; } }
-
- //
- // Implementation details
- //
- public PrinterQueueEventArgs(string response, int statusHResult)
- {
- _response = response;
- _statusHResult = statusHResult;
- }
-
- private int _statusHResult;
- private string _response;
- }
-
- ///
- /// Maps to COM IPrinterQueue
- ///
- public interface IPrinterQueue
- {
- ///
- /// Maps to COM IPrinterQueue::Handle
- ///
- IntPtr Handle { get; }
-
- ///
- /// Maps to COM IPrinterQueue::Name
- ///
- string Name { get; }
-
- ///
- /// Maps to COM IPrinterQueue::SendBidiQuery
- ///
- void SendBidiQuery(string bidiQuery);
-
- ///
- /// Maps to COM IPrinterQueue::GetProperties
- ///
- IPrinterPropertyBag GetProperties();
-
-#if WINDOWS_81_APIS
- ///
- /// Maps to COM IPrinterQueue2::SendBidiSetRequestAsync
- ///
- /// Maps to COM callback type IPrinterBidiSetRequestCallback
- /// IPrinterExtensionAsyncOperation - async operation context
- IPrinterExtensionAsyncOperation SendBidiSetRequestAsync(string bidiRequest, IPrinterBidiSetRequestCallback callback);
-
- ///
- /// Maps to COM IPrinterQueue2::GetPrinterQueueView
- ///
- IPrinterQueueView GetPrinterQueueView(uint viewOffset, uint viewSize);
-#endif
-
- ///
- /// Maps to COM IPrinterQueueEvent::OnBidiResponseReceived
- ///
- event EventHandler OnBidiResponseReceived;
- }
-
- ///
- /// Maps to COM IPrinterExtensionRequest
- ///
- public interface IPrinterExtensionRequest
- {
- ///
- /// Maps to COM IPrinterExtensionRequest::Complete
- ///
- void Complete();
-
- ///
- /// Maps to COM IPrinterExtensionRequest::Cancel
- ///
- void Cancel(int statusHResult, string logMessage);
- }
-}
-
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/Properties/AssemblyInfo.cs b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/Properties/AssemblyInfo.cs
deleted file mode 100644
index 8b42d1af..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Microsoft.Samples.Printing.PrinterExtensionLibrary")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft Corporation")]
-[assembly: AssemblyProduct("Microsoft.Samples.Printing.PrinterExtensionLibrary")]
-[assembly: AssemblyCopyright("Copyright (c) 2011 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)]
-
-// 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/PrinterExtensionSample.sln b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln
deleted file mode 100644
index a326659a..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln
+++ /dev/null
@@ -1,149 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27004.2005
-MinimumVisualStudioVersion = 12.0
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExtensionSample", "ExtensionSample", "{9344DE0C-3F42-4605-A320-733663E320B7}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PrinterExtensionLibrary", "PrinterExtensionLibrary", "{721C5039-DB88-43E2-8369-D80B8E5A7643}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrinterExtensionSample", "ExtensionSample\PrinterExtensionSample.csproj", "{CF554A99-6889-4B86-934F-B6AADBFEFC01}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrinterExtensionLibrary", "PrinterExtensionLibrary\PrinterExtensionLibrary.csproj", "{D8DA0C4D-F972-4546-9068-8EB256F222F7}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Win10 Debug|Any CPU = Win10 Debug|Any CPU
- Win10 Debug|ARM64 = Win10 Debug|ARM64
- Win10 Debug|x64 = Win10 Debug|x64
- Win10 Debug|x86 = Win10 Debug|x86
- Win10 Release|Any CPU = Win10 Release|Any CPU
- Win10 Release|ARM64 = Win10 Release|ARM64
- Win10 Release|x64 = Win10 Release|x64
- Win10 Release|x86 = Win10 Release|x86
- Win8 Debug|Any CPU = Win8 Debug|Any CPU
- Win8 Debug|ARM64 = Win8 Debug|ARM64
- Win8 Debug|x64 = Win8 Debug|x64
- Win8 Debug|x86 = Win8 Debug|x86
- Win8 Release|Any CPU = Win8 Release|Any CPU
- Win8 Release|ARM64 = Win8 Release|ARM64
- Win8 Release|x64 = Win8 Release|x64
- Win8 Release|x86 = Win8 Release|x86
- Win8.1 Debug|Any CPU = Win8.1 Debug|Any CPU
- Win8.1 Debug|ARM64 = Win8.1 Debug|ARM64
- Win8.1 Debug|x64 = Win8.1 Debug|x64
- Win8.1 Debug|x86 = Win8.1 Debug|x86
- Win8.1 Release|Any CPU = Win8.1 Release|Any CPU
- Win8.1 Release|ARM64 = Win8.1 Release|ARM64
- Win8.1 Release|x64 = Win8.1 Release|x64
- Win8.1 Release|x86 = Win8.1 Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|Any CPU.ActiveCfg = Win10 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|Any CPU.Build.0 = Win10 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x64.Build.0 = Win10 Debug|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x86.ActiveCfg = Win10 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x86.Build.0 = Win10 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|Any CPU.ActiveCfg = Win10 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|Any CPU.Build.0 = Win10 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x64.ActiveCfg = Win10 Release|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x64.Build.0 = Win10 Release|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x86.ActiveCfg = Win10 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x86.Build.0 = Win10 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|Any CPU.Build.0 = Win8 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|ARM64.Build.0 = Win8 Debug|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|x64.Build.0 = Win8 Debug|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|x86.ActiveCfg = Win8 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|x86.Build.0 = Win8 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|Any CPU.ActiveCfg = Win8 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|Any CPU.Build.0 = Win8 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|ARM64.ActiveCfg = Win8 Release|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|ARM64.Build.0 = Win8 Release|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|x64.ActiveCfg = Win8 Release|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|x64.Build.0 = Win8 Release|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|x86.ActiveCfg = Win8 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|x86.Build.0 = Win8 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|Any CPU.ActiveCfg = Win8.1 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|Any CPU.Build.0 = Win8.1 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|ARM64.Build.0 = Win8.1 Debug|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|x86.ActiveCfg = Win8.1 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|x86.Build.0 = Win8.1 Debug|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|Any CPU.ActiveCfg = Win8.1 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|Any CPU.Build.0 = Win8.1 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|ARM64.Build.0 = Win8.1 Release|ARM64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x86.ActiveCfg = Win8.1 Release|x86
- {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x86.Build.0 = Win8.1 Release|x86
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|Any CPU.ActiveCfg = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|Any CPU.Build.0 = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|ARM64.Build.0 = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x64.ActiveCfg = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x64.Build.0 = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x86.ActiveCfg = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x86.Build.0 = Win10 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|Any CPU.ActiveCfg = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|Any CPU.Build.0 = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|ARM64.ActiveCfg = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|ARM64.Build.0 = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x64.ActiveCfg = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x64.Build.0 = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x86.ActiveCfg = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x86.Build.0 = Win10 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|Any CPU.Build.0 = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|ARM64.Build.0 = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x64.ActiveCfg = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x64.Build.0 = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x86.ActiveCfg = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x86.Build.0 = Win8 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|Any CPU.ActiveCfg = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|Any CPU.Build.0 = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|ARM64.Build.0 = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|x64.ActiveCfg = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|x64.Build.0 = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|x86.ActiveCfg = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|x86.Build.0 = Win8 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|Any CPU.ActiveCfg = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|Any CPU.Build.0 = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|ARM64.Build.0 = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|x86.ActiveCfg = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|x86.Build.0 = Win8.1 Debug|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|Any CPU.ActiveCfg = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|Any CPU.Build.0 = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|ARM64.Build.0 = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x64.Build.0 = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x86.ActiveCfg = Win8.1 Release|Any CPU
- {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x86.Build.0 = Win8.1 Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {CF554A99-6889-4B86-934F-B6AADBFEFC01} = {9344DE0C-3F42-4605-A320-733663E320B7}
- {D8DA0C4D-F972-4546-9068-8EB256F222F7} = {721C5039-DB88-43E2-8369-D80B8E5A7643}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {5B431928-8836-4F52-A5C2-080A90BE06D3}
- EndGlobalSection
-EndGlobal
diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/README.md b/print/v4PrintDriverSamples/PrinterExtensionSample/README.md
deleted file mode 100644
index 043811a4..00000000
--- a/print/v4PrintDriverSamples/PrinterExtensionSample/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-page_type: sample
-description: "Demonstrates how to use .NET to build a customized, desktop UI for a v4 print driver."
-languages:
-- csharp
-products:
-- windows
-- windows-wdk
----
-
-# Printer Extension Sample
-
-This sample demonstrates how to use .NET to build a customized, desktop UI for a v4 print driver. This .NET app uses PrintTicket, PrintCapabilities and Bidi in order to communicate with the print system and is suitable for inclusion in a v4 print driver.
-
-> [!NOTE]
-> This sample is for the v4 print driver model.
-
-## Related topics
-
-[Building a Driver with Visual Studio and the WDK](https://docs.microsoft.com/windows-hardware/drivers/develop/building-a-driver)
-
-[v4 Printer Driver](https://docs.microsoft.com/windows-hardware/drivers/print/v4-printer-driver)
--
cgit v1.3.1