Exemple #1
0
        private void CapabilitiesListValuesForm_Load(object sender, EventArgs e)
        {
            Int32         value;
            string        valueString = string.Empty;
            WiaCapability capability  = (WiaCapability)FrmMain._capabilitiesList[_selItemIndex];

            _tbPropertyName.Text = capability.PropertyName;

            if ((capability.PropertyAttributes & WiaPropertyAttributesFlags.List) == WiaPropertyAttributesFlags.List)
            {
                // Set the dialog caption.
                this.Text = "WIA List Property Values";

                // Change the list control label text.
                _lblValues.Text = "List Values";

                if (capability.Values.ListValues.ValuesCount <= 0)
                {
                    return;
                }

                int index = 0;
                // Add the list values to the list.
                foreach (object i in capability.Values.ListValues.Values)
                {
                    if (capability.VariableType == WiaVariableTypes.Bstr)
                    {
                        valueString = Convert.ToString(capability.Values.ListValues.Values[index]);
                    }
                    else if (capability.VariableType == WiaVariableTypes.Clsid)
                    {
                        System.Guid guidValue = (System.Guid)capability.Values.ListValues.Values[index];
                        valueString = guidValue.ToString();
                    }
                    else
                    {
                        value = Convert.ToInt32(capability.Values.ListValues.Values[index]);
                        int ret = HelperFunctions.GetWiaListPropertyValueString(capability.PropertyId, (int)value);
                        if (ret == 0)
                        {
                            // Add the received value as is to the values list.
                            valueString = value.ToString();
                        }
                        else
                        {
                            valueString = HelperFunctions.ListPropertyValueString;
                        }
                    }
                    if (!string.IsNullOrEmpty(valueString))
                    {
                        _lbValues.Items.Add(valueString);
                    }

                    index++;
                }
            }
            else
            {
                // Set the dialog caption.
                this.Text = "WIA Flag Property Values";

                // Change the list control label text.
                _lblValues.Text = "Flag Values";

                value = capability.Values.FlagsValues.FlagValues;
                int ret = HelperFunctions.GetWiaFlagPropertyValueString(capability.PropertyId, value);
                if (ret == 0)
                {
                    // add the values with their native ID's
                    _lbValues.Items.Add(value.ToString());
                }
                else
                {
                    foreach (string i in FrmMain._flagValuesStrings)
                    {
                        _lbValues.Items.Add(i);
                    }
                }
            }
        }