예제 #1
0
        public static GraphPattern PatternByName(string Name)
        {
            GraphPattern Ptrn = Patterns.Wire;

            ///
            if (Name.Contains("R"))
            {
                Ptrn = Patterns.Resistor;
            }
            if (Name.Contains("C"))
            {
                Ptrn = Patterns.Capacitor;
            }
            if (Name.Contains("L"))
            {
                Ptrn = Patterns.Inductor;
            }
            if (Name.Contains("S"))
            {
                Ptrn = Patterns.Source;
            }
            ///
            return(Ptrn);
        }
예제 #2
0
        //Геометрия
        public static void DrawScheme(Bitmap SchemePicture)
        {
            //Заполнение массива точек ветвления
            Scheme.Clear(SchemePicture);
            int TruePointsCount = Points.Count() + 1;//Коичество точек + одна, на которую замыкаются потребители с предпоследней точки ветвления

            SchemePoints = new Point[TruePointsCount];

            int Width             = SchemePicture.Width;
            int Height            = SchemePicture.Height;
            int Pairs             = (int)Math.Ceiling((double)SchemePoints.Length / 2);
            int PairsInterval     = 200; //Интервал между парами точек
            int SchemeLinesOffset = 80;  //Отступы от горизонтальной середины

            int FirstWPos = 0;

            for (int i = 0; i < Pairs; i++)
            {
                int TopPos    = (PairsInterval / 2) + (PairsInterval * i) - ((PairsInterval * Pairs) / 2);
                int BottomPos = -TopPos;

                //

                if (i == 0)
                {
                    FirstWPos = TopPos;        //Запоминаем сдвиг первой точки
                }
                if (TruePointsCount == Pairs + i + 1)
                {
                    BottomPos = FirstWPos;                                 //Присваиваем сдвиг к последней точке
                }
                //

                if (TruePointsCount > i)
                {
                    SchemePoints[i] = new Point(Width / 2 + TopPos, Height / 2 - SchemeLinesOffset);
                }
                if (TruePointsCount > Pairs + i)
                {
                    SchemePoints[Pairs + i] = new Point(Width / 2 + BottomPos, Height / 2 + SchemeLinesOffset);
                }
            }

            /*for (int i = 0; i < SchemePoints.Length; i++)
             * {
             *  Scheme.DrawPoint(SchemePoints[i], Program.SchemePicture);
             * }*/

            //

            for (int i = 0; i < SchemePoints.Length - 1; i++) //Рисование того, что между точками
            {
                Consumer[][] PointConsumers = Points[i];

                //MessageBox.Show(PointConsumers.Length.ToString(), "");

                for (int p = 0; p < PointConsumers.Length; p++)//Параллели между точками
                {
                    GraphPattern[] Patterns = new GraphPattern[PointConsumers[p].Length];
                    string[]       Names    = new string[PointConsumers[p].Length];
                    //
                    for (int l = 0; l < PointConsumers[p].Length; l++)//Перебор линейных потребителей
                    {
                        Patterns[l] = PatternByName(PointConsumers[p][l].Name);
                        Names[l]    = PointConsumers[p][l].Name;
                    }

                    DrawConsumers(SchemePoints[i], SchemePoints[i + 1], p, PointConsumers.Length, Patterns, Names, SchemePicture);
                }
            }

            string       VoltageSign = "";
            GraphPattern SourcePattern;

            if (Physics.isDirect)
            {
                VoltageSign   = "+" + Physics.U + " В";
                SourcePattern = PatternByName("S");
            }
            else
            {
                VoltageSign   = "~" + Physics.U + " В";
                SourcePattern = PatternByName("L");
            }

            DrawConsumers(SchemePoints[0], SchemePoints[SchemePoints.Length - 1], 0, 0, new GraphPattern[] { SourcePattern }, new string[] { VoltageSign /*"A+"*/ }, SchemePicture);
        }