[Roam-commit] SF.net SVN: roam: [70] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-04-02 05:26:31
|
Revision: 70
http://roam.svn.sourceforge.net/roam/?rev=70&view=rev
Author: jonfroehlich
Date: 2007-04-01 22:26:29 -0700 (Sun, 01 Apr 2007)
Log Message:
-----------
1. added XmlUtils for XML related utility functions. one method, for example, extracts XML attributes and values and adds them to a dictionary
2. added ImageMap--I'm just getting started with this (it should probably be in Sandbox or something)
Modified Paths:
--------------
Trunk/Source/Roam.Common/Roam.Common.csproj
Trunk/Source/Roam.Common/Utils/TimeUtils.cs
Trunk/Source/Roam.Test/Roam.Test.csproj
Trunk/Source/Roam.UI/Roam.UI.csproj
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Common/Utils/XmlUtils.cs
Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs
Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs
Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx
Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs
Trunk/Source/Roam.UI/Controls/ImageMap.cs
Modified: Trunk/Source/Roam.Common/Roam.Common.csproj
===================================================================
--- Trunk/Source/Roam.Common/Roam.Common.csproj 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.Common/Roam.Common.csproj 2007-04-02 05:26:29 UTC (rev 70)
@@ -98,6 +98,7 @@
<Compile Include="Utils\TimeUtils.cs" />
<Compile Include="Utils\TypeUtils.cs" />
<Compile Include="Utils\WindowUtils.cs" />
+ <Compile Include="Utils\XmlUtils.cs" />
</ItemGroup>
<Import Condition="'$(TargetFrameworkVersion)' == 'v1.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.v1.targets" />
<Import Condition="'$(TargetFrameworkVersion)' == 'v2.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
Modified: Trunk/Source/Roam.Common/Utils/TimeUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/TimeUtils.cs 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.Common/Utils/TimeUtils.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -115,5 +115,19 @@
throw new InvalidOperationException(String.Format("TimeResolution {0} not supported", timeResolution));
}
+
+ public static readonly DateTime UNIX_START_DATE = new DateTime(1970, 1, 1, 0, 0, 0);
+
+ public static long ConvertToUnixTimeStamp(DateTime dateTime)
+ {
+ TimeSpan ts = UNIX_START_DATE - UNIX_START_DATE;
+ return (long)ts.TotalSeconds;
+ }
+
+ public static DateTime ConvertToDateTime(long unixTimeStamp)
+ {
+ return UNIX_START_DATE.AddSeconds(unixTimeStamp);
+ }
+
}
}
Added: Trunk/Source/Roam.Common/Utils/XmlUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/XmlUtils.cs (rev 0)
+++ Trunk/Source/Roam.Common/Utils/XmlUtils.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml;
+
+namespace Roam.Common.Utils
+{
+ public static class XmlUtils
+ {
+ public static IDictionary<string, string> GetAttributes(XmlReader xmlReader)
+ {
+ Dictionary<string, string> attributes = new Dictionary<string, string>(5);
+ if (xmlReader.HasAttributes)
+ {
+ while (xmlReader.MoveToNextAttribute())
+ {
+ attributes[xmlReader.Name.ToLower()] = xmlReader.Value;
+ }
+ }
+ return attributes;
+ }
+ }
+}
Modified: Trunk/Source/Roam.Test/Roam.Test.csproj
===================================================================
--- Trunk/Source/Roam.Test/Roam.Test.csproj 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.Test/Roam.Test.csproj 2007-04-02 05:26:29 UTC (rev 70)
@@ -190,6 +190,10 @@
<DependentUpon>CheckedListBoxTest.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="UI\Controls\ImageMapTest.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>ImageMapTest.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="UI\Controls\RoundedRectTest2.resx">
<SubType>Designer</SubType>
<DependentUpon>RoundedRectTest2.cs</DependentUpon>
@@ -438,6 +442,12 @@
<Compile Include="UI\Controls\CameraMediaSnifferTest.Designer.cs">
<DependentUpon>CameraMediaSnifferTest.cs</DependentUpon>
</Compile>
+ <Compile Include="UI\Controls\ImageMapTest.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="UI\Controls\ImageMapTest.Designer.cs">
+ <DependentUpon>ImageMapTest.cs</DependentUpon>
+ </Compile>
<Compile Include="UI\Controls\RoundedRectTest2.cs">
<SubType>Form</SubType>
</Compile>
@@ -451,7 +461,7 @@
<DependentUpon>TextBoxFilteredListTest.cs</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FontTest.cs">
- <SubType>Component</SubType>
+ <SubType>Form</SubType>
</Compile>
<Compile Include="UI\Controls\FontTest.Designer.cs">
<DependentUpon>FontTest.cs</DependentUpon>
Added: Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.Designer.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,74 @@
+namespace Roam.Test.UI.Controls
+{
+ partial class ImageMapTest
+ {
+ /// <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.imageMap1 = new Roam.UI.Controls.ImageMap();
+ this.SuspendLayout();
+ //
+ // mainMenu1
+ //
+ this.mainMenu1.MenuItems.Add(this.menuItem1);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Text = "Exit";
+ this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
+ //
+ // imageMap1
+ //
+ this.imageMap1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.imageMap1.Location = new System.Drawing.Point(0, 0);
+ this.imageMap1.Name = "imageMap1";
+ this.imageMap1.Size = new System.Drawing.Size(240, 266);
+ this.imageMap1.TabIndex = 0;
+ this.imageMap1.Text = "imageMap1";
+ //
+ // ImageMapTest
+ //
+ 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.imageMap1);
+ this.Menu = this.mainMenu1;
+ this.Name = "ImageMapTest";
+ this.Text = "ImageMapTest";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuItem menuItem1;
+ private Roam.UI.Controls.ImageMap imageMap1;
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Roam.Test.UI.Controls
+{
+ public partial class ImageMapTest : Form
+ {
+ public ImageMapTest()
+ {
+ InitializeComponent();
+ }
+
+ private void menuItem1_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
Added: Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx
===================================================================
--- Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx (rev 0)
+++ Trunk/Source/Roam.Test/UI/Controls/ImageMapTest.resx 2007-04-02 05:26:29 UTC (rev 70)
@@ -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
Added: Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs (rev 0)
+++ Trunk/Source/Roam.UI/Controls/ImageMap.Designer.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,36 @@
+namespace Roam.UI.Controls
+{
+ partial class ImageMap
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <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 Component 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()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
Added: Trunk/Source/Roam.UI/Controls/ImageMap.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/ImageMap.cs (rev 0)
+++ Trunk/Source/Roam.UI/Controls/ImageMap.cs 2007-04-02 05:26:29 UTC (rev 70)
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Roam.UI.Controls
+{
+ public enum ImageMapOverlayMode
+ {
+ None,
+ DrawGrid,
+ DrawGridWithNumbers
+ }
+
+ public enum ImageMapSizeMode
+ {
+ /// <summary>
+ /// The image is placed in the upper-left corner of the ImageMap.
+ /// The image is clipped if it is larger than the ImageMap it is contained in.
+ /// </summary>
+ Normal,
+
+ /// <summary>
+ /// The image within the ImageMap is stretched or shrunk to fit the size of the ImageMap.
+ /// </summary>
+ StretchImage
+ }
+
+ public partial class ImageMap : Control
+ {
+ private Image _image;
+ private ImageMapOverlayMode _overlayMode = ImageMapOverlayMode.DrawGridWithNumbers;
+ private ImageMapSizeMode _sizeMode = ImageMapSizeMode.Normal;
+ private float _gridAlpha = 0.5f;
+ private Font _gridFont = new Font(FontFamily.GenericSansSerif, 14, FontStyle.Bold);
+ private Color _gridColor = Color.PowderBlue;
+ private float _gridThickness = 2;
+
+ public ImageMap()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnPaint(PaintEventArgs pe)
+ {
+ Graphics g = pe.Graphics;
+ DrawGrid(g, null, this.ClientRectangle);
+ // Calling the base class OnPaint
+ base.OnPaint(pe);
+ }
+
+ protected virtual void DrawGrid(Graphics g, Image bottomLayers, Rectangle drawingArea)
+ {
+ Pen gridPen = new Pen(_gridColor, _gridThickness);
+ SolidBrush gridBrush = new SolidBrush(_gridColor);
+
+ //split up area into a 3x3 grid
+ const int numGrids = 3;
+ Size gridSize = new Size((int)(drawingArea.Width / (float)numGrids), (int)(drawingArea.Height / (float)numGrids));
+ for (int gridLine = 1; gridLine < numGrids; gridLine++)
+ {
+ //draw horizontal horizontal line
+ int y = drawingArea.Top + gridLine * gridSize.Height;
+ g.DrawLine(gridPen, drawingArea.Left, y, drawingArea.Right, y);
+
+ //draw vertical grid line
+ int x = drawingArea.Left + gridLine * gridSize.Width;
+ g.DrawLine(gridPen, x, drawingArea.Top, x, drawingArea.Bottom);
+ }
+
+ //draw labels within grid
+ for (int i = 1; i <= numGrids * numGrids; i++)
+ {
+ string label = i.ToString();
+ SizeF labelSize = g.MeasureString(label, _gridFont);
+ int row = (int)Math.Floor(i / (float)numGrids);
+ int col = (i - 1) % numGrids;
+
+ int xLeftGrid = drawingArea.Left + col * gridSize.Width;
+ int yTopGrid = drawingArea.Top + row * gridSize.Height;
+
+ float xLabel = xLeftGrid + gridSize.Width / 2f - labelSize.Width / 2f;
+ float yLabel = yTopGrid + gridSize.Height / 2f - labelSize.Width / 2f;
+
+ g.DrawString(label, _gridFont, gridBrush, xLabel, yLabel);
+ }
+
+ gridPen.Dispose();
+ gridBrush.Dispose();
+ }
+ }
+}
Modified: Trunk/Source/Roam.UI/Roam.UI.csproj
===================================================================
--- Trunk/Source/Roam.UI/Roam.UI.csproj 2007-03-21 20:36:36 UTC (rev 69)
+++ Trunk/Source/Roam.UI/Roam.UI.csproj 2007-04-02 05:26:29 UTC (rev 70)
@@ -121,6 +121,12 @@
<Compile Include="Controls\ImageListBox.Designer.cs">
<DependentUpon>ImageListBox.cs</DependentUpon>
</Compile>
+ <Compile Include="Controls\ImageMap.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Controls\ImageMap.Designer.cs">
+ <DependentUpon>ImageMap.cs</DependentUpon>
+ </Compile>
<Compile Include="Controls\KeyFilteredListBox.cs">
<SubType>Component</SubType>
</Compile>
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.
|