/// <summary>
        /// Adds information about the value of capability in specified usage mode to the string builder.
        /// </summary>
        /// <param name="capUsageMode"></param>
        /// <param name="capValue"></param>
        /// <param name="capsInfo"></param>
        private void AddCapInfoToCapsInfo(DeviceCapabilityUsageMode capUsageMode, TwainValueContainerBase capValue, StringBuilder capsInfo)
        {
            capsInfo.Append(string.Format("  Usage mode: {0}{1}", capUsageMode, Environment.NewLine));
            capsInfo.Append(string.Format("    Value container type: {0}{1}", capValue.ContainerType, Environment.NewLine));

            switch (capValue.ContainerType)
            {
            case TwainValueContainerType.OneValue:
                TwainOneValueContainer oneDeviceCapabilityValue = (TwainOneValueContainer)capValue;
                AddCapOneCurrentValueInfoToCapsInfo(oneDeviceCapabilityValue, capsInfo);
                break;

            case TwainValueContainerType.Range:
                TwainRangeValueContainer rangeDeviceCapabilityValue = (TwainRangeValueContainer)capValue;
                AddCapRangeCurrentValueInfoToCapsInfo(rangeDeviceCapabilityValue, capsInfo);
                AddCapRangeDefaultValueInfoToCapsInfo(rangeDeviceCapabilityValue, capsInfo);
                AddCapMinValueInfoToCapsInfo(rangeDeviceCapabilityValue, capsInfo);
                AddCapMaxValueInfoToCapsInfo(rangeDeviceCapabilityValue, capsInfo);
                AddCapStepSizeInfoToCapsInfo(rangeDeviceCapabilityValue, capsInfo);
                break;

            case TwainValueContainerType.Enum:
                TwainEnumValueContainer enumDeviceCapabilityValue = (TwainEnumValueContainer)capValue;
                AddCapEnumCurrentValueInfoToCapsInfo(enumDeviceCapabilityValue, capsInfo);
                AddCapEnumDefaultValueInfoToCapsInfo(enumDeviceCapabilityValue, capsInfo);
                AddCapValuesInfoToCapsInfo(enumDeviceCapabilityValue, capsInfo);
                break;

            case TwainValueContainerType.Array:
                TwainArrayValueContainer arrayDeviceCapabilityValue = (TwainArrayValueContainer)capValue;
                AddCapValuesInfoToCapsInfo(arrayDeviceCapabilityValue, capsInfo);
                break;
            }
        }
 /// <summary>
 /// Gets information about the step size of value stored in Enum container.
 /// </summary>
 /// <param name="deviceCapabilityValue"></param>
 /// <param name="capsInfo"></param>
 private void AddCapStepSizeInfoToCapsInfo(TwainRangeValueContainer deviceCapabilityValue, StringBuilder capsInfo)
 {
     capsInfo.Append(string.Format("    Step size: {0} ({1}){2}", deviceCapabilityValue.StepSize, deviceCapabilityValue.StepSize.GetType(), Environment.NewLine));
 }
 /// <summary>
 /// Gets information about the step size of value stored in Enum container.
 /// </summary>
 /// <param name="deviceCapabilityValue"></param>
 private void AddCapStepSizeToForm(TwainRangeValueContainer deviceCapabilityValue)
 {
     stepSizeTextBox.Text = deviceCapabilityValue.StepSize.ToString();
 }
 /// <summary>
 /// Gets information about the maximal value stored in Enum container.
 /// </summary>
 /// <param name="deviceCapabilityValue"></param>
 private void AddCapMaxValueToForm(TwainRangeValueContainer deviceCapabilityValue)
 {
     maxValueTextBox.Text = deviceCapabilityValue.MaxValue.ToString();
 }
 /// <summary>
 /// Gets information about the default value stored in Range container.
 /// </summary>
 /// <param name="deviceCapabilityValue"></param>
 private void AddCapRangeDefaultValueToForm(TwainRangeValueContainer deviceCapabilityValue)
 {
     defaultValueTextBox.Text = deviceCapabilityValue.DefaultValue.ToString();
 }
 /// <summary>
 /// Gets information about the current value stored in Range container.
 /// </summary>
 /// <param name="deviceCapabilityValue"></param>
 private void AddCapRangeCurrentValueToForm(TwainRangeValueContainer deviceCapabilityValue)
 {
     currentValueTextBox.Text = deviceCapabilityValue.Value.ToString();
 }
        /// <summary>
        /// Gets information about value of specified capability in specified usage mode.
        /// </summary>
        /// <param name="deviceCapability"></param>
        /// <param name="usageMode"></param>
        private void GetCapValue(DeviceCapability deviceCapability, DeviceCapabilityUsageMode usageMode)
        {
            usageModeTextBox.Text     = "";
            containerTypeTextBox.Text = "";
            valueTypeTextBox.Text     = "";
            currentValueTextBox.Text  = "";
            minValueTextBox.Text      = "";
            maxValueTextBox.Text      = "";
            defaultValueTextBox.Text  = "";
            stepSizeTextBox.Text      = "";
            supportedValuesListBox.Items.Clear();

            try
            {
                TwainValueContainerBase deviceCapabilityValue = null;
                if (usageMode == DeviceCapabilityUsageMode.GetCurrent)
                {
                    deviceCapabilityValue = deviceCapability.GetCurrentValue();
                }
                else if (usageMode == DeviceCapabilityUsageMode.GetDefault)
                {
                    deviceCapabilityValue = deviceCapability.GetDefaultValue();
                }
                else
                {
                    deviceCapabilityValue = deviceCapability.GetValue();
                }

                if (getMethodComboBox.Items.Count == 0)
                {
                    //
                    usageModeTextBox.Text = deviceCapability.UsageMode.ToString();
                    //
                    if ((deviceCapability.UsageMode & DeviceCapabilityUsageMode.Get) != 0)
                    {
                        getMethodComboBox.Items.Add(DeviceCapabilityUsageMode.Get);
                    }
                    if ((deviceCapability.UsageMode & DeviceCapabilityUsageMode.GetCurrent) != 0)
                    {
                        getMethodComboBox.Items.Add(DeviceCapabilityUsageMode.GetCurrent);
                    }
                    if ((deviceCapability.UsageMode & DeviceCapabilityUsageMode.GetDefault) != 0)
                    {
                        getMethodComboBox.Items.Add(DeviceCapabilityUsageMode.GetDefault);
                    }
                }

                if (deviceCapabilityValue != null)
                {
                    //
                    containerTypeTextBox.Text = deviceCapabilityValue.ContainerType.ToString();
                    valueTypeTextBox.Text     = deviceCapability.ValueType.ToString();

                    //
                    switch (deviceCapabilityValue.ContainerType)
                    {
                    case TwainValueContainerType.OneValue:
                        TwainOneValueContainer oneDeviceCapabilityValue = (TwainOneValueContainer)deviceCapabilityValue;
                        AddCapOneCurrentValueToForm(oneDeviceCapabilityValue);
                        break;

                    case TwainValueContainerType.Range:
                        TwainRangeValueContainer rangeDeviceCapabilityValue = (TwainRangeValueContainer)deviceCapabilityValue;
                        AddCapRangeCurrentValueToForm(rangeDeviceCapabilityValue);
                        AddCapRangeDefaultValueToForm(rangeDeviceCapabilityValue);
                        AddCapMinValueToForm(rangeDeviceCapabilityValue);
                        AddCapMaxValueToForm(rangeDeviceCapabilityValue);
                        AddCapStepSizeToForm(rangeDeviceCapabilityValue);
                        break;

                    case TwainValueContainerType.Enum:
                        TwainEnumValueContainer enumDeviceCapabilityValue = (TwainEnumValueContainer)deviceCapabilityValue;
                        AddCapEnumCurrentValueToForm(enumDeviceCapabilityValue);
                        AddCapEnumDefaultValueToForm(enumDeviceCapabilityValue);
                        AddCapValuesToForm(enumDeviceCapabilityValue);
                        break;

                    case TwainValueContainerType.Array:
                        TwainArrayValueContainer arrayDeviceCapabilityValue = (TwainArrayValueContainer)deviceCapabilityValue;
                        AddCapValuesToForm(arrayDeviceCapabilityValue);
                        break;
                    }
                }
            }
            catch (TwainDeviceCapabilityException ex)
            {
                currentValueTextBox.Text = ex.Message;
            }
        }