/// <summary> /// This method is invoked when there is an error retrieving Bidi information. /// A mock bidi response is loaded from resource and displayed. /// </summary> private void MockInkStatus() { // // Load mock bidi response resource. // Assembly a = Assembly.GetExecutingAssembly(); Stream xmlData = a.GetManifestResourceStream("PrinterExtensionSample.bidi_Ink_mock.xml"); StreamReader sr = new StreamReader(xmlData); string xmlString = sr.ReadToEnd(); // // Display the ink levels from the mock data. // BidiHelperSource = new BidiHelper(xmlString); if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("BidiHelperSource")); } InkStatusTitle = "Ink status (Mocked data)"; }
/// <summary> /// This is the method invoked when a bidi response is received. /// </summary> /// <param name="sender">IPrinterQueue object.</param> /// <param name="e">The results of the bidi response.</param> private void OnBidiResponseReceived(object sender, PrinterQueueEventArgs e) { if (e.StatusHResult != (int)HRESULT.S_OK) { MockInkStatus(); return; } // // Display the ink levels from the mock data. // BidiHelperSource = new BidiHelper(e.Response); if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("BidiHelperSource")); } InkStatusTitle = "Ink status (Live data)"; }