Initial commit to new repository
This commit is contained in:
238
src/AxCopilot/Views/ShortcutHelpWindow.xaml.cs
Normal file
238
src/AxCopilot/Views/ShortcutHelpWindow.xaml.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AxCopilot.Views;
|
||||
|
||||
/// <summary>Ctrl+K로 열리는 단축키 참조 모달 창</summary>
|
||||
public partial class ShortcutHelpWindow : Window
|
||||
{
|
||||
// ─── P/Invoke ────────────────────────────────────────────────────────────
|
||||
[DllImport("user32.dll")] private static extern void ReleaseCapture();
|
||||
[DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
private const int WM_NCLBUTTONDOWN = 0xA1;
|
||||
private const int HTBOTTOMRIGHT = 17;
|
||||
|
||||
// (키 문자열, 설명, 아이콘 코드, 배경색)
|
||||
private record ShortcutRow(string Key, string Description, string Icon = "\uE72D", string Color = "#4B5EFC");
|
||||
|
||||
public ShortcutHelpWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += (_, _) =>
|
||||
{
|
||||
// 저장된 설정 로드
|
||||
var svc = (System.Windows.Application.Current as App)?.SettingsService;
|
||||
if (svc != null)
|
||||
ThemeColorChk.IsChecked = svc.Settings.Launcher.ShortcutHelpUseThemeColor;
|
||||
|
||||
BuildItems();
|
||||
};
|
||||
}
|
||||
|
||||
private void BuildItems()
|
||||
{
|
||||
bool useTheme = ThemeColorChk.IsChecked == true;
|
||||
|
||||
// ── 탐색 ──────────────────────────────────────────────────────────
|
||||
var nav = new[]
|
||||
{
|
||||
new ShortcutRow("↑ / ↓", "결과 목록 위/아래로 이동", "\uE74A", "#4B5EFC"),
|
||||
new ShortcutRow("PageUp / PageDown","목록 5칸 빠른 이동", "\uE74A", "#4B5EFC"),
|
||||
new ShortcutRow("Home / End", "목록 처음 항목 / 마지막 항목으로 점프", "\uE74A", "#4B5EFC"),
|
||||
new ShortcutRow("Tab", "선택 항목 제목을 입력창에 자동 완성", "\uE748", "#7B68EE"),
|
||||
new ShortcutRow("→", "파일/앱 선택 시 액션 모드(복사·실행 등) 진입", "\uE76C", "#107C10"),
|
||||
new ShortcutRow("Escape", "액션 모드면 일반 모드로 복귀, 아니면 AX Commander 닫기", "\uE711", "#C50F1F"),
|
||||
};
|
||||
|
||||
// ── 파일 동작 ──────────────────────────────────────────────────────
|
||||
var file = new[]
|
||||
{
|
||||
new ShortcutRow("Enter", "선택 항목 실행 (파일 열기·명령 실행·URL 열기 등)", "\uE768", "#107C10"),
|
||||
new ShortcutRow("Ctrl+Enter", "선택 파일·앱을 관리자(UAC 상승) 권한으로 실행", "\uE7EF", "#C50F1F"),
|
||||
new ShortcutRow("Alt+Enter", "선택 항목의 Windows 속성 대화 상자 열기", "\uE7EE", "#8B2FC9"),
|
||||
new ShortcutRow("Ctrl+C", "선택 항목의 파일 이름(확장자 제외)을 클립보드에 복사","\uE8C8", "#0078D4"),
|
||||
new ShortcutRow("Ctrl+Shift+C", "선택 항목의 전체 경로를 클립보드에 복사", "\uE8C8", "#0078D4"),
|
||||
new ShortcutRow("Ctrl+Shift+E", "파일 탐색기를 열고 선택 항목 위치를 하이라이트", "\uE8DA", "#107C10"),
|
||||
new ShortcutRow("Ctrl+T", "선택 항목 폴더 경로에서 터미널(wt/cmd) 열기", "\uE756", "#323130"),
|
||||
new ShortcutRow("Ctrl+P", "선택 항목을 즐겨찾기에 추가 (이미 있으면 제거)", "\uE734", "#D97706"),
|
||||
new ShortcutRow("F2", "선택 파일·폴더의 이름 변경 모드로 전환", "\uE70F", "#6B2C91"),
|
||||
new ShortcutRow("Delete", "선택 항목을 최근 목록에서 제거 (확인 후 실행)", "\uE74D", "#C50F1F"),
|
||||
};
|
||||
|
||||
// ── 뷰 전환 ────────────────────────────────────────────────────────
|
||||
var view = new[]
|
||||
{
|
||||
new ShortcutRow("Ctrl+B", "즐겨찾기 목록 보기 (다시 누르면 닫기, 토글)", "\uE735", "#D97706"),
|
||||
new ShortcutRow("Ctrl+R", "최근 실행 목록 보기 (다시 누르면 닫기, 토글)", "\uE81C", "#0078D4"),
|
||||
new ShortcutRow("Ctrl+H", "클립보드 히스토리 목록 보기", "\uE77F", "#8B2FC9"),
|
||||
new ShortcutRow("Ctrl+D", "다운로드 폴더 경로 바로 열기", "\uE8B7", "#107C10"),
|
||||
new ShortcutRow("Ctrl+F", "입력 초기화 후 파일 검색 모드로 포커스 이동", "\uE71E", "#4B5EFC"),
|
||||
new ShortcutRow("F1", "헬프 화면 열기 (help 입력과 동일)", "\uE897", "#4B5EFC"),
|
||||
};
|
||||
|
||||
// ── 실행 및 기타 ───────────────────────────────────────────────────
|
||||
var run = new[]
|
||||
{
|
||||
new ShortcutRow("Ctrl+1 ~ Ctrl+9", "표시 중인 N번째 결과를 즉시 실행 (번호 배지와 연동)", "\uE8C4", "#107C10"),
|
||||
new ShortcutRow("Ctrl+L", "입력창 전체 초기화", "\uE711", "#9999BB"),
|
||||
new ShortcutRow("Ctrl+W", "AX Commander 창 즉시 닫기", "\uE711", "#9999BB"),
|
||||
new ShortcutRow("Ctrl+K", "이 단축키 참조 창 열기", "\uE8FD", "#4B5EFC"),
|
||||
new ShortcutRow("Ctrl+,", "설정 창 열기", "\uE713", "#4B5EFC"),
|
||||
new ShortcutRow("F5", "파일 인덱스 즉시 재구축", "\uE72C", "#107C10"),
|
||||
new ShortcutRow("Shift+Enter", "Large Type / 병합 실행 / 캡처 모드: 지연 캡처(3/5/10초) 타이머", "\uE8A7", "#7B68EE"),
|
||||
};
|
||||
|
||||
// ── 입력 예약어 ───────────────────────────────────────────────────
|
||||
var prefix = new[]
|
||||
{
|
||||
new ShortcutRow("cd [경로/별칭]", "지정한 경로 또는 등록된 폴더 별칭을 탐색기로 열기", "\uE8DA", "#107C10"),
|
||||
new ShortcutRow("~ [이름]", "워크스페이스 저장(save)/복원(restore)/목록(list)", "\uE8B7", "#C50F1F"),
|
||||
new ShortcutRow("# [검색어]", "클립보드 히스토리 검색·붙여넣기", "\uE77F", "#8B2FC9"),
|
||||
new ShortcutRow("fav [검색어]", "즐겨찾기 목록 검색 및 열기. add/del 로 관리", "\uE735", "#D97706"),
|
||||
new ShortcutRow("recent [검색어]", "최근 실행 항목 검색", "\uE81C", "#0078D4"),
|
||||
new ShortcutRow("cap [모드]", "화면 캡처 (region/window/scroll/screen) · Shift+Enter: 지연 캡처", "\uE722", "#C09010"),
|
||||
new ShortcutRow("help [검색어]", "도움말 및 기능 목록 검색", "\uE897", "#4B5EFC"),
|
||||
new ShortcutRow("/ [명령]", "시스템 명령 (lock/sleep/restart/shutdown 등)", "\uE7E8", "#C50F1F"),
|
||||
new ShortcutRow("! [질문]", "AX Agent — Ollama/vLLM/Gemini/Claude", "\uE8BD", "#8B2FC9"),
|
||||
};
|
||||
|
||||
NavigationItems.Items.Clear();
|
||||
FileActionItems.Items.Clear();
|
||||
ViewItems.Items.Clear();
|
||||
RunItems.Items.Clear();
|
||||
PrefixItems.Items.Clear();
|
||||
|
||||
Populate(NavigationItems, nav, useTheme);
|
||||
Populate(FileActionItems, file, useTheme);
|
||||
Populate(ViewItems, view, useTheme);
|
||||
Populate(RunItems, run, useTheme);
|
||||
Populate(PrefixItems, prefix, useTheme);
|
||||
}
|
||||
|
||||
private static void Populate(ItemsControl control, ShortcutRow[] rows, bool useThemeColor)
|
||||
{
|
||||
// 현재 테마에서 텍스트/배경 색상 읽기
|
||||
var primaryText = System.Windows.Application.Current.TryFindResource("PrimaryText") as Brush
|
||||
?? new SolidColorBrush(Color.FromRgb(0x33, 0x33, 0x55));
|
||||
var itemBg = System.Windows.Application.Current.TryFindResource("ItemBackground") as Brush
|
||||
?? new SolidColorBrush(Color.FromRgb(0xEE, 0xEE, 0xFF));
|
||||
var accentBrush = System.Windows.Application.Current.TryFindResource("AccentColor") as SolidColorBrush;
|
||||
var accentHex = accentBrush != null ? $"#{accentBrush.Color.R:X2}{accentBrush.Color.G:X2}{accentBrush.Color.B:X2}" : "#4B5EFC";
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var colorHex = useThemeColor ? accentHex : row.Color;
|
||||
|
||||
var grid = new Grid { Margin = new Thickness(0, 0, 0, 3) };
|
||||
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(28) });
|
||||
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(148) });
|
||||
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
|
||||
|
||||
// 아이콘 배지
|
||||
var iconBorder = new Border
|
||||
{
|
||||
Width = 22, Height = 22,
|
||||
CornerRadius = new CornerRadius(5),
|
||||
Background = ParseBrush(colorHex + "22"),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
};
|
||||
iconBorder.Child = new TextBlock
|
||||
{
|
||||
Text = row.Icon,
|
||||
FontFamily = new FontFamily("Segoe MDL2 Assets"),
|
||||
FontSize = 10,
|
||||
Foreground = ParseBrush(colorHex),
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetColumn(iconBorder, 0);
|
||||
grid.Children.Add(iconBorder);
|
||||
|
||||
// 키 배지 — 테마 ItemBackground 사용
|
||||
var keyBorder = new Border
|
||||
{
|
||||
Background = itemBg,
|
||||
CornerRadius = new CornerRadius(5),
|
||||
Padding = new Thickness(7, 3, 7, 3),
|
||||
Margin = new Thickness(4, 1, 8, 1),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
HorizontalAlignment = HorizontalAlignment.Left,
|
||||
};
|
||||
keyBorder.Child = new TextBlock
|
||||
{
|
||||
Text = row.Key,
|
||||
FontFamily = new FontFamily("Consolas, Courier New"),
|
||||
FontSize = 11,
|
||||
Foreground = primaryText,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
Grid.SetColumn(keyBorder, 1);
|
||||
grid.Children.Add(keyBorder);
|
||||
|
||||
// 설명 — 테마 PrimaryText 사용
|
||||
var desc = new TextBlock
|
||||
{
|
||||
Text = row.Description,
|
||||
FontSize = 11.5,
|
||||
Foreground = primaryText,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
LineHeight = 16,
|
||||
};
|
||||
Grid.SetColumn(desc, 2);
|
||||
grid.Children.Add(desc);
|
||||
|
||||
control.Items.Add(grid);
|
||||
}
|
||||
}
|
||||
|
||||
private static SolidColorBrush ParseBrush(string hex)
|
||||
{
|
||||
try { return new SolidColorBrush((Color)ColorConverter.ConvertFromString(hex)); }
|
||||
catch { return new SolidColorBrush(Colors.Transparent); }
|
||||
}
|
||||
|
||||
// ─── 테마 색상 체크박스 ─────────────────────────────────────────────────
|
||||
|
||||
private void ThemeColorChk_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 설정 저장
|
||||
var svc = (System.Windows.Application.Current as App)?.SettingsService;
|
||||
if (svc != null)
|
||||
{
|
||||
svc.Settings.Launcher.ShortcutHelpUseThemeColor = ThemeColorChk.IsChecked == true;
|
||||
svc.Save();
|
||||
}
|
||||
// 목록 다시 그리기
|
||||
BuildItems();
|
||||
}
|
||||
|
||||
// ─── 리사이즈 그립 ──────────────────────────────────────────────────────
|
||||
|
||||
private void ResizeGrip_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ButtonState != MouseButtonState.Pressed) return;
|
||||
ReleaseCapture();
|
||||
SendMessage(new WindowInteropHelper(this).Handle, WM_NCLBUTTONDOWN, (IntPtr)HTBOTTOMRIGHT, IntPtr.Zero);
|
||||
}
|
||||
|
||||
// ─── 이벤트 ─────────────────────────────────────────────────────────────
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
private void Window_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape) Close();
|
||||
}
|
||||
|
||||
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Pressed)
|
||||
try { DragMove(); } catch { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user