Ejemplo n.º 1
0
        private void _switchCondition()
        {
            /*
             Complex operators in switch will kill program
             */
            _block = new ConditionalSpecBlock() { Text = _operator.Text, X = 0, Y = 0};
            Blocks = new List<Block>();
            Block prev = _block;

            Width = _block.Width;
            Height = _block.Height;
            foreach (var o in _operator.PDown)
            {
                Block graph = new GraphicOperator(o) { X = X + _block.Width / 2, Y = prev.Y + prev.Height + 2};
                Graphics.DrawImage(graph.Image, graph.RX, graph.RY);

                Height += graph.Height + 2;
                prev = graph;
                Width = Math.Max(Width, graph.Width + _block.Width/2);
                Blocks.Add(graph);
            }

            Graphics.DrawArrow(ArrowPen, _block.RX + _block.RWidth / 2, _block.RY+_block.RHeight,
                                         _block.RX + _block.RWidth / 2, RHeight + 40);

            foreach (var o in _operator.PDefault)
            {
                Block graph = new GraphicOperator(o) { X = X, Y = prev.Y + prev.Height + 2 };
                Graphics.DrawImage(graph.Image, graph.RX, graph.RY);

                Height += graph.Height + 2;
                prev = graph;
                Width = Math.Max(Width, graph.Width + _block.Width / 2);
            }
            Height += 2;
        }
Ejemplo n.º 2
0
        private void _ifCondition()
        {
            Size left, right;
            _leftBranch = _preBuildBranch(_operator.PLeft, out left);
            _rightBranch = _preBuildBranch(_operator.PRight, out right);

            Height = Math.Max(left.Height, right.Height) + 8;
            _block = new ConditionalSpecBlock() { Text = _operator.Text };
            int w = Math.Max(left.Width, right.Width) * 2 + _block.Width / 2;
            if (w < 40) w = 3 * _block.Width;
            _block.X = (w - _block.Width) / 2;
            Width = w;

            _postionizeBranchOnImage(_leftBranch, 0, 6, w / 2);
            _postionizeBranchOnImage(_rightBranch, w / 2, 6, w / 2);
            Blocks = new List<Block>();
            Blocks.AddRange(_leftBranch);
            Blocks.AddRange(_rightBranch);
        }