public WiaDataSource(WIA.DeviceInfo info)
 {
   fIdent = info;
   fDevice = null;
   fItem = null;
   fCommonDialog = null;
 }
Beispiel #2
0
        private void SetupPageSize(WIA.Item item, PageSize pageSize, ColorDepth colorDepth, Resolution resolution, Orientation orientation, bool setSize)
        {
            if (item == null)
                return;

            item.Properties["Horizontal Resolution"].set_Value(resolution.Value);
            item.Properties["Vertical Resolution"].set_Value(resolution.Value);
            item.Properties["Current Intent"].set_Value(colorDepth.Value);
            item.Properties["Bits Per Pixel"].set_Value(colorDepth.BitsPerPixel);

            double hExtent = item.Properties["Horizontal Extent"].SubTypeMax;
            double vExtent = item.Properties["Vertical Extent"].SubTypeMax;

            if (setSize)
            {
                if (orientation.Direction == 0)
                {
                    item.Properties["Horizontal Extent"].set_Value(resolution.Value * pageSize.Width);
                    item.Properties["Vertical Extent"].set_Value(resolution.Value * pageSize.Height);
                }
                else
                {
                    item.Properties["Horizontal Extent"].set_Value(resolution.Value * pageSize.Height);
                    item.Properties["Vertical Extent"].set_Value(resolution.Value * pageSize.Width);
                }
            }
            else
            {
                item.Properties["Horizontal Extent"].set_Value(hExtent);
                item.Properties["Vertical Extent"].set_Value(vExtent);
            }
        }
Beispiel #3
0
        public WIA.Device ShowSelectDevice(WIA.WiaDeviceType DeviceType = WIA.WiaDeviceType.UnspecifiedDeviceType, bool AlwaysSelectDevice = false, bool CancelError = false)
        {
            var vm = new DeviceDialogViewModel();
            _wm.ShowWindow(vm);

            if (vm.Device == null) return null;

            return vm.Connect();
        }
 public static void SetProperty(WIA.Properties properties, WiaProperty propertyId, object value)
 {
   foreach(WIA.Property property in properties)
   {
     if(property.PropertyID == (int)propertyId)
     {
       property.set_Value(value);
       break;
     }
   }
 }
      public static object GetProperty(WIA.Properties properties, WiaProperty propertyId)
      {
        object result = null;

        foreach(WIA.Property property in properties)
        {
          if(property.PropertyID == (int)propertyId)
          {
            result = property.get_Value();
            break;
          }
        }

        return result;
      }
Beispiel #6
0
        private void SetupPageSize(WIA.Item item, PageSize pageSize, int colorDepth, int bpp, int dotsPerInch, int rotation)
        {
            if (item == null) return;

               // item.Properties["Rotation"].set_Value(rotation);

            item.Properties["Horizontal Resolution"].set_Value(dotsPerInch);
            item.Properties["Vertical Resolution"].set_Value(dotsPerInch);

            if (rotation == 0)
            {
                item.Properties["Horizontal Extent"].set_Value(dotsPerInch * pageSize.Width);
                item.Properties["Vertical Extent"].set_Value(dotsPerInch * pageSize.Height);
            }
            else
            {
                item.Properties["Horizontal Extent"].set_Value(dotsPerInch * pageSize.Height);
                item.Properties["Vertical Extent"].set_Value(dotsPerInch * pageSize.Width);
            }
            item.Properties["Current Intent"].set_Value(colorDepth);
            item.Properties["Bits Per Pixel"].set_Value(bpp);
        }
Beispiel #7
0
		private void WritePropertiesToFile(WIA.Properties properties)
		{
			foreach (Property prop in properties)
			{
				var name = prop.Name;
				var val = prop.get_Value();
				int? min = null;
				int? max = null;
				try
				{
					min = prop.SubTypeMin;
					max = prop.SubTypeMax;
				}
				catch (Exception)
				{
				}

				File.AppendAllText(
					"info2.txt",
					string.Format("id: {4}, name: {0}, val: {1}, min: {2}, max: {3}\r\n", name, val, min.HasValue ? min.Value.ToString() : "", max.HasValue ? max.Value.ToString() : "", prop.PropertyID));
				
			}
		}
Beispiel #8
0
		private Property FindProperty(WIA.Properties properties, WiaProperty property)
		{
			Log("Try to find property: " + property);
			foreach (Property prop in properties)
			{
				if (prop.PropertyID == (int)property)
				{
					Log(string.Format("Property '{0}' was found", property));
					return prop;
				}
			}
			Log(string.Format("Property '{0}' was not found", property));
			return null;
		}
Beispiel #9
0
 private static int GetDeviceProperty( WIA.Device device, string propertyId )
 {
     return (int) ( from WIA.Property property in device.Properties
                    where property.PropertyID == Convert.ToUInt32( propertyId )
                    select property.get_Value() ).FirstOrDefault();
 }
Beispiel #10
0
        public WiaDevice(WIA.Device device)
        {
            this.device = device;

            properties = new WiaPropertyMap(device);
        }
Beispiel #11
0
 public dynamic ShowTransfer(WIA.Item Item, string FormatID = "{00000000-0000-0000-0000-000000000000}", bool CancelError = false)
 {
     throw new System.NotImplementedException();
 }
Beispiel #12
0
 internal WebcamWIA(WIA.DeviceInfo deviceInfo)
 {
     m_deviceInfo = deviceInfo;
     foreach (WIA.Property property in deviceInfo.Properties) {
         if (property.Name.Equals("Name", StringComparison.OrdinalIgnoreCase)) {
             m_name = (string)property.get_Value();
             break;
         }
     }
 }
Beispiel #13
0
 public void ShowItemProperties(WIA.Item Item, bool CancelError = false)
 {
     throw new System.NotImplementedException();
 }
Beispiel #14
0
 public void ShowDeviceProperties(WIA.Device Device, bool CancelError = false)
 {
     throw new System.NotImplementedException();
 }
Beispiel #15
0
 public dynamic ShowAcquisitionWizard(WIA.Device Device)
 {
     throw new System.NotImplementedException();
 }
Beispiel #16
0
 public WIA.ImageFile ShowAcquireImage(WIA.WiaDeviceType DeviceType = WIA.WiaDeviceType.UnspecifiedDeviceType, WIA.WiaImageIntent Intent = WIA.WiaImageIntent.UnspecifiedIntent, WIA.WiaImageBias Bias = WIA.WiaImageBias.MaximizeQuality, string FormatID = "{00000000-0000-0000-0000-000000000000}", bool AlwaysSelectDevice = false, bool UseCommonUI = true, bool CancelError = false)
 {
     throw new System.NotImplementedException();
 }
 public static Image WiaImageFileToImage(WIA.ImageFile imageFile)
 {
   // Converts the ImageFile to a byte array, then to an Image
   Byte[] imageBytes = (byte[])imageFile.FileData.get_BinaryData();
   return Imaging.ImageFromByteArray(imageBytes);
 }
		private static Property FindProperty(WIA.Properties properties, WiaProperty property)
		{
			foreach (Property prop in properties)
			{
				if (prop.PropertyID == (int)property)
				{
					return prop;
				}
			}
			return null;
		}
Beispiel #19
0
 public WIA.Items ShowSelectItems(WIA.Device Device, WIA.WiaImageIntent Intent = WIA.WiaImageIntent.UnspecifiedIntent, WIA.WiaImageBias Bias = WIA.WiaImageBias.MaximizeQuality, bool SingleSelect = true, bool UseCommonUI = true, bool CancelError = false)
 {
     throw new System.NotImplementedException();
 }
Beispiel #20
0
 //TODO: possibly reverse iteration to improve performance
 private bool DeleteItem(WIA.Items items, string itemId)
 {
     for (int x = 1; x <= items.Count; x++) {
         if (items[x].ItemID == itemId) {
             items.Remove(x);
             return true;
         } else if (items[x].Items.Count > 0) {
             if (DeleteItem(items[x].Items, itemId)) {
                 return true;
             }
         }
     }
     return false;
 }