Skip to content

Commit e464f31

Browse files
committed
WiaCopyTool
1 parent b18b8a5 commit e464f31

File tree

5 files changed

+166
-0
lines changed

5 files changed

+166
-0
lines changed

Bench.sln

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "F", "F\F.fsproj", "{CF639BEB-DCE9-46F2-8D7F-3C9C2101403E}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WiaCopyTool", "WiaCopyTool\WiaCopyTool.csproj", "{A0D941EF-1EF6-47CD-9E4F-EDD3497DC594}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{CF639BEB-DCE9-46F2-8D7F-3C9C2101403E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{CF639BEB-DCE9-46F2-8D7F-3C9C2101403E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{CF639BEB-DCE9-46F2-8D7F-3C9C2101403E}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{A0D941EF-1EF6-47CD-9E4F-EDD3497DC594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{A0D941EF-1EF6-47CD-9E4F-EDD3497DC594}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{A0D941EF-1EF6-47CD-9E4F-EDD3497DC594}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{A0D941EF-1EF6-47CD-9E4F-EDD3497DC594}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("WiaCopyTool")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("WiaCopyTool")]
12+
[assembly: AssemblyCopyright("Copyright © 2015")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// Setting ComVisible to false makes the types in this assembly not visible
17+
// to COM components. If you need to access a type in this assembly from
18+
// COM, set the ComVisible attribute to true on that type.
19+
[assembly: ComVisible(false)]
20+
21+
// The following GUID is for the ID of the typelib if this project is exposed to COM
22+
[assembly: Guid("a0d941ef-1ef6-47cd-9e4f-edd3497dc594")]
23+
24+
// Version information for an assembly consists of the following four values:
25+
//
26+
// Major Version
27+
// Minor Version
28+
// Build Number
29+
// Revision
30+
//
31+
// You can specify all the values or you can default the Build and Revision Numbers
32+
// by using the '*' as shown below:
33+
// [assembly: AssemblyVersion("1.0.*")]
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]

WiaCopyTool/WiaCopy.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace WiaCopyTool
2+
{
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
7+
using WIA;
8+
9+
public static class WiaCopy
10+
{
11+
public static IEnumerable<IDeviceInfo> GetAppleDevices()
12+
{
13+
return new DeviceManager().DeviceInfos.Cast<IDeviceInfo>().Where(di =>
14+
di.Type == WiaDeviceType.CameraDeviceType
15+
&& di.Properties["Manufacturer"].get_Value() == "Apple Inc."
16+
&& di.Properties["Description"].get_Value() == "Apple iPhone");
17+
}
18+
19+
public static IEnumerable<Item> GetImgItems(IDeviceInfo deviceInfo)
20+
{
21+
var device = deviceInfo.Connect();
22+
return device.Items.Cast<Item>().Where(i => i.Properties["Item Name"].get_Value().ToString().StartsWith("IMG"));
23+
}
24+
25+
public static void TransferItem(Item item, string path)
26+
{
27+
var targetName = item.Properties["Item Name"].get_Value() + ".jpg";
28+
Directory.CreateDirectory(path);
29+
item.Transfer().SaveFile(Path.Combine(path, targetName));
30+
}
31+
}
32+
}

WiaCopyTool/WiaCopyTool.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace WiaCopyTool
2+
{
3+
using System;
4+
using System.IO;
5+
6+
public static class WiaCopyTool
7+
{
8+
public static void Main()
9+
{
10+
var savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Auto Import");
11+
12+
foreach (var iPhone in WiaCopy.GetAppleDevices())
13+
{
14+
foreach (var imgItem in WiaCopy.GetImgItems(iPhone))
15+
{
16+
WiaCopy.TransferItem(imgItem, Path.Combine(savePath, iPhone.Properties["Name"].get_Value()));
17+
}
18+
}
19+
}
20+
}
21+
}

WiaCopyTool/WiaCopyTool.csproj

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
4+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5+
<PropertyGroup>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{A0D941EF-1EF6-47CD-9E4F-EDD3497DC594}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>WiaCopyTool</RootNamespace>
12+
<AssemblyName>WiaCopyTool</AssemblyName>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup>
36+
<StartupObject />
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="WiaCopyTool.cs" />
44+
<Compile Include="WiaCopy.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<COMReference Include="WIA">
49+
<Guid>{94A0E92D-43C0-494E-AC29-FD45948A5221}</Guid>
50+
<VersionMajor>1</VersionMajor>
51+
<VersionMinor>0</VersionMinor>
52+
<Lcid>0</Lcid>
53+
<WrapperTool>tlbimp</WrapperTool>
54+
<Isolated>False</Isolated>
55+
<EmbedInteropTypes>True</EmbedInteropTypes>
56+
</COMReference>
57+
</ItemGroup>
58+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
59+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
60+
<PropertyGroup>
61+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
62+
</PropertyGroup>
63+
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
64+
</Target>
65+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
66+
Other similar extension points exist, see Microsoft.Common.targets.
67+
<Target Name="BeforeBuild">
68+
</Target>
69+
<Target Name="AfterBuild">
70+
</Target>
71+
-->
72+
</Project>

0 commit comments

Comments
 (0)