[Roam-commit] SF.net SVN: roam: [62] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-03-05 09:02:45
|
Revision: 62
http://roam.svn.sourceforge.net/roam/?rev=62&view=rev
Author: jonfroehlich
Date: 2007-03-05 01:02:39 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
1. Removed FileUtils from Roam.Common (this class is in the Roam.csproj now under StorageCardUtils)
2. Cleaned up Roam.Common so that it no longer relies on OpenNETCF
3. Added some helper methods to FontUtils and DrawingUtils
Modified Paths:
--------------
Trunk/Source/Roam.Common/Roam.Common.csproj
Trunk/Source/Roam.Common/Utils/FontUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
Trunk/Source/Roam.suo
Removed Paths:
-------------
Trunk/Source/Roam.Common/Utils/FileUtils.cs
Modified: Trunk/Source/Roam.Common/Roam.Common.csproj
===================================================================
--- Trunk/Source/Roam.Common/Roam.Common.csproj 2007-03-04 09:24:32 UTC (rev 61)
+++ Trunk/Source/Roam.Common/Roam.Common.csproj 2007-03-05 09:02:39 UTC (rev 62)
@@ -49,7 +49,6 @@
<HintPath>..\..\Library\Release\log4net.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
- <Reference Include="OpenNETCF, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e60dbea84bb431b7, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@@ -85,7 +84,6 @@
<Compile Include="Utils\BufferAppender.cs" />
<Compile Include="Utils\CollectionUtils.cs" />
<Compile Include="Utils\ColorUtils.cs" />
- <Compile Include="Utils\FileUtils.cs" />
<Compile Include="Utils\FontUtils.cs" />
<Compile Include="Utils\GraphicsUtils.cs" />
<Compile Include="Utils\IFilter.cs" />
Deleted: Trunk/Source/Roam.Common/Utils/FileUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/FileUtils.cs 2007-03-04 09:24:32 UTC (rev 61)
+++ Trunk/Source/Roam.Common/Utils/FileUtils.cs 2007-03-05 09:02:39 UTC (rev 62)
@@ -1,117 +0,0 @@
-#region Copyright & License
-//
-// Copyright (c) 2005 - 2007 The Regents of the University of Washington, Intel
-// Research Seattle, and the Roam project. All rights reserved.
-//
-// This software is open-source under the BSD license. You may obtain a copy
-// of this license at
-//
-// http://roam.sourceforge.net/license.txt
-//
-// Alternatively, please see "license.txt" which should be included in
-// this source code distribution.
-//
-#endregion Copyright & License
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OpenNETCF.Runtime.InteropServices.ComTypes;
-using System.Runtime.InteropServices;
-using Roam.Common;
-
-namespace Roam.Common.Utils
-{
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public static class FileUtils
- {
- public const int MAX_PATH = 260;
-
- //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/apisp/html/sp__wcesdk_findfirstflashcard.asp
- //HANDLE FindFirstFlashCard(
- // LPWIN32_FIND_DATA lpFindFlashData
- //);
- [DllImport("note_prj.dll")]
- public static extern IntPtr FindFirstFlashCard(out Win32FindData findData);
-
- //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedata5/html/wce50lrfWIN32FINDDATA.asp
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- //typedef struct _WIN32_FIND_DATA {
- // DWORD dwFileAttributes;
- // FILETIME ftCreationTime;
- // FILETIME ftLastAccessTime;
- // FILETIME ftLastWriteTime;
- // DWORD nFileSizeHigh;
- // DWORD nFileSizeLow;
- // DWORD dwOID;
- // TCHAR cFileName[MAX_PATH];
- //} WIN32_FIND_DATA;
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
- public struct Win32FindData
- {
- public uint dwFileAttributes;
- public FILETIME ftCreationTime;
- public FILETIME ftLastAccessTime;
- public FILETIME ftLastWriteTime;
- public uint nFileSizeHigh;
- public uint nFileSizeLow;
- public uint dwOID;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
- public string cFileName;
- }
-
- //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedata5/html/wce50lrffindclose.asp
- //BOOL FindClose(
- // HANDLE hFindFile
- //);
- [DllImport("coredll.dll")]
- public static extern bool FindClose(IntPtr hFindFile);
-
- public static String GetFirstFlashCardPath()
- {
- Win32FindData win32FindData;
- IntPtr intPtr = FindFirstFlashCard(out win32FindData);
- String path = win32FindData.cFileName;
- FindClose(intPtr);
-
- if (String.IsNullOrEmpty(path))
- {
- throw new ResourceNotFoundException("Could not find a flash card on this device");
- }
-
- return path;
- }
-
- public static bool FlashCardExists()
- {
- try
- {
- string flashCardPath = GetFirstFlashCardPath();
- return !String.IsNullOrEmpty(flashCardPath);
- }
- catch (ResourceNotFoundException rnfe)
- {
- return false;
- }
- }
-
- }
-}
Modified: Trunk/Source/Roam.Common/Utils/FontUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/FontUtils.cs 2007-03-04 09:24:32 UTC (rev 61)
+++ Trunk/Source/Roam.Common/Utils/FontUtils.cs 2007-03-05 09:02:39 UTC (rev 62)
@@ -46,6 +46,21 @@
}
}
+ public static Font GetFont(string fontName, Font defaultFont)
+ {
+ return GetFont(fontName, defaultFont.Size, defaultFont.Style, defaultFont);
+ }
+
+ public static Font GetFont(float fontSize, Font defaultFont)
+ {
+ return GetFont(defaultFont.Name, fontSize, defaultFont.Style, defaultFont);
+ }
+
+ public static Font GetFont(FontStyle fontStyle, Font defaultFont)
+ {
+ return GetFont(defaultFont.Name, defaultFont.Size, fontStyle, defaultFont);
+ }
+
public static FontFamily GetFontFamily(string fontFamily)
{
switch (fontFamily)
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-04 09:24:32 UTC (rev 61)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-05 09:02:39 UTC (rev 62)
@@ -438,7 +438,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>
@@ -576,7 +576,7 @@
<DependentUpon>SystemColorTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\TabControlTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\TabControlTest.Designer.cs">
<DependentUpon>TabControlTest.cs</DependentUpon>
Modified: Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-04 09:24:32 UTC (rev 61)
+++ Trunk/Source/Roam.UI/Controls/ScrollableLabel.cs 2007-03-05 09:02:39 UTC (rev 62)
@@ -23,6 +23,7 @@
using Roam.Common.Collections;
using Roam.UI.Drawing;
using Roam.Common.Utils;
+using Roam.UI.Utils;
namespace Roam.UI.Controls
{
@@ -58,7 +59,12 @@
private Fill _backFill = new FillSimpleLinearGradient(new SimpleLinearGradient(Color.FromArgb(206, 223, 239), Color.White, SimpleLinearGradient.FillDirection.TopToBottom));
#endregion Private Fields
- public ScrollableLabel()
+ public ScrollableLabel()
+ : this(String.Empty)
+ {
+ }
+
+ public ScrollableLabel(string text)
{
_vScrollBar = new VScrollBar();
_vScrollBar.ValueChanged += new EventHandler(OnVerticalScrollbarValueChanged);
@@ -66,6 +72,7 @@
this.Controls.Add(_vScrollBar);
InitializeComponent();
OnResize(EventArgs.Empty);
+ Text = text;
}
#region Properties
@@ -534,6 +541,12 @@
RectangleF drawStringArea = new RectangleF(xPos + _textPadding, yPos, width - 2 * _textPadding, _textBounds.Height);
g.DrawString(str, this.Font, frontBrush, drawStringArea);
+ //debug - draw an outline in red
+ //Pen redPen = new Pen(Color.Red);
+ //g.DrawRectangle(redPen, DrawingUtils.GetRectangle(drawStringArea));
+ //redPen.Dispose();
+ //end debug
+
//cleanup
backBrush.Dispose();
frontBrush.Dispose();
Modified: Trunk/Source/Roam.UI/Utils/DrawingUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-03-04 09:24:32 UTC (rev 61)
+++ Trunk/Source/Roam.UI/Utils/DrawingUtils.cs 2007-03-05 09:02:39 UTC (rev 62)
@@ -18,6 +18,7 @@
using System.Drawing;
using System.Runtime.InteropServices;
using Roam.Common.Utils;
+using System.Windows.Forms;
namespace Roam.UI.Utils
{
@@ -290,6 +291,24 @@
return ret == 0 ? false : true;
}
+ private static Control _control = new Control();
+ public static SizeF MeasureString(string s, Font font)
+ {
+ SizeF sizeText;
+ lock (_control)
+ {
+ Graphics g = _control.CreateGraphics();
+ sizeText = g.MeasureString(s, font);
+ g.Dispose();
+ }
+ return sizeText;
+ }
+
+ public static float GetHeight(Font font)
+ {
+ return MeasureString("Aghfy!q#'", font).Height;
+ }
+
public static string ToString(Size size)
{
return "[" + size.Width + ", " + size.Height + "]";
@@ -304,6 +323,11 @@
{
return "[" + r.X + ", " + r.Y + ", " + r.Width + ", " + r.Height + "]";
}
+
+ public static Rectangle GetRectangle(RectangleF drawStringArea)
+ {
+ return new Rectangle((int)drawStringArea.X, (int)drawStringArea.Y, (int)drawStringArea.Width, (int)drawStringArea.Height);
+ }
}
/// <summary>
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.
|