|
///File Name: InteractiveWindow.cs
///This file include declaration of the class InteractiveWindow, this class
///represent a window properties and visual functionality. this class implement the interfaces:
///1. IWindow - for the window properties.
///2. IInteractiveWindow - for the window visual functionality.
///3. IDisposable.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DesktopManager.BL.Interfaces;
using System.Drawing;
using DesktopManager.BL.Window;
namespace DesktopManager.BL
{
public enum eWindowDisplayState
{
Shown,
Hidden
}
public class InteractiveWindow : IWindow, IDisposable, IInteractiveWindow
{
protected IOsApiProvider m_OsApiProvider = WindowsApiProvider.Create();
protected IWindow m_Window;
public void Hide()
{
this.m_OsApiProvider.HideWindow(this.m_Window.Handle);
this.State = eWindowDisplayState.Hidden;
}
public void Show()
{
this.m_OsApiProvider.ShowWindow(this.m_Window.Handle);
this.State = eWindowDisplayState.Shown;
}
public void BringUp()
{
this.m_OsApiProvider.BringUpWindow(this.m_Window.Handle);
this.State = eWindowDisplayState.Shown;
}
public bool IsAlive()
{
return this.m_OsApiProvider.IsWindowAlive(this.m_Window.Handle);
}
private eWindowDisplayState m_State;
public eWindowDisplayState State
{
get { return m_State; }
set
{
eWindowDisplayState prevState = this.m_State;
m_State = value;
if (prevState != value)
{
this.OnWindowStateChanged();
}
}
}
public InteractiveWindow(IWindow i_Window)
{
this.m_Window = i_Window;
this.State = eWindowDisplayState.Shown;
}
public void Toggle()
{
if (this.m_State == eWindowDisplayState.Shown)
{
this.Hide();
}
else
{
this.Show();
}
}
#region IDisposable Members
public void Dispose()
{
this.Show();
if (this.m_Window is IDisposable)
{
(this.m_Window as IDisposable).Dispose();
}
GC.SuppressFinalize(this);
}
#endregion
#region IWindow Members
public string Class
{
get { return this.m_Window.Class; }
}
public IntPtr Handle
{
get { return this.m_Window.Handle; }
}
public Image Icon
{
get { return this.m_Window.Icon; }
}
public uint ParentProcessId
{
get { return this.m_Window.ParentProcessId; }
}
public string Title
{
get { return this.m_Window.Title; }
}
#endregion
#region IInteractiveWindow Members
public event EventHandler<EventArgsWindowStateChanged> WindowStateChangedEvent;
#endregion
protected void OnWindowStateChanged()
{
if (this.WindowStateChangedEvent != null)
{
this.WindowStateChangedEvent(this, new EventArgsWindowStateChanged(this.State));
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.