[Roam-commit] SF.net SVN: roam: [121] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2008-03-02 00:55:31
|
Revision: 121
http://roam.svn.sourceforge.net/roam/?rev=121&view=rev
Author: jonfroehlich
Date: 2008-03-01 16:55:29 -0800 (Sat, 01 Mar 2008)
Log Message:
-----------
1. fixed exception issue in SqlCeConnectionManager when HasActiveConnection() was called when _connectionPool was null
2. updated SplashForm to use a solid transparency layer rather than another png
Modified Paths:
--------------
Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs
Trunk/Source/Roam.UI/Forms/SplashForm.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs
===================================================================
--- Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs 2008-02-29 20:30:37 UTC (rev 120)
+++ Trunk/Source/Roam.SqlCe/SqlCeConnectionManager.cs 2008-03-02 00:55:29 UTC (rev 121)
@@ -147,7 +147,7 @@
/// <returns></returns>
public static bool HasActiveConnection()
{
- return _connectionPool.HasActiveConnection(Thread.CurrentThread);
+ return (_connectionPool == null) ? false : _connectionPool.HasActiveConnection(Thread.CurrentThread);
}
/// <summary>
@@ -156,7 +156,7 @@
/// <returns></returns>
public static bool HasActiveConnection(Thread thread)
{
- return _connectionPool.HasActiveConnection(thread);
+ return (_connectionPool == null) ? false : _connectionPool.HasActiveConnection(thread);
}
/// <summary>
@@ -168,7 +168,8 @@
{
lock (_objLock)
{
- return _connectionPool.ActiveConnections;
+ return (_connectionPool == null) ?
+ new Dictionary<Thread, SqlCeConnection>(0) : _connectionPool.ActiveConnections;
}
}
@@ -182,12 +183,10 @@
{
if (_connectionPool == null)
{
- InvalidOperationException ioe =
- new InvalidOperationException("The SqlConnectionManager must be initialized before calling GetConnection");
- _log.Error(ioe.Message, ioe);
- throw ioe;
+ return false;
}
- return _connectionPool.Close();
+ bool retVal = _connectionPool.Close();
+ return retVal;
}
}
Modified: Trunk/Source/Roam.UI/Forms/SplashForm.cs
===================================================================
--- Trunk/Source/Roam.UI/Forms/SplashForm.cs 2008-02-29 20:30:37 UTC (rev 120)
+++ Trunk/Source/Roam.UI/Forms/SplashForm.cs 2008-03-02 00:55:29 UTC (rev 121)
@@ -29,6 +29,7 @@
using Roam.Common.Collections;
using System.Diagnostics;
using Roam.Common.Utils;
+using Roam.UI.Utils;
namespace Roam.UI.Forms
{
@@ -41,9 +42,13 @@
/// <author>Jon Froehlich</author>
public partial class SplashForm : Form, IProgress
{
+ #region Delegates
+ private delegate void NoParamsDelegate();
+ private delegate void IntParamDelegate(int i);
+ #endregion Delegates
+
#region Private Fields
private IImage _img;
- private IImage _imgOverlay;
private String _strTitle;
private Buffer<String> _logBuffer = new Buffer<String>(30);
private Bitmap _bmpOffScreen = new Bitmap(1, 1);
@@ -51,9 +56,10 @@
private Color _logColor = Color.White;
private System.Windows.Forms.Timer _animationTimer = new System.Windows.Forms.Timer();
private MemoryAppender _memoryAppender = null;
- private delegate void NoParamsDelegate();
- private NoParamsDelegate _invalidateDelegate;
- private delegate void IntParamDelegate(int i);
+ private NoParamsDelegate _invalidateDelegate;
+ private bool _drawAlphaLayer = true;
+ private int _alphaValue = 128;
+ private Color _alphaColor = Color.Black;
#endregion Private Fields
public SplashForm()
@@ -62,10 +68,7 @@
InitializeComponent();
_invalidateDelegate = Invalidate;
_memoryAppender = (MemoryAppender)LogUtils.GetAppender("StartupAppender");
- //this.BackColor = Color.FromArgb(51, 69, 83);
- _animationTimer.Interval = 1000;
- _animationTimer.Tick += new EventHandler(OnAnimationTimer);
- _animationTimer.Enabled = true;
+ //this.BackColor = Color.FromArgb(51, 69, 83);
}
public SplashForm(String strImageFile)
@@ -74,21 +77,42 @@
new ImagingFactory().CreateImageFromFile(strImageFile, out _img);
}
- public SplashForm(String strImageFile, String strOverlayImageFile)
- : this(strImageFile)
- {
- new ImagingFactory().CreateImageFromFile(strOverlayImageFile, out _imgOverlay);
- }
-
- public SplashForm(Stream imageStream, Stream imageOverlayStream)
+ public SplashForm(Stream imageStream)
: this()
{
ImagingFactory imagingFactory = new ImagingFactory();
imagingFactory.CreateImageFromStream(new StreamOnFile(imageStream), out _img);
- imagingFactory.CreateImageFromStream(new StreamOnFile(imageOverlayStream), out _imgOverlay);
}
#region Properties
+
+ /// <summary>
+ /// Gets or sets the alpha layer color.
+ /// </summary>
+ public Color AlphaLayerColor
+ {
+ get { return _alphaColor; }
+ set { _alphaColor = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the alpha value out of 255.
+ /// </summary>
+ public int AlphaValue
+ {
+ get { return _alphaValue; }
+ set { _alphaValue = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets whether to draw the alpha layer.
+ /// </summary>
+ public bool DrawAlphaLayer
+ {
+ get { return _drawAlphaLayer; }
+ set { _drawAlphaLayer = value; }
+ }
+
public int Maximum
{
get { return _progressBar.Maximum; }
@@ -260,10 +284,18 @@
// Shut down the form
this.Close();
}
-
#endregion Public Methods
#region Protected Methods
+ protected override void OnLoad(EventArgs e)
+ {
+ _animationTimer.Interval = 1000;
+ _animationTimer.Tick += new EventHandler(OnAnimationTimer);
+ _animationTimer.Enabled = true;
+
+ base.OnLoad(e);
+ }
+
protected override void OnClosed(EventArgs e)
{
if (_memoryAppender != null)
@@ -329,16 +361,15 @@
{
_img.Draw(hDC, rc, null);
}
+ g.ReleaseHdc(hDC);
- //draw the translucent overlay, if it exists, and text log
- Rectangle overlayBounds = new Rectangle(30, 80, this.ClientRectangle.Width - 60, this.ClientRectangle.Height - 110);
- if (_imgOverlay != null)
+ //draw the translucent overlay
+ Rectangle overlayBounds = new Rectangle(30, 80, this.ClientRectangle.Width - 60,
+ this.ClientRectangle.Height - 110);
+ if (_drawAlphaLayer)
{
- rc = RECT.FromXYWH(overlayBounds.X, overlayBounds.Y,
- overlayBounds.Width, overlayBounds.Height);
- _imgOverlay.Draw(hDC, rc, null);
+ DrawTranslucentLayer(_bmpOffScreen, overlayBounds, _alphaColor, _alphaValue);
}
- g.ReleaseHdc(hDC);
//draw log
Brush logFontBrush = new SolidBrush(_logColor);
@@ -350,7 +381,8 @@
String strLog = sb.ToString();
SizeF textBounds = g.MeasureString(strLog, _logFont);
RectangleF textDrawArea = new RectangleF(overlayBounds.X,
- overlayBounds.Y + overlayBounds.Height - textBounds.Height, overlayBounds.Width, textBounds.Height);
+ overlayBounds.Y + overlayBounds.Height - textBounds.Height,
+ overlayBounds.Width, textBounds.Height);
g.Clip = new Region(overlayBounds);
g.DrawString(strLog, _logFont, logFontBrush, textDrawArea);
@@ -365,6 +397,30 @@
#endregion Protected Methods
+ #region Private Methods
+
+ /// <summary>
+ /// Draws a translucent layer on top of the bitmap.
+ /// </summary>
+ /// <param name="bitmap">The bitmap to draw a alpha layer on top of</param>
+ /// <param name="color">The color of the alpha layer</param>
+ /// <param name="alphaValue">The translucency value</param>
+ private void DrawTranslucentLayer(Bitmap bitmap, Rectangle overlayBounds, Color color, int alphaValue)
+ {
+ Graphics g = Graphics.FromImage(bitmap);
+ Bitmap alphaBitmap = new Bitmap(overlayBounds.Width, overlayBounds.Height);
+ Graphics gAlpha = Graphics.FromImage(alphaBitmap);
+ SolidBrush alphaBrush = new SolidBrush(color);
+ gAlpha.FillRectangle(alphaBrush, 0, 0, alphaBitmap.Width, alphaBitmap.Height);
+ //Rectangle alphaDestRectangle = new Rectangle(0, 0,
+ // alphaBitmap.Width, alphaBitmap.Height);
+ float alphaFloat = alphaValue / 255f;
+ DrawingUtils.AlphaBlend(g, overlayBounds, alphaBitmap, alphaFloat);
+ alphaBitmap.Dispose();
+ alphaBrush.Dispose();
+ gAlpha.Dispose();
+ }
+
private void OnAnimationTimer(object sender, EventArgs e)
{
bool bInvalidate = false;
@@ -391,7 +447,10 @@
this.Invalidate();
}
}
+ #endregion Private Methods
+ #region IProgress Members
+
public void Increment(int value)
{
if (InvokeRequired)
@@ -417,5 +476,7 @@
_progressBar.PerformStep();
}
}
+
+ #endregion
}
}
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.
|