2026-01-08 20:15:57 +09:00
|
|
|
#nullable enable
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2026-01-20 20:18:47 +09:00
|
|
|
namespace UVC.UIToolkit
|
2026-01-08 20:15:57 +09:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2026-02-04 20:31:52 +09:00
|
|
|
/// 라디오 그룹 속성 데이터 클래스입니다.
|
|
|
|
|
/// UI는 UTKRadioPropertyItemView에서 담당합니다.
|
2026-01-08 20:15:57 +09:00
|
|
|
/// </summary>
|
|
|
|
|
public class UTKRadioPropertyItem : UTKPropertyItemBase<int>
|
|
|
|
|
{
|
|
|
|
|
#region Fields
|
|
|
|
|
private List<string> _choices;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
2026-02-04 20:31:52 +09:00
|
|
|
/// <summary>속성 타입</summary>
|
2026-01-08 20:15:57 +09:00
|
|
|
public override UTKPropertyType PropertyType => UTKPropertyType.RadioGroup;
|
|
|
|
|
|
|
|
|
|
/// <summary>선택 가능한 항목 목록</summary>
|
|
|
|
|
public List<string> Choices
|
|
|
|
|
{
|
|
|
|
|
get => _choices;
|
2026-02-04 20:31:52 +09:00
|
|
|
set => _choices = value ?? new List<string>();
|
2026-01-08 20:15:57 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>현재 선택된 항목의 텍스트</summary>
|
|
|
|
|
public string? SelectedText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Value >= 0 && Value < _choices.Count)
|
|
|
|
|
{
|
|
|
|
|
return _choices[Value];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Constructor
|
2026-02-04 20:31:52 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// 라디오 그룹 속성을 생성합니다.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">고유 ID</param>
|
|
|
|
|
/// <param name="name">표시 이름</param>
|
|
|
|
|
/// <param name="choices">선택 항목 목록</param>
|
|
|
|
|
/// <param name="selectedIndex">초기 선택 인덱스</param>
|
|
|
|
|
/// <param name="isReadOnly">읽기 전용 여부</param>
|
2026-02-10 20:48:49 +09:00
|
|
|
/// <param name="showLabel">라벨 표시 여부</param>
|
|
|
|
|
public UTKRadioPropertyItem(string id, string name, List<string> choices, int selectedIndex = 0, bool isReadOnly = false, bool showLabel = true)
|
2026-01-08 20:15:57 +09:00
|
|
|
: base(id, name, Math.Max(0, Math.Min(selectedIndex, (choices?.Count ?? 1) - 1)))
|
|
|
|
|
{
|
|
|
|
|
_choices = choices ?? new List<string>();
|
2026-02-10 20:48:49 +09:00
|
|
|
_isReadOnly = isReadOnly;
|
|
|
|
|
_showLabel = showLabel;
|
2026-01-08 20:15:57 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-04 20:31:52 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// 라디오 그룹 속성을 생성합니다.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">고유 ID</param>
|
|
|
|
|
/// <param name="name">표시 이름</param>
|
|
|
|
|
/// <param name="choices">선택 항목 목록</param>
|
|
|
|
|
/// <param name="selectedIndex">초기 선택 인덱스</param>
|
|
|
|
|
/// <param name="isReadOnly">읽기 전용 여부</param>
|
2026-02-10 20:48:49 +09:00
|
|
|
/// <param name="showLabel">라벨 표시 여부</param>
|
|
|
|
|
public UTKRadioPropertyItem(string id, string name, IEnumerable<string> choices, int selectedIndex = 0, bool isReadOnly = false, bool showLabel = true)
|
|
|
|
|
: this(id, name, choices?.ToList() ?? new List<string>(), selectedIndex, isReadOnly, showLabel)
|
2026-01-08 20:15:57 +09:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Public Methods
|
|
|
|
|
/// <summary>텍스트로 선택</summary>
|
|
|
|
|
public void SelectByText(string text)
|
|
|
|
|
{
|
|
|
|
|
int index = _choices.IndexOf(text);
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
Value = index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|