PrinterResolution.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CommonUI / System / Drawing / Printing / PrinterResolution.cs / 1 / PrinterResolution.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Drawing.Printing { 
    using System.Runtime.Serialization.Formatters; 
    using System.Runtime.InteropServices;
    using System.Diagnostics; 
    using System.Diagnostics.CodeAnalysis;
    using System;
    using System.Drawing;
    using System.ComponentModel; 
    using Microsoft.Win32;
    using System.Globalization; 
 
    /// 
    ///  
    ///     Retrieves
    ///       the resolution supported by a printer.
    /// 
    [Serializable] 
    public class PrinterResolution {
        private int x; 
        private int y; 
        private PrinterResolutionKind kind;
 
        /// 
        /// 
        ///    
        ///       Initializes a new instance of the  class with default properties. 
        ///       This constructor is required for the serialization of the  class.
        ///     
        ///  
        public PrinterResolution()
        { 
            this.kind = PrinterResolutionKind.Custom;
        }

        internal PrinterResolution(PrinterResolutionKind kind, int x, int y) { 
            this.kind = kind;
            this.x = x; 
            this.y = y; 
        }
 
        /// 
        /// 
        ///    
        ///       Gets 
        ///       a value indicating the kind of printer resolution.
        ///       Setter added to enable serialization of the PrinterSettings object. 
        ///     
        /// 
        public PrinterResolutionKind Kind { 
            get { return kind;}
            set {
                //valid values are 0xfffffffc to 0x0
                if (!ClientUtils.IsEnumValid(value, (int)value, (int)PrinterResolutionKind.High, (int)PrinterResolutionKind.Custom)) 
                {
                    throw new InvalidEnumArgumentException("value", (int)value, typeof(PrinterResolutionKind)); 
                } 

                kind = value; 
            }
        }

        ///  
        /// 
        ///     
        ///       Gets the printer resolution in the horizontal direction, 
        ///       in dots per inch.
        ///       Setter added to enable serialization of the PrinterSettings object. 
        ///    
        /// 
        public int X {
            get { 
                return x;
            } 
            set { 
                x = value;
            } 
        }

        /// 
        ///  
        ///     Gets the printer resolution in the vertical direction,
        ///       in dots per inch. 
        ///       Setter added to enable serialization of the PrinterSettings object. 
        ///    
        ///  
        public int Y {
            get {
                return y;
            } 
            set {
                y = value; 
            } 
        }
 
        /// 
        /// 
        /// 
        ///     
        ///       Provides some interesting information about the PrinterResolution in
        ///       String form. 
        ///     
        /// 
        public override string ToString() { 
            if (kind != PrinterResolutionKind.Custom)
                return "[PrinterResolution " + TypeDescriptor.GetConverter(typeof(PrinterResolutionKind)).ConvertToString((int) Kind)
                + "]";
            else 
                return "[PrinterResolution"
                + " X=" + X.ToString(CultureInfo.InvariantCulture) 
                + " Y=" + Y.ToString(CultureInfo.InvariantCulture) 
                + "]";
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007. 
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK