[Roam-commit] SF.net SVN: roam: [83] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-07-18 08:42:11
|
Revision: 83
http://roam.svn.sourceforge.net/roam/?rev=83&view=rev
Author: jonfroehlich
Date: 2007-07-18 01:42:09 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
1. fixed bug in FilteredListBox when items were filtered and Items.Clear() was called the filtered items were not removed. Added method RemoveFilteredItems()
2. Fixed a bug in DesktopUtils with regards to SetWallpaper--I accidentally opened a file stream than tried to save to that file via Image.Save(path). That's just not gonna work
3. Updated WindowUtils with some more useful windows related utility functions
Modified Paths:
--------------
Trunk/Source/Roam/Utils/ProcessUtils.cs
Trunk/Source/Roam.Common/Utils/WindowUtils.cs
Trunk/Source/Roam.UI/Controls/FilteredListBox.cs
Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs
Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam/Utils/ProcessUtils.cs
===================================================================
--- Trunk/Source/Roam/Utils/ProcessUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam/Utils/ProcessUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -71,13 +71,6 @@
/// <param name="pvEnvironment">[in] Not supported; set to NULL. </param>
/// <param name="pszCurDir">[in] Not supported; set to NULL. </param>
/// <param name="psiStartInfo">[in] Not supported; set to NULL. </param>
- /// <summary>
- ///
- /// </summary>
- /// <remarks>
- ///
- /// </remarks>
- /// <author>Jon Froehlich</author>
/// <param name="pProcInfo">[out] Pointer to a PROCESS_INFORMATION structure that receives identification information about the new process. </param>
/// <returns>true indicates success</returns>
[DllImport("CoreDll.DLL", SetLastError = true)]
Modified: Trunk/Source/Roam.Common/Utils/WindowUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.Common/Utils/WindowUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -80,67 +80,105 @@
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
+ /// <summary>
+ /// Returns true if the given control contains the handle
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="control"></param>
+ /// <returns></returns>
public static bool ContainsHandle(IntPtr handle, Control control)
{
- if (control.Handle == handle)
- {
- return true;
- }
- else
- {
- return ContainsHandle(handle, control.Controls);
- }
+ if (control.Handle == handle) { return true; }
+ else { return ContainsHandle(handle, control.Controls); }
}
+ /// <summary>
+ /// Returns true if the control collection contains the given handle
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="controls"></param>
+ /// <returns></returns>
public static bool ContainsHandle(IntPtr handle, Control.ControlCollection controls)
{
foreach (Control control in controls)
{
- if (control.Handle == handle)
- {
- return true;
- }
-
- if (ContainsHandle(handle, control.Controls))
- {
- return true;
- }
+ if (control.Handle == handle) { return true; }
+ if (ContainsHandle(handle, control.Controls)) { return true; }
}
return false;
}
+ /// <summary>
+ /// Returns the Control whose hWnd matches the provided handle and is
+ /// within the provided container
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="container"></param>
+ /// <returns></returns>
public static Control FindWindow(IntPtr handle, Control container)
{
- if (handle == container.Handle)
- {
- return container;
- }
- else
- {
- return FindWindow(handle, container.Controls);
- }
+ if (handle == container.Handle) { return container; }
+ else { return FindWindow(handle, container.Controls); }
}
+ /// <summary>
+ /// Returns the Control corresponding to the handle in the provided
+ /// control collection
+ /// </summary>
+ /// <param name="handle"></param>
+ /// <param name="controls"></param>
+ /// <returns></returns>
public static Control FindWindow(IntPtr handle, Control.ControlCollection controls)
{
foreach (Control control in controls)
{
- if (control.Handle == handle)
- {
- return control;
- }
+ if (control.Handle == handle) { return control; }
Control c = FindWindow(handle, control.Controls);
- if (c != null)
- {
- return c;
- }
+ if (c != null) { return c; }
}
return null;
}
+ /// <summary>
+ /// This function retrieves the handle to the top-level window whose class name and window name match the specified strings.
+ /// This function does not search child windows.
+ /// </summary>
+ /// <param name="lpClassName">Long pointer to a null-terminated string that specifies the class name or is an atom that
+ /// identifies the class-name string. If this parameter is an atom, it must be a global atom
+ /// created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be
+ /// placed in the low-order word of lpClassName; the high-order word must be zero. </param>
+ /// <param name="lpWindowName">Long pointer to a null-terminated string that specifies the window name (the window's title).
+ /// If this parameter is NULL, all window names match. </param>
+ /// <returns>A handle to the window that has the specified class name and window name indicates success. NULL indicates failure.
+ /// To get extended error information, call GetLastError. </returns>
+ /// <remarks>
+ /// If lpClassName is an atom, it must be an atom returned from RegisterClass.
+ /// </remarks>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+
+ /// <summary>
+ /// This function retrieves the handle to the top-level window whose window name match the specified strings.
+ /// This function does not search child windows.
+ /// </summary>
+ /// <param name="windowTitle"></param>
+ /// <returns></returns>
+ public static IntPtr FindWindow(string windowTitle)
+ {
+ return FindWindow(null, windowTitle);
+ }
+
+ /// <summary>
+ /// This function returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is
+ /// the area on top of which all icons and other windows are painted.
+ /// </summary>
+ /// <returns>The return value is a handle to the desktop window.</returns>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr GetDesktopWindow();
+
public static void PrintWindowHandles(Control control)
{
Debug.WriteLine(String.Format("Name: {0} Type: {1} Handle: {2}", control.Name, control.GetType().FullName, control.Handle));
Modified: Trunk/Source/Roam.UI/Controls/FilteredListBox.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/FilteredListBox.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.UI/Controls/FilteredListBox.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -65,6 +65,11 @@
}
}
+ public virtual void RemoveFilteredItems()
+ {
+ if (_filteredItems != null) { _filteredItems.Clear(); }
+ }
+
public virtual void SetFilter(IFilter<ListItem> filter)
{
_log.DebugFormat("SetFilter : entered with filter={0}", filter.ToString());
Modified: Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs
===================================================================
--- Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.UI/Controls/TextBoxFilteredList.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -184,6 +184,15 @@
{
get { return _addButton; }
}
+
+ public string SelectedText
+ {
+ get
+ {
+ if (_filteredListBox.SelectedIndex != -1) { return _filteredListBox.SelectedItem.ToString(); }
+ else return _textBox.Text;
+ }
+ }
#endregion Properties
#region Public Methods
@@ -222,6 +231,11 @@
_filteredListBox.Size = new Size(this.Width, this.Height - _textBorder.Bottom);
this.Invalidate();
}
+
+ public void RemoveFilteredItems()
+ {
+ _filteredListBox.RemoveFilteredItems();
+ }
#endregion Public Methods
#region Protected Methods
Modified: Trunk/Source/Roam.UI/Utils/DesktopUtils.cs
===================================================================
--- Trunk/Source/Roam.UI/Utils/DesktopUtils.cs 2007-07-16 07:03:17 UTC (rev 82)
+++ Trunk/Source/Roam.UI/Utils/DesktopUtils.cs 2007-07-18 08:42:09 UTC (rev 83)
@@ -23,6 +23,7 @@
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
+using System.Threading;
namespace Roam.UI.Utils
{
@@ -72,7 +73,6 @@
File.Delete(tempFilePath);
}
- FileStream fs = File.Create(tempFilePath);
image.Save(tempFilePath, ImageFormat.Jpeg);
SetWallpaper(tempFilePath);
}
@@ -117,5 +117,13 @@
Win32Window.SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
}
+
+ /// <summary>
+ /// This function returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is
+ /// the area on top of which all icons and other windows are painted.
+ /// </summary>
+ /// <returns>The return value is a handle to the desktop window.</returns>
+ [DllImport("coredll.dll", SetLastError = true)]
+ public static extern IntPtr GetDesktopWindow();
}
}
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.
|