[Roam-commit] SF.net SVN: roam: [95] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-09-17 03:33:43
|
Revision: 95
http://roam.svn.sourceforge.net/roam/?rev=95&view=rev
Author: jonfroehlich
Date: 2007-09-16 20:33:41 -0700 (Sun, 16 Sep 2007)
Log Message:
-----------
added storage card utility methods in StorageCardUtils that return details on the size of the storage card and how much free space exists
Modified Paths:
--------------
Trunk/Source/Roam/Utils/StorageCardUtils.cs
Trunk/Source/Roam.Common/Roam.Common.csproj
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Common/Utils/MeasurementUtils.cs
Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.Designer.cs
Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.cs
Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.resx
Modified: Trunk/Source/Roam/Utils/StorageCardUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/StorageCardUtils.cs 2007-09-15 07:41:18 UTC (rev 94)
+++ Trunk/Source/Roam/Utils/StorageCardUtils.cs 2007-09-17 03:33:41 UTC (rev 95)
@@ -114,5 +114,33 @@
return false;
}
}
+
+ public static long GetStorageCardSizeInBytes()
+ {
+ if (!FlashCardExists()) { return 0; }
+
+ string storageCardPath = GetFirstFlashCardPath();
+ ulong byteAvailableToCaller, totalNumOfBytes, totalNumOfFreeBytes;
+ GetDiskFreeSpaceEx(storageCardPath, out byteAvailableToCaller, out totalNumOfBytes, out totalNumOfFreeBytes);
+ return (long)totalNumOfBytes;
+ }
+
+ public static long GetStorageCardFreeSpaceInBytes()
+ {
+ if (!FlashCardExists()) { return 0; }
+
+ string storageCardPath = GetFirstFlashCardPath();
+ ulong byteAvailableToCaller, totalNumOfBytes, totalNumOfFreeBytes;
+ GetDiskFreeSpaceEx(storageCardPath, out byteAvailableToCaller, out totalNumOfBytes, out totalNumOfFreeBytes);
+ return (long)totalNumOfFreeBytes;
+ }
+
+ [DllImport("coredll.dll")]
+ private static extern bool GetDiskFreeSpaceEx(
+ string lpDirectoryName,
+ out ulong lpFreeBytesAvailableToCaller,
+ out ulong lpTotalNumberOfBytes,
+ out ulong lpTotalNumberOfFreeBytes
+ );
}
}
Modified: Trunk/Source/Roam.Common/Roam.Common.csproj
===================================================================
--- Trunk/Source/Roam.Common/Roam.Common.csproj 2007-09-15 07:41:18 UTC (rev 94)
+++ Trunk/Source/Roam.Common/Roam.Common.csproj 2007-09-17 03:33:41 UTC (rev 95)
@@ -79,6 +79,7 @@
<Compile Include="Utils\EnumUtils.cs" />
<Compile Include="Utils\ErrorUtils.cs" />
<Compile Include="Utils\ImagingUtils.cs" />
+ <Compile Include="Utils\MeasurementUtils.cs" />
<Compile Include="Utils\SummaryStatistics.cs" />
<Compile Include="Utils\Vector2.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Added: Trunk/Source/Roam.Common/Utils/MeasurementUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/MeasurementUtils.cs (rev 0)
+++ Trunk/Source/Roam.Common/Utils/MeasurementUtils.cs 2007-09-17 03:33:41 UTC (rev 95)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Roam.Common.Utils
+{
+ public static class MeasurementUtils
+ {
+ public static readonly long BitsInAByte = 8;
+ public static readonly long BytesInAKilobyte = 1024;
+ public static readonly long BytesInAMegabyte = BytesInAKilobyte * 1024;
+ public static readonly long BytesInAGigabyte = BytesInAMegabyte * 1024;
+
+ public static double ConvertBytesToMegabyte(long bytes)
+ {
+ return bytes / (double)BytesInAMegabyte;
+ }
+
+ public static double ConvertBytesToGigabyte(long bytes)
+ {
+ return bytes / (double)BytesInAGigabyte;
+ }
+ }
+}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-09-15 07:41:18 UTC (rev 94)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-09-17 03:33:41 UTC (rev 95)
@@ -366,6 +366,10 @@
<SubType>Designer</SubType>
<DependentUpon>PowerTestForm.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="Utils\StorageCardUtilsTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>StorageCardUtilsTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Utils\TextBoxForm.resx">
<SubType>Designer</SubType>
<DependentUpon>TextBoxForm.cs</DependentUpon>
@@ -762,6 +766,12 @@
<Compile Include="Utils\PowerTestForm.Designer.cs">
<DependentUpon>PowerTestForm.cs</DependentUpon>
</Compile>
+ <Compile Include="Utils\StorageCardUtilsTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Utils\StorageCardUtilsTest.Designer.cs">
+ <DependentUpon>StorageCardUtilsTest.cs</DependentUpon>
+ </Compile>
<Compile Include="Utils\TextBoxForm.cs">
<SubType>Form</SubType>
</Compile>
Added: Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.Designer.cs 2007-09-17 03:33:41 UTC (rev 95)
@@ -0,0 +1,98 @@
+namespace Roam.Test.Utils
+{
+ partial class StorageCardUtilsTest
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+ private System.Windows.Forms.MainMenu mainMenu1;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.mainMenu1 = new System.Windows.Forms.MainMenu();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this._scrollableLabel = new Roam.UI.Controls.ScrollableLabel();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.menuItem4 = new System.Windows.Forms.MenuItem();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ this.mainMenu1.MenuItems.Add(this.menuItem2);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // menuItem2
+ //
+ this.menuItem2.MenuItems.Add(this.menuItem3);
+ this.menuItem2.MenuItems.Add(this.menuItem4);
+ this.menuItem2.Text = "Menu";
+ //
+ // _scrollableLabel
+ //
+ this._scrollableLabel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this._scrollableLabel.Font = new System.Drawing.Font("Segoe Condensed", 7F, System.Drawing.FontStyle.Regular);
+ this._scrollableLabel.Location = new System.Drawing.Point(0, 0);
+ this._scrollableLabel.Name = "_scrollableLabel";
+ this._scrollableLabel.Size = new System.Drawing.Size(240, 266);
+ this._scrollableLabel.TabIndex = 5;
+ this._scrollableLabel.Text = "scrollableLabel1";
+ //
+ // menuItem3
+ //
+ this.menuItem3.Text = "Clear";
+ this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
+ //
+ // menuItem4
+ //
+ this.menuItem4.Text = "Refresh";
+ this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
+ //
+ // StorageCardUtilsTest
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(131F, 131F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
+ this.AutoScroll = true;
+ this.ClientSize = new System.Drawing.Size(240, 266);
+ this.Controls.Add(this._scrollableLabel);
+ this.Menu = this.mainMenu1;
+ this.Name = "StorageCardUtilsTest";
+ this.Text = "StorageCardUtilsTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem menuItem3;
+ private System.Windows.Forms.MenuItem menuItem4;
+ private Roam.UI.Controls.ScrollableLabel _scrollableLabel;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.cs
===================================================================
--- Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.cs 2007-09-17 03:33:41 UTC (rev 95)
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Roam.Utils;
+using Roam.Common.Utils;
+using OpenNETCF.Diagnostics;
+
+namespace Roam.Test.Utils
+{
+ public partial class StorageCardUtilsTest : Form
+ {
+ public StorageCardUtilsTest()
+ {
+ InitializeComponent();
+ _scrollableLabel.Clear();
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void menuItem3_Click(object sender, EventArgs e)
+ {
+ _scrollableLabel.Clear();
+ }
+
+ private void menuItem4_Click(object sender, EventArgs e)
+ {
+ Stopwatch stopWatch = Stopwatch.StartNew();
+ string storagePath = StorageCardUtils.GetFirstFlashCardPath();
+ bool doesStorageCardExists = StorageCardUtils.FlashCardExists();
+ long storageCardSizeInBytes = StorageCardUtils.GetStorageCardSizeInBytes();
+ long freeSpaceInBytes = StorageCardUtils.GetStorageCardFreeSpaceInBytes();
+ stopWatch.Stop();
+
+ if (doesStorageCardExists)
+ {
+ _scrollableLabel.AddLine("Storage card found");
+ _scrollableLabel.AddLine(@"Storage card path: \{0}\", storagePath);
+ _scrollableLabel.AddLine("Storage card size: {0:0.0} megabytes",
+ MeasurementUtils.ConvertBytesToMegabyte(storageCardSizeInBytes));
+ _scrollableLabel.AddLine("Free space on storage card: {0:0.0} megabytes",
+ MeasurementUtils.ConvertBytesToMegabyte(freeSpaceInBytes));
+ }
+ else
+ {
+ _scrollableLabel.AddLine("No storage card was found");
+ }
+ _scrollableLabel.AddLine("Took {0}", stopWatch.Elapsed);
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.resx
===================================================================
--- Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/Utils/StorageCardUtilsTest.resx 2007-09-17 03:33:41 UTC (rev 95)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
+ <value>Smartphone QVGA</value>
+ </metadata>
+ <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+</root>
\ No newline at end of file
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.
|