Skip to content

feat: 删除主界面组件/行确认功能#1702

Open
kaokao221 wants to merge 3 commits intoClassIsland:masterfrom
kaokao221:component-delete-confirm
Open

feat: 删除主界面组件/行确认功能#1702
kaokao221 wants to merge 3 commits intoClassIsland:masterfrom
kaokao221:component-delete-confirm

Conversation

@kaokao221
Copy link
Copy Markdown
Contributor

这个 Pull Request 做了什么?

feat: 删除主界面组件/行确认功能。

相关 Issue

Fixes #1647

检查清单

  • 我已经在本地测试过这个 PR,确保欲实现的功能或修复的问题能正常工作。

Copy link
Copy Markdown
Member

@HelloWRC HelloWRC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议考虑使用 Flyout 这类轻量级弹出对话框进行确认,不然使用 ContentDialog 时删除组件时有些太繁琐了。

另外,如果可以,也请将此功能同步到编辑模式中。

Copy link
Copy Markdown
Member

@HelloWRC HelloWRC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请在后续提交前至少在本地测试一遍。

请注意,如果您继续使用 AI 生成没有审核过,甚至是连编译都无法通过的的代码并提交 PR,我们可能会临时或永久限制您向本仓库发起 PR 的能力。

Comment on lines -179 to -252
private void ButtonChildrenViewClose_OnClick(object sender, RoutedEventArgs e)
{
CloseComponentChildrenView();
}

private void CloseComponentChildrenView()
{
ViewModel.IsComponentChildrenViewOpen = false;
ViewModel.ChildrenComponentSettingsNavigationStack.Clear();
ViewModel.CanChildrenNavigateBack = false;
ViewModel.SelectedComponentContainerChildren = [];
ViewModel.SelectedRootComponent = null;
}

private void ButtonOpenRuleset_OnClick(object sender, RoutedEventArgs e)
{
if (this.FindResource("RulesetControl") is not RulesetControl control ||
ViewModel.SelectedMainWindowLineSettings == null)
return;
control.Ruleset = ViewModel.SelectedMainWindowLineSettings.HidingRules;
OpenDrawer("RulesetControl");
}

private void ButtonShowChildrenComponents_OnClick(object sender, RoutedEventArgs e)
{
SetCurrentSelectedComponentContainer(ViewModel.SelectedComponentSettings);
}

private void SetCurrentSelectedComponentContainer(ComponentSettings? componentSettings, bool isBack=false)
{
if (componentSettings?.AssociatedComponentInfo?.IsComponentContainer != true)
{
return;
}

var type = componentSettings.AssociatedComponentInfo.ComponentType?.BaseType;
if (componentSettings.Settings is JsonElement && type != null)
{
componentSettings.Settings = ComponentsService.LoadComponentSettings(componentSettings, type);
}
if (componentSettings.Settings is not IComponentContainerSettings settings)
{
return;
}
if (componentSettings == ViewModel.SelectedComponentSettingsMain)
{
ViewModel.ChildrenComponentSettingsNavigationStack.Clear();
ViewModel.SelectedRootComponent = componentSettings;
} else if (ViewModel.SelectedContainerComponent != null && !isBack)
{
ViewModel.ChildrenComponentSettingsNavigationStack.Push(ViewModel.SelectedContainerComponent);
}
ViewModel.SelectedComponentContainerChildren = settings.Children;
ViewModel.SelectedContainerComponent = componentSettings;
ViewModel.IsComponentChildrenViewOpen = true;
ViewModel.CanChildrenNavigateBack = ViewModel.ChildrenComponentSettingsNavigationStack.Count >= 1;
}

private void ListBoxComponents_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
// 这里应该把指针按下的事件吞掉,这样在拖动这里面的在组件时就不会把事件往上传送到上级,让上级 ListBoxItem 也跟着被拖动。
e.Handled = true;
}

private void ButtonCreateMainWindowLine_OnClick(object? sender, RoutedEventArgs e)
{
var index = ViewModel.SelectedMainWindowLineSettings == null
? 0
: Math.Max(0,
ViewModel.ComponentsService.CurrentComponents.Lines.IndexOf(ViewModel.SelectedMainWindowLineSettings) + 1);
var lineSettings = new MainWindowLineSettings();
ViewModel.ComponentsService.CurrentComponents.Lines.Insert(index, lineSettings);
ViewModel.SelectedMainWindowLineSettings = lineSettings;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请恢复此处被删除的代码,使其至少能正常通过编译。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

删除主界面组件/行确认功能及删除组件/行后撤销功能

2 participants