[Phase L2-8] DockBar 위젯 확장 — 날씨·일정·배터리 추가

Services/WeatherWidgetService.cs (신규 58줄):
- wttr.in API 호출, 30분 캐시
- 사내 모드(InternalModeEnabled=true)에서는 "--" 즉시 반환
- Invalidate()로 강제 캐시 초기화 지원

ViewModels/LauncherViewModel.Widgets.cs:
- Widget_WeatherText (setter: 코드비하인드에서 직접 갱신)
- Widget_CalText: DateTime.Now → "M/d (ddd)" 형식 (ko-KR)
- Widget_BatteryText / Widget_BatteryIcon / Widget_BatteryVisible

Views/LauncherWindow.Widgets.cs:
- StartWidgetUpdates(): 배터리 즉시 갱신 + 날씨 비동기 갱신 호출
- 1초 타이머: 배터리 30초마다, 날씨 캐시체크 2분마다
- UpdateBatteryWidget(): PowerStatus 읽기, 잔량별 MDL2 아이콘 선택
- RefreshWeatherAsync(): WeatherWidgetService 호출 → VM 프로퍼티 갱신
- WgtWeather_Click: 사외 모드=wttr.in 열기, 사내 모드=캐시 초기화
- WgtCal_Click: ms-clock: 또는 outlookcal: 열기
- WgtBattery_Click: ms-settings:powersleep 열기

Views/LauncherWindow.xaml:
- WidgetBar 내부: Grid → StackPanel + 2행 구조로 변환
- Row A: 기존 4개 위젯 (시스템·포모·메모·서버, 변경 없음)
- Row B: E(날씨 파랑) · F(일정 핑크) · G(배터리 녹색) 신규 추가
- 배터리: BoolToVisibilityConverter로 데스크톱에서 자동 숨김

빌드: 경고 0, 오류 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-04 10:50:57 +09:00
parent f557f53449
commit fc881124b9
4 changed files with 407 additions and 101 deletions

View File

@@ -57,6 +57,51 @@ public partial class LauncherViewModel
public bool Widget_McpOnline => ServerStatusService.Instance.McpOnline;
public string Widget_McpName => ServerStatusService.Instance.McpName;
// ─── 날씨 ─────────────────────────────────────────────────────────────────
private string _widget_WeatherText = "--";
/// <summary>날씨 위젯 텍스트 예: "⛅ 18°C" (사외 모드) / "--" (사내 모드)</summary>
public string Widget_WeatherText
{
get => _widget_WeatherText;
internal set { _widget_WeatherText = value; OnPropertyChanged(); }
}
// ─── 날짜/일정 ────────────────────────────────────────────────────────────
/// <summary>날짜 위젯 텍스트 예: "4/4 (화)"</summary>
public string Widget_CalText =>
DateTime.Now.ToString("M/d (ddd)",
System.Globalization.CultureInfo.GetCultureInfo("ko-KR"));
// ─── 배터리 ───────────────────────────────────────────────────────────────
private string _widget_BatteryText = "--";
private string _widget_BatteryIcon = "\uE83F";
private bool _widget_BatteryVisible = false;
/// <summary>배터리 퍼센트 및 충전 표시. 예: "87%" / "45% ⚡"</summary>
public string Widget_BatteryText
{
get => _widget_BatteryText;
internal set { _widget_BatteryText = value; OnPropertyChanged(); }
}
/// <summary>배터리 잔량별 Segoe MDL2 아이콘 코드포인트</summary>
public string Widget_BatteryIcon
{
get => _widget_BatteryIcon;
internal set { _widget_BatteryIcon = value; OnPropertyChanged(); }
}
/// <summary>배터리 위젯 표시 여부 (데스크톱/배터리 없음이면 false)</summary>
public bool Widget_BatteryVisible
{
get => _widget_BatteryVisible;
internal set { _widget_BatteryVisible = value; OnPropertyChanged(); }
}
// ─── 갱신 메서드 ──────────────────────────────────────────────────────────
/// <summary>1초마다 LauncherWindow.Widgets.cs에서 호출 — UI 바인딩 갱신.</summary>
@@ -75,6 +120,9 @@ public partial class LauncherViewModel
OnPropertyChanged(nameof(Widget_LlmOnline));
OnPropertyChanged(nameof(Widget_McpOnline));
OnPropertyChanged(nameof(Widget_McpName));
OnPropertyChanged(nameof(Widget_CalText));
// WeatherText / BatteryText / BatteryIcon / BatteryVisible 는
// LauncherWindow.Widgets.cs에서 직접 setter 호출로 갱신
}
private int _widgetRefreshTick;