//
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for AddGraph
        ///</summary>
        //[TestMethod()]
        public void AddGraphTest()
        {
            Random    rnd    = new Random();
            GraphForm target = new GraphForm();

            double[] iDataArray = new double[100];
            for (int i = 0; i < 100; i++)
            {
                iDataArray[i] = (double)rnd.Next(-100, 100) / 10.0;
            }
            ConsoleColor iColor = ConsoleColor.Green;
            string       iName  = "Random #1";

            target.AddGraph(iDataArray, iColor, iName: iName, iOffset: -10);
            iDataArray = new double[50];
            for (int i = 0; i < 50; i++)
            {
                iDataArray[i] = (double)rnd.Next(-50, 50) / 10.0;
            }
            iColor = ConsoleColor.Red;
            iName  = "Random #2";
            target.AddGraph(iDataArray, iColor, iName: iName, iOffset: 30.0, iInterval: 0.5);
            while (target.ShowDialog() == DialogResult.None)
            {
                ;
            }
        }
예제 #2
0
        public static Token CreatePlot(string operation, List <Token> arguments)
        {
            if (arguments.Count < 2)
            {
                return(Token.Error("Function requires more than one parameter"));
            }

            GraphForm gf = new GraphForm();

            for (int i = 0; i < arguments.Count;)
            {
                if (arguments.Count - i > 2 && arguments[i + 2].TokenType == TokenType.Text)
                {
                    if (!gf.AddCurve(arguments[i].VectorArray, arguments[i + 1].VectorArray, arguments[i + 2].TokenName))
                    {
                        return(Token.Error("Parameters not valid"));
                    }
                    i += 3;
                }
                else if (arguments.Count - i >= 2)
                {
                    if (!gf.AddCurve(arguments[i].VectorArray, arguments[i + 1].VectorArray))
                    {
                        return(Token.Error("Data not valid"));
                    }
                    i += 2;
                }
                else
                {
                    return(Token.Error("Parameters not valid"));
                }
            }
            gf.ShowDialog();
            return(Token.Void);
        }
예제 #3
0
        private void metroButton14_Click(object sender, EventArgs e)
        {
            string from = dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss");
            string to   = dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss");

            index = dataGridView6.CurrentCell.RowIndex;
            string    processName   = dataGridView6[0, index].Value.ToString();
            GraphForm generateGraph = new GraphForm(from, to, processName);

            generateGraph.ShowDialog();
        }
예제 #4
0
        /// <summary>
        /// Otevře formulář pro definici dat grafu
        /// </summary>
        private void ShowGraphFormEditor(GraphInfo graphInfo)
        {
            if (this._Database == null || !this._Database.HasData)
            {
                throw new InvalidOperationException("Dosud nejsou načtena a připravena data, počkejte malou chvilku...");
            }

            bool isNewGraph = (graphInfo == null);

            if (graphInfo == null)
            {
                graphInfo = new GraphInfo();
            }
            using (var graphForm = new GraphForm(this.VisibleBounds))
            {
                graphForm.Database            = this._Database;
                graphForm.ShowSaveAsNewButton = !isNewGraph;                   // Zobrazit tlačítko "Uložit jako nový graf" jen tehdy, když editujeme nějaký stávající graf
                graphForm.CurrentGraphInfo    = graphInfo;
                var result = graphForm.ShowDialog(this);

                if ((isNewGraph && result == DialogResult.OK) || (!isNewGraph && result == DialogResult.Yes))
                {                                           // Uložit nový graf:
                    graphInfo = graphForm.CurrentGraphInfo; // Převezmeme si novou instanci z editoru.
                    graphInfo.ResetId();
                    graphInfo.SaveToFile();
                    _Graphs.Add(graphInfo);
                    _GraphListBox.Refresh();
                    _GraphListBox.SelectedItem = graphInfo;                    // Nový graf se bude aktivovat (a tím se i zobrazí) přes event: _GraphListBox.SelectedIndexChanged
                }
                else if (!isNewGraph && result == DialogResult.OK)
                {                                                        // Uložit stávající graf:
                    graphInfo.Serial = graphForm.CurrentGraphInfoSerial; // Ponecháme si svoji instanci grafu, ale vepíšeme do ní data z editoru
                    graphInfo.SaveToFile();
                    ShowCurrentGraph();                                  // Protože se nemění selectovaný prvek v _GraphListBox, musím vynutit zobrazení grafu
                }
            }
        }