mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-27 23:19:46 +00:00
Some checks are pending
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
72 lines
2.9 KiB
C#
72 lines
2.9 KiB
C#
using AIStudio.Dialogs;
|
|
using AIStudio.Settings;
|
|
|
|
using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
|
|
|
namespace AIStudio.Components.Settings;
|
|
|
|
public partial class SettingsPanelProfiles : SettingsPanelBase
|
|
{
|
|
private async Task AddProfile()
|
|
{
|
|
var dialogParameters = new DialogParameters<ProfileDialog>
|
|
{
|
|
{ x => x.IsEditing, false },
|
|
};
|
|
|
|
var dialogReference = await this.DialogService.ShowAsync<ProfileDialog>(T("Add Profile"), dialogParameters, DialogOptions.FULLSCREEN);
|
|
var dialogResult = await dialogReference.Result;
|
|
if (dialogResult is null || dialogResult.Canceled)
|
|
return;
|
|
|
|
var addedProfile = (Profile)dialogResult.Data!;
|
|
addedProfile = addedProfile with { Num = this.SettingsManager.ConfigurationData.NextProfileNum++ };
|
|
|
|
this.SettingsManager.ConfigurationData.Profiles.Add(addedProfile);
|
|
|
|
await this.SettingsManager.StoreSettings();
|
|
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
|
}
|
|
|
|
private async Task EditProfile(Profile profile)
|
|
{
|
|
var dialogParameters = new DialogParameters<ProfileDialog>
|
|
{
|
|
{ x => x.DataNum, profile.Num },
|
|
{ x => x.DataId, profile.Id },
|
|
{ x => x.DataName, profile.Name },
|
|
{ x => x.DataNeedToKnow, profile.NeedToKnow },
|
|
{ x => x.DataActions, profile.Actions },
|
|
{ x => x.IsEditing, true },
|
|
};
|
|
|
|
var dialogReference = await this.DialogService.ShowAsync<ProfileDialog>(T("Edit Profile"), dialogParameters, DialogOptions.FULLSCREEN);
|
|
var dialogResult = await dialogReference.Result;
|
|
if (dialogResult is null || dialogResult.Canceled)
|
|
return;
|
|
|
|
var editedProfile = (Profile)dialogResult.Data!;
|
|
this.SettingsManager.ConfigurationData.Profiles[this.SettingsManager.ConfigurationData.Profiles.IndexOf(profile)] = editedProfile;
|
|
|
|
await this.SettingsManager.StoreSettings();
|
|
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
|
}
|
|
|
|
private async Task DeleteProfile(Profile profile)
|
|
{
|
|
var dialogParameters = new DialogParameters
|
|
{
|
|
{ "Message", string.Format(T("Are you sure you want to delete the profile '{0}'?"), profile.Name) },
|
|
};
|
|
|
|
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(T("Delete Profile"), dialogParameters, DialogOptions.FULLSCREEN);
|
|
var dialogResult = await dialogReference.Result;
|
|
if (dialogResult is null || dialogResult.Canceled)
|
|
return;
|
|
|
|
this.SettingsManager.ConfigurationData.Profiles.Remove(profile);
|
|
await this.SettingsManager.StoreSettings();
|
|
|
|
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
|
}
|
|
} |