[Roam-commit] SF.net SVN: roam: [110] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-12-12 08:38:10
|
Revision: 110
http://roam.svn.sourceforge.net/roam/?rev=110&view=rev
Author: jonfroehlich
Date: 2007-12-12 00:38:05 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
updated CameraMediaCapturedSniffer
Modified Paths:
--------------
Trunk/Source/Roam/Media/CameraMediaCapturedSniffer.cs
Trunk/Source/Roam/Roam.csproj
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.sln
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam/Media/CameraMediaCapturedSniffer.cs
===================================================================
--- Trunk/Source/Roam/Media/CameraMediaCapturedSniffer.cs 2007-12-07 06:40:03 UTC (rev 109)
+++ Trunk/Source/Roam/Media/CameraMediaCapturedSniffer.cs 2007-12-12 08:38:05 UTC (rev 110)
@@ -20,6 +20,7 @@
using System.Threading;
using Microsoft.WindowsMobile.Status;
using System.Diagnostics;
+using Roam.Utils;
namespace Roam.Media
{
@@ -38,6 +39,7 @@
{
public event EventHandler<MediaCapturedEventArgs> MediaCaptured;
+ #region Fields
private List<FileSystemWatcher> _listFileSystemWatchers = new List<FileSystemWatcher>();
/// <summary>
@@ -47,8 +49,10 @@
/// not work. Therefore, our filter is set to *.* -- we can always filter
/// after we receive a FileCreatedEvent
/// </summary>
- private string _filter = "*.*";
+ private string _filter = "*.*";
+ #endregion Fields
+ #region Constructors
public CameraMediaCapturedSniffer()
{
string[] paths = GetMediaPathsToMonitor();
@@ -62,27 +66,21 @@
FileSystemWatcher fsw = new FileSystemWatcher(paths[i], _filter);
fsw.Created += new FileSystemEventHandler(OnFileCreated);
+ fsw.IncludeSubdirectories = true;
fsw.EnableRaisingEvents = true;
- fsw.NotifyFilter = NotifyFilters.FileName;
+ fsw.NotifyFilter = NotifyFilters.FileName;// | NotifyFilters.DirectoryName;
- FileSystemWatcher fsw2 = new FileSystemWatcher(paths[i], _filter);
- fsw2.Changed += new FileSystemEventHandler(OnFileChanged);
- fsw2.EnableRaisingEvents = true;
- fsw2.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
-
_listFileSystemWatchers.Add(fsw);
}
}
+ #endregion Constructors
- public virtual void OnFileChanged(object sender, FileSystemEventArgs e)
- {
- Debug.WriteLine("OnFileChanged: " + e.FullPath);
- }
-
+ #region Methods
public virtual void Dispose()
{
foreach (FileSystemWatcher fsw in _listFileSystemWatchers)
{
+ fsw.Created -= new FileSystemEventHandler(OnFileCreated);
fsw.Dispose();
}
_listFileSystemWatchers.Clear();
@@ -90,39 +88,33 @@
protected virtual string[] GetMediaPathsToMonitor()
{
- //jeffixme the location of the date dir needs to change
- //when the day rollovers;
- //we can either update them each time the date changes or
- //only when the camera application is being used (check system state)
- string dateDir = DateTime.Now.ToString("MM-dd-yyyy") + " 00001";
-
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- //a previous version of this class received these paths
+ //TODO: a previous version of this class received these paths
//from the Registry--should I go back to that?
- string localPicturePath = @"My Documents\My Pictures\";
- string storagePicturePath = @"\Storage Card\My Documents\My Pictures\";
- string localVideoPath = @"My Documents\My Videos\";
- string storageVideoPath = @"\Storage Card\My Documents\My Videos\";
+ //the path is [HKEY_CURRENT_USER\Software\Microsoft\Pictures\Camera\USER]
+ //it seems like this value is empty (defaultdir) is empty though.
+ List<string> paths = new List<string>(8);
+ string localPicturePath = @"\My Documents\My Pictures";
+ string localVideoPath = @"\My Documents\My Videos";
+ paths.Add(localPicturePath);
+ paths.Add(localVideoPath);
- string[] paths = new string[] {
- localPicturePath, storagePicturePath, localVideoPath, storageVideoPath,
- Path.Combine(localPicturePath, dateDir), Path.Combine(storagePicturePath, dateDir),
- Path.Combine(localVideoPath, dateDir), Path.Combine(storageVideoPath, dateDir)
- };
- return paths;
+ if (StorageCardUtils.FlashCardExists())
+ {
+ string storageCardPath = StorageCardUtils.GetFirstFlashCardPath();
+ string storagePicturePath = "\\" + Path.Combine(storageCardPath, @"My Documents\My Pictures");
+ string storageVideoPath = "\\" + Path.Combine(storageCardPath, @"My Documents\My Videos");
+ paths.Add(storagePicturePath);
+ paths.Add(storageVideoPath);
+ }
+
+ return paths.ToArray();
}
private void OnFileCreated(object sender, FileSystemEventArgs e)
{
- Debug.WriteLine("OnFileCreated: " + e.FullPath);
string activeApp = SystemState.ActiveApplication;
-
+ Debug.WriteLine("OnFileCreated: " + e.FullPath);
+
//use file exists to make sure its a file and not a dir that
//passed through the filter
if (File.Exists(e.FullPath))
@@ -148,7 +140,7 @@
{
if (File.Exists(mediaCapturedEventArgs.FullPath))
{
- //see if we can open the file (OnFileCreated is called before the file is fully written)
+ //see if we can open the file (OnFileCreated can be called before the file is fully written)
Stream s = File.Open(mediaCapturedEventArgs.FullPath, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
s.Close();
successfullyOpened = true;
@@ -183,6 +175,7 @@
MediaCaptured(sender, mcea);
}
}
+ #endregion Methods
}
/// <summary>
@@ -194,11 +187,14 @@
/// <author>Jon Froehlich</author>
public class MediaCapturedEventArgs : EventArgs
{
+ #region Fields
private string _directory;
private string _filename;
private string _activeApp;
private MediaType _mediaType;
+ #endregion Fields
+ #region Constructors
public MediaCapturedEventArgs(string directory, string filename, string activeAppAtTimeOfCapture)
{
_directory = directory;
@@ -206,13 +202,17 @@
_activeApp = activeAppAtTimeOfCapture;
_mediaType = GetMediaType(filename);
}
+ #endregion Constructors
+ #region Properties
public string ActiveApplication { get { return _activeApp; } }
public string FullPath { get { return Path.Combine(_directory, _filename); } }
public string Directory { get { return _directory; } }
public string Filename { get { return _filename; } }
public MediaType MediaType { get { return _mediaType; } }
+ #endregion Properties
+ #region Methods
protected virtual MediaType GetMediaType(string filename)
{
string ext = Path.GetExtension(filename);
@@ -232,6 +232,7 @@
return MediaType.Unknown;
}
}
+ #endregion Methods
}
/// <summary>
Modified: Trunk/Source/Roam/Roam.csproj
===================================================================
--- Trunk/Source/Roam/Roam.csproj 2007-12-07 06:40:03 UTC (rev 109)
+++ Trunk/Source/Roam/Roam.csproj 2007-12-12 08:38:05 UTC (rev 110)
@@ -69,7 +69,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Media\CameraMediaSniffer.cs" />
+ <Compile Include="Media\CameraMediaCapturedSniffer.cs" />
<Compile Include="Media\CyclePlayer.cs" />
<Compile Include="Media\LedPlayer.cs" />
<Compile Include="Media\Player.cs" />
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-12-07 06:40:03 UTC (rev 109)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-12-12 08:38:05 UTC (rev 110)
@@ -564,7 +564,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Form</SubType>
+ <SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.sln
===================================================================
--- Trunk/Source/Roam.sln 2007-12-07 06:40:03 UTC (rev 109)
+++ Trunk/Source/Roam.sln 2007-12-12 08:38:05 UTC (rev 110)
@@ -18,10 +18,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox.Roam", "Sandbox.Roam\Sandbox.Roam.csproj", "{19CDE0E2-71D7-4F81-841D-5A89F709E3D9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerTest", "PowerTest\PowerTest.csproj", "{3B5B1E77-4C54-4C1F-A7CC-127951DA9165}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2C7DA866-BB34-4F97-98E9-A5CD2DB49090}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -132,25 +128,8 @@
{19CDE0E2-71D7-4F81-841D-5A89F709E3D9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{19CDE0E2-71D7-4F81-841D-5A89F709E3D9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{19CDE0E2-71D7-4F81-841D-5A89F709E3D9}.Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Debug|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Debug|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Any CPU.Build.0 = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165}.Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {3B5B1E77-4C54-4C1F-A7CC-127951DA9165} = {2C7DA866-BB34-4F97-98E9-A5CD2DB49090}
- EndGlobalSection
EndGlobal
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|