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>
113 lines
3.2 KiB
C#
113 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
using Decal.Interop.Controls;
|
|
using Decal.Interop.Inject;
|
|
|
|
namespace Decal.DecalControls
|
|
{
|
|
[ComVisible(true)]
|
|
[Guid("E099DC60-0F19-4690-AB7C-8B5834DA286E")]
|
|
[ClassInterface(ClassInterfaceType.None)]
|
|
[ComSourceInterfaces("Decal.Interop.Controls.IChoiceEvents\0\0")]
|
|
[ProgId("DecalControls.Choice")]
|
|
public class ChoiceImpl : ControlBase, IChoice
|
|
{
|
|
public event IChoiceEvents_DestroyEventHandler Destroy;
|
|
public event IChoiceEvents_ChangeEventHandler Change;
|
|
public event IChoiceEvents_DropDownEventHandler DropDown;
|
|
|
|
private struct ChoiceItem
|
|
{
|
|
public string Display;
|
|
public object Data;
|
|
}
|
|
|
|
private readonly List<ChoiceItem> _items = new List<ChoiceItem>();
|
|
private int _selected = -1;
|
|
private bool _dropped;
|
|
private int _dropLines = 5;
|
|
|
|
public void AddChoice(string strDisplay, object vData = null)
|
|
{
|
|
_items.Add(new ChoiceItem { Display = strDisplay, Data = vData });
|
|
}
|
|
|
|
public int ChoiceCount => _items.Count;
|
|
|
|
public object Data
|
|
{
|
|
get => (_selected >= 0 && _selected < _items.Count) ? _items[_selected].Data : null;
|
|
set
|
|
{
|
|
if (_selected >= 0 && _selected < _items.Count)
|
|
{
|
|
var item = _items[_selected];
|
|
item.Data = value;
|
|
_items[_selected] = item;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string Text
|
|
{
|
|
get => (_selected >= 0 && _selected < _items.Count) ? _items[_selected].Display : "";
|
|
set
|
|
{
|
|
if (_selected >= 0 && _selected < _items.Count)
|
|
{
|
|
var item = _items[_selected];
|
|
item.Display = value ?? "";
|
|
_items[_selected] = item;
|
|
Invalidate();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void RemoveChoice(int nIndex)
|
|
{
|
|
if (nIndex >= 0 && nIndex < _items.Count)
|
|
{
|
|
_items.RemoveAt(nIndex);
|
|
if (_selected >= _items.Count) _selected = _items.Count - 1;
|
|
Invalidate();
|
|
}
|
|
}
|
|
|
|
public bool Dropped
|
|
{
|
|
get => _dropped;
|
|
set
|
|
{
|
|
_dropped = value;
|
|
if (_dropped) DropDown?.Invoke(ID);
|
|
Invalidate();
|
|
}
|
|
}
|
|
|
|
public int Selected
|
|
{
|
|
get => _selected;
|
|
set
|
|
{
|
|
if (value >= -1 && value < _items.Count && value != _selected)
|
|
{
|
|
_selected = value;
|
|
Invalidate();
|
|
Change?.Invoke(ID, _selected);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int DropLines { get => _dropLines; set { _dropLines = value; Invalidate(); } }
|
|
|
|
public void Clear()
|
|
{
|
|
_items.Clear();
|
|
_selected = -1;
|
|
Invalidate();
|
|
}
|
|
|
|
protected override void OnDestroy() => Destroy?.Invoke(ID);
|
|
}
|
|
}
|