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 ---- 20 files changed, 2175 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 (limited to 'print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample') 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -