Exemplo n.º 1
0
        void _s_题_填空_答案_获取Completed(object sender, 务.题_填空_答案_获取CompletedEventArgs e)
        {
            var data = new 填空题 {
                题 = _题, 答案 = e.Result.ToList <题.题_填空_答案>()
            };
            var f = new 题_填空_修改(data)
            {
                ParentLayoutRoot = this.LayoutRoot
            };

            f.Closed += f_Closed;
            f.ShowDialog();
        }
Exemplo n.º 2
0
        void _s_题_填空_答案_获取Completed(object sender, 务.题_填空_答案_获取CompletedEventArgs e)
        {
            if (_selected_row == null || _selected_row.题编号 != _填空题.题.题编号)
            {
                return;
            }
            _填空题.答案 = e.Result.ToList <题.题_填空_答案>();

            #region 预览

            var result = _填空题;

            _预览_RichTextBox.Blocks.Clear();

            var s   = "<___root___>" + result.题.显示模板 + "</___root___>";
            var xe  = XElement.Parse(s);
            var xns = xe.Nodes();
            var p   = new Paragraph {
                FontSize = 16
            };
            p.Inlines.Add(new Run
            {
                Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0))
                ,
                FontWeight = FontWeights.Bold
                ,
                Text = @"题面:

"
            });
            foreach (var xn in xns)
            {
                if (xn.NodeType == XmlNodeType.Text)
                {
                    p.Inlines.Add(new Run
                    {
                        Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0))
                        ,
                        FontWeight = FontWeights.Normal
                        ,
                        Text = ((XText)xn).Value
                    });
                }
                else
                {
                    if (xn.NodeType == XmlNodeType.Element)
                    {
                        var x = (XElement)xn;
                        if (x.Name.LocalName == "c")
                        {
                            p.Inlines.Add(new Run
                            {
                                Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255))
                                ,
                                FontWeight = FontWeights.Bold
                                ,
                                Text = " _" + x.Value + "_ "
                            });
                        }
                        else if (x.Name.LocalName == "a")
                        {
                            // todo: 图片
                        }
                    }
                }
            }

            _预览_RichTextBox.Blocks.Add(p);

            #endregion

            // 还原控件状态
            _DataGrid.IsEnabled = true;
            _DataGrid.Focus();
        }