Example #1
0
        /// <summary>
        /// 駒オブジェクトなどを初期化します。
        /// </summary>
        protected override void OnInitialize()
        {
            base.OnInitialize();

            BaseScale = new Vector3D(
                this.shogi.CellSize.Width,
                this.shogi.CellSize.Height,
                1.0);

            // 駒台の駒の場合
            if (Square == null)
            {
                this.numberText = new DecoratedText()
                {
                    TextFormat      = "×{0}",
                    Foreground      = Brushes.Black,
                    FontWeight      = FontWeights.ExtraBlack,
                    Stroke          = Brushes.White,
                    StrokeThickness = 0.8,
                };
            }

            UpdateModel();
            UpdateElement();
        }
Example #2
0
        private static ComputedNode CreateNodes(EvaluationContext context)
        {
            ComputedNode root = null;

            List <ComputedNode> computedNodes = new List <ComputedNode>();

            foreach (Step step in context.Steps)
            {
                ComputedNode cn = new ComputedNode()
                {
                    Results             = step.OutVariables.Select(i => context.GetValue(i)).ToArray(),
                    ExpressionImage     = step.Image,
                    Description         = step.SourceExpression.Title,
                    ResultVariableNames = step.OutVariables.ToList(),
                    Step = step
                };


                List <Branch> branches = new List <Branch>();

                foreach (SourceVariable variable in step.InSourceVariables)
                {
                    branches.Add(new Branch()
                    {
                        Node = new VariableNode()
                        {
                            Description = variable.Description,
                            Text        = DecoratedText.Create(variable.Name),
                            Name        = variable.Name,
                            Value       = context.GetValue(variable.Name)
                        }
                    });
                }

                /*
                 * foreach (string variable in step.InTempVariables)
                 * {
                 *  branches.Add(new Branch() { Node = computedNodes.First(j => j.ResultVariableNames.Contains(variable)) });
                 * }
                 */


                foreach (Step fromStep in step.Froms)
                {
                    branches.Add(new Branch()
                    {
                        Node = computedNodes.First(j => j.Step == fromStep)
                    });
                }


                List <Branch> distinctBranches = new List <Branch>();

                foreach (Branch branch in branches)
                {
                    if (!distinctBranches.Any(i => i.Node == branch.Node))
                    {
                        distinctBranches.Add(branch);
                        cn.InheritVariables(branch.Node);
                    }
                }

                cn.Branches = distinctBranches.ToList();


                computedNodes.Insert(0, cn);
                root = cn;
            }

            return(root);
        }
Example #3
0
 public TextExpression(string text, bool isItalic)
 {
     this.text     = DecoratedText.Create(text);
     this.isItalic = isItalic;
 }
        public void GetFormattedLineCountTest(string text, int expectedLines)
        {
            var decoratedText = new DecoratedText <byte>();

            decoratedText.Insert(default, text);