Exemplo n.º 1
0
        private void UpdateChartBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int frequencyinmilliseconds = 5000;

            String[] information = new String[9];

            while (true)
            {
                foreach (String currency in requestedcurrencies)
                {
                    //There really should only be one string in requested currencies in
                    //light of the whole only able to chose one currecny at a time from
                    //the box list on the actual form so.
                    while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false))
                    {
                    }
                    information = TrueFX.RequestCurrency(currency);
                    //The zero thing should work for the commented reason above
                    currencychart.Invoke(chartagentplotpoint, information, 0);
                }
                System.Threading.Thread.Sleep(frequencyinmilliseconds);
                //PROBLEM: Past mode will not work for the chart becuase their is no mechanism
                //to check for pastmode. So, it will not gather data for pastmode? But then again,
                //if pastmode is enabled, it should check right within the TrueFX Class. So I don't
                //know
            }
        }
Exemplo n.º 2
0
 private void label2_Click(object sender, EventArgs e)
 {
     if (FEDataFolderSelector.ShowDialog() == DialogResult.OK)
     {
         foreignexchangedatafolderpath = FEDataFolderSelector.SelectedPath;
         FEDFolderSelectButton1.Text   = FEDataFolderSelector.SelectedPath;
         TrueFX.setfedatafolderpath(FEDataFolderSelector.SelectedPath);
     }
 }
Exemplo n.º 3
0
        private void UpdateCSVFileBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            int frequencyinmilliseconds = 5000; //In milliseconds

            while (true)
            {
                logdata(TrueFX.getinformationbatch());
                System.Threading.Thread.Sleep(frequencyinmilliseconds);
            }
        }
Exemplo n.º 4
0
 private void Initialize()
 {
     //statest.Cells[0].Value = "Hello";
     //ForexMarketUpdatesTable.Rows.
     currencychart = CurrencyGraph;
     table         = ForexMarketUpdatesTable;
     InitializeForexTable(table);
     UpdateTableBackgroundWorker.RunWorkerAsync();
     UpdateChartBackgroundWorker.RunWorkerAsync();
     UpdateCSVFileBackgroundWorker.RunWorkerAsync();
     TrueFX.initialize();
 }
Exemplo n.º 5
0
        private void UpdateCSVFileBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // I REALLY HOPE I DESIGNATED A SEPERATE THREAD FOR THIS BECAUSE THIS COULD EXPLAIN OUR PROBLEM

            int frequencyinmilliseconds = 5000; //In milliseconds

            while (true)
            {
                logdata(TrueFX.getinformationbatch());
                System.Threading.Thread.Sleep(frequencyinmilliseconds);
            }
        }
Exemplo n.º 6
0
        private void Initialize()
        {
            // We would have to change this in order to implement the new stuff.

            //statest.Cells[0].Value = "Hello";
            //ForexMarketUpdatesTable.Rows.
            currencychart = CurrencyGraph;
            table         = ForexMarketUpdatesTable;
            InitializeForexTable(table);
            UpdateChartBackgroundWorker.WorkerSupportsCancellation = true;
            UpdateTableBackgroundWorker.RunWorkerAsync();
            UpdateCSVFileBackgroundWorker.RunWorkerAsync();
            TrueFX.initialize();
        }
Exemplo n.º 7
0
        // This is method is linked to the UpdateChartBackgroundWorker.ASYNC( ) command in the beginning of the program, to start
        // the auto pilot of the update on the chart.

        private void UpdateChartBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // It think I found the source of our mis sync. I set this thread to run in the background, and I even beleive
            // that I have a seperate thread for the graph as well. I gotta find a way for the two threads to communicate to
            // each other. I may try some event based programming for them to sync up. Because If I sync them at the
            // begin, anything can cause a delay in either one of them causing them to get thrown out of sync. So...,
            // it would be better for them to communicate to each other, so that way, they can constantly stay in-sync no
            // matter what happen during the RUNTIME of the program. ~ July 17th, 2017 OH THIS IS THE CHART WORKER!!!

            int frequencyinmilliseconds = 5000;

            String[] information = new String[9];

            while (true)
            {
                if (UpdateChartBackgroundWorker.CancellationPending == true)
                {
                    Console.WriteLine("WE RETURNED 1"); e.Cancel = true; return;
                }

                foreach (String currency in requestedcurrencies)
                {
                    //There really should only be one string in requested currencies in
                    //light of the whole only able to chose one currecny at a time from
                    //the box list on the actual form so.
                    while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false))
                    {
                    }
                    information = TrueFX.RequestCurrency(currency);
                    //The zero thing should work for the commented reason above


                    //Console.WriteLine("ENETERED THE THREAD"); // BUG SQUASHING COMMENT
                    // The program doesn't enter the the loop if currency to be logged is checked.
                    // That must mean requestedcurrencies is empty, when we check the currecncies to be logged check box.


                    currencychart.Invoke(chartagentplotpoint, information, 0);
                }
                if (UpdateChartBackgroundWorker.CancellationPending == true)
                {
                    Console.WriteLine("I RETURNED!"); e.Cancel = true; return;
                }
                System.Threading.Thread.Sleep(frequencyinmilliseconds);
                //PROBLEM: Past mode will not work for the chart becuase their is no mechanism
                //to check for pastmode. So, it will not gather data for pastmode? But then again,
                //if pastmode is enabled, it should check right within the TrueFX Class. So I don't
                //know
            }
        }
Exemplo n.º 8
0
 private void PastModeCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (PastModeCheckBox.Checked == true)
     {
         TrueFX.enablepastmode();
         CheckedListBox copy = (CheckedListBox)(TrueFXMissionControlControl.Controls.Find("GraphPastData", true)[0]);
         copy.SetItemCheckState(0, CheckState.Unchecked);
         copy.SelectedIndex = 0; //To trigger the selected index change for the handler above.
         TrueFXMissionControlControl.Controls.Find("GraphPastData", true)[0].Visible = false;
     }
     else
     {
         TrueFXMissionControlControl.Controls.Find("GraphPastData", true)[0].Visible = true; TrueFX.disablepastmode();
     }
 }
Exemplo n.º 9
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            // August 15th, Tuesday, 2017
            //
            // This is the only place in the ecosystem we use the authenticate with TrueFX method. We use it nowhere else.
            //

            if (TrueFX.Authenticate(UsernameField.Text, PasswordField.Text))
            {
                new TrueFXMissionConrtol().Show();
            }
            else
            {
                ErrorMessageTrueFXLoginIn.Text = "Either The Username Or Password Is Incorrect";
            }
        }
Exemplo n.º 10
0
        private void UpdateTableBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //Equivalent to about 5 seconds
            int frequencyinmilliseconds = 5000;

            String[] information;
            String   bidbigfigurestring;
            String   bidpointsstring;
            String   offerbigfigurestring;
            String   offerpointsstring;
            String   currency;
            String   millisecondtimestamp;
            String   high;
            String   low;
            String   open;

            while (true)
            {
                if (TrueFX.getpastmodestate() == true)
                {
                    foreach (String currencyname in requestedcurrencies)
                    {
                        //This while loop is gonna be a problem for past mode
                        //Because we dont exactly need the market to be open in order for
                        //Past mode to be enabled, but here it does. Same thing for the
                        //The UpdaetChart method below too. Have to fix that.

                        //This logic will run for a bit, but it will crash eventually. You need to
                        //add a method that will peek to see if there is any more data to log.


                        while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false))
                        {
                        }
                        if (TrueFX.getpastmodestate() == false)
                        {
                            break;
                        }
                        information = TrueFX.RequestCurrency(currencyname);

                        //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1);
                        currency             = information[0];
                        millisecondtimestamp = information[1];
                        bidbigfigurestring   = information[2];
                        bidpointsstring      = information[3];
                        offerbigfigurestring = information[4];
                        offerpointsstring    = information[5];
                        high = information[6];
                        low  = information[7];
                        open = information[8];

                        table.Invoke(tableagentaddrow,
                                     currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring,
                                     offerbigfigurestring + offerpointsstring, high, low, open);
                        //This should still work because theoretically only
                        //One currency is checked at a time still so
                        //currencychart.Invoke(chartagentplotpoint, information, 0);
                    }
                }

                //Whats happening is past mode is getting enabled in the middle of the else loop,
                //Forcing thre rest of the currencies to do the requested thing for all currencies
                //But you might not have the data for it. Ill have to fix this.

                else
                {
                    foreach (String currencyname in ALLCURRENCIES)
                    {
                        //This while loop is gonna be a problem for past mode
                        //Because we dont exactly need the market to be open in order for
                        //Past mode to be enabled, but here it does. Same thing for the
                        //The UpdaetChart method below too. Have to fix that.

                        while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false))
                        {
                        }
                        if (TrueFX.getpastmodestate())
                        {
                            break;
                        }
                        information = TrueFX.RequestCurrency(currencyname);

                        //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1);
                        currency             = information[0];
                        millisecondtimestamp = information[1];
                        bidbigfigurestring   = information[2];
                        bidpointsstring      = information[3];
                        offerbigfigurestring = information[4];
                        offerpointsstring    = information[5];
                        high = information[6];
                        low  = information[7];
                        open = information[8];

                        table.Invoke(tableagentaddrow,
                                     currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring,
                                     offerbigfigurestring + offerpointsstring, high, low, open);
                        //This should still work because theoretically only
                        //One currency is checked at a time still so
                        //currencychart.Invoke(chartagentplotpoint, information, 0);
                    }
                }

                System.Threading.Thread.Sleep(frequencyinmilliseconds);

                //This method really isn't very visually pleasing
                //table.Invoke( tableagentclearrow );
            }
        }
Exemplo n.º 11
0
        // This method is linked with the UpdateTableBackgroundWorker_DoWork

        private void UpdateTableBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //Equivalent to about 5 seconds
            int frequencyinmilliseconds = 5000;

            String[] information;
            String   bidbigfigurestring;
            String   bidpointsstring;
            String   offerbigfigurestring;
            String   offerpointsstring;
            String   currency;
            String   millisecondtimestamp;
            String   high;
            String   low;
            String   open;

            while (true)
            {
                //
                //
                //
                //
                // This is the past mode portion of the piece
                //
                //
                //
                //


                // This past mode isn't developed for the async
                if (TrueFX.getpastmodestate() == true)
                {
                    foreach (String currencyname in requestedcurrencies)
                    {
                        //This while loop is gonna be a problem for past mode
                        //Because we dont exactly need the market to be open in order for
                        //Past mode to be enabled, but here it does. Same thing for the
                        //The UpdaetChart method below too. Have to fix that.

                        //This logic will run for a bit, but it will crash eventually. You need to
                        //add a method that will peek to see if there is any more data to log.


                        while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false))
                        {
                        }
                        if (TrueFX.getpastmodestate() == false)
                        {
                            break;
                        }
                        information = TrueFX.RequestCurrency(currencyname);

                        //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1);
                        currency             = information[0];
                        millisecondtimestamp = information[1];
                        bidbigfigurestring   = information[2];
                        bidpointsstring      = information[3];
                        offerbigfigurestring = information[4];
                        offerpointsstring    = information[5];
                        high = information[6];
                        low  = information[7];
                        open = information[8];

                        tabledata[currencyname] = information;

                        table.Invoke(tableagentaddrow,
                                     currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring,
                                     offerbigfigurestring + offerpointsstring, high, low, open);

                        if (ChartTableSyncCheckBox.Checked == true)
                        {
                            if (UpdateChartBackgroundWorker.IsBusy == true)
                            {
                                UpdateChartBackgroundWorker.CancelAsync();
                                break;
                            }
                            else
                            {
                                foreach (String currencychecked in requestedcurrencies)
                                {
                                    //There really should only be one string in requested currencies in
                                    //light of the whole only able to chose one currecny at a time from
                                    //the box list on the actual form so.
                                    // while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false)) { }
                                    information = tabledata[currencychecked];
                                    //The zero thing should work for the commented reason above


                                    //Console.WriteLine("ENETERED THE THREAD"); // BUG SQUASHING COMMENT
                                    // The program doesn't enter the the loop if currency to be logged is checked.
                                    // That must mean requestedcurrencies is empty, when we check the currecncies to be logged check box.


                                    currencychart.Invoke(chartagentplotpoint, information, 0);
                                }
                            }
                        }

                        else
                        {
                            UpdateChartBackgroundWorker.RunWorkerAsync();
                        }
                        //This should still work because theoretically only
                        //One currency is checked at a time still so
                        //currencychart.Invoke(chartagentplotpoint, information, 0);
                    }
                }

                //Whats happening is past mode is getting enabled in the middle of the else loop,
                //Forcing thre rest of the currencies to do the requested thing for all currencies
                //But you might not have the data for it. Ill have to fix this.

                else
                {
                    foreach (String currencyname in ALLCURRENCIES)
                    {
                        //This while loop is gonna be a problem for past mode
                        //Because we dont exactly need the market to be open in order for
                        //Past mode to be enabled, but here it does. Same thing for the
                        //The UpdaetChart method below too. Have to fix that.

                        while (((TrueFX.getinformationbatch() == /*null*/ Environment.NewLine) || (TrueFX.getinformationbatch() == null)) && (TrueFX.getpastmodestate() == false))
                        {
                        }
                        if (TrueFX.getpastmodestate())
                        {
                            break;
                        }
                        information = TrueFX.RequestCurrency(currencyname);

                        //currency = information[0].Remove(information[0].IndexOf('\n'), information[0].IndexOf('\n') + 1);
                        currency             = information[0];
                        millisecondtimestamp = information[1];
                        bidbigfigurestring   = information[2];
                        bidpointsstring      = information[3];
                        offerbigfigurestring = information[4];
                        offerpointsstring    = information[5];
                        high = information[6];
                        low  = information[7];
                        open = information[8];

                        tabledata[currencyname] = information;

                        table.Invoke(tableagentaddrow,
                                     currency, millisecondtimestamp, bidbigfigurestring + bidpointsstring,
                                     offerbigfigurestring + offerpointsstring, high, low, open);
                        //This should still work because theoretically only
                        //One currency is checked at a time still so
                        //currencychart.Invoke(chartagentplotpoint, information, 0);

                        if (ChartTableSyncCheckBox.Checked == true)
                        {
                            if (UpdateChartBackgroundWorker.IsBusy == true)
                            {
                                Console.WriteLine("ITS CANCELING THE UPDATE BACKGROUND");
                                UpdateChartBackgroundWorker.CancelAsync();
                                break;
                            }
                            else
                            {
                                foreach (String currencychecked in requestedcurrencies)
                                {
                                    //There really should only be one string in requested currencies in
                                    //light of the whole only able to chose one currecny at a time from
                                    //the box list on the actual form so.

                                    information = tabledata[currencychecked];
                                    //The zero thing should work for the commented reason above


                                    //Console.WriteLine("ENETERED THE THREAD"); // BUG SQUASHING COMMENT
                                    // The program doesn't enter the the loop if currency to be logged is checked.
                                    // That must mean requestedcurrencies is empty, when we check the currecncies to be logged check box.

                                    if (UpdateChartBackgroundWorker.IsBusy)
                                    {
                                        Console.WriteLine("WHY IS IT BUSY?");
                                    }
                                    currencychart.Invoke(chartagentplotpoint, information, 0);
                                }
                            }
                        }

                        else
                        {
                            // There are still errors here. I think whats happening is that we call for the cancellation of work, and we
                            // don't wait for the updatechartbackgroundworker to return befor calling the run asynchronus method.

                            Console.WriteLine("The extra special async cancel");
                            UpdateChartBackgroundWorker.CancelAsync();
                            while (UpdateChartBackgroundWorker.IsBusy)
                            {
                            }
                            UpdateChartBackgroundWorker.RunWorkerAsync();
                        }
                    }
                }

                System.Threading.Thread.Sleep(frequencyinmilliseconds);

                //This method really isn't very visually pleasing
                //table.Invoke( tableagentclearrow );
            }
        }