internal override sealed PrintCapabilityOption NewOptionCallback(PrintCapabilityFeature baseFeature) { ScalingOption newOption = new ScalingOption(baseFeature); return(newOption); }
/// <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); }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool complete = false; ScalingOption option = baseOption as ScalingOption; if (option._optionName != null) { int enumValue = PrintSchemaMapper.SchemaNameToEnumValueWithArray( PrintSchemaTags.Keywords.PageScalingKeys.ScalingNames, PrintSchemaTags.Keywords.PageScalingKeys.ScalingEnums, option._optionName); if (enumValue > 0) { option._value = (PageScaling)enumValue; } } if (option.Value != PageScaling.Unspecified) { if (option.Value == PageScaling.None) { // Non-custom scaling option doesn't need any ParameterRefs complete = true; } else if (option.Value == PageScaling.Custom) { // Custom scaling option must have the 2 scale ParameterRefs if ((option._scaleWIndex >= 0) && (option._scaleHIndex >= 0)) { complete = true; } else { // Need to reset the local parameter required flag since we are // ignoring the custom scaling option if (option._scaleWIndex >= 0) { option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleWIndex, false); } if (option._scaleHIndex >= 0) { option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleHIndex, false); } } } else if (option.Value == PageScaling.CustomSquare) { // Custom square scaling option must have the scale ParameterRef if (option._squareScaleIndex >= 0) { complete = true; } else { // Need to reset the local parameter required flag since we are // ignoring the custom scaling option if (option._squareScaleIndex >= 0) { option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._squareScaleIndex, false); } } } } if (complete) { this.ScalingOptions.Add(option); } return(complete); }