LunarPresentation/Commands/Tree/MoveLeafDown.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
using System.Windows;
namespace SHomeWorkshop.LunarPresentation.Commands
{
public partial class Command
{
/// <summary>
/// 令叶在同级向下移动一个位置——不支持跨分支平移。
/// </summary>
public static void MoveLeafDown()
{
if (Globals.selectedEditor == null) return;
if (Globals.selectedEditor.SelectedExpression == null) return;
LunarPresentation.Expressions.Expression curEx
= Globals.selectedEditor.SelectedExpression;
if (curEx is Expressions.LeafPanel == false)
{
MessageBox.Show("请先选中一个叶面板!", Globals.appName,
MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
Expressions.LeafPanel curLeaf = curEx as Expressions.LeafPanel;
if (curLeaf.LeafType == Expressions.LeafPanel.LeafPanelType.Root)
{
MessageBox.Show("树的叶首面板不支持平移操作!", Globals.appName,
MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (curLeaf.ParentExpression == null ||
curLeaf.ParentExpression is Expressions.Tree == false) return;
Expressions.Tree pTree = curLeaf.ParentExpression as Expressions.Tree;
Expressions.LeafPanel preLevelLeaf = curLeaf.PreLevelLeaf;
if (preLevelLeaf == null) return;
List<Expressions.LeafPanel> sameLevelLeaves = preLevelLeaf.NextLevelLeaves;
if (sameLevelLeaves == null || sameLevelLeaves.Count <= 0 ||
sameLevelLeaves.Contains(curLeaf) == false) return;
if (curLeaf.Index >= sameLevelLeaves.Count) return;
Expressions.LeafPanel bottomLeaf = null;
for (int i = curLeaf.Index + 1; i < sameLevelLeaves.Count; i++)
{
Expressions.LeafPanel lp = sameLevelLeaves[i];
if (lp.LeafType == curLeaf.LeafType)
{
bottomLeaf = lp;
//只要找到第一个索引大于(不一定是大1)当前叶、且方向与当前叶相同的即可。
break;
}
}
后面还有 28 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。