internal override sealed void OptionAttrCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { // no option attribute to handle return; }
internal override sealed bool OptionPropCallback(PrintCapabilityOption option, XmlPrintCapReader reader) { // no option property to handle return(false); }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { NUpOption option = baseOption as NUpOption; bool handled = false; // we are only handling scored property here if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.NUpKeys.PagesPerSheet) { try { option._pagesPerSheet = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } handled = true; } } return(handled); }
internal override sealed bool FeaturePropCallback(PrintCapabilityFeature feature, XmlPrintCapReader reader) { // no feature property to handle return(false); }
/// <summary> /// Constructs a new builder for the given XML Print Capabilities /// </summary> /// <param name="xmlStream">readable stream containing the Print Capabilities XML</param> /// <exception cref="FormatException">thrown by XmlPrintCapReader if XML Print Capabilities is not well-formed</exception> public PrintCapBuilder(Stream xmlStream) { // Instantiates the reader _reader = new XmlPrintCapReader(xmlStream); }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { FixedMediaSizeOption option = baseOption as FixedMediaSizeOption; bool handled = false; if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { handled = true; string sPropertyName = reader.CurrentElementNameAttrValue; if ((sPropertyName == PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeWidth) || (sPropertyName == PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeHeight)) { if (reader.MoveToNextSchemaElement(reader.CurrentElementDepth + 1, PrintSchemaNodeTypes.ScoredPropertyLevelTypes)) { if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.Value) { // Child property is Value for fixed media size int intValue = 0; bool convertOK = false; try { intValue = XmlConvertHelper.ConvertStringToInt32(reader.CurrentElementTextValue); convertOK = true; } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- Invalid int value '" + reader.CurrentElementTextValue + "' at line number " + reader._xmlReader.LineNumber + ", line position " + reader._xmlReader.LinePosition + ": " + e.Message); #endif } if (convertOK) { if (sPropertyName == PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeWidth) { option._mediaSizeWidth = intValue; } else { option._mediaSizeHeight = intValue; } } } } else { #if _DEBUG Trace.WriteLine("-Error- Missing required Value or ParameterRef child-element at line number " + reader._xmlReader.LineNumber + ", line position " + reader._xmlReader.LinePosition); #endif } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown ScoredProperty '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } return(handled); }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { ResolutionOption option = baseOption as ResolutionOption; bool handled = false; if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { handled = true; if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageResolutionKeys.ResolutionX) { try { option._resolutionX = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageResolutionKeys.ResolutionY) { try { option._resolutionY = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageResolutionKeys.QualitativeResolution) { int enumValue; if (PrintSchemaMapper.CurrentPropertyQValueToEnumValue(reader, PrintSchemaTags.Keywords.PageResolutionKeys.QualityNames, PrintSchemaTags.Keywords.PageResolutionKeys.QualityEnums, out enumValue)) { option._qualityValue = (PageQualitativeResolution)enumValue; } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown ScoredProperty '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } return(handled); }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { bool handled = false; ScalingOption option = baseOption as ScalingOption; if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { handled = true; string sPropertyName = reader.CurrentElementNameAttrValue; if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleWidth) || (sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleHeight) || (sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomSquareScale)) { // custom or custom square scaling properties try { string paramRefName = reader.GetCurrentPropertyParamRefNameWithException(); if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleWidth) && (paramRefName == PrintSchemaTags.Keywords.ParameterDefs.PageScalingScaleWidth)) { option._scaleWIndex = (int)PrintSchemaLocalParameterDefs.PageScalingScaleWidth; // Mark the local parameter-def as required option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleWIndex, true); } else if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleHeight) && (paramRefName == PrintSchemaTags.Keywords.ParameterDefs.PageScalingScaleHeight)) { option._scaleHIndex = (int)PrintSchemaLocalParameterDefs.PageScalingScaleHeight; // Mark the local parameter-def as required option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleHIndex, true); } else if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomSquareScale) && (paramRefName == PrintSchemaTags.Keywords.ParameterDefs.PageSquareScalingScale)) { option._squareScaleIndex = (int)PrintSchemaLocalParameterDefs.PageSquareScalingScale; // Mark the local parameter-def as required option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._squareScaleIndex, true); } else { #if _DEBUG Trace.WriteLine("-Warning- skip unknown ParameterRef " + paramRefName + "' at line number " + reader._xmlReader.LineNumber + ", line position " + reader._xmlReader.LinePosition); #endif } } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown ScoredProperty '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } return(handled); }
/// <summary> /// Standard PrintCapabilities feature option-property callback. /// </summary> internal abstract bool OptionPropCallback(PrintCapabilityOption option, XmlPrintCapReader reader);
/// <exception cref="XmlException">XML parser finds non-well-formness of XML</exception> internal override sealed bool BuildProperty(XmlPrintCapReader reader) { #if _DEBUG Trace.Assert(reader.CurrentElementNodeType == PrintSchemaNodeTypes.Property, "THIS SHOULD NOT HAPPEN: RootPropertyPropCallback gets non-Property node"); #endif int subPropDepth = reader.CurrentElementDepth + 1; // Loops over immediate property children of the root-level property while (reader.MoveToNextSchemaElement(subPropDepth, PrintSchemaNodeTypes.Property)) { if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.ImageableSizeWidth) { try { this._imageableSizeWidth = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.ImageableSizeHeight) { try { this._imageableSizeHeight = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.ImageableArea) { this._imageableArea = new CanvasImageableArea(this); // When need to loop at a deeper depth, the code should cache the desired depth // value and use the cached value in the while-loop. Using CurrentElementDepth // in while-loop won't work correctly since the CurrentElementDepth value is changing. int iaPropDepth = reader.CurrentElementDepth + 1; // loop over one level down to read "ImageableArea" child-element properties while (reader.MoveToNextSchemaElement(iaPropDepth, PrintSchemaNodeTypes.Property)) { if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.OriginWidth) { try { this._imageableArea._originWidth = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.OriginHeight) { try { this._imageableArea._originHeight = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.ExtentWidth) { try { this._imageableArea._extentWidth = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageImageableSizeKeys.ExtentHeight) { try { this._imageableArea._extentHeight = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else { #if _DEBUG Trace.WriteLine("-Warning- skip unknown ImageableArea sub-property '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } } else { #if _DEBUG Trace.WriteLine("-Warning- skip unknown PageImageableSize sub-Property '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } bool isValid = false; // We require ImageableSizeWidth/Height and ExtentWidth/Height values must be non-negative if ((this._imageableSizeWidth >= 0) && (this._imageableSizeHeight >= 0)) { isValid = true; // If ImageableArea is present, then its ExtentWidth/Height values must be non-negative. if (this.ImageableArea != null) { isValid = false; if ((this.ImageableArea._extentWidth >= 0) && (this.ImageableArea._extentHeight >= 0)) { isValid = true; } } } else { #if _DEBUG Trace.WriteLine("-Error- invalid PageImageableSize size values: " + this.ToString()); #endif } return(isValid); }
/// <summary> /// Standard PrintCapabilities feature option-attribute callback. /// </summary> internal abstract void OptionAttrCallback(PrintCapabilityOption option, XmlPrintCapReader reader);
/// <summary> /// Standard PrintCapabilities feature feature-property calllback. /// </summary> internal abstract bool FeaturePropCallback(PrintCapabilityFeature feature, XmlPrintCapReader reader);
// derived types must implement following abstract method /// <summary> /// Standard PrintCapabilities root-level property's callback to parse and build itself. /// </summary> internal abstract bool BuildProperty(XmlPrintCapReader reader);
// With current design, all parameter-def properties are generic to any specific parameters, // so we just need to implement the prop-callback at the base class level and all derived // classes will inherit the implementation. /// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool ParamDefPropCallback(ParameterDefinition baseParam, XmlPrintCapReader reader) { NonNegativeIntParameterDefinition param = baseParam as NonNegativeIntParameterDefinition; bool handled = true; #if _DEBUG Trace.Assert(reader.CurrentElementNodeType == PrintSchemaNodeTypes.Property, "THIS SHOULD NOT HAPPEN: NonNegativeIntParamDefPropCallback() gets non-Property node"); #endif if (reader.CurrentElementPSFNameAttrValue == PrintSchemaTags.Keywords.ParameterProps.DefaultValue) { try { param._defaultValue = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementPSFNameAttrValue == PrintSchemaTags.Keywords.ParameterProps.MaxValue) { try { param._maxValue = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementPSFNameAttrValue == PrintSchemaTags.Keywords.ParameterProps.MinValue) { try { param._minValue = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown Property '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } return(handled); }
// derived types must implement following abstract methods /// <summary> /// Standard PrintCapabilities parameter-def property callback. /// </summary> internal abstract bool ParamDefPropCallback(ParameterDefinition baseParam, XmlPrintCapReader reader);