Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,43 @@
"WebSearch",
"Bash(git worktree:*)",
"Bash(git merge:*)",
"Bash(git push:*)"
"Bash(git push:*)",
"Bash(gh auth:*)",
"Bash(gh app create:*)",
"Bash(gh extension install:*)",
"Bash(gh extension search:*)",
"WebFetch(domain:docs.claude.com)",
"Bash(powershell.exe:*)"
],
"deny": [],
"ask": []
},
"enableAllProjectMcpServers": true,
"enabledMcpjsonServers": [
"playwright"
]
],
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "powershell -ExecutionPolicy Bypass -File \".claude/stop-hook.ps1\""
}
]
}
],
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "notify-send 'Claude Code' 'Awaiting your input'"
}
]
}
]
}
}
34 changes: 34 additions & 0 deletions .claude/stop-hook.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Claude Code Stop Hook Script
param()

$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$currentWorkingDir = $env:cwd
if (-not $currentWorkingDir) {
$currentWorkingDir = Get-Location
}

# Send toast notification
try {
Import-Module BurntToast -ErrorAction SilentlyContinue
if (Get-Module -Name BurntToast) {
$projectName = Split-Path $currentWorkingDir -Leaf
New-BurntToastNotification -Text "Claude Task Completed", $projectName, "Completed at: $timestamp"
}
}
catch {
# Silently ignore notification failures
}

# Send email notification
try {
$projectName = Split-Path $currentWorkingDir -Leaf
$emailSubject = "Claude Task Completed"
$emailBody = "Project: $projectName`nDirectory: $currentWorkingDir`nCompleted at: $timestamp"

if (Test-Path 'E:\tool\SendMail\SendMail.exe') {
& 'E:\tool\SendMail\SendMail.exe' $emailSubject $emailBody
}
}
catch {
# Silently ignore email failures
}
29 changes: 29 additions & 0 deletions KingOfTool/MultiFileExample/Calculator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace MultiFileExample
{
public class Calculator
{
public int Add(int a, int b)
{
return a + b;
}

public int Subtract(int a, int b)
{
return a - b;
}

public int Multiply(int a, int b)
{
return a * b;
}

public double Divide(double a, double b)
{
if (b == 0)
{
throw new System.DivideByZeroException("Cannot divide by zero");
}
return a / b;
}
}
}
27 changes: 27 additions & 0 deletions KingOfTool/MultiFileExample/Person.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace MultiFileExample
{
public class Person
{
public string Name { get; set; }
public int Age { get; set; }

public Person(string name, int age)
{
Name = name;
Age = age;
}

public void Introduce()
{
Console.WriteLine($"你好,我是{Name},今年{Age}岁。");
}

public void Birthday()
{
Age++;
Console.WriteLine($"{Name}过生日了!现在{Age}岁了。");
}
}
}
32 changes: 32 additions & 0 deletions KingOfTool/MultiFileExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;

namespace MultiFileExample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Multi-File Compilation Example");
Console.WriteLine("==============================");

// 使用 Calculator 类
var calculator = new Calculator();
int result = calculator.Add(10, 20);
Console.WriteLine($"10 + 20 = {result}");

result = calculator.Multiply(5, 6);
Console.WriteLine($"5 × 6 = {result}");

// 使用 Person 类
var person = new Person("张三", 25);
person.Introduce();

// 使用 StringHelper 静态类
string text = "Hello World";
string reversed = StringHelper.Reverse(text);
Console.WriteLine($"'{text}' reversed is '{reversed}'");

Console.WriteLine("\n多文件编译成功!");
}
}
}
52 changes: 52 additions & 0 deletions KingOfTool/MultiFileExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 多文件编译示例

这个示例展示了 SharpPad 的多文件编译功能。

## 使用方法

### 1. 在 SharpPad 中导入这些文件
将以下文件添加到 SharpPad:
- `Program.cs` - 主程序入口文件
- `Calculator.cs` - 计算器类
- `Person.cs` - 人员类
- `StringHelper.cs` - 字符串辅助工具类

### 2. 选择要一起编译的文件
有两种方式选择文件:

#### 方式一:手动选择
- 在文件列表中,每个文件前都有一个复选框
- 勾选你想要一起编译的文件
- 通常需要选择所有相关的 `.cs` 文件

#### 方式二:快速选择所有 CS 文件
- 点击文件列表顶部的 "✓CS" 按钮
- 这会自动选中所有 `.cs` 文件

### 3. 运行代码
- 确保已选择所有需要的文件
- 点击"运行"按钮
- SharpPad 会自动:
- 检测包含 Main 方法的入口文件
- 将所有选中的文件一起编译
- 执行生成的程序

### 4. 清除选择
- 点击文件列表顶部的 "✗" 按钮可以清除所有选择

## 功能特点

1. **自动入口检测**:系统会自动找到包含 `Main` 方法的文件作为程序入口
2. **跨文件引用**:可以在不同文件间引用类和方法
3. **命名空间支持**:支持使用命名空间组织代码
4. **向后兼容**:如果没有选择任何文件,将以单文件模式运行当前编辑器中的代码

## 示例说明

这个示例包含:
- **Program.cs**:主程序,使用其他文件中定义的类
- **Calculator.cs**:提供基本的数学运算
- **Person.cs**:定义人员类及其方法
- **StringHelper.cs**:提供字符串操作的静态方法

运行后,你将看到所有类协同工作的输出结果。
33 changes: 33 additions & 0 deletions KingOfTool/MultiFileExample/StringHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Linq;

namespace MultiFileExample
{
public static class StringHelper
{
public static string Reverse(string input)
{
if (string.IsNullOrEmpty(input))
return input;

return new string(input.Reverse().ToArray());
}

public static bool IsPalindrome(string input)
{
if (string.IsNullOrEmpty(input))
return false;

string cleaned = input.Replace(" ", "").ToLower();
return cleaned == Reverse(cleaned);
}

public static int CountWords(string input)
{
if (string.IsNullOrWhiteSpace(input))
return 0;

return input.Split(new[] { ' ', '\t', '\n', '\r' },
System.StringSplitOptions.RemoveEmptyEntries).Length;
}
}
}
Loading
Loading