// The MIT License (MIT) // Copyright (c) 2013 Yin-Chun Wang // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using NTwain.Data; using NTwain.Values; using System; namespace NTwain.Triplets { public sealed class Capability : OpBase { internal Capability(TwainSession session) : base(session) { } /// /// Returns the Source’s Current, Default and Available Values for a specified capability. /// /// The capability. /// public ReturnCode Get(TWCapability capability) { Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.Get); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Get, capability); } /// /// Returns the Source’s Current Value for the specified capability. /// /// The capability. /// public ReturnCode GetCurrent(TWCapability capability) { Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetCurrent); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetCurrent, capability); } /// /// Returns the Source’s Default Value. This is the Source’s preferred default value. /// /// The capability. /// public ReturnCode GetDefault(TWCapability capability) { Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.GetDefault); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetDefault, capability); } /// /// Returns help text suitable for use in a GUI; for instance: "Specify the amount of detail in an /// image. Higher values result in more detail." for ICapXRESOLUTION. /// /// The capability. /// public ReturnCode GetHelp(TWCapability capability) { Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetHelp); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetHelp, capability); } /// /// Returns a label suitable for use in a GUI, for instance "Resolution:" /// for ICapXRESOLUTION. /// /// The capability. /// public ReturnCode GetLabel(TWCapability capability) { Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabel); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetLabel, capability); } /// /// Return all of the labels for a capability of type or , for example /// "US Letter" for ICapSupportedSizes’ TWSS_USLETTER. /// /// The capability. /// public ReturnCode GetLabelEnum(TWCapability capability) { Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.GetLabelEnum); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.GetLabelEnum, capability); } /// /// Returns the Source’s support status of this capability. /// /// The capability. /// public ReturnCode QuerySupport(TWCapability capability) { Session.VerifyState(4, 7, DataGroups.Control, DataArgumentType.Capability, Message.QuerySupport); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.QuerySupport, capability); } /// /// Change the Current Value of the specified capability back to its power-on value and return the /// new Current Value. /// /// The capability. /// public ReturnCode Reset(TWCapability capability) { Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.Reset); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Reset, capability); } /// /// This command resets all of the current values and constraints to their defaults for all of the /// negotiable capabilities supported by the driver. /// /// The capability. /// public ReturnCode ResetAll(TWCapability capability) { Session.VerifyState(4, 4, DataGroups.Control, DataArgumentType.Capability, Message.ResetAll); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.ResetAll, capability); } /// /// Changes the Current Value(s) and Available Values of the specified capability to those specified /// by the application. /// Current Values are set when the container is a or . Available and /// Current Values are set when the container is a or . /// /// The capability. /// public ReturnCode Set(TWCapability capability) { Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.Capability, Message.Set); return PInvoke.DsmEntry(Session.AppId, Session.SourceId, Message.Set, capability); } } }