LunarPresentation/Commands/SwitchLineAndColumn.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Windows;

namespace SHomeWorkshop.LunarPresentation.Commands
{
    public partial class Command
    {
        public static void SwitchLineAndColumn()
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;

            if ((Globals.selectedEditor.SelectedExpression is Expressions.Grid) == false)
            {
                MessageBox.Show("只有网格式才支持“行列转置”操作!", Globals.appName,
                    MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            LunarPresentation.Expressions.Grid grid
                = Globals.selectedEditor.SelectedExpression as Expressions.Grid;

            RunSwitchLineAndColumn(grid);

            ModifingItem mi = new ModifingItem();
            Action action = new Action(grid.ExID, grid.ParentPanel.BasePanel.Children.IndexOf(grid),
                grid.GetType().Name, "SwitchLineAndColumn", null, null);
            mi.Add(action);
            grid.Editor.Do(mi);
        }

        public static void RunSwitchLineAndColumn(LunarPresentation.Expressions.Grid grid)
        {
            // 此功能不支持有合并单元格的情况。
            foreach (Expressions.SubPanel sPanel in grid.SubPanels)
            {
                Expressions.GridPanel gp = sPanel as Expressions.GridPanel;

                if (gp != null &&
                    gp.MergeStanding != Expressions.GridPanel.Standing.Normal)
                {
                    MessageBox.Show("网格式中有合并单元格时,“行列转置”这一功能无效!",
                        Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
            }

            int lc = grid.LinesCount;
            int cc = grid.ColumnsCount;

            grid.ColumnsCount = lc;
            grid.LinesCount = cc;

            if (grid.SubPanels.Count >= 1)
            {
                foreach (Expressions.SubPanel sPanel in grid.SubPanels)
                {
                    Expressions.GridPanel gp = sPanel as Expressions.GridPanel;

                    if (gp != null)
                    {
后面还有 11 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。