LunarPresentation/Commands/InsertExam.cs

(开头部分) 3KB

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

using System.Windows.Controls;

namespace SHomeWorkshop.LunarPresentation.Commands
{
    public partial class Command
    {
        /// <summary>
        /// 注意:主、客观题均以“扩展式”组合其它类型公式而成,故实现代码可合并。
        /// </summary>
        private static void InsertExam(string examItemXmlText)
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;

            LunarPresentation.Expressions.Expression curEx = Globals.selectedEditor.SelectedExpression;

            Expressions.SubPanel sPanel = curEx as Expressions.SubPanel;
            if (sPanel != null)
            {
                if (sPanel.BasePanel.Children.Count <= 0)
                {
                    System.Windows.MessageBox.Show("发生意外错误,插入试题的目标子面板中没有任何公式!",
                        Globals.appName, System.Windows.MessageBoxButton.OK,
                        System.Windows.MessageBoxImage.Warning);
                    return;
                }
                curEx = sPanel.BasePanel.Children[sPanel.BasePanel.Children.Count - 1] as Expressions.Expression;
            }

            if (curEx == null)
            {
                System.Windows.MessageBox.Show("请先选取一个公式作为插入新试题的目标位置!",
                        Globals.appName, System.Windows.MessageBoxButton.OK,
                        System.Windows.MessageBoxImage.Warning);
                return;
            }

            if (curEx.Parent is StackPanel)
            {
                curEx.XmlData.InsertXml(examItemXmlText);

                StackPanel spanel = curEx.Parent as StackPanel;
                LunarPresentation.Expressions.Expander newExpression =
                    new LunarPresentation.Expressions.Expander(curEx.RootPanel, curEx.ParentPanel, curEx.Editor);
                spanel.Children.Insert(spanel.Children.IndexOf(curEx) + 1, newExpression);
                newExpression.XmlData = curEx.XmlData.NextSibling;

                ModifingItem mi = new ModifingItem();
                Action action = new Action(newExpression.ExID, spanel.Children.IndexOf(newExpression),
                   newExpression.GetType().Name, "InsertExpression", null, newExpression.XmlData.OuterXml,
                   ActionType.Insert, newExpression.ParentPanel.ExID);

                Action actionIndent = new Action(newExpression.ExID, spanel.Children.IndexOf(newExpression),
                    newExpression.GetType().Name, "Indent", newExpression.Indent.ToString(), curEx.Indent.ToString());


                newExpression.Indent = curEx.Indent;// 插入新公式时自动同步缩进。

                mi.Add(action); mi.Add(actionIndent);
                newExpression.Editor.Do(mi);
后面还有 23 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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