openDecal/Managed/Decal.Interop.Controls/Decal.Interop.Controls/IControlEvents_EventProvider.cs
erik d1442e3747 Initial commit: Complete open-source Decal rebuild
All 5 phases of the open-source Decal rebuild:

Phase 1: 14 decompiled .NET projects (Interop.*, Adapter, FileService, DecalUtil)
Phase 2: 10 native DLLs rewritten as C# COM servers with matching GUIDs
  - DecalDat, DHS, SpellFilter, DecalInput, DecalNet, DecalFilters
  - Decal.Core, DecalControls, DecalRender, D3DService
Phase 3: C++ shims for Inject.DLL (D3D9 hooking) and LauncherHook.DLL
Phase 4: DenAgent WinForms tray application
Phase 5: WiX installer and build script

25 C# projects building with 0 errors.
Native C++ projects require VS 2022 + Windows SDK (x86).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:27:56 +01:00

154 lines
3.3 KiB
C#

using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
namespace Decal.Interop.Controls;
internal sealed class IControlEvents_EventProvider : IControlEvents_Event, IDisposable
{
private IConnectionPointContainer m_ConnectionPointContainer;
private ArrayList m_aEventSinkHelpers;
private IConnectionPoint m_ConnectionPoint;
private void Init()
{
IConnectionPoint ppCP = null;
Guid riid = new Guid(new byte[16]
{
195, 203, 235, 47, 140, 72, 79, 68, 173, 8,
93, 48, 151, 210, 209, 237
});
m_ConnectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
m_ConnectionPoint = ppCP;
m_aEventSinkHelpers = new ArrayList();
}
event IControlEvents_DestroyEventHandler IControlEvents_Event.Destroy
{
add
{
bool lockTaken = default(bool);
try
{
Monitor.Enter(this, ref lockTaken);
if (m_ConnectionPoint == null)
{
Init();
}
IControlEvents_SinkHelper controlEvents_SinkHelper = new IControlEvents_SinkHelper();
int pdwCookie = 0;
m_ConnectionPoint.Advise(controlEvents_SinkHelper, out pdwCookie);
controlEvents_SinkHelper.m_dwCookie = pdwCookie;
controlEvents_SinkHelper.m_DestroyDelegate = value;
m_aEventSinkHelpers.Add(controlEvents_SinkHelper);
}
finally
{
if (lockTaken)
{
Monitor.Exit(this);
}
}
}
remove
{
bool lockTaken = default(bool);
try
{
Monitor.Enter(this, ref lockTaken);
if (m_aEventSinkHelpers == null)
{
return;
}
int count = m_aEventSinkHelpers.Count;
int num = 0;
if (0 >= count)
{
return;
}
do
{
IControlEvents_SinkHelper controlEvents_SinkHelper = (IControlEvents_SinkHelper)m_aEventSinkHelpers[num];
if (controlEvents_SinkHelper.m_DestroyDelegate != null && ((controlEvents_SinkHelper.m_DestroyDelegate.Equals(value) ? 1u : 0u) & 0xFFu) != 0)
{
m_aEventSinkHelpers.RemoveAt(num);
m_ConnectionPoint.Unadvise(controlEvents_SinkHelper.m_dwCookie);
if (count <= 1)
{
Marshal.ReleaseComObject(m_ConnectionPoint);
m_ConnectionPoint = null;
m_aEventSinkHelpers = null;
}
break;
}
num++;
}
while (num < count);
}
finally
{
if (lockTaken)
{
Monitor.Exit(this);
}
}
}
}
public IControlEvents_EventProvider(object P_0)
{
//Error decoding local variables: Signature type sequence must have at least one element.
m_ConnectionPointContainer = (IConnectionPointContainer)P_0;
}
public void Finalize()
{
bool lockTaken = default(bool);
try
{
Monitor.Enter(this, ref lockTaken);
if (m_ConnectionPoint == null)
{
return;
}
int count = m_aEventSinkHelpers.Count;
int num = 0;
if (0 < count)
{
do
{
IControlEvents_SinkHelper controlEvents_SinkHelper = (IControlEvents_SinkHelper)m_aEventSinkHelpers[num];
m_ConnectionPoint.Unadvise(controlEvents_SinkHelper.m_dwCookie);
num++;
}
while (num < count);
}
Marshal.ReleaseComObject(m_ConnectionPoint);
}
catch (Exception)
{
}
finally
{
if (lockTaken)
{
Monitor.Exit(this);
}
}
}
public void Dispose()
{
//Error decoding local variables: Signature type sequence must have at least one element.
Finalize();
GC.SuppressFinalize(this);
}
}