Skip to content

Commit

Permalink
Merge pull request #294 from AuroraZiling/main
Browse files Browse the repository at this point in the history
Docs update
  • Loading branch information
kikipoulet authored Oct 3, 2024
2 parents fdfe1be + 7cf1976 commit aa3b65f
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 17 deletions.
4 changes: 0 additions & 4 deletions docs/docs/documentation/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ Visit [SukiUI on Nuget](https://www.nuget.org/packages/SukiUI) for more informat

5. Select `SukiUI.dll` you downloaded

6. Add a Nuget package `System.Reactive`

::: tip
The package list should be:

![](/getting-started/introduction-final-package-list.webp "package list")

If installed by referencing `.dll`, there should be a `System.Reactive` here.
:::
</details>
6 changes: 1 addition & 5 deletions docs/docs/documentation/getting-started/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public partial class MainWindow : Window

Modified `MainWindow.axaml.cs`:


```csharp
using SukiUI.Controls; // [!code highlight]
Expand All @@ -85,9 +84,6 @@ public partial class MainWindow : SukiWindow // [!code highlight]

You're now ready to use SukiUI ! We advise you to theme your app now. Please check the [Theming Page](https://kikipoulet.github.io/SukiUI/documentation/theming/basic.html) and the [SukiWindow Page](https://kikipoulet.github.io/SukiUI/documentation/controls/layout/sukiwindow.html)




::: warning
If you encounter the following exception:
- `SukiWindow` not found [Issue#265](https://github.com/kikipoulet/SukiUI/issues/265)
Expand All @@ -98,4 +94,4 @@ If you encounter the following exception:
There are two possible solutions to try:
- Upgrade or downgrade the version of `Avalonia` and `SukiUI` until the exception is resolved
- While ensuring that `Avalonia` is up to date (beta), reference the build `.dll` from [Github Action](https://github.com/kikipoulet/SukiUI/actions/workflows/build.yml) and proceed with the [following steps](/documentation/getting-started/installation#via-github-action)
:::
:::
9 changes: 7 additions & 2 deletions docs/docs/documentation/hosts/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The host is designed in such a way as to be MVVM friendly and as long as you hav
Here is a simple example setup using MVVM:

### View

```xml
<!-- XMLNS definitions omitted for brevity -->
<suki:SukiWindow>
Expand All @@ -17,6 +18,7 @@ Here is a simple example setup using MVVM:
```

### ViewModel

```cs
public class ExampleViewModel
{
Expand All @@ -28,6 +30,7 @@ public class ExampleViewModel
If you do not wish to use MVVM, or would rather a simpler solution that "just works", then you can choose to implement it like this:

### AXAML

```xml
<!-- XMLNS definitions omitted for brevity -->
<suki:SukiWindow>
Expand All @@ -36,7 +39,9 @@ If you do not wish to use MVVM, or would rather a simpler solution that "just wo
</suki:SukiWindow.Hosts>
<suki:SukiWindow>
```

### Code-Behind

```cs
public class MainWindow : SukiWindow
{
Expand Down Expand Up @@ -105,11 +110,11 @@ public void DisplayDialog()
{
dialogManager.CreateDialog()
.WithActionButton("Don't Close", _ => { })
.WithActionButton("Close ", _ => { }, true) // last parameter optional
.WithActionButton("Close ", _ => { }, true) // last parameter optional
.TryShow();
}
```

## MessageBox Style

It is possible to use the `.OfType()` method to cause the dialog to use an included MessageBox style, the styles included are: Information, Success, Warning and Error.
It is possible to use the `.OfType()` method to cause the dialog to use an included MessageBox style, the styles included are: `Information`, `Success`, `Warning` and `Error`.
4 changes: 0 additions & 4 deletions docs/docs/zh/documentation/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ dotnet add package SukiUI --version 6.0.0

5. 选择刚刚下载的 `SukiUI.dll` 并添加

6. 添加 Nuget 包 `System.Reactive`

::: tip
最终,你的包列表应为:

![](/getting-started/introduction-final-package-list.webp "package list")

如果你是以引用`dll`的方式安装的,此处应有 `System.Reactive`
:::
5 changes: 4 additions & 1 deletion docs/docs/zh/documentation/getting-started/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
</Application>
```

::: warning
如果没有设置主题颜色 `ThemeColor`,创建的窗口和许多控件都将完全透明
:::

## 将 MainWindow 更改为 SukiWindow

原来的 `MainWindow.axaml`:
Expand Down Expand Up @@ -60,7 +64,6 @@ public partial class MainWindow : Window

修改后的 `MainWindow.axaml.cs`:


```csharp
using SukiUI.Controls; // [!code highlight]
Expand Down
117 changes: 116 additions & 1 deletion docs/docs/zh/documentation/hosts/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,119 @@

SukiUI 提供了一个用于弹出对话框的[可选窗口控件](./hosts),该控件可以很轻易地在 `SukiWindow.Hosts` 添加(这也是最推荐且能达到最佳效果的使用方法)

该对话框对 MVVM 设计模式友好,同时你也可以通过 `ISukiDialogManager` 来获得给定的 `SukiDialogHost` 实例,从而显示对话框。
该对话框对 MVVM 设计模式友好,同时你也可以通过 `ISukiDialogManager` 来获得给定的 `SukiDialogHost` 实例,从而显示对话框。

以下是一些 MVVM 设计模式下使用的例子:

### View

```xml
<!-- XMLNS 定义已略去 -->
<suki:SukiWindow>
<suki:SukiWindow.Hosts>
<suki:SukiDialogHost Manager="{Binding DialogManager}"/>
</suki:SukiWindow.Hosts>
<suki:SukiWindow>
```

### ViewModel

```cs
public class ExampleViewModel
{
public ISukiDialogManager DialogManager { get; } = new SukiDialogManager();
}
```
---

如果你并未使用 MVVM 设计模式,只是想做一些简单实现,可以参考以下方法:

### AXAML

```xml
<!-- XMLNS 定义已略去 -->
<suki:SukiWindow>
<suki:SukiWindow.Hosts>
<suki:SukiDialogHost Name="DialogHost"/>
</suki:SukiWindow.Hosts>
<suki:SukiWindow>
```

### Code-Behind

```cs
public class MainWindow : SukiWindow
{
public static ISukiDialogManager DialogManager = new SukiDialogManager();

public MainWindow()
{
InitializeComponent();
DialogHost.Manager = DialogManager;
}
}
```

### 用法

```cs
MainWindow.DialogManager.CreateDialog()
.TryShow();
```

## 显示对话框

为了创建和显示对话框,SukiUI 提供了一种现代的构建方式。你可以在 `ISukiDialogManager` 实例上调用 `.CreateDialog()` 方法来开始构建对话框。

接下来,通过链式调用可以轻松设置对话框的标题、内容等。所有方法都有相应的 XML 注释说明。

构建完对话框后,调用 `.TryShow()` 方法即可显示对话框,前提是当前没有其他对话框正在显示。

例如,下面是一个简单的对话框示例:

```cs
public void DisplayDialog()
{
DialogManager.CreateDialog()
.WithTitle("示例对话框")
.WithContent("这里是示例对话框的内容。")
.TryShow();
}
```

## 关闭对话框

默认情况下,对话框没有自动关闭机制。要添加关闭方式,可以使用 `.Dismiss()` 方法。目前最常见的方式是 `.ByClickingBackground()`,即用户点击对话框外部时关闭对话框。

例如,下面的代码展示了一个点击背景即可关闭的空对话框:

```cs
public void DisplayDialog()
{
DialogManager.CreateDialog()
.Dismiss().ByClickingBackground()
.TryShow();
}
```

另一种关闭对话框的方式是通过操作按钮,接下来将介绍这一点。

## 交互操作

你可以通过 `.WithActionButton()` 方法为对话框添加按钮。该方法可以设置按钮的文字、点击后的回调操作,并且可以选择性地通过 `dismissOnClick` 参数来控制点击后是否关闭对话框。你也可以添加多个按钮,根据需要设置不同的操作。

以下是一个包含两个按钮的对话框示例,其中一个按钮会关闭对话框:

```cs
public void DisplayDialog()
{
DialogManager.CreateDialog()
.WithActionButton("保持打开", _ => { })
.WithActionButton("关闭", _ => { }, true) // 点击后关闭对话框
.TryShow();
}
```

## 消息框样式

你还可以通过 `.OfType()` 方法为对话框应用内置的消息框样式,目前支持的信息类型包括:`Information`, `Success`, `Warning``Error`

0 comments on commit aa3b65f

Please sign in to comment.