[Roam-commit] SF.net SVN: roam: [97] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-09-19 04:32:33
|
Revision: 97
http://roam.svn.sourceforge.net/roam/?rev=97&view=rev
Author: jonfroehlich
Date: 2007-09-18 21:32:31 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
added incomplete ImageMap class to Roam.Test/Sandbox
Modified Paths:
--------------
Trunk/Source/Roam.suo
Added Paths:
-----------
Trunk/Source/Roam.Test/Sandbox/ImageMap.Designer.cs
Trunk/Source/Roam.Test/Sandbox/ImageMap.cs
Added: Trunk/Source/Roam.Test/Sandbox/ImageMap.Designer.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/ImageMap.Designer.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/ImageMap.Designer.cs 2007-09-19 04:32:31 UTC (rev 97)
@@ -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.Test/Sandbox/ImageMap.cs
===================================================================
--- Trunk/Source/Roam.Test/Sandbox/ImageMap.cs (rev 0)
+++ Trunk/Source/Roam.Test/Sandbox/ImageMap.cs 2007-09-19 04:32:31 UTC (rev 97)
@@ -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.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|