Example #1
0
File: Form1.cs Project: MaxSh0/net2
        private void numericUpDown9_ValueChanged(object sender, EventArgs e)
        {
            GraphPane pane = Graph1.GraphPane;

            pane.XAxis.Scale.Max = decimal.ToDouble(numericUpDown9.Value);

            GraphPane pane2 = Graph2.GraphPane;

            pane2.XAxis.Scale.Max = decimal.ToDouble(numericUpDown9.Value);

            GraphPane pane3 = Graph3.GraphPane;

            pane3.XAxis.Scale.Max = decimal.ToDouble(numericUpDown9.Value);


            pane.YAxis.Scale.MinAuto = true;
            pane.YAxis.Scale.MaxAuto = true;
            pane.IsBoundedRanges     = true;

            pane3.YAxis.Scale.MinAuto = true;
            pane3.YAxis.Scale.MaxAuto = true;
            pane3.IsBoundedRanges     = true;


            Graph1.AxisChange();
            Graph1.Invalidate();
            Graph2.AxisChange();
            Graph2.Invalidate();
            Graph3.AxisChange();
            Graph3.Invalidate();
        }
Example #2
0
        private static void GraphExecution()
        {
            Graph2 <string> cities = new Graph2 <string>();

            cities.AddVertex("Frankfurt"); //0
            cities.AddVertex("Mannheim");  //1
            cities.AddVertex("Karisruhe"); //2
            cities.AddVertex("Augusburg"); //3
            cities.AddVertex("Munchen");   //4
            cities.AddVertex("Wuzburg");   //5
            cities.AddVertex("Erfurt");    //6
            cities.AddVertex("Numberg");   //7
            cities.AddVertex("Stuttgart"); //8
            cities.AddVertex("Kassel");    //9

            cities.AddEdge(0, 1);
            cities.AddEdge(0, 5);
            cities.AddEdge(0, 9);
            cities.AddEdge(1, 2);
            cities.AddEdge(2, 3);
            cities.AddEdge(3, 4);
            cities.AddEdge(5, 6);
            cities.AddEdge(5, 7);
            cities.AddEdge(8, 7);
            cities.AddEdge(7, 4);
            cities.AddEdge(9, 4);
            Console.WriteLine("\n");
            Console.WriteLine("----- DFS CITIES ------");
            cities.DFS();
            Console.ReadLine();
        }
Example #3
0
        public double FindBestPath(Graph2 g)
        {
            try
            {
                string start = "0";

                // Dijkstra's (modified)
                weights[start] = 1;

                PriorityQueue2 pq = new PriorityQueue2(n);
                pq.InsertOrChange(start, 1);

                while (!pq.IsEmpty())
                {
                    string u = pq.DeleteMax();
                    foreach (Edge2 e in g.GetNeighbors(u))
                    {
                        if (weights[e.GetEndVertex()] < weights[u] * e.GetFactor())
                        {
                            weights[e.GetEndVertex()] = (weights[u] * e.GetFactor());
                            pq.InsertOrChange(e.GetEndVertex(), weights[e.GetEndVertex()]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            double best = weights[(n - 1).ToString()];

            return(best);
        }
Example #4
0
    public void run()
    {
        var graph  = new Graph2(mesh);
        var source = graph.Quantize(kinematic.position);
        var dest   = graph.Quantize(transform.position);

        var path = graph.FindPath(source, dest).Select(n => n.position).ToList();

        ILocation target;

        // Path is short, go straight
        if (path.Count <= 2)
        {
            target = new Location(transform.position);

            // Go to first segment of path
        }
        else
        {
            target = new Location(path[1]);
        }

        var arrive = Dynamic.Arrive(kinematic, steering, target, arriveOptions);
        var face   = Dynamic.Face(kinematic, steering, new Location(transform.position), alignOptions);

        steering = arrive.Combine(face);

        kinematic.UpdateKinematic(steering);
    }
 public MainWindow()
 {
     InitializeComponent();
     Graph1.Init(App.Controller1, 3, 2000);
     Graph2.Init(App.Controller2, 3, 2000);
     Parameter1.Init(App.Controller1);
     Parameter2.Init(App.Controller2);
 }
Example #6
0
 public RRTSD(GameObject terrain_manager_game_object)
 {
     terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
     start_pos       = terrain_manager.myInfo.start_pos;
     graph           = new Graph2(start_pos);
     goal_pos        = terrain_manager.myInfo.goal_pos;
     x_min           = terrain_manager.myInfo.x_low;
     x_max           = terrain_manager.myInfo.x_high;
     z_min           = terrain_manager.myInfo.z_low;
     z_max           = terrain_manager.myInfo.z_high;
     x_free          = getXFree();
     printXFree();
 }
Example #7
0
    public Graph2 <Vector3Int> MakeGraphFromPositionsListForTileType(List <PositionVector> _positions, ETile tileType)
    {
        List <int> nodes = new List <int>();
        Dictionary <int, List <int> > edges = new Dictionary <int, List <int> >();
        int ids = 0;
        Graph2 <Vector3Int> _graph = new Graph2 <Vector3Int>(nodes, edges);

        // This only needs to be made once
        nidsByPos = new int[size.x, size.y];

        // Make nodes
        foreach (PositionVector p in _positions)
        {
            nodes.Add(ids);             // Adds node to graph
            _graph.SetData(ids, p.vec); // Adds vector data to node
            nidsByPos[p.x, p.y] = ids;
            ids += 1;
        }

        // Make edges based on tile type
        foreach (PositionVector p in _positions)
        {
            var        neighbors = GetNeighborPositions(p); // TODO: support neighbor filtering by type
            int        pid       = nidsByPos[p.x, p.y];
            List <int> nids      = new List <int>();
            foreach (var n in neighbors)
            {
                int nid = 0;
                try
                {
                    nid = nidsByPos[n.x, n.y];
                }
                catch (System.Exception ex)
                {
                    // Detects invalid positions
                    Console.WriteLine("INVALID POS: " + n);
                    throw ex;
                }

                ETile tileAtNode = MGet(n.x, n.y, tilemap);
                if (tileAtNode == tileType)
                {
                    nids.Add(nid);
                }
            }
            edges.Add(pid, nids);
        }

        return(_graph);
    }
Example #8
0
        private void AtualizarTempoReal()
        {
            textBoxReceber.Text = "";

            if (valor1 >= 0 && valor1 <= 100)
            {
                progressBar1.Value = valor1;
            }

            if (valor2 >= 0 && valor2 <= 100)
            {
                progressBar2.Value = valor2;
            }

            if (valor3 >= 0 && valor3 <= 100)
            {
                progressBar3.Value = valor3;
            }

            //if (CBTipo.SelectedIndex == 0)
            //{
            atualizaTextBox();
            //}

            if (Graph.Series[0].Points.Count >= 9)
            {
                Graph.Series[0].Points.RemoveAt(0);
                Graph.Update();
            }

            if (Graph1.Series[0].Points.Count >= 9)
            {
                Graph1.Series[0].Points.RemoveAt(0);
                Graph1.Update();
            }


            if (Graph2.Series[0].Points.Count >= 9)
            {
                Graph2.Series[0].Points.RemoveAt(0);
                Graph2.Update();
            }

            string hora = DateTime.Now.ToLongTimeString();

            Graph.Series[0].Points.AddXY(hora, valor1);
            Graph1.Series[0].Points.AddXY(hora, valor2);
            Graph2.Series[0].Points.AddXY(hora, valor3);
        }
Example #9
0
 public RRTSDrone(GameObject terrain_manager_game_object)
 {
     maxSpeed      = 200;
     maxSteerAngle = 25 * Mathf.PI / 180;
     UnityEngine.Debug.Log(max_steer_angle + " " + maxSteerAngle);
     terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
     start_pos       = terrain_manager.myInfo.start_pos;
     graph           = new Graph2(start_pos);
     goal_pos        = terrain_manager.myInfo.goal_pos;
     x_min           = terrain_manager.myInfo.x_low;
     x_max           = terrain_manager.myInfo.x_high;
     z_min           = terrain_manager.myInfo.z_low;
     z_max           = terrain_manager.myInfo.z_high;
     x_free          = getXFree();
 }
Example #10
0
 public RRTS(GameObject terrain_manager_game_object, float m_maxSpeed, float m_MaximumSteerAngle)
 {
     stepSize        = (int)(5 / t);
     maxSpeed        = m_maxSpeed;
     maxSteerAngle   = m_MaximumSteerAngle * Mathf.PI / 180;
     terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>();
     start_pos       = terrain_manager.myInfo.start_pos;
     graph           = new Graph2(start_pos);
     goal_pos        = terrain_manager.myInfo.goal_pos;
     x_min           = terrain_manager.myInfo.x_low;
     x_max           = terrain_manager.myInfo.x_high;
     z_min           = terrain_manager.myInfo.z_low;
     z_max           = terrain_manager.myInfo.z_high;
     x_free          = getXFree();
     //printXFree();
 }
Example #11
0
        private void End()
        {
            Graphics Graph;
            Graphics Graph2;

            Graph  = splitContainer1.Panel1.CreateGraphics();
            Graph2 = splitContainer1.Panel2.CreateGraphics();

            Graph.Clear(BackColor);
            Graph2.Clear(BackColor);

            timer2.Enabled = false;
            IfStarted      = false;

            button3.Enabled    = true;
            button1.Enabled    = true;
            button2.Enabled    = true;
            button4.Enabled    = false;
            button5.Enabled    = false;
            menuStrip1.Enabled = true;

            label3.Text = $"{Properties.Settings.Default.Timer / 60}:{Properties.Settings.Default.Timer % 60}";


            Typed = null;

            MissclickPercentage = Missclicks / CharCounter * 100;
            MissclickPercentage = Math.Round(MissclickPercentage, 1);

            try
            {
                Speed    = 60 / (Properties.Settings.Default.Timer - TimeLeft) * CharCounter;
                TimeLeft = Properties.Settings.Default.Timer;
            }
            catch (DivideByZeroException)
            {
                Speed = 0;
            }

            label16.Text = Speed.ToString();

            label17.Text = MissclickPercentage.ToString();

            label19.Text = CharCounter.ToString();

            label13.Text = Missclicks.ToString();
        }
Example #12
0
        public void GetInfo()
        {
            try
            {
                string   line = "";
                string[] currentLine;
                int      m      = 0;
                int      mCount = 0;

                while ((line = Console.ReadLine()) != null && line != "")
                {
                    currentLine = line.Split();
                    if (currentLine.Length == 2)
                    {
                        mCount = 0;
                        m      = Convert.ToInt32(currentLine[1]);
                        n      = Convert.ToInt32(currentLine[0]);
                        if (m == 0)
                        {
                            return;
                        }
                        g1      = new Graph2();
                        weights = new Dictionary <string, double>();
                        for (int i = 0; i < n; i++)
                        {
                            g1.Add(i.ToString());
                            weights.Add(i.ToString(), 0);
                        }
                        continue;
                    }

                    if (mCount < m)
                    {
                        AddToGraph(g1, currentLine[0], currentLine[1], Convert.ToDouble(currentLine[2]));
                        mCount++;
                    }
                    if (mCount == m)
                    {
                        Console.WriteLine(FindBestPath(g1).ToString("#0.0000"));
                    }
                }
            }
            catch (Exception e)
            { }
        }
Example #13
0
File: Form1.cs Project: MaxSh0/net2
 private void numericUpDown10_ValueChanged(object sender, EventArgs e)
 {
     if (decimal.ToDouble(numericUpDown9.Value) > decimal.ToDouble(numericUpDown10.Value))
     {
         GraphPane pane  = Graph1.GraphPane;
         GraphPane pane2 = Graph2.GraphPane;
         GraphPane pane3 = Graph3.GraphPane;
         pane.XAxis.Scale.Min  = decimal.ToDouble(numericUpDown10.Value);
         pane2.XAxis.Scale.Min = decimal.ToDouble(numericUpDown10.Value);
         pane3.XAxis.Scale.Min = decimal.ToDouble(numericUpDown10.Value);
         Graph1.AxisChange();
         Graph1.Invalidate();
         Graph2.AxisChange();
         Graph2.Invalidate();
         Graph3.AxisChange();
         Graph3.Invalidate();
     }
     else
     {
         numericUpDown10.Value = numericUpDown10.Value - 100;
     }
 }
Example #14
0
        private RoutingPath GetRoutingPath(ApplicationDbContext myContext, string lon1, string lat1, int level1, string lon2, string lat2, int level2)
        {
            List <GraphDataItem> dtEdges   = new List <GraphDataItem>();
            RoutingPath          totalPath = null;

            Point3D sourceToFind = new Point3D {
                Latitude = Decimal.Parse(lat1), Type = Point3D.PointType.PATH_POINT, Level = level1, Longitude = Decimal.Parse(lon1)
            };
            Point3D targetToFind = new Point3D {
                Latitude = Decimal.Parse(lat2), Type = Point3D.PointType.PATH_POINT, Level = level2, Longitude = Decimal.Parse(lon2)
            };
            Point3D source = myContext.Points.ToList().Where(x => x.Level == level1 && x.Latitude == sourceToFind.Latitude && x.Longitude == sourceToFind.Longitude).FirstOrDefault();
            Point3D target = myContext.Points.ToList().Where(x => x.Level == level2 && x.Latitude == targetToFind.Latitude && x.Longitude == targetToFind.Longitude).FirstOrDefault();

            if (source == null)
            {
                source = sourceToFind;
                source.setWktAndGeometry();
            }
            if (target == null)
            {
                target = targetToFind;
                target.setWktAndGeometry();
            }
            var pathPoints = myContext.Points.Where(x => x.Type == Point3D.PointType.PATH_POINT | x.Type == Point3D.PointType.LEVEL_CONNECTION);

            //double minToTarget = double.MaxValue;
            //Point3D closestTarget = null;
            foreach (LineStringDTO item in myContext.LineStrings.Include("Source").Include("Target").ToList())
            {
                //if (item.connectorType != ConnectorType.NONE)
                //  System.Diagnostics.Debugger.Break();
                dtEdges.Add(new GraphDataItem
                {
                    Name           = item.Name,
                    Cost           = item.Distance,
                    EdgeID         = (int)item.Id,
                    IsReverse      = item.BiDirectional,
                    ReverseCost    = item.BiDirectional ? item.Distance : double.PositiveInfinity,
                    SourceVertexID = (int)item.Source.Id,
                    TargetVertexID = (int)item.Target.Id
                });
                //edges.Add(item.toGeneric());
            }
            List <IHasEntrances> sourceContainers = new List <IHasEntrances>();
            List <IHasEntrances> targetContainers = new List <IHasEntrances>();

            //GetStoreContainersOfPoint(myContext, source, target, sourceContainers, targetContainers);

            List <POI> containersSource = poisRep.GetContainerByLocation(lon1, lat1, level1);

            foreach (var item in containersSource)
            {
                if (item is IHasEntrances)
                {
                    sourceContainers.Add((IHasEntrances)item);
                }
            }
            List <POI> containersTarget = poisRep.GetContainerByLocation(lon2, lat2, level2);

            foreach (var item in containersTarget)
            {
                if (item is IHasEntrances)
                {
                    targetContainers.Add((IHasEntrances)item);
                }
            }
            //point is inside store - need to add the edge to the entrance first
            List <GraphDataItem> edgesFromSourceToGraph = GetAdditionalEdgeOfSourceOrTargetToNearest(myContext, sourceContainers, source, pathPoints, false);

            if (edgesFromSourceToGraph == null)
            {
                return(getRoutingPathFromDataGraphItems(myContext, source, target, dtEdges, true));
            }
            else
            {
                dtEdges.AddRange(edgesFromSourceToGraph);
            }

            List <GraphDataItem> edgesFromGraphToTarget = GetAdditionalEdgeOfSourceOrTargetToNearest(myContext, targetContainers, target, pathPoints, true);

            if (edgesFromGraphToTarget == null)
            {
                return(getRoutingPathFromDataGraphItems(myContext, source, target, dtEdges, true));
            }
            else
            {
                dtEdges.AddRange(edgesFromGraphToTarget);
            }
            //dtEdges.AddRange(GetAdditionalEdgeOfSourceOrTargetToNearest(myContext, targetContainers, target, pathPoints, true));

            //LineString3D<Point3D> targetToNearestPath = new LineString3D<Point3D>
            //{
            //    Level = target.Level,
            //    Source = target,
            //    Target = closestTarget,
            //    Distance = minToTarget
            //};
            //targetToNearestPath.setWktAndLocationG();
            ////List<Point3D> fromandTo = new List<Point3D> { source, target };
            ////pathPoints.Concat(fromandTo);
            ////List<LineString3D<Point3D>> edges = new List<LineString3D<Point3D>>();

            //dtEdges.Add(new GraphDataItem { Cost = targetToNearestPath.Distance, EdgeID = (int)targetToNearestPath.Id, IsReverse = false, SourceVertexID = (int)targetToNearestPath.Source.Id, TargetVertexID = (int)targetToNearestPath.Target.Id });
            //edges.Add(sourceToNearestPath);
            //edges.Add(targetToNearestPath);
            Graph2            graph2 = new Graph2(dtEdges);
            GraphSearchResult result = graph2.GetShortestPath((int)source.Id, (int)target.Id);

            if (result == null || result.Count() == 0)
            {
                //totalPath = getRoutingPathFromDataGraphItems(myContext, source, target, dtEdges, true);
            }
            else
            {
                totalPath = getRoutingPathFromDataGraphItems(myContext, source, target, result, false);
            }

            return(totalPath);
        }
Example #15
0
        static void Main(string[] args)
        {
            int[,] matrixAdj =
            {
                //1 2 3 4 5 6 7 8
                { 0, 1, 1, 0, 0, 0, 0, 0 }, //1
                { 1, 0, 0, 0, 0, 1, 1, 0 }, //2
                { 1, 0, 0, 1, 0, 1, 0, 1 }, //3
                { 0, 0, 1, 0, 1, 0, 0, 0 }, //4
                { 0, 0, 0, 1, 0, 1, 0, 0 }, //5
                { 0, 1, 1, 0, 1, 0, 0, 0 }, //6
                { 0, 1, 0, 0, 0, 0, 0, 1 }, //7
                { 0, 0, 1, 0, 0, 0, 1, 0 }  //8
            };

            Graph1 graph = new Graph1(matrixAdj, 8);

            Console.Write("Введите вершину X:");
            int X = int.Parse(Console.ReadLine());

            while (X == 0 || X > 8)
            {
                Console.WriteLine("Значение введено не верно.Введите верное значение от 1 до 8:");
                X = int.Parse(Console.ReadLine());
            }
            Console.Write("Введите вершину Y:");
            int Y = int.Parse(Console.ReadLine());

            while (Y == 0 || Y > 8)
            {
                Console.WriteLine("Значение введено не верно.Введите верное значение от 1 до 8:");
                Y = int.Parse(Console.ReadLine());
            }

            Console.WriteLine("В виде матрицы инцидентности:");

            Console.WriteLine("DFS:");
            Stack <int> DFS = graph.DFS(X - 1, Y - 1);

            PrintPath(DFS);
            Console.WriteLine();

            Console.WriteLine("BFS:");
            Stack <int> BFS = graph.BFS(X - 1, Y - 1);

            PrintPath(BFS);
            Console.WriteLine();


            Console.WriteLine("В виде связного списка:");

            Dictionary <int, List <int> > graph1 = new Dictionary <int, List <int> >();

            graph1[1] = new List <int> {
                2, 3
            };
            graph1[2] = new List <int> {
                1, 6, 7
            };
            graph1[3] = new List <int> {
                1, 4, 6, 8
            };
            graph1[4] = new List <int> {
                3, 5
            };
            graph1[5] = new List <int> {
                4, 6
            };
            graph1[6] = new List <int> {
                2, 3, 5
            };
            graph1[7] = new List <int> {
                2, 8
            };
            graph1[8] = new List <int> {
                3, 7
            };

            Graph2 graphList = new Graph2(graph1, 8);

            Console.WriteLine("DFS:");
            Stack <int> DFSList = graphList.DFS(X - 1, Y - 1);

            PrintPath(DFSList);
            Console.WriteLine();

            Console.WriteLine("BFS:");
            Stack <int> BFSList = graphList.BFS(X - 1, Y - 1);

            PrintPath(BFSList);
        }
Example #16
0
 public void AddToGraph(Graph2 g, string v1, string v2, double f)
 {
     g.AddNeighbor(v1, v2, f);
     g.AddNeighbor(v2, v1, f);
 }
Example #17
0
File: Form1.cs Project: MaxSh0/net2
        private void DrawGraph()
        {
            turn = 0;
            int    j        = 0;
            double rejected = 0;
            double accepted = 0;

            double[] mass3y     = new double[decimal.ToInt64(numericUpDown1.Value)];
            double[] mass3dlina = new double[decimal.ToInt64(numericUpDown1.Value)];
            // Получим панель для рисования
            GraphPane pane  = Graph1.GraphPane;
            GraphPane pane2 = Graph2.GraphPane;
            GraphPane pane3 = Graph3.GraphPane;

            // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы
            pane.CurveList.Clear();
            pane2.CurveList.Clear();
            pane2.GraphObjList.Clear();
            pane3.CurveList.Clear();
            // Создадим список точек
            PointPairList list1              = new PointPairList();
            PointPairList list1_1            = new PointPairList();
            PointPairList list1_2            = new PointPairList();
            PointPairList list2              = new PointPairList();
            PointPairList list2_2            = new PointPairList();
            PointPairList list3              = new PointPairList();
            double        y                  = 0;
            double        x                  = 0;
            double        valuePuasson       = 0;
            double        valueTreatment     = 0;
            double        valueTreatmentPast = 0;

            list3.Add(0, 0);
            list1_2.Add(0, 0);
            list1_1.Add(0, 0);

            numericUpDown9.Value  = 100;
            pane.YAxis.Title.Text = "Количество заявок";
            pane.XAxis.Title.Text = "Время";

            pane2.YAxis.Title.Text = "Серверы";
            pane2.XAxis.Title.Text = "Время";

            pane3.YAxis.Title.Text = "Очередь";
            pane3.XAxis.Title.Text = "Время";
            // Заполняем список точек
            for (int i = 0; i < decimal.ToDouble(numericUpDown1.Value); i++)
            {
                mass3y[i] = y;
                list2.Add(y, 3); // заполняем значения для второго графика

                //подписываем графики
                TextObj text2 = new TextObj("t" + i.ToString(), y, 2.5);
                pane2.GraphObjList.Add(text2);
                text2.FontSpec.Border.IsVisible = false;
                text2.FontSpec.Size             = 20;

                list1.Add(y, x);  // заполняем значения для первого графика
                x++;
                list1.Add(y, x);

                valuePuasson = rand.Generate(decimal.ToDouble(numericUpDown4.Value));


                valueTreatment = y + rand.Generate(decimal.ToDouble(numericUpDown8.Value));

                // заполняем значения для 2 графика
                if (valueTreatmentPast <= y)
                {
                    list2_2.Add(y, 1);
                    list2_2.Add(valueTreatment, 1);


                    //подписываем графики
                    TextObj text = new TextObj("m" + i.ToString(), (y + valueTreatment) / 2, 0.75);
                    pane2.GraphObjList.Add(text);
                    text.FontSpec.Size = 15;

                    mass3dlina[i] = valueTreatment;
                }
                else
                {
                    valueTreatment += valueTreatmentPast;
                    mass3dlina[i]   = valueTreatment;
                    list2_2.Add(valueTreatmentPast, 1);
                    list2_2.Add(valueTreatment, 1);

                    //подписываем графики
                    TextObj text = new TextObj("m" + i.ToString(), (valueTreatmentPast + valueTreatment) / 2, 0.75);
                    pane2.GraphObjList.Add(text);
                    text.FontSpec.Size = 15;
                }
                valueTreatmentPast = valueTreatment;
                list2_2.Add(PointPair.Missing, PointPair.Missing);
                y += valuePuasson;
            }
            //заполняем точки для графика очереди
            for (int i = 0; i < decimal.ToDouble(numericUpDown1.Value) - 1; i++)
            {
                //пока есть точки концов продолжительности между двумя входными запросами уменьшаем график на 1
                while (turn > 0 && mass3y[i] < mass3dlina[j] && mass3y[i + 1] > mass3dlina[j])
                {
                    list3.Add(mass3dlina[j], turn);
                    turn--;
                    list3.Add(mass3dlina[j], turn);
                    j++;
                }
                //если точка входящего запроса меньше точки длины предыдущего то увеличиваем график на 1
                if (mass3y[i + 1] < mass3dlina[i])
                {
                    if (turn != decimal.ToDouble(numericUpDown3.Value))
                    {
                        list3.Add(mass3y[i + 1], turn);
                        turn++;
                        list3.Add(mass3y[i + 1], turn);
                        //заполняем график обработанных запросов точками
                        list1_2.Add(mass3dlina[i], accepted);
                        accepted++;
                        list1_2.Add(mass3dlina[i], accepted);
                    }
                    else //заполняем график отказов точками
                    {
                        list1_1.Add(mass3y[i + 1], rejected);
                        rejected++;
                        list1_1.Add(mass3y[i + 1], rejected);
                    }
                }
                else
                {
                    j++;//показатель того сколько отрезков продолжительности прошли
                    //заполняем график обработанных запросов точками
                    list1_2.Add(mass3dlina[i], accepted);
                    accepted++;
                    list1_2.Add(mass3dlina[i], accepted);
                }
            }
            //дорисовываем концовку графика
            while (turn > 0)
            {
                list3.Add(mass3dlina[j], turn);
                turn--;
                list3.Add(mass3dlina[j], turn);
                j++;
            }
            list1_2.Add(mass3dlina[decimal.ToInt64(numericUpDown1.Value) - 1], accepted);
            list1_2.Add(mass3dlina[decimal.ToInt64(numericUpDown1.Value) - 1], accepted + 1);
            // Создадим кривые
            LineItem myCurve2   = pane2.AddCurve("Заявка", list2, Color.Blue, SymbolType.VDash);
            LineItem myCurve2_2 = pane2.AddCurve("Процесс обработки заявки", list2_2, Color.Blue, SymbolType.VDash);
            LineItem myCurve1   = pane.AddCurve("Всего", list1, Color.Blue, SymbolType.None);
            LineItem myCurve1_1 = pane.AddCurve("Отказ", list1_1, Color.Red, SymbolType.None);
            LineItem myCurve1_2 = pane.AddCurve("Обработаны", list1_2, Color.Green, SymbolType.None);
            LineItem myCurve3   = pane3.AddCurve("Очередь", list3, Color.Red, SymbolType.None);

            //2 кривую делаем невидимой
            myCurve2.Line.IsVisible = false;
            //толщина кривых
            myCurve1.Line.Width   = 2.0f;
            myCurve1_1.Line.Width = 2.0f;
            myCurve1_2.Line.Width = 2.0f;
            myCurve2.Line.Width   = 2.0f;
            myCurve2_2.Line.Width = 2.0f;
            myCurve3.Line.Width   = 2.0f;


            //myCurve2_2.Line.Fill = new ZedGraph.Fill( Color.Blue);
            //размеры шрифтов
            pane.XAxis.Scale.FontSpec.Size = 20;
            pane.YAxis.Scale.FontSpec.Size = 20;

            pane2.XAxis.Scale.FontSpec.Size = 20;
            pane2.YAxis.Scale.FontSpec.Size = 20;

            pane3.XAxis.Scale.FontSpec.Size = 20;
            pane3.YAxis.Scale.FontSpec.Size = 20;

            pane.Legend.FontSpec.Size  = 20;
            pane2.Legend.FontSpec.Size = 20;
            pane3.Legend.FontSpec.Size = 20;

            pane.XAxis.Title.FontSpec.Size = 20;
            pane.YAxis.Title.FontSpec.Size = 20;

            pane2.XAxis.Title.FontSpec.Size = 20;
            pane2.YAxis.Title.FontSpec.Size = 20;

            pane3.XAxis.Title.FontSpec.Size = 20;
            pane3.YAxis.Title.FontSpec.Size = 20;

            //Задаем начальные приближения графика
            pane.YAxis.Scale.MinAuto = true;
            pane.YAxis.Scale.MaxAuto = true;
            pane.XAxis.Scale.Min     = 0;
            pane.XAxis.Scale.Max     = 100;
            pane.IsBoundedRanges     = true;


            pane2.YAxis.Scale.MinAuto = true;
            pane2.YAxis.Scale.MaxAuto = true;
            pane2.XAxis.Scale.Min     = 0;
            pane2.XAxis.Scale.Max     = 100;
            pane2.IsBoundedRanges     = true;

            pane3.YAxis.Scale.Min     = 0;
            pane3.YAxis.Scale.MaxAuto = true;
            pane3.XAxis.Scale.Min     = 0;
            pane3.XAxis.Scale.Max     = 100;
            pane3.IsBoundedRanges     = true;

            // Вызываем метод AxisChange (), чтобы обновить данные об осях.
            Graph1.AxisChange();
            Graph2.AxisChange();
            Graph3.AxisChange();
            // Обновляем график
            Graph1.Invalidate();
            Graph2.Invalidate();
            Graph3.Invalidate();
        }
Example #18
0
        private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (IfStarted == false)
            {
                return;
            }

            try
            {
                char FirstChar = Result.First <char>();

                button3.Enabled    = false;
                button1.Enabled    = false;
                button2.Enabled    = false;
                button4.Enabled    = true;
                button5.Enabled    = true;
                menuStrip1.Enabled = false;
                button5.Visible    = true;
                button6.Visible    = false;

                label9.Text = e.KeyChar.ToString();

                Graphics Graph;
                Graphics Graph2;

                Font font = new Font("Sans Serif", Properties.Settings.Default.TextSize);
                Graph  = splitContainer1.Panel1.CreateGraphics();
                Graph2 = splitContainer1.Panel2.CreateGraphics();

                Graph.Clear(BackColor);
                Graph2.Clear(BackColor);


                timer2.Enabled = true;

                if (e.KeyChar == FirstChar)
                {
                    Typed += e.KeyChar;
                    if (TextRenderer.MeasureText(Typed, font).Width > 620)
                    {
                        Typed = Typed.Remove(0, 1);
                    }

                    Result = Result.Remove(0, 1);

                    Graph.Clear(BackColor);
                    Graph2.Clear(BackColor);

                    Graph.DrawString(Result, font, Brushes.Black, 1, 30);
                    Graph2.DrawString(Typed, font, Brushes.Black, 1, 30);
                }
                else
                {
                    ++Missclicks;
                    Graph.DrawString(Result, font, Brushes.Black, 1, 30);
                    Graph2.DrawString(Typed, font, Brushes.Black, 1, 30);
                }


                ++CharCounter;
            }
            catch (InvalidOperationException)
            {
                End();
                SessionStats();
            }
        }