Files
mirror-processhacker/trunk/ProcessHacker/Components/EventProperties.cs
T
wj32 c14ae0f4c1 new handle properties window
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1332 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-05-28 10:55:11 +00:00

82 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ProcessHacker.Native.Objects;
using ProcessHacker.Native.Security;
namespace ProcessHacker.Components
{
public partial class EventProperties : UserControl
{
private EventHandle _eventHandle;
private Win32Handle<EventAccess> _dupHandle;
public EventProperties(EventHandle eventHandle)
{
InitializeComponent();
_eventHandle = eventHandle;
this.UpdateInfo();
}
private void UpdateInfo()
{
var basicInfo = _eventHandle.GetBasicInformation();
labelType.Text = basicInfo.EventType.ToString();
labelSignaled.Text = (basicInfo.EventState != 0).ToString();
}
private void TryExecute(MethodInvoker action)
{
try
{
action();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void UpgradeExecute(MethodInvoker action)
{
this.TryExecute(() =>
{
_dupHandle = _eventHandle.Duplicate(EventAccess.QueryState | EventAccess.ModifyState);
_eventHandle = EventHandle.FromHandle(_dupHandle);
action();
});
}
private void buttonSet_Click(object sender, EventArgs e)
{
this.UpgradeExecute(() => _eventHandle.Set());
this.UpdateInfo();
}
private void buttonPulse_Click(object sender, EventArgs e)
{
this.UpgradeExecute(() => _eventHandle.Pulse());
this.UpdateInfo();
}
private void buttonClear_Click(object sender, EventArgs e)
{
this.UpgradeExecute(() => _eventHandle.Clear());
this.UpdateInfo();
}
private void buttonReset_Click(object sender, EventArgs e)
{
this.UpgradeExecute(() => _eventHandle.Reset());
this.UpdateInfo();
}
}
}