openDecal/Managed/Decal.DecalControls/NotebookImpl.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

64 lines
1.9 KiB
C#

using System.Collections.Generic;
using System.Runtime.InteropServices;
using Decal.Interop.Controls;
using Decal.Interop.Inject;
namespace Decal.DecalControls
{
[ComVisible(true)]
[Guid("ED14E7C5-11BE-4DFD-9829-873AB6BE3CFC")]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces("Decal.Interop.Controls.INotebookEvents\0\0")]
[ProgId("DecalControls.Notebook")]
public class NotebookImpl : ControlBase, INotebook
{
public event INotebookEvents_DestroyEventHandler Destroy;
public event INotebookEvents_ChangeEventHandler Change;
private struct Page
{
public string Text;
public IControl Client;
}
private readonly List<Page> _pages = new List<Page>();
private int _activeTab;
public void AddPage(string strText, IControl pClient)
{
_pages.Add(new Page { Text = strText ?? "", Client = pClient });
Invalidate();
}
public int ActiveTab
{
get => _activeTab;
set
{
if (value >= 0 && value < _pages.Count && value != _activeTab)
{
_activeTab = value;
Invalidate();
Change?.Invoke(ID, _activeTab);
}
}
}
public string PageText
{
get => (_activeTab >= 0 && _activeTab < _pages.Count) ? _pages[_activeTab].Text : "";
set
{
if (_activeTab >= 0 && _activeTab < _pages.Count)
{
var page = _pages[_activeTab];
page.Text = value ?? "";
_pages[_activeTab] = page;
Invalidate();
}
}
}
protected override void OnDestroy() => Destroy?.Invoke(ID);
}
}