示例#1
0
文件: BlockSum.cs 项目: olegkozyr/mda
        public BlockSum(Point leftTopPoint)
        {
            ShapePoints[0] = leftTopPoint;

            BlockSize   = BlockSumMinSize;
            InPortSigns = new List <FormattedText>();

            PortPoints.RemoveAt(1);
            ConnectionObj.RemoveAt(1);
            ConnectionEnd.RemoveAt(1);

            PortDeltaMax = BlockSumMinSize.Height / 3;
            PortDelta    = FontSize;  //отступ знаков от верхнего края

            SetInPortSigns("++");
        }
示例#2
0
文件: BlockSum.cs 项目: olegkozyr/mda
        public void SetInPortSigns(string text)
        {
            int i;

            if (InPortSigns.Count != text.Length)
            {
                if (InPortSigns.Count < text.Length)
                {
                    textLength = InPortSigns.Count;

                    for (i = InPortSigns.Count; i < text.Length; i++)
                    {
                        InPortSigns.Add(new FormattedText(
                                            text[i].ToString(),
                                            CultureInfo.GetCultureInfo("en-us"),
                                            FlowDirection.LeftToRight,
                                            new Typeface("TimesNewRoman"),
                                            FontSize,
                                            Brushes.Black));
                        PortPoints.Add(new Point[PortPointCount]);
                        ConnectionObj.Add(null);
                        ConnectionEnd.Add(-1);
                    }
                }
                else
                {
                    textLength = text.Length;
                    if (text.Length < MinLeftPortCount)
                    {
                        intTemp = MinLeftPortCount;
                    }
                    else
                    {
                        intTemp = text.Length;
                    }

                    for (i = InPortSigns.Count; i > intTemp; i--)
                    {
                        InPortSigns.RemoveAt(i - 1);
                        PortPoints.RemoveAt(i);
                        ClearConnection(i, -1);
                        ConnectionObj.RemoveAt(i);
                        ConnectionEnd.RemoveAt(i);
                    }
                }

                ChangeLocation(ShapePoints[0], true);
            }
            else
            {
                textLength = InPortSigns.Count;
            }

            for (i = 0; i < textLength; i++)
            {
                if (InPortSigns[i].Text != text[i].ToString())
                {
                    InPortSigns[i] = new FormattedText(
                        text[i].ToString(),
                        CultureInfo.GetCultureInfo("en-us"),
                        FlowDirection.LeftToRight,
                        new Typeface("TimesNewRoman"),
                        FontSize,
                        Brushes.Black);
                }
            }

            this.Draw(true, false);
        }
示例#3
0
        public void SetPortCount(int[] newPortCount)
        {
            int i;
            int ex = 0;

            //левые порты
            if (PortCount[0] != newPortCount[0])
            {
                ex = 1;
                if (PortCount[0] < newPortCount[0])
                {
                    for (i = PortCount[0]; i < newPortCount[0]; i++)
                    {
                        PortPoints.Insert(i, new Point[PortPointCount]);
                        InLinePoints.Insert(i, new Point());
                        ConnectionObj.Insert(i, null);
                        ConnectionEnd.Insert(i, -1);
                    }
                }
                else
                {
                    intTemp = newPortCount[0] - 1;
                    for (i = PortCount[0] - 1; i > intTemp; i--)
                    {
                        PortPoints.RemoveAt(i);
                        InLinePoints.RemoveAt(i);
                        ClearConnection(i, -1);
                        ConnectionObj.RemoveAt(i);
                        ConnectionEnd.RemoveAt(i);
                    }
                }

                PortCount[0] = newPortCount[0];
            }

            //правые порты
            if (PortCount[1] != newPortCount[1])
            {
                ex = 1;
                if (PortCount[1] < newPortCount[1])
                {
                    for (i = PortCount[1]; i < newPortCount[1]; i++)
                    {
                        PortPoints.Add(new Point[PortPointCount]);
                        InLinePoints.Add(new Point());
                        ConnectionObj.Add(null);
                        ConnectionEnd.Add(-1);
                    }
                }
                else
                {
                    intTemp = newPortCount[1] - 1;
                    for (i = PortCount[1] + PortCount[0] - 1; i > intTemp + PortCount[0]; i--)
                    {
                        PortPoints.RemoveAt(i);
                        InLinePoints.RemoveAt(i);
                        ClearConnection(i);
                        ConnectionObj.RemoveAt(i);
                        ConnectionEnd.RemoveAt(i);
                    }
                }

                PortCount[1] = newPortCount[1];
            }

            if (ex == 1)
            {
                ChangeLocation(ShapePoints[0], true);
            }
        }